@leanix/components 0.4.612 → 0.4.613
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -57,7 +57,7 @@ import Text from '@tiptap/extension-text';
|
|
57
57
|
import TextAlign from '@tiptap/extension-text-align';
|
58
58
|
import Underline from '@tiptap/extension-underline';
|
59
59
|
import { Markdown } from 'tiptap-markdown';
|
60
|
-
import { PluginKey, Plugin } from '@tiptap/pm/state';
|
60
|
+
import { PluginKey, Plugin, NodeSelection } from '@tiptap/pm/state';
|
61
61
|
import { DecorationSet, Decoration } from '@tiptap/pm/view';
|
62
62
|
import { Link } from '@tiptap/extension-link';
|
63
63
|
import { BubbleMenuPlugin } from '@tiptap/extension-bubble-menu';
|
@@ -10672,6 +10672,26 @@ class AngularNodeView extends NodeView {
|
|
10672
10672
|
this.renderer.detectChanges();
|
10673
10673
|
}
|
10674
10674
|
this.appendContendDom();
|
10675
|
+
/**
|
10676
|
+
* Ensure the node is selected when clicked.
|
10677
|
+
*
|
10678
|
+
* ProseMirror/Tiptap sometimes does not trigger `selectionUpdate` for single-node editors
|
10679
|
+
* or when the node is already implicitly selected. By explicitly creating a NodeSelection
|
10680
|
+
* and dispatching it, we force ProseMirror to treat this node as newly selected, which
|
10681
|
+
* triggers `handleSelectionUpdate` and updates the NodeView's selected state.
|
10682
|
+
*/
|
10683
|
+
this.handleMouseDown = (event) => {
|
10684
|
+
if (!this.editor.isEditable)
|
10685
|
+
return;
|
10686
|
+
const pos = this.getPos();
|
10687
|
+
const nodeSelection = NodeSelection.create(this.editor.state.doc, pos);
|
10688
|
+
const tr = this.editor.state.tr.setSelection(nodeSelection);
|
10689
|
+
this.editor.view.dispatch(tr);
|
10690
|
+
this.editor.view.focus();
|
10691
|
+
this.selectNode();
|
10692
|
+
event.stopPropagation();
|
10693
|
+
};
|
10694
|
+
this.dom.addEventListener('mousedown', this.handleMouseDown);
|
10675
10695
|
}
|
10676
10696
|
get dom() {
|
10677
10697
|
return this.renderer.dom;
|
@@ -10726,6 +10746,8 @@ class AngularNodeView extends NodeView {
|
|
10726
10746
|
return true;
|
10727
10747
|
}
|
10728
10748
|
selectNode() {
|
10749
|
+
if (!this.editor.isEditable)
|
10750
|
+
return;
|
10729
10751
|
this.renderer.updateProps({ selected: true });
|
10730
10752
|
}
|
10731
10753
|
deselectNode() {
|
@@ -10734,6 +10756,10 @@ class AngularNodeView extends NodeView {
|
|
10734
10756
|
destroy() {
|
10735
10757
|
this.renderer.destroy();
|
10736
10758
|
this.editor.off('selectionUpdate', this.handleSelectionUpdate);
|
10759
|
+
if (this.handleMouseDown) {
|
10760
|
+
this.dom.removeEventListener('mousedown', this.handleMouseDown);
|
10761
|
+
this.handleMouseDown = undefined;
|
10762
|
+
}
|
10737
10763
|
this.contentDOMElement = null;
|
10738
10764
|
}
|
10739
10765
|
}
|