aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/formattedText/FormattedTextBox.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-11-19 11:55:52 -0500
committerbobzel <zzzman@gmail.com>2023-11-19 11:55:52 -0500
commit95ca3c2419a760970d56a4af656b28c4f3b6c073 (patch)
treed8afa191064d09cffce31eb912e0cb3fea915d62 /src/client/views/nodes/formattedText/FormattedTextBox.tsx
parent2b0e4ccc096998eb1d727f2e85ea8c1a63b27e08 (diff)
fixed creating anchors when pinning pdf/web/text doc with selection. fixed showing selected text overlay for text docs.
Diffstat (limited to 'src/client/views/nodes/formattedText/FormattedTextBox.tsx')
-rw-r--r--src/client/views/nodes/formattedText/FormattedTextBox.tsx15
1 files changed, 12 insertions, 3 deletions
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<FieldViewProps
static _bulletStyleSheet: any = addStyleSheet();
static _userStyleSheet: any = addStyleSheet();
static _hadSelection: boolean = false;
+ private _selectionHTML: string | undefined;
private _sidebarRef = React.createRef<SidebarAnnos>();
private _sidebarTagRef = React.createRef<React.Component>();
private _ref: React.RefObject<HTMLDivElement> = React.createRef();
@@ -316,6 +317,15 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
});
const coordsB = this._editorView!.coordsAtPos(this._editorView!.state.selection.to);
this.props.isSelected() && AnchorMenu.Instance.jumpTo(coordsB.left, coordsB.bottom);
+ let ele: Opt<HTMLDivElement> = 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<FieldViewProps
this._editorView!.dispatch(tr.removeMark(sel.from, sel.to, splitter));
this.dataDoc[UpdatingFromServer] = this.dataDoc[ForceServerWrite] = false;
anchor.text = selectedText;
+ anchor.text_html = this._selectionHTML ?? selectedText;
anchor.title = selectedText.substring(0, 30);
+ anchor.presentation_zoomText = true;
return anchor;
}
return anchorDoc ?? this.rootDoc;
@@ -1641,9 +1653,6 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent<FieldViewProps
let target = e.target as any; // hrefs are stored on the dataset of the <a> node that wraps the hyerlink <span>
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