Make moveLineUp and changeLanguageTo command respect state.readOnly

This commit is contained in:
Jonatan Heyman 2023-01-16 15:33:05 +01:00
parent fc63ad1651
commit c8cc1cb5f1

View File

@ -46,6 +46,8 @@ export const selectAll = ({ state, dispatch }) => {
* Prevent moveLineUp from executing if any cursor is on the first line of the first note * Prevent moveLineUp from executing if any cursor is on the first line of the first note
*/ */
export function moveLineUp({ state, dispatch }) { export function moveLineUp({ state, dispatch }) {
if (state.readOnly)
return false
if (state.selection.ranges.some(range => { if (state.selection.ranges.some(range => {
let startLine = state.doc.lineAt(range.from) let startLine = state.doc.lineAt(range.from)
return startLine.from <= state.facet(blockState)[0].content.from return startLine.from <= state.facet(blockState)[0].content.from
@ -57,6 +59,8 @@ export function moveLineUp({ state, dispatch }) {
export function changeLanguageTo(state, dispatch, block, language, auto) { export function changeLanguageTo(state, dispatch, block, language, auto) {
if (state.readOnly)
return false
const delimRegex = /^\n∞∞∞[a-z]{0,16}(-a)?\n/g const delimRegex = /^\n∞∞∞[a-z]{0,16}(-a)?\n/g
if (state.doc.sliceString(block.delimiter.from, block.delimiter.to).match(delimRegex)) { if (state.doc.sliceString(block.delimiter.from, block.delimiter.to).match(delimRegex)) {
//console.log("changing language to", language) //console.log("changing language to", language)