From 4ab742c54d600fb62b02268f48e711258558924b Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Tue, 10 Dec 2019 18:47:27 -0500 Subject: fixes to color marks --- src/client/util/RichTextSchema.tsx | 2 +- src/client/util/TooltipTextMenu.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client/util/RichTextSchema.tsx b/src/client/util/RichTextSchema.tsx index 7cb8448ca..4369be1ee 100644 --- a/src/client/util/RichTextSchema.tsx +++ b/src/client/util/RichTextSchema.tsx @@ -313,7 +313,7 @@ export const marks: { [index: string]: MarkSpec } = { attrs: { color: { default: "#000" } }, - inclusive: false, + inclusive: true, parseDOM: [{ tag: "span", getAttrs(dom: any) { return { color: dom.getAttribute("color") }; diff --git a/src/client/util/TooltipTextMenu.tsx b/src/client/util/TooltipTextMenu.tsx index 01d566831..f29dbf2e4 100644 --- a/src/client/util/TooltipTextMenu.tsx +++ b/src/client/util/TooltipTextMenu.tsx @@ -839,9 +839,11 @@ export class TooltipTextMenu { } public static insertColor(color: String, state: EditorState, dispatch: any) { - if (state.selection.empty) return false; - const colorMark = state.schema.mark(state.schema.marks.pFontColor, { color: color }); + if (state.selection.empty) { + dispatch(state.tr.addStoredMark(colorMark)); + return false; + } dispatch(state.tr.addMark(state.selection.from, state.selection.to, colorMark)); } -- cgit v1.2.3-70-g09d2 From 68ad65580e5d01e4d47f2573972f908b7f403c17 Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Tue, 10 Dec 2019 19:08:25 -0500 Subject: fixed alt-t for mac --- src/client/views/nodes/DocumentView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/views/nodes/DocumentView.tsx b/src/client/views/nodes/DocumentView.tsx index 9219da80b..727d631c4 100644 --- a/src/client/views/nodes/DocumentView.tsx +++ b/src/client/views/nodes/DocumentView.tsx @@ -140,7 +140,7 @@ export class DocumentView extends DocComponent(Docu } onKeyDown = (e: React.KeyboardEvent) => { - if (e.altKey && e.key === "t" && !(e.nativeEvent as any).StopPropagationForReal) { + if (e.altKey && (e.key === "†" || e.key === "t") && !(e.nativeEvent as any).StopPropagationForReal) { (e.nativeEvent as any).StopPropagationForReal = true; // e.stopPropagation() doesn't seem to work... e.stopPropagation(); if (!StrCast(this.Document.showTitle)) this.Document.showTitle = "title"; -- cgit v1.2.3-70-g09d2 From ca70b29bbb1818764b98196f8c28a1255a17965c Mon Sep 17 00:00:00 2001 From: Bob Zeleznik Date: Tue, 10 Dec 2019 19:35:08 -0500 Subject: added %q to indent paragraphs --- src/client/util/ParagraphNodeSpec.ts | 6 ++++++ src/client/util/RichTextRules.ts | 14 ++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/client/util/ParagraphNodeSpec.ts b/src/client/util/ParagraphNodeSpec.ts index fceb8c00f..0a3b68217 100644 --- a/src/client/util/ParagraphNodeSpec.ts +++ b/src/client/util/ParagraphNodeSpec.ts @@ -34,6 +34,7 @@ const ParagraphNodeSpec: NodeSpec = { color: { default: null }, id: { default: null }, indent: { default: null }, + inset: { default: null }, lineSpacing: { default: null }, // TODO: Add UI to let user edit / clear padding. paddingBottom: { default: null }, @@ -76,6 +77,7 @@ function toDOM(node: Node): DOMOutputSpec { const { align, indent, + inset, lineSpacing, paddingTop, paddingBottom, @@ -109,6 +111,10 @@ function toDOM(node: Node): DOMOutputSpec { style += `text-indent: ${indent}; padding-left: ${indent < 0 ? -indent : undefined};`; } + if (inset) { + style += `margin-left: ${inset}; margin-right: ${inset};`; + } + style && (attrs.style = style); if (indent) { diff --git a/src/client/util/RichTextRules.ts b/src/client/util/RichTextRules.ts index 5f2d67a3e..94bfc5ef2 100644 --- a/src/client/util/RichTextRules.ts +++ b/src/client/util/RichTextRules.ts @@ -142,6 +142,20 @@ export const inpRules = { } return null; }), + new InputRule( + new RegExp(/q$/), + (state, match, start, end) => { + if (state.selection.to === state.selection.from) return null; + 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, inset: 30 }); + return replaced.setSelection(new TextSelection(replaced.doc.resolve(end - 2))); + } + } + return null; + }), new InputRule( new RegExp(/!$/), (state, match, start, end) => { -- cgit v1.2.3-70-g09d2