diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-12-10 23:38:26 -0500 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-12-10 23:38:26 -0500 |
commit | 011c777f4109afffd335ba3f447e258e1ad53ddf (patch) | |
tree | cb98e1ea0b855af387e12c80fc358384127453b5 /src | |
parent | 921554d7d585a1138c7cf8d02d1e46f47c7cafe7 (diff) |
made indent & other alignment commands toggles
Diffstat (limited to 'src')
-rw-r--r-- | src/client/util/RichTextRules.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index ba2bc785d..22b2a8204 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -123,8 +123,9 @@ export const inpRules = { const pos = (state.doc.resolve(start) as any); let depth = pos.path.length / 3 - 1; for (; depth >= 0; depth--) { - if (pos.node(depth).type === schema.nodes.paragraph) { - const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, pos.node(depth).type, { ...pos.node(depth).attrs, indent: 25 }); + let node = pos.node(depth); + if (node.type === schema.nodes.paragraph) { + const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, node.type, { ...node.attrs, indent: node.attrs.indent === 25 ? undefined : 25 }); return replaced.setSelection(new TextSelection(replaced.doc.resolve(end - 2))); } } @@ -137,8 +138,9 @@ export const inpRules = { const pos = (state.doc.resolve(start) as any); let depth = pos.path.length / 3 - 1; for (; depth >= 0; depth--) { - if (pos.node(depth).type === schema.nodes.paragraph) { - const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, pos.node(depth).type, { ...pos.node(depth).attrs, indent: -25 }); + let node = pos.node(depth); + if (node.type === schema.nodes.paragraph) { + const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, node.type, { ...node.attrs, indent: node.attrs.indent === -25 ? undefined : -25 }); return replaced.setSelection(new TextSelection(replaced.doc.resolve(end - 2))); } } @@ -151,12 +153,13 @@ export const inpRules = { const pos = (state.doc.resolve(start) as any); if (state.selection instanceof NodeSelection && (state.selection as NodeSelection).node.type === schema.nodes.ordered_list) { let node = (state.selection as NodeSelection).node; - return state.tr.setNodeMarkup(pos.pos, node.type, { ...node.attrs, indent: 30 }); + return state.tr.setNodeMarkup(pos.pos, node.type, { ...node.attrs, indent: node.attrs.indent === 30 ? undefined : 30 }); } let depth = pos.path.length / 3 - 1; for (; depth >= 0; depth--) { - if (pos.node(depth).type === schema.nodes.paragraph) { - const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, pos.node(depth).type, { ...pos.node(depth).attrs, inset: 30 }); + let node = pos.node(depth); + if (node.type === schema.nodes.paragraph) { + const replaced = state.tr.setNodeMarkup(pos.pos - pos.parentOffset - 1, node.type, { ...node.attrs, inset: node.attrs.inset === 30 ? undefined : 30 }); return replaced.setSelection(new TextSelection(replaced.doc.resolve(end - 2))); } } |