From 95ca3c2419a760970d56a4af656b28c4f3b6c073 Mon Sep 17 00:00:00 2001 From: bobzel Date: Sun, 19 Nov 2023 11:55:52 -0500 Subject: fixed creating anchors when pinning pdf/web/text doc with selection. fixed showing selected text overlay for text docs. --- src/client/views/nodes/formattedText/FormattedTextBox.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/client/views/nodes/formattedText') diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index c828297b3..b65c440d1 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -93,6 +93,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent(); private _sidebarTagRef = React.createRef(); private _ref: React.RefObject = React.createRef(); @@ -316,6 +317,15 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent = undefined; + try { + const contents = window.getSelection()?.getRangeAt(0).cloneContents(); + if (contents) { + ele = document.createElement('div'); + ele.append(contents); + } + this._selectionHTML = ele?.innerHTML; + } catch (e) {} }; dispatchTransaction = (tx: Transaction) => { @@ -1054,7 +1064,9 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent node that wraps the hyerlink while (target && !target.dataset?.targethrefs) target = target.parentElement; FormattedTextBoxComment.update(this, editor, undefined, target?.dataset?.targethrefs, target?.dataset.linkdoc, target?.dataset.nopreview === 'true'); - if (pcords && pcords.inside > 0 && state.doc.nodeAt(pcords.inside)?.type === state.schema.nodes.dashDoc) { - return; - } } }; @action -- cgit v1.2.3-70-g09d2