From cfeaa00ebec604f69cf2559809ed19abe126411f Mon Sep 17 00:00:00 2001 From: bobzel Date: Thu, 21 Jan 2021 00:25:53 -0500 Subject: fixed dropdown behavior of menu buttons -- specifically styleBrush --- .../views/nodes/formattedText/RichTextMenu.tsx | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx index 9000018f4..992194e2b 100644 --- a/src/client/views/nodes/formattedText/RichTextMenu.tsx +++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx @@ -56,7 +56,6 @@ export class RichTextMenu extends AntimodeMenu { @observable private activeListType: string = ""; @observable private activeAlignment: string = "left"; - @observable private brushIsEmpty: boolean = true; @observable private brushMarks: Set = new Set(); @observable private showBrushDropdown: boolean = false; @@ -635,13 +634,12 @@ export class RichTextMenu extends AntimodeMenu { ; return ( - + ); } @action clearBrush() { - RichTextMenu.Instance.brushIsEmpty = true; RichTextMenu.Instance.brushMarks = new Set(); } @@ -649,26 +647,22 @@ export class RichTextMenu extends AntimodeMenu { fillBrush(state: EditorState, dispatch: any) { if (!this.view) return; - if (this.brushIsEmpty) { + if (!Array.from(this.brushMarks.keys()).length) { const selected_marks = this.getMarksInSelection(this.view.state); if (selected_marks.size >= 0) { this.brushMarks = selected_marks; - this.brushIsEmpty = !this.brushIsEmpty; } } else { const { from, to, $from } = this.view.state.selection; if (!this.view.state.selection.empty && $from && $from.nodeAfter) { - if (this.brushMarks && to - from > 0) { + if (to - from > 0) { this.view.dispatch(this.view.state.tr.removeMark(from, to)); Array.from(this.brushMarks).filter(m => m.type !== schema.marks.user_mark).forEach((mark: Mark) => { this.setMark(mark, this.view!.state, this.view!.dispatch); }); } } - else { - this.brushIsEmpty = !this.brushIsEmpty; - } } } @@ -816,8 +810,7 @@ export class RichTextMenu extends AntimodeMenu { ; - return ; + return ; } async getTextLinkTargetTitle() { @@ -1026,6 +1019,7 @@ interface ButtonDropdownProps { openDropdownOnButton?: boolean; link?: boolean; pdf?: boolean; + } @observer @@ -1070,9 +1064,11 @@ export class ButtonDropdown extends React.Component { return (
this.ref = node}> {!this.props.pdf ? -
+
{this.props.button} -
+
+ +
: <> -- cgit v1.2.3-70-g09d2