@atlaskit/editor-core 178.0.1 → 178.1.0
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.
- package/CHANGELOG.md +40 -0
- package/dist/cjs/create-editor/create-plugins-list.js +3 -1
- package/dist/cjs/plugins/alignment/ui/ToolbarAlignment/index.js +26 -13
- package/dist/cjs/plugins/annotation/index.js +4 -2
- package/dist/cjs/plugins/annotation/ui/InlineCommentView.js +6 -2
- package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +8 -1
- package/dist/cjs/plugins/block-type/commands/delete-block-content.js +53 -0
- package/dist/cjs/plugins/block-type/commands/index.js +9 -1
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/cjs/plugins/card/pm-plugins/doc.js +21 -4
- package/dist/cjs/plugins/card/toolbar.js +4 -2
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +4 -1
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +16 -9
- package/dist/cjs/plugins/collab-edit/actions.js +1 -1
- package/dist/cjs/plugins/collab-edit/index.js +1 -1
- package/dist/cjs/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +5 -0
- package/dist/cjs/plugins/floating-toolbar/ui/Select.js +2 -1
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +18 -9
- package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
- package/dist/cjs/plugins/hyperlink/index.js +2 -1
- package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +15 -2
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +27 -22
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
- package/dist/cjs/plugins/list/styles.js +1 -1
- package/dist/cjs/plugins/media/commands/helpers.js +24 -2
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +14 -16
- package/dist/cjs/plugins/media/nodeviews/mediaNodeUpdater.js +232 -183
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +1 -3
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/cjs/plugins/media/pm-plugins/keymap.js +46 -0
- package/dist/cjs/plugins/rank.js +3 -2
- package/dist/cjs/plugins/selection/pm-plugins/events/create-selection-between.js +86 -0
- package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +84 -0
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +6 -56
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +7 -2
- package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -2
- package/dist/cjs/ui/Addon/ClickAreaBlock/index.js +22 -61
- package/dist/cjs/ui/Addon/ClickAreaInline/index.js +22 -56
- package/dist/cjs/ui/Addon/click-area-helper.js +28 -6
- package/dist/cjs/ui/Alignment/AlignmentButton/index.js +4 -2
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/cjs/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
- package/dist/cjs/utils/document.js +11 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +3 -1
- package/dist/es2019/plugins/alignment/ui/ToolbarAlignment/index.js +28 -13
- package/dist/es2019/plugins/annotation/index.js +4 -2
- package/dist/es2019/plugins/annotation/ui/InlineCommentView.js +6 -2
- package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +8 -1
- package/dist/es2019/plugins/block-type/commands/delete-block-content.js +49 -0
- package/dist/es2019/plugins/block-type/commands/index.js +2 -1
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +3 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -2
- package/dist/es2019/plugins/card/pm-plugins/doc.js +19 -3
- package/dist/es2019/plugins/card/toolbar.js +4 -2
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +5 -2
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +15 -9
- package/dist/es2019/plugins/collab-edit/actions.js +1 -1
- package/dist/es2019/plugins/collab-edit/index.js +1 -1
- package/dist/es2019/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/es2019/plugins/expand/pm-plugins/keymap.js +5 -0
- package/dist/es2019/plugins/floating-toolbar/ui/Select.js +2 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +18 -9
- package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
- package/dist/es2019/plugins/hyperlink/index.js +2 -1
- package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +11 -2
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +1 -5
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
- package/dist/es2019/plugins/list/styles.js +15 -11
- package/dist/es2019/plugins/media/commands/helpers.js +18 -1
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +14 -16
- package/dist/es2019/plugins/media/nodeviews/mediaNodeUpdater.js +37 -13
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +1 -2
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/keymap.js +45 -0
- package/dist/es2019/plugins/rank.js +3 -2
- package/dist/es2019/plugins/selection/pm-plugins/events/create-selection-between.js +79 -0
- package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +77 -0
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +5 -55
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +6 -2
- package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +3 -2
- package/dist/es2019/ui/Addon/ClickAreaBlock/index.js +20 -31
- package/dist/es2019/ui/Addon/ClickAreaInline/index.js +20 -27
- package/dist/es2019/ui/Addon/click-area-helper.js +28 -6
- package/dist/es2019/ui/Alignment/AlignmentButton/index.js +4 -2
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/es2019/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
- package/dist/es2019/utils/document.js +9 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +3 -1
- package/dist/esm/plugins/alignment/ui/ToolbarAlignment/index.js +26 -13
- package/dist/esm/plugins/annotation/index.js +4 -2
- package/dist/esm/plugins/annotation/ui/InlineCommentView.js +6 -2
- package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +8 -1
- package/dist/esm/plugins/block-type/commands/delete-block-content.js +46 -0
- package/dist/esm/plugins/block-type/commands/index.js +2 -1
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +3 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +8 -4
- package/dist/esm/plugins/card/nodeviews/blockCard.js +1 -1
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -2
- package/dist/esm/plugins/card/pm-plugins/doc.js +20 -3
- package/dist/esm/plugins/card/toolbar.js +4 -2
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +5 -2
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +16 -9
- package/dist/esm/plugins/collab-edit/actions.js +1 -1
- package/dist/esm/plugins/collab-edit/index.js +1 -1
- package/dist/esm/plugins/collab-edit/provider/channel.js +1 -1
- package/dist/esm/plugins/expand/pm-plugins/keymap.js +5 -0
- package/dist/esm/plugins/floating-toolbar/ui/Select.js +2 -1
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +18 -9
- package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -0
- package/dist/esm/plugins/hyperlink/index.js +2 -1
- package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +15 -3
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +27 -22
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +6 -2
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +2 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +2 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +2 -1
- package/dist/esm/plugins/list/styles.js +1 -1
- package/dist/esm/plugins/media/commands/helpers.js +20 -1
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +14 -16
- package/dist/esm/plugins/media/nodeviews/mediaNodeUpdater.js +235 -184
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +1 -2
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/keymap.js +45 -0
- package/dist/esm/plugins/rank.js +3 -2
- package/dist/esm/plugins/selection/pm-plugins/events/create-selection-between.js +76 -0
- package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +74 -0
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +4 -57
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +1 -1
- package/dist/esm/plugins/text-formatting/ui/Toolbar/dropdown-menu.js +7 -2
- package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +4 -2
- package/dist/esm/ui/Addon/ClickAreaBlock/index.js +17 -58
- package/dist/esm/ui/Addon/ClickAreaInline/index.js +17 -53
- package/dist/esm/ui/Addon/click-area-helper.js +28 -6
- package/dist/esm/ui/Alignment/AlignmentButton/index.js +4 -2
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +2 -1
- package/dist/esm/ui/ToolbarArrowKeyNavigationProvider/index.js +22 -9
- package/dist/esm/utils/document.js +11 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/alignment/ui/ToolbarAlignment/index.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +10 -0
- package/dist/types/plugins/block-type/commands/index.d.ts +1 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -1
- package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -0
- package/dist/types/plugins/hyperlink/ui/EditorLinkPicker/index.d.ts +6 -1
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +1 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +1 -0
- package/dist/types/plugins/media/commands/helpers.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/mediaNodeUpdater.d.ts +3 -1
- package/dist/types/plugins/media/types.d.ts +2 -0
- package/dist/types/plugins/selection/pm-plugins/events/create-selection-between.d.ts +4 -0
- package/dist/types/plugins/selection/pm-plugins/events/keydown.d.ts +2 -0
- package/dist/types/ui/Addon/ClickAreaBlock/index.d.ts +2 -5
- package/dist/types/ui/Addon/ClickAreaInline/index.d.ts +2 -5
- package/dist/types/ui/Addon/click-area-helper.d.ts +1 -1
- package/dist/types/ui/Alignment/AlignmentButton/index.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/InsertMenu.d.ts +1 -1
- package/dist/types/ui/ElementBrowser/types.d.ts +1 -0
- package/docs/0-intro.tsx +9 -0
- package/package.json +17 -19
- package/report.api.md +4 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { TextSelection } from 'prosemirror-state';
|
|
2
|
+
|
|
3
|
+
const isCollpasedExpand = node => {
|
|
4
|
+
return Boolean(node && ['expand', 'nestedExpand'].includes(node.type.name) && !node.attrs.__expanded);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const findFixedProblematicNodePosition = ($pos, direction) => {
|
|
8
|
+
if ($pos.pos === 0 || $pos.depth === 0) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const pos = direction === 'up' ? $pos.before() : $pos.after();
|
|
13
|
+
const $posResolved = $pos.doc.resolve(pos);
|
|
14
|
+
const maybeExpandNode = direction === 'up' ? $posResolved.nodeBefore : $posResolved.nodeAfter;
|
|
15
|
+
|
|
16
|
+
if (maybeExpandNode && isCollpasedExpand(maybeExpandNode)) {
|
|
17
|
+
const nodeSize = maybeExpandNode.nodeSize;
|
|
18
|
+
const expandPosition = direction === 'up' ? pos - nodeSize : pos + nodeSize;
|
|
19
|
+
const startPosNode = Math.max(expandPosition, 0);
|
|
20
|
+
const $startPosNode = $pos.doc.resolve(Math.min(startPosNode, $pos.doc.content.size));
|
|
21
|
+
return $startPosNode;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const onKeydown = (view, event) => {
|
|
28
|
+
/*
|
|
29
|
+
* This workaround is needed for some specific situation with collapsed expand.
|
|
30
|
+
*
|
|
31
|
+
* The way expand was built, no browser reconize selection on it.
|
|
32
|
+
* For instance, when a selection going to a "collapsed" expand
|
|
33
|
+
* the browser will try to send the cursor to inside the expand content (wrong),
|
|
34
|
+
* this behavior is caused because the expand content is never true hidden
|
|
35
|
+
* we just set the height to 1px.
|
|
36
|
+
*
|
|
37
|
+
* So, we need to capture a possible selection event
|
|
38
|
+
* when a collapsed exxpand is the next node in the common depth.
|
|
39
|
+
* If that is true, we create a new TextSelection and stop the event bubble
|
|
40
|
+
*/
|
|
41
|
+
if (!(event instanceof KeyboardEvent)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!event.shiftKey || event.ctrlKey || event.metaKey) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(event.key)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const {
|
|
54
|
+
selection: {
|
|
55
|
+
$head,
|
|
56
|
+
$anchor
|
|
57
|
+
}
|
|
58
|
+
} = view.state;
|
|
59
|
+
|
|
60
|
+
if (event.key === 'ArrowRight' && $head.nodeAfter || event.key === 'ArrowLeft' && $head.nodeBefore) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const direction = ['ArrowLeft', 'ArrowUp', 'Home'].includes(event.key) ? 'up' : 'down';
|
|
65
|
+
const $fixedProblematicNodePosition = findFixedProblematicNodePosition($head, direction);
|
|
66
|
+
|
|
67
|
+
if ($fixedProblematicNodePosition) {
|
|
68
|
+
const forcedTextSelection = TextSelection.create(view.state.doc, $anchor.pos, $fixedProblematicNodePosition.pos);
|
|
69
|
+
const tr = view.state.tr;
|
|
70
|
+
tr.setSelection(forcedTextSelection);
|
|
71
|
+
view.dispatch(tr);
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
@@ -4,29 +4,12 @@ import { SelectionActionTypes } from '../actions';
|
|
|
4
4
|
import { createPluginState, getPluginState } from '../plugin-factory';
|
|
5
5
|
import { selectionPluginKey } from '../types';
|
|
6
6
|
import { getAllSelectionAnalyticsPayload, getCellSelectionAnalyticsPayload, getDecorations, getNodeSelectionAnalyticsPayload, getRangeSelectionAnalyticsPayload, shouldRecalcDecorations } from '../utils';
|
|
7
|
+
import { onKeydown } from './events/keydown';
|
|
8
|
+
import { onCreateSelectionBetween } from './events/create-selection-between';
|
|
7
9
|
export const getInitialState = state => ({
|
|
8
10
|
decorationSet: getDecorations(state.tr),
|
|
9
11
|
selection: state.selection
|
|
10
12
|
});
|
|
11
|
-
|
|
12
|
-
const toggleContentEditable = (node, root = false) => {
|
|
13
|
-
if (root || node.getAttribute('contenteditable') === 'true') {
|
|
14
|
-
const wasTrue = node.getAttribute('contenteditable') === 'true';
|
|
15
|
-
node.setAttribute('contenteditable', 'false');
|
|
16
|
-
requestAnimationFrame(() => {
|
|
17
|
-
if (wasTrue) {
|
|
18
|
-
node.setAttribute('contenteditable', 'true');
|
|
19
|
-
} else {
|
|
20
|
-
node.removeAttribute('contenteditable');
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
} // any children with contenteditable = true block selection from proceeding
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const children = Array.from(node.children);
|
|
27
|
-
children.forEach(child => toggleContentEditable(child));
|
|
28
|
-
};
|
|
29
|
-
|
|
30
13
|
export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) => {
|
|
31
14
|
return new SafePlugin({
|
|
32
15
|
key: selectionPluginKey,
|
|
@@ -94,11 +77,14 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
|
|
|
94
77
|
},
|
|
95
78
|
|
|
96
79
|
props: {
|
|
80
|
+
createSelectionBetween: onCreateSelectionBetween,
|
|
81
|
+
|
|
97
82
|
decorations(state) {
|
|
98
83
|
return getPluginState(state).decorationSet;
|
|
99
84
|
},
|
|
100
85
|
|
|
101
86
|
handleDOMEvents: {
|
|
87
|
+
keydown: onKeydown,
|
|
102
88
|
// We only want to fire analytics for a click and drag range/cell selection when
|
|
103
89
|
// the user has finished, otherwise we will get an event almost every time they move
|
|
104
90
|
// their mouse which is too much
|
|
@@ -113,42 +99,6 @@ export const createPlugin = (dispatch, dispatchAnalyticsEvent, options = {}) =>
|
|
|
113
99
|
}
|
|
114
100
|
}
|
|
115
101
|
|
|
116
|
-
return false;
|
|
117
|
-
},
|
|
118
|
-
keydown: (editorView, event) => {
|
|
119
|
-
// Bugfix for block ReactNodeViews like table and extension
|
|
120
|
-
// They could not be selected with Shift + ArrowDown/ArrowUp
|
|
121
|
-
// Fixed when contenteditable = false, but then you couldn't edit their contents
|
|
122
|
-
// Therefore, briefly set contenteditable=false to allow the selection through, then set it back to true
|
|
123
|
-
if (event instanceof KeyboardEvent && event.shiftKey && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
124
|
-
const {
|
|
125
|
-
state
|
|
126
|
-
} = editorView; // If current depth is on the top most level, skip that
|
|
127
|
-
|
|
128
|
-
if (state.selection.$head.depth <= 0) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
let pos;
|
|
133
|
-
|
|
134
|
-
if (event.key === 'ArrowDown') {
|
|
135
|
-
pos = state.selection.$head.after();
|
|
136
|
-
} else {
|
|
137
|
-
pos = Math.max(state.selection.$head.before() - 1, 0); // block extensions only take up one position, dont need to get before()
|
|
138
|
-
|
|
139
|
-
if (!editorView.nodeDOM(pos)) {
|
|
140
|
-
pos = state.doc.resolve(pos).before();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const node = editorView.nodeDOM(pos);
|
|
145
|
-
|
|
146
|
-
if (node instanceof HTMLDivElement && node.className.includes('View-content-wrap') // class added by ReactNodeView
|
|
147
|
-
) {
|
|
148
|
-
toggleContentEditable(node, true);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
102
|
return false;
|
|
153
103
|
}
|
|
154
104
|
}
|
|
@@ -171,7 +171,7 @@ export class ToolbarTextColor extends React.Component {
|
|
|
171
171
|
zIndex: akEditorMenuZIndex,
|
|
172
172
|
fitWidth: fitWidth,
|
|
173
173
|
onOpenChange: this.onOpenChange,
|
|
174
|
-
|
|
174
|
+
closeOnTab: true,
|
|
175
175
|
trigger: jsx(ToolbarButton, {
|
|
176
176
|
buttonId: TOOLBAR_BUTTON.TEXT_COLOR,
|
|
177
177
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
@@ -18,10 +18,14 @@ export const FormattingTextDropdownMenu = /*#__PURE__*/React.memo(({
|
|
|
18
18
|
items
|
|
19
19
|
}], [items]);
|
|
20
20
|
const onItemActivated = useCallback(({
|
|
21
|
-
item
|
|
21
|
+
item,
|
|
22
|
+
shouldCloseMenu = true
|
|
22
23
|
}) => {
|
|
23
24
|
item.command(editorView.state, editorView.dispatch);
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
if (shouldCloseMenu) {
|
|
27
|
+
closeMenu();
|
|
28
|
+
}
|
|
25
29
|
}, [editorView.state, editorView.dispatch, closeMenu]);
|
|
26
30
|
return /*#__PURE__*/React.createElement(DropdownMenu, {
|
|
27
31
|
mountTo: popupsMountPoint,
|
|
@@ -40,9 +40,10 @@ export function ToolbarDropdown(props) {
|
|
|
40
40
|
const items = useItems(props);
|
|
41
41
|
|
|
42
42
|
const handleOnItemActivated = ({
|
|
43
|
-
item
|
|
43
|
+
item,
|
|
44
|
+
shouldCloseMenu = true
|
|
44
45
|
}) => {
|
|
45
|
-
setIsDropdownOpen(
|
|
46
|
+
setIsDropdownOpen(!shouldCloseMenu);
|
|
46
47
|
return onItemActivated({
|
|
47
48
|
editorView: props.editorView,
|
|
48
49
|
buttonName: item.value.name
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
1
|
/** @jsx jsx */
|
|
4
2
|
import React from 'react';
|
|
5
3
|
import { css, jsx } from '@emotion/react';
|
|
@@ -8,33 +6,24 @@ const clickWrapper = css`
|
|
|
8
6
|
flex-grow: 1;
|
|
9
7
|
height: 100%;
|
|
10
8
|
`;
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!view) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (!editorDisabled) {
|
|
26
|
-
// if the editor is disabled -- we don't want to intercept any click events
|
|
27
|
-
clickAreaClickHandler(view, event);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
render() {
|
|
33
|
-
return jsx("div", {
|
|
34
|
-
"data-testid": "click-wrapper",
|
|
35
|
-
css: clickWrapper,
|
|
36
|
-
onClick: this.handleClick
|
|
37
|
-
}, this.props.children);
|
|
38
|
-
}
|
|
9
|
+
export const ClickAreaBlock = ({
|
|
10
|
+
editorView,
|
|
11
|
+
editorDisabled,
|
|
12
|
+
children
|
|
13
|
+
}) => {
|
|
14
|
+
const handleMouseDown = React.useCallback(event => {
|
|
15
|
+
if (!editorView) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
39
18
|
|
|
40
|
-
|
|
19
|
+
if (!editorDisabled) {
|
|
20
|
+
clickAreaClickHandler(editorView, event);
|
|
21
|
+
}
|
|
22
|
+
}, [editorView, editorDisabled]);
|
|
23
|
+
return jsx("div", {
|
|
24
|
+
"data-testid": "click-wrapper",
|
|
25
|
+
css: clickWrapper,
|
|
26
|
+
onMouseDown: handleMouseDown
|
|
27
|
+
}, children);
|
|
28
|
+
};
|
|
29
|
+
export default ClickAreaBlock;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
1
|
/** @jsx jsx */
|
|
4
2
|
import React from 'react';
|
|
5
3
|
import { css, jsx } from '@emotion/react';
|
|
@@ -7,29 +5,24 @@ import { createParagraphAtEnd } from '../../../commands';
|
|
|
7
5
|
const clickArea = css`
|
|
8
6
|
flex-grow: 1;
|
|
9
7
|
`;
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (editorView) {
|
|
20
|
-
if (createParagraphAtEnd()(editorView.state, editorView.dispatch)) {
|
|
21
|
-
editorView.focus();
|
|
22
|
-
event.stopPropagation();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
return jsx("div", {
|
|
30
|
-
css: clickArea,
|
|
31
|
-
onClick: this.handleClick
|
|
32
|
-
});
|
|
33
|
-
}
|
|
8
|
+
export const ClickAreaInline = ({
|
|
9
|
+
editorView,
|
|
10
|
+
children
|
|
11
|
+
}) => {
|
|
12
|
+
const handleMouseDown = React.useCallback(event => {
|
|
13
|
+
if (!editorView) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
34
16
|
|
|
35
|
-
|
|
17
|
+
if (createParagraphAtEnd()(editorView.state, editorView.dispatch)) {
|
|
18
|
+
editorView.focus();
|
|
19
|
+
event.stopPropagation();
|
|
20
|
+
}
|
|
21
|
+
}, [editorView]);
|
|
22
|
+
return jsx("div", {
|
|
23
|
+
"data-testid": "click-wrapper",
|
|
24
|
+
css: clickArea,
|
|
25
|
+
onMouseDown: handleMouseDown
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
export default ClickAreaInline;
|
|
@@ -13,6 +13,10 @@ const insideContentArea = ref => {
|
|
|
13
13
|
|
|
14
14
|
return false;
|
|
15
15
|
};
|
|
16
|
+
|
|
17
|
+
const insideProseMirrorEditableArea = ref => {
|
|
18
|
+
return Boolean(ref === null || ref === void 0 ? void 0 : ref.closest('.ProseMirror'));
|
|
19
|
+
};
|
|
16
20
|
/**
|
|
17
21
|
* @see ED-14699 - check if editor is inside a modal to continue to bring cursor to input when
|
|
18
22
|
* any part of the editor container is clicked
|
|
@@ -37,11 +41,19 @@ export const checkForModal = target => {
|
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
const clickAreaClickHandler = (view, event) => {
|
|
40
|
-
var _view$hasFocus;
|
|
44
|
+
var _view$hasFocus, _event$currentTarget;
|
|
41
45
|
|
|
42
|
-
const isTargetContentArea = event.currentTarget.querySelector('.ak-editor-content-area');
|
|
43
46
|
const isEditorFocused = !!(view !== null && view !== void 0 && (_view$hasFocus = view.hasFocus) !== null && _view$hasFocus !== void 0 && _view$hasFocus.call(view));
|
|
44
|
-
const target = event.target;
|
|
47
|
+
const target = event.target;
|
|
48
|
+
const isTargetContentArea = target.classList.contains('ak-editor-content-area');
|
|
49
|
+
const isTargetChildOfContentArea = insideContentArea(target.parentNode);
|
|
50
|
+
const isTargetInsideEditableArea = insideProseMirrorEditableArea(target); // Any click inside ProseMirror should be managed by ProseMirror
|
|
51
|
+
|
|
52
|
+
if (isTargetInsideEditableArea) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const isEventComingFromContentArea = Boolean(event.currentTarget.querySelector('.ak-editor-content-area')); // @see https://product-fabric.atlassian.net/browse/ED-4287
|
|
45
57
|
// click event gets triggered twice on a checkbox (on <label> first and then on <input>)
|
|
46
58
|
// by the time it gets triggered on input, PM already re-renders nodeView and detaches it from DOM
|
|
47
59
|
// which doesn't pass the check !contentArea.contains(event.target)
|
|
@@ -52,10 +64,20 @@ const clickAreaClickHandler = (view, event) => {
|
|
|
52
64
|
|
|
53
65
|
const isTextAreaClicked = target.nodeName === 'TEXTAREA';
|
|
54
66
|
const isBreadcrumbClicked = !!closestElement(target, 'nav[aria-label="Breadcrumbs"]');
|
|
55
|
-
const isTargetChildOfContentArea = insideContentArea(target.parentNode);
|
|
56
67
|
const selection = window.getSelection();
|
|
57
|
-
const isEditorPopupTextSelected = (selection === null || selection === void 0 ? void 0 : selection.type) === 'Range' && closestElement(selection === null || selection === void 0 ? void 0 : selection.anchorNode, '[data-editor-popup]');
|
|
58
|
-
|
|
68
|
+
const isEditorPopupTextSelected = (selection === null || selection === void 0 ? void 0 : selection.type) === 'Range' && closestElement(selection === null || selection === void 0 ? void 0 : selection.anchorNode, '[data-editor-popup]'); // This is a super workaround to find when events are coming from Confluence InlineComment modal
|
|
69
|
+
// We don't own those components, so we can't change them
|
|
70
|
+
|
|
71
|
+
const isEventComingFromInlineCommentPopup = Boolean(closestElement(event.currentTarget, 'div[offset]')) || Boolean(closestElement(target, 'div[offset]'));
|
|
72
|
+
const isButtonClicked = Boolean(closestElement(event.currentTarget, 'button')) || Boolean(closestElement(target, 'button')) || ((_event$currentTarget = event.currentTarget) === null || _event$currentTarget === void 0 ? void 0 : _event$currentTarget.nodeName) === 'BUTTON' || target.nodeName === 'BUTTON';
|
|
73
|
+
const isTargetInsideContentArea = Boolean(isTargetChildOfContentArea);
|
|
74
|
+
const isBetweenContentAreaAndEditableContent = isTargetInsideContentArea && !isTargetInsideEditableArea;
|
|
75
|
+
const edgeCaseScenario1 = (isBetweenContentAreaAndEditableContent || !isEventComingFromContentArea) && !isEditorFocused;
|
|
76
|
+
const edgeCaseScenario2 = !isTargetInsideContentArea && isEditorFocused;
|
|
77
|
+
const edgeCaseScenario3 = isTargetContentArea && !isTargetInsideContentArea && !isEditorFocused;
|
|
78
|
+
const edgeCaseScenario4 = isEventComingFromContentArea && !isTargetContentArea && !isTargetInsideContentArea && !isEditorFocused;
|
|
79
|
+
const edgeCases = edgeCaseScenario1 || edgeCaseScenario2 || edgeCaseScenario3 || edgeCaseScenario4;
|
|
80
|
+
const isClickOutsideEditor = edgeCases && !isEventComingFromInlineCommentPopup && !isButtonClicked && !isInputClicked && !isTextAreaClicked && !isPopupClicked && !isBreadcrumbClicked && !isEditorPopupTextSelected && checkForModal(target); // click was within editor container and focus should be brought to input
|
|
59
81
|
|
|
60
82
|
if (isClickOutsideEditor && view) {
|
|
61
83
|
outsideProsemirrorEditorClickHandler(view, event);
|
|
@@ -13,9 +13,11 @@ class AlignmentButton extends PureComponent {
|
|
|
13
13
|
const {
|
|
14
14
|
onClick,
|
|
15
15
|
value
|
|
16
|
-
} = this.props;
|
|
16
|
+
} = this.props; // detect if the click event comes from keyboard where screenX and screenY are 0
|
|
17
|
+
|
|
18
|
+
const isMouseEvent = e instanceof MouseEvent;
|
|
17
19
|
e.preventDefault();
|
|
18
|
-
onClick(value);
|
|
20
|
+
onClick(value, isMouseEvent);
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
|
|
@@ -21,6 +21,7 @@ import { ELEMENT_ITEM_HEIGHT } from './constants';
|
|
|
21
21
|
const InsertMenu = ({
|
|
22
22
|
editorView,
|
|
23
23
|
dropdownItems,
|
|
24
|
+
showElementBrowserLink,
|
|
24
25
|
onInsert,
|
|
25
26
|
toggleVisiblity
|
|
26
27
|
}) => {
|
|
@@ -40,7 +41,7 @@ const InsertMenu = ({
|
|
|
40
41
|
value: item.value
|
|
41
42
|
}), [onInsert]);
|
|
42
43
|
const quickInsertDropdownItems = dropdownItems.map(transform);
|
|
43
|
-
const viewMoreItem = quickInsertDropdownItems.pop();
|
|
44
|
+
const viewMoreItem = showElementBrowserLink && quickInsertDropdownItems.pop();
|
|
44
45
|
const onInsertItem = useCallback(item => {
|
|
45
46
|
toggleVisiblity();
|
|
46
47
|
|
|
@@ -29,18 +29,24 @@ export const ToolbarArrowKeyNavigationProvider = ({
|
|
|
29
29
|
const wrapperRef = useRef(null);
|
|
30
30
|
const selectedItemIndex = useRef(0);
|
|
31
31
|
const incrementIndex = useCallback(list => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
let index = 0;
|
|
33
|
+
|
|
34
|
+
if (document.activeElement) {
|
|
35
|
+
index = list.indexOf(document.activeElement);
|
|
36
|
+
index = (index + 1) % list.length;
|
|
36
37
|
}
|
|
38
|
+
|
|
39
|
+
selectedItemIndex.current = index;
|
|
37
40
|
}, []);
|
|
38
41
|
const decrementIndex = useCallback(list => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
let index = 0;
|
|
43
|
+
|
|
44
|
+
if (document.activeElement) {
|
|
45
|
+
index = list.indexOf(document.activeElement);
|
|
46
|
+
index = (list.length + index - 1) % list.length;
|
|
43
47
|
}
|
|
48
|
+
|
|
49
|
+
selectedItemIndex.current = index;
|
|
44
50
|
}, []);
|
|
45
51
|
|
|
46
52
|
const handleArrowRight = () => {
|
|
@@ -108,12 +114,19 @@ export const ToolbarArrowKeyNavigationProvider = ({
|
|
|
108
114
|
return;
|
|
109
115
|
}
|
|
110
116
|
|
|
117
|
+
const menuWrapper = document.querySelector('.menu-key-handler-wrapper');
|
|
118
|
+
|
|
119
|
+
if (menuWrapper) {
|
|
120
|
+
// if menu wrapper exists, then a menu is open and arrow keys will be handled by MenuArrowKeyNavigationProvider
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
|
|
111
124
|
const filteredFocusableElements = getFilteredFocusableElements(wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current);
|
|
112
125
|
|
|
113
126
|
if (!filteredFocusableElements || (filteredFocusableElements === null || filteredFocusableElements === void 0 ? void 0 : filteredFocusableElements.length) === 0) {
|
|
114
127
|
return;
|
|
115
128
|
} //This is kind of hack to reset the current focused toolbar item
|
|
116
|
-
//to handle some
|
|
129
|
+
//to handle some use cases such as Tab in/out of main toolbar
|
|
117
130
|
|
|
118
131
|
|
|
119
132
|
if (!((_wrapperRef$current = wrapperRef.current) !== null && _wrapperRef$current !== void 0 && _wrapperRef$current.contains(targetElement))) {
|
|
@@ -217,11 +217,18 @@ export function processRawValue(schema, value, providerFactory, sanitizePrivateC
|
|
|
217
217
|
|
|
218
218
|
if (isTransformed && dispatchAnalyticsEvent) {
|
|
219
219
|
dispatchAnalyticsEvent({
|
|
220
|
-
action: ACTION.
|
|
220
|
+
action: ACTION.DEDUPE_MARKS_TRANSFORMED_V2,
|
|
221
221
|
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
222
222
|
eventType: EVENT_TYPE.OPERATIONAL,
|
|
223
223
|
attributes: {
|
|
224
|
-
|
|
224
|
+
/** UGC WARNING
|
|
225
|
+
*
|
|
226
|
+
* DO NOT include the `mark` attributes inside, we map here to only
|
|
227
|
+
* extract the mark type as that is the only non-UGC safe information
|
|
228
|
+
* that we can add to event-attributes
|
|
229
|
+
*
|
|
230
|
+
*/
|
|
231
|
+
discardedMarkTypes: discardedMarks.map(mark => mark.type)
|
|
225
232
|
}
|
|
226
233
|
});
|
|
227
234
|
}
|
package/dist/es2019/version.json
CHANGED
|
@@ -185,6 +185,7 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
|
|
|
185
185
|
allowDropzoneDropLine: isFullPage,
|
|
186
186
|
allowMediaSingleEditable: !isMobile,
|
|
187
187
|
allowRemoteDimensionsFetch: !isMobile,
|
|
188
|
+
editorSelectionAPI: editorSelectionAPI,
|
|
188
189
|
// This is a wild one. I didnt quite understand what the code was doing
|
|
189
190
|
// so a bit of guess for now.
|
|
190
191
|
allowMarkingUploadsAsIncomplete: isMobile,
|
|
@@ -261,7 +262,8 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
|
|
|
261
262
|
disableLayout: true
|
|
262
263
|
},
|
|
263
264
|
allowMediaGroup: false,
|
|
264
|
-
isCopyPasteEnabled: true
|
|
265
|
+
isCopyPasteEnabled: true,
|
|
266
|
+
editorSelectionAPI: editorSelectionAPI
|
|
265
267
|
}]);
|
|
266
268
|
}
|
|
267
269
|
}
|
|
@@ -43,8 +43,10 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
43
43
|
isOpen: false
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "changeAlignment", function (align) {
|
|
47
|
-
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "changeAlignment", function (align, togglePopup) {
|
|
47
|
+
if (togglePopup) {
|
|
48
|
+
_this.toggleOpen();
|
|
49
|
+
}
|
|
48
50
|
|
|
49
51
|
return _this.props.changeAlignment(align);
|
|
50
52
|
});
|
|
@@ -77,11 +79,10 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
77
79
|
}
|
|
78
80
|
});
|
|
79
81
|
|
|
80
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
82
|
+
_defineProperty(_assertThisInitialized(_this), "hideOnEscape", function () {
|
|
81
83
|
var _this$toolbarItemRef2, _this$toolbarItemRef3;
|
|
82
84
|
|
|
83
|
-
_this.hide();
|
|
84
|
-
|
|
85
|
+
_this.hide();
|
|
85
86
|
|
|
86
87
|
(_this$toolbarItemRef2 = _this.toolbarItemRef) === null || _this$toolbarItemRef2 === void 0 ? void 0 : (_this$toolbarItemRef3 = _this$toolbarItemRef2.current) === null || _this$toolbarItemRef3 === void 0 ? void 0 : _this$toolbarItemRef3.focus();
|
|
87
88
|
});
|
|
@@ -111,17 +112,29 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
111
112
|
boundariesElement: popupsBoundariesElement,
|
|
112
113
|
scrollableElement: popupsScrollableElement,
|
|
113
114
|
isOpen: isOpen,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
onOpenChange: function onOpenChange(_ref2) {
|
|
116
|
+
var _this2$toolbarItemRef, _this2$toolbarItemRef2;
|
|
117
|
+
|
|
118
|
+
var isOpen = _ref2.isOpen;
|
|
119
|
+
|
|
120
|
+
_this2.setState({
|
|
121
|
+
isOpen: isOpen
|
|
118
122
|
});
|
|
123
|
+
|
|
124
|
+
(_this2$toolbarItemRef = _this2.toolbarItemRef) === null || _this2$toolbarItemRef === void 0 ? void 0 : (_this2$toolbarItemRef2 = _this2$toolbarItemRef.current) === null || _this2$toolbarItemRef2 === void 0 ? void 0 : _this2$toolbarItemRef2.focus();
|
|
125
|
+
},
|
|
126
|
+
handleClickOutside: function handleClickOutside(event) {
|
|
127
|
+
if (event instanceof MouseEvent) {
|
|
128
|
+
_this2.hide({
|
|
129
|
+
isOpen: false,
|
|
130
|
+
event: event
|
|
131
|
+
});
|
|
132
|
+
}
|
|
119
133
|
},
|
|
120
|
-
handleEscapeKeydown: this.
|
|
121
|
-
onOpenChange: this.hide,
|
|
134
|
+
handleEscapeKeydown: this.hideOnEscape,
|
|
122
135
|
fitWidth: 112,
|
|
123
136
|
fitHeight: 80,
|
|
124
|
-
|
|
137
|
+
closeOnTab: true,
|
|
125
138
|
trigger: jsx(ToolbarButton, {
|
|
126
139
|
spacing: isReducedSpacing ? 'none' : 'default',
|
|
127
140
|
disabled: disabled,
|
|
@@ -145,7 +158,7 @@ export var AlignmentToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
145
158
|
})
|
|
146
159
|
}, jsx(Alignment, {
|
|
147
160
|
onClick: function onClick(align) {
|
|
148
|
-
return _this2.changeAlignment(align);
|
|
161
|
+
return _this2.changeAlignment(align, false);
|
|
149
162
|
},
|
|
150
163
|
selectedAlignment: pluginState.align
|
|
151
164
|
})), jsx("span", {
|
|
@@ -82,11 +82,13 @@ var annotationPlugin = function annotationPlugin(annotationProviders) {
|
|
|
82
82
|
return null;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
return /*#__PURE__*/React.createElement(
|
|
85
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
86
|
+
"data-editor-popup": "true"
|
|
87
|
+
}, /*#__PURE__*/React.createElement(InlineCommentView, {
|
|
86
88
|
providers: annotationProviders,
|
|
87
89
|
editorView: editorView,
|
|
88
90
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
89
|
-
});
|
|
91
|
+
}));
|
|
90
92
|
}
|
|
91
93
|
});
|
|
92
94
|
}
|
|
@@ -59,7 +59,9 @@ export function InlineCommentView(_ref) {
|
|
|
59
59
|
selection: selection.toJSON(),
|
|
60
60
|
position: position,
|
|
61
61
|
docSize: editorView.state.doc.nodeSize,
|
|
62
|
-
error: error.toString()
|
|
62
|
+
error: error.toString()
|
|
63
|
+
},
|
|
64
|
+
nonPrivacySafeAttributes: {
|
|
63
65
|
errorStack: error.stack || undefined
|
|
64
66
|
}
|
|
65
67
|
};
|
|
@@ -80,7 +82,8 @@ export function InlineCommentView(_ref) {
|
|
|
80
82
|
|
|
81
83
|
var textSelection = state.doc.textBetween(selection.from, selection.to);
|
|
82
84
|
return /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
"data-testid": AnnotationTestIds.floatingComponent
|
|
85
|
+
"data-testid": AnnotationTestIds.floatingComponent,
|
|
86
|
+
"data-editor-popup": "true"
|
|
84
87
|
}, /*#__PURE__*/React.createElement(CreateComponent, {
|
|
85
88
|
dom: dom,
|
|
86
89
|
textSelection: textSelection,
|
|
@@ -127,6 +130,7 @@ export function InlineCommentView(_ref) {
|
|
|
127
130
|
}
|
|
128
131
|
|
|
129
132
|
return /*#__PURE__*/React.createElement(AnnotationViewWrapper, {
|
|
133
|
+
"data-editor-popup": "true",
|
|
130
134
|
"data-testid": AnnotationTestIds.floatingComponent,
|
|
131
135
|
key: getAnnotationViewKey(activeAnnotations),
|
|
132
136
|
onViewed: onAnnotationViewed
|
|
@@ -48,12 +48,19 @@ export var plugin = new SafePlugin({
|
|
|
48
48
|
key: stateKey,
|
|
49
49
|
view: function view(_view) {
|
|
50
50
|
var pluginState = stateKey.getState(_view.state);
|
|
51
|
+
var prevFrom = -1;
|
|
52
|
+
var prevTo = -1;
|
|
51
53
|
return {
|
|
52
54
|
update: function update(view) {
|
|
53
55
|
var _view$state$selection = view.state.selection,
|
|
54
56
|
from = _view$state$selection.from,
|
|
55
57
|
to = _view$state$selection.to;
|
|
56
|
-
|
|
58
|
+
|
|
59
|
+
if (from !== prevFrom || to !== prevTo) {
|
|
60
|
+
pluginState.notifyNewSelection(from, to);
|
|
61
|
+
prevFrom = from;
|
|
62
|
+
prevTo = to;
|
|
63
|
+
}
|
|
57
64
|
}
|
|
58
65
|
};
|
|
59
66
|
}
|