From 89d3ec54886a588f3b7c8e46e771830eeefc3c8b Mon Sep 17 00:00:00 2001 From: vellichora Date: Tue, 7 Jan 2020 15:58:10 -0500 Subject: added logic so that text nodes started on the very left still show the full richtextmenu --- src/client/util/RichTextMenu.tsx | 49 ++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'src/client/util/RichTextMenu.tsx') diff --git a/src/client/util/RichTextMenu.tsx b/src/client/util/RichTextMenu.tsx index 4538a77d6..ae55dbd30 100644 --- a/src/client/util/RichTextMenu.tsx +++ b/src/client/util/RichTextMenu.tsx @@ -29,7 +29,7 @@ library.add(faBold, faItalic, faUnderline, faStrikethrough, faSuperscript, faSub @observer export default class RichTextMenu extends AntimodeMenu { static Instance: RichTextMenu; - public overDropdown: boolean = false; // kind of hacky way to prevent selects not being selectable + public overMenu: boolean = false; // kind of hacky way to prevent selects not being selectable private view?: EditorView; private editorProps: FieldViewProps & FormattedTextBoxProps | undefined; @@ -188,9 +188,7 @@ export default class RichTextMenu extends AntimodeMenu { } }); } - function onPointerEnter() { self.overDropdown = true; } - function onPointerLeave() { self.overDropdown = false; } - return ; + return ; } createNodesDropdown(activeOption: string, options: { node: NodeType | any | null, title: string, label: string, command: (node: NodeType | any) => void, hidden?: boolean }[]): JSX.Element { @@ -213,9 +211,7 @@ export default class RichTextMenu extends AntimodeMenu { } }); } - function onPointerEnter() { self.overDropdown = true; } - function onPointerLeave() { self.overDropdown = false; } - return ; + return ; } changeFontSize = (mark: Mark, view: EditorView) => { @@ -311,7 +307,9 @@ export default class RichTextMenu extends AntimodeMenu { return (
- + {this.showBrushDropdown ? (
@@ -652,6 +650,17 @@ export default class RichTextMenu extends AntimodeMenu { return ref_node; } + @action onPointerEnter(e: React.PointerEvent) { RichTextMenu.Instance.overMenu = true; } + @action onPointerLeave(e: React.PointerEvent) { RichTextMenu.Instance.overMenu = false; } + + @action + toggleMenuPin = (e: React.MouseEvent) => { + this.Pinned = !this.Pinned; + if (!this.Pinned) { + this.fadeOut(true); + } + } + render() { const fontSizeOptions = [ @@ -705,16 +714,28 @@ export default class RichTextMenu extends AntimodeMenu { this.createButton("indent", "Summarize", undefined, this.insertSummarizer), ]}
- const row2 =
{[ - this.createMarksDropdown(this.activeFontSize, fontSizeOptions), - this.createMarksDropdown(this.activeFontFamily, fontFamilyOptions), - this.createNodesDropdown(this.activeListType, listTypeOptions), - ]}
+ const row2 =
+
{[ + this.createMarksDropdown(this.activeFontSize, fontSizeOptions), + this.createMarksDropdown(this.activeFontFamily, fontFamilyOptions), + this.createNodesDropdown(this.activeListType, listTypeOptions), + ]}
+
+ + {this.getDragger()} +
+
const buttons = [ row1, row2 ]; - return this.getElementWithRows(buttons, 2); + return ( +
+ {this.getElementWithRows(buttons, 2)} +
+ ); } } \ No newline at end of file -- cgit v1.2.3-70-g09d2