aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/RichTextMenu.tsx
diff options
context:
space:
mode:
authorGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-11-01 22:58:45 +0800
committerGeireann Lindfield Roberts <60007097+geireann@users.noreply.github.com>2020-11-01 22:58:45 +0800
commitfa65753233e17d90a3306432bba9d212307e5b68 (patch)
tree005123322c4a65b558e7ece45edcffe20b8dca1d /src/client/views/nodes/formattedText/RichTextMenu.tsx
parent3def219d20179486fe3427c957f680e5d1d705df (diff)
parent7b96bc4770bd275db0ddd664bb6e8ff33bbbcb78 (diff)
Merge branch 'master' into presentation_v1
Diffstat (limited to 'src/client/views/nodes/formattedText/RichTextMenu.tsx')
-rw-r--r--src/client/views/nodes/formattedText/RichTextMenu.tsx8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index 2700c508b..cf9b03308 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -31,6 +31,7 @@ const { toggleMark } = require("prosemirror-commands");
export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
static Instance: RichTextMenu;
public overMenu: boolean = false; // kind of hacky way to prevent selects not being selectable
+ private _linkToRef = React.createRef<HTMLInputElement>();
@observable public view?: EditorView;
public editorProps: FieldViewProps & FormattedTextBoxProps | undefined;
@@ -154,6 +155,9 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
@action
public updateMenu(view: EditorView | undefined, lastState: EditorState | undefined, props: any) {
+ if (this._linkToRef.current?.getBoundingClientRect().width) {
+ return;
+ }
this.view = view;
if (!view || !view.hasFocus()) {
return;
@@ -792,7 +796,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
const self = this;
function onLinkChange(e: React.ChangeEvent<HTMLInputElement>) {
- self.TextView.endUndoTypingBatch();
+ self.TextView?.endUndoTypingBatch();
UndoManager.RunInBatch(() => self.setCurrentLink(e.target.value), "link change");
}
@@ -807,7 +811,7 @@ export class RichTextMenu extends AntimodeMenu<AntimodeMenuProps> {
const dropdownContent =
<div className="dropdown link-menu">
<p>Linked to:</p>
- <input value={link} placeholder="Enter URL" onChange={onLinkChange} />
+ <input value={link} ref={this._linkToRef} placeholder="Enter URL" onChange={onLinkChange} />
<button className="make-button" onPointerDown={e => this.makeLinkToURL(link, "add:right")}>Apply hyperlink</button>
<div className="divider"></div>
<button className="remove-button" onPointerDown={e => this.deleteLink()}>Remove link</button>