@atlaskit/editor-common 129.0.0 → 129.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 +24 -0
- package/dist/cjs/clipboard/index.js +41 -21
- package/dist/cjs/extensibility/extensionNodeView.js +17 -2
- package/dist/cjs/extensibility/preserveRemixNodeView.js +150 -0
- package/dist/cjs/extensions/native-embed-maui-extension-key.js +8 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/quick-insert/get-matching-quick-insert-components.js +38 -9
- package/dist/cjs/quick-insert/getQuickInsertMenuRows.js +12 -0
- package/dist/cjs/quick-insert/registered-menu-model.js +7 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/clipboard/index.js +18 -6
- package/dist/es2019/extensibility/extensionNodeView.js +15 -2
- package/dist/es2019/extensibility/preserveRemixNodeView.js +132 -0
- package/dist/es2019/extensions/native-embed-maui-extension-key.js +2 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/quick-insert/get-matching-quick-insert-components.js +23 -3
- package/dist/es2019/quick-insert/getQuickInsertMenuRows.js +4 -0
- package/dist/es2019/quick-insert/registered-menu-model.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/clipboard/index.js +40 -20
- package/dist/esm/extensibility/extensionNodeView.js +17 -2
- package/dist/esm/extensibility/preserveRemixNodeView.js +145 -0
- package/dist/esm/extensions/native-embed-maui-extension-key.js +2 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/quick-insert/get-matching-quick-insert-components.js +37 -9
- package/dist/esm/quick-insert/getQuickInsertMenuRows.js +5 -0
- package/dist/esm/quick-insert/registered-menu-model.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/extensibility/preserveRemixNodeView.d.ts +33 -0
- package/dist/types/extensions/native-embed-maui-extension-key.d.ts +1 -0
- package/dist/types/quick-insert/build-quick-insert-menu-model.d.ts +1 -0
- package/dist/types/quick-insert/getQuickInsertMenuRows.d.ts +3 -0
- package/dist/types/quick-insert/registered-menu-model.d.ts +1 -0
- package/extensibility/preserve-remix-node-view/package.json +10 -0
- package/extensions/native-embed-maui-extension-key/package.json +10 -0
- package/package.json +2 -2
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { NATIVE_EMBED_MAUI_EXTENSION_KEY } from '../extensions/native-embed-maui-extension-key';
|
|
2
|
+
|
|
3
|
+
// Do not polyfill with insertBefore: it disconnects an iframe and resets its browsing context.
|
|
4
|
+
|
|
5
|
+
const editors = new WeakMap();
|
|
6
|
+
/** Only block Remix embeds with a stable identity can participate in the handoff. */
|
|
7
|
+
const isRemixNodeForPreservation = node => node.type.name === 'extension' && node.attrs.extensionKey === NATIVE_EMBED_MAUI_EXTENSION_KEY && typeof node.attrs.localId === 'string' && node.attrs.localId.length > 0;
|
|
8
|
+
const sameChart = (left, right) => left.mark(left.marks.filter(mark => mark.type.name !== 'annotation')).eq(right.mark(right.marks.filter(mark => mark.type.name !== 'annotation')));
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A disposable ProseMirror slot around a retained React portal. destroy() parks the
|
|
12
|
+
* portal before ProseMirror disconnects its mark wrapper. After reconciliation, the
|
|
13
|
+
* replacement claims the parked portal without taking one from a still-live node.
|
|
14
|
+
*/
|
|
15
|
+
export function preserveRemixNodeView({
|
|
16
|
+
node,
|
|
17
|
+
view,
|
|
18
|
+
getPos,
|
|
19
|
+
renderProps,
|
|
20
|
+
rendererKind,
|
|
21
|
+
createExtensionNode
|
|
22
|
+
}) {
|
|
23
|
+
if (!isRemixNodeForPreservation(node)) {
|
|
24
|
+
return createExtensionNode(node).init();
|
|
25
|
+
}
|
|
26
|
+
const ownerDocument = view.dom.ownerDocument;
|
|
27
|
+
const slot = ownerDocument.createElement('div');
|
|
28
|
+
if (!view.dom.isConnected || typeof getPos !== 'function' || typeof slot.moveBefore !== 'function') {
|
|
29
|
+
return createExtensionNode(node).init();
|
|
30
|
+
}
|
|
31
|
+
const owner = {
|
|
32
|
+
getPos,
|
|
33
|
+
destroyed: false
|
|
34
|
+
};
|
|
35
|
+
let entries = editors.get(view);
|
|
36
|
+
if (!entries) {
|
|
37
|
+
entries = new Set();
|
|
38
|
+
editors.set(view, entries);
|
|
39
|
+
}
|
|
40
|
+
const registry = entries;
|
|
41
|
+
let entry;
|
|
42
|
+
let latestNode = node;
|
|
43
|
+
let latestDecorations = [];
|
|
44
|
+
let latestInnerDecorations;
|
|
45
|
+
|
|
46
|
+
// Construction can precede the old slot's destroy(). Defer portal adoption until
|
|
47
|
+
// both hooks have run; no rendering opportunity occurs between these microtasks.
|
|
48
|
+
queueMicrotask(() => {
|
|
49
|
+
if (owner.destroyed || view.isDestroyed || !slot.isConnected) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
entry = Array.from(registry).find(existing => existing.owner.destroyed && existing.rendererKind === rendererKind && sameChart(existing.inner.node, latestNode));
|
|
53
|
+
if (entry) {
|
|
54
|
+
var _slot$moveBefore, _entry$parking;
|
|
55
|
+
entry.owner = owner;
|
|
56
|
+
entry.inner.reactComponentProps = renderProps;
|
|
57
|
+
(_slot$moveBefore = slot.moveBefore) === null || _slot$moveBefore === void 0 ? void 0 : _slot$moveBefore.call(slot, entry.inner.dom, null);
|
|
58
|
+
(_entry$parking = entry.parking) === null || _entry$parking === void 0 ? void 0 : _entry$parking.remove();
|
|
59
|
+
entry.parking = undefined;
|
|
60
|
+
if (!entry.inner.update(latestNode, latestDecorations, latestInnerDecorations)) {
|
|
61
|
+
// A matching chart is normally accepted, but honour the NodeView contract
|
|
62
|
+
// if a renderer rejects it. Remove the old portal before creating a replacement.
|
|
63
|
+
registry.delete(entry);
|
|
64
|
+
const dom = entry.inner.dom;
|
|
65
|
+
entry.inner.destroy();
|
|
66
|
+
dom.remove();
|
|
67
|
+
entry = undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!entry) {
|
|
71
|
+
// Construct only after the old slot has had a chance to park its portal.
|
|
72
|
+
const inner = createExtensionNode(latestNode);
|
|
73
|
+
const retained = {
|
|
74
|
+
inner,
|
|
75
|
+
owner,
|
|
76
|
+
rendererKind
|
|
77
|
+
};
|
|
78
|
+
entry = retained;
|
|
79
|
+
inner.getPos = () => retained.owner.destroyed ? undefined : retained.owner.getPos();
|
|
80
|
+
inner.init();
|
|
81
|
+
slot.appendChild(inner.dom);
|
|
82
|
+
registry.add(retained);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
dom: slot,
|
|
87
|
+
// The retained extension is an atom: ProseMirror must not manage the portal's children.
|
|
88
|
+
update(next, decorations, innerDecorations) {
|
|
89
|
+
if (next.type !== node.type || next.attrs.localId !== node.attrs.localId || next.attrs.extensionKey !== node.attrs.extensionKey) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
latestNode = next;
|
|
93
|
+
latestDecorations = decorations;
|
|
94
|
+
latestInnerDecorations = innerDecorations;
|
|
95
|
+
return entry ? entry.inner.update(next, decorations, innerDecorations) : true;
|
|
96
|
+
},
|
|
97
|
+
stopEvent: event => {
|
|
98
|
+
var _entry$inner$stopEven, _entry;
|
|
99
|
+
return (_entry$inner$stopEven = (_entry = entry) === null || _entry === void 0 ? void 0 : _entry.inner.stopEvent(event)) !== null && _entry$inner$stopEven !== void 0 ? _entry$inner$stopEven : false;
|
|
100
|
+
},
|
|
101
|
+
ignoreMutation: mutation => {
|
|
102
|
+
var _entry$inner$ignoreMu, _entry2;
|
|
103
|
+
return (_entry$inner$ignoreMu = (_entry2 = entry) === null || _entry2 === void 0 ? void 0 : _entry2.inner.ignoreMutation(mutation)) !== null && _entry$inner$ignoreMu !== void 0 ? _entry$inner$ignoreMu : mutation.type !== 'selection';
|
|
104
|
+
},
|
|
105
|
+
destroy() {
|
|
106
|
+
owner.destroyed = true;
|
|
107
|
+
if (!entry) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const retained = entry;
|
|
111
|
+
if (retained.inner.dom.isConnected) {
|
|
112
|
+
var _parking$moveBefore;
|
|
113
|
+
const parking = ownerDocument.createElement('div');
|
|
114
|
+
// Transient, outside the editable document and inaccessible while awaiting handoff.
|
|
115
|
+
parking.hidden = true;
|
|
116
|
+
ownerDocument.body.appendChild(parking);
|
|
117
|
+
(_parking$moveBefore = parking.moveBefore) === null || _parking$moveBefore === void 0 ? void 0 : _parking$moveBefore.call(parking, retained.inner.dom, null);
|
|
118
|
+
retained.parking = parking;
|
|
119
|
+
}
|
|
120
|
+
// Give constructors queued after destroy() a chance to claim the portal first.
|
|
121
|
+
queueMicrotask(() => queueMicrotask(() => {
|
|
122
|
+
if (retained.owner === owner && registry.delete(retained)) {
|
|
123
|
+
var _retained$parking;
|
|
124
|
+
const dom = retained.inner.dom;
|
|
125
|
+
retained.inner.destroy();
|
|
126
|
+
dom.remove();
|
|
127
|
+
(_retained$parking = retained.parking) === null || _retained$parking === void 0 ? void 0 : _retained$parking.remove();
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
@@ -13,7 +13,7 @@ const NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
13
13
|
const RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
14
14
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
15
15
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
16
|
-
const packageVersion = "
|
|
16
|
+
const packageVersion = "129.0.0";
|
|
17
17
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
18
18
|
// Remove URL as it has UGC
|
|
19
19
|
// Ignored via go/ees007
|
|
@@ -2,11 +2,25 @@ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atla
|
|
|
2
2
|
import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
|
|
3
3
|
import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
|
|
4
4
|
import { ASK_ROVO_MENU_ITEM } from './keys';
|
|
5
|
+
const SEARCH_TOP_MATCH_LIMIT = 5;
|
|
5
6
|
const getRank = (component, parentKey) => {
|
|
6
7
|
var _component$parents$fi, _component$parents, _component$parents$fi2;
|
|
7
8
|
return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 ? void 0 : (_component$parents$fi2 = _component$parents.find(parent => parent.key === parentKey)) === null || _component$parents$fi2 === void 0 ? void 0 : _component$parents$fi2.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
|
|
8
9
|
};
|
|
9
|
-
const compareMatchedItems = (a, b) => a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
|
|
10
|
+
const compareMatchedItems = (a, b) => a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
11
|
+
const compareSearchResults = (a, b) => a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
12
|
+
const getSearchResults = matches => {
|
|
13
|
+
const topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
|
|
14
|
+
const topMatchIdentities = new Set(topMatches.map(({
|
|
15
|
+
identity
|
|
16
|
+
}) => identity));
|
|
17
|
+
const tailMatches = matches.filter(({
|
|
18
|
+
identity
|
|
19
|
+
}) => !topMatchIdentities.has(identity));
|
|
20
|
+
return [...topMatches, ...tailMatches].map(({
|
|
21
|
+
item
|
|
22
|
+
}) => item);
|
|
23
|
+
};
|
|
10
24
|
|
|
11
25
|
/**
|
|
12
26
|
* Resolves registered menu items for a non-empty query. This intentionally has
|
|
@@ -33,12 +47,13 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
33
47
|
};
|
|
34
48
|
}
|
|
35
49
|
const matches = new Map();
|
|
50
|
+
const sourceIndexByComponent = new Map(components.map((component, index) => [component, index]));
|
|
36
51
|
for (const section of topLevelChildren) {
|
|
37
52
|
if (section.type !== 'menu-section' || isMenuFooterSectionKey(section.key) || !willComponentRender(section, childrenMap, surfaceContext)) {
|
|
38
53
|
continue;
|
|
39
54
|
}
|
|
40
55
|
for (const item of (_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []) {
|
|
41
|
-
var _childrenMap$get, _item$match, _match$score;
|
|
56
|
+
var _childrenMap$get, _item$match, _match$score, _sourceIndexByCompone;
|
|
42
57
|
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
|
|
43
58
|
continue;
|
|
44
59
|
}
|
|
@@ -54,6 +69,7 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
54
69
|
item,
|
|
55
70
|
itemRank: getRank(item, section.key),
|
|
56
71
|
score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
|
|
72
|
+
sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
|
|
57
73
|
section,
|
|
58
74
|
sectionRank: getRank(section, root.key)
|
|
59
75
|
};
|
|
@@ -63,8 +79,10 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
63
79
|
}
|
|
64
80
|
}
|
|
65
81
|
}
|
|
82
|
+
const uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
|
|
83
|
+
const searchResults = query !== '' ? getSearchResults(uniqueMatches) : undefined;
|
|
66
84
|
const sectionsByKey = new Map();
|
|
67
|
-
for (const match of
|
|
85
|
+
for (const match of uniqueMatches) {
|
|
68
86
|
const existing = sectionsByKey.get(match.section.key);
|
|
69
87
|
if (existing) {
|
|
70
88
|
existing.push(match.item);
|
|
@@ -77,6 +95,7 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
77
95
|
return {
|
|
78
96
|
footer: undefined,
|
|
79
97
|
root,
|
|
98
|
+
searchResults,
|
|
80
99
|
sections
|
|
81
100
|
};
|
|
82
101
|
}
|
|
@@ -91,6 +110,7 @@ export const getMatchingQuickInsertComponents = ({
|
|
|
91
110
|
fallbackItems,
|
|
92
111
|
footer,
|
|
93
112
|
root,
|
|
113
|
+
searchResults,
|
|
94
114
|
sections
|
|
95
115
|
};
|
|
96
116
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const getQuickInsertMenuRows = model => {
|
|
2
|
+
var _model$searchResults, _model$fallbackItems;
|
|
3
|
+
return [...((_model$searchResults = model.searchResults) !== null && _model$searchResults !== void 0 ? _model$searchResults : model.sections.flat()), ...((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : [])];
|
|
4
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @atlaskit/editor/no-re-export */
|
|
2
2
|
|
|
3
3
|
export { buildQuickInsertMenuModel } from './build-quick-insert-menu-model';
|
|
4
|
+
export { getQuickInsertMenuRows } from './getQuickInsertMenuRows';
|
|
4
5
|
export { quickInsertProviderMenuItemKey } from './getQuickInsertProviderMenuItemKey';
|
|
5
6
|
export { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
|
|
6
7
|
export { getMatchingQuickInsertComponents } from './get-matching-quick-insert-components';
|
|
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
|
|
|
14
14
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
15
15
|
import Layer from '../Layer';
|
|
16
16
|
const packageName = "@atlaskit/editor-common";
|
|
17
|
-
const packageVersion = "
|
|
17
|
+
const packageVersion = "129.0.0";
|
|
18
18
|
const halfFocusRing = 1;
|
|
19
19
|
const dropOffset = '0, 8';
|
|
20
20
|
const fadeIn = keyframes({
|
|
@@ -83,10 +83,17 @@ export var copyToClipboard = /*#__PURE__*/function () {
|
|
|
83
83
|
};
|
|
84
84
|
}();
|
|
85
85
|
|
|
86
|
-
//
|
|
87
|
-
|
|
86
|
+
// EDF-2436: the copy helpers below are called fire-and-forget from click handlers, so a
|
|
87
|
+
// late rejection (eg. the polyfill's DOM fallback running after the document is gone)
|
|
88
|
+
// becomes an unhandled rejection and takes down the whole process. Attaching a no-op
|
|
89
|
+
// handler marks it handled; callers that await still receive the error.
|
|
90
|
+
var markRejectionHandled = function markRejectionHandled(promise) {
|
|
91
|
+
promise.catch(function () {});
|
|
92
|
+
return promise;
|
|
93
|
+
};
|
|
94
|
+
var writeHTMLToClipboard = /*#__PURE__*/function () {
|
|
88
95
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(elementToCopy, plainTextToCopy) {
|
|
89
|
-
var data, _t3;
|
|
96
|
+
var data, _t3, _t4;
|
|
90
97
|
return _regeneratorRuntime.wrap(function (_context2) {
|
|
91
98
|
while (1) switch (_context2.prev = _context2.next) {
|
|
92
99
|
case 0:
|
|
@@ -113,34 +120,40 @@ export var copyHTMLToClipboard = /*#__PURE__*/function () {
|
|
|
113
120
|
_t3 = _context2["catch"](1);
|
|
114
121
|
throw new Error('Clipboard api is not supported');
|
|
115
122
|
case 4:
|
|
116
|
-
_context2.next =
|
|
123
|
+
_context2.next = 9;
|
|
117
124
|
break;
|
|
118
125
|
case 5:
|
|
119
|
-
if (!!document && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object') {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// Hence of use of this polyfill
|
|
123
|
-
copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
|
|
124
|
-
} catch (error) {
|
|
125
|
-
// eslint-disable-next-line no-console
|
|
126
|
-
console.log(error);
|
|
127
|
-
}
|
|
126
|
+
if (!(!!document && (typeof document === "undefined" ? "undefined" : _typeof(document)) === 'object')) {
|
|
127
|
+
_context2.next = 9;
|
|
128
|
+
break;
|
|
128
129
|
}
|
|
129
|
-
|
|
130
|
+
_context2.prev = 6;
|
|
131
|
+
_context2.next = 7;
|
|
132
|
+
return copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy);
|
|
133
|
+
case 7:
|
|
134
|
+
_context2.next = 9;
|
|
135
|
+
break;
|
|
136
|
+
case 8:
|
|
137
|
+
_context2.prev = 8;
|
|
138
|
+
_t4 = _context2["catch"](6);
|
|
139
|
+
// eslint-disable-next-line no-console
|
|
140
|
+
console.log(_t4);
|
|
141
|
+
case 9:
|
|
130
142
|
case "end":
|
|
131
143
|
return _context2.stop();
|
|
132
144
|
}
|
|
133
|
-
}, _callee2, null, [[1, 3]]);
|
|
145
|
+
}, _callee2, null, [[1, 3], [6, 8]]);
|
|
134
146
|
}));
|
|
135
|
-
return function
|
|
147
|
+
return function writeHTMLToClipboard(_x2, _x3) {
|
|
136
148
|
return _ref2.apply(this, arguments);
|
|
137
149
|
};
|
|
138
150
|
}();
|
|
139
151
|
|
|
140
|
-
// At the time of development, Firefox doesn't support ClipboardItem API
|
|
141
|
-
// Hence of use of this polyfill
|
|
142
152
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
143
|
-
export var
|
|
153
|
+
export var copyHTMLToClipboard = function copyHTMLToClipboard(elementToCopy, plainTextToCopy) {
|
|
154
|
+
return markRejectionHandled(writeHTMLToClipboard(elementToCopy, plainTextToCopy));
|
|
155
|
+
};
|
|
156
|
+
var writeHTMLToClipboardPolyfill = /*#__PURE__*/function () {
|
|
144
157
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(elementToCopy, plainTextToCopy) {
|
|
145
158
|
var dt;
|
|
146
159
|
return _regeneratorRuntime.wrap(function (_context3) {
|
|
@@ -162,11 +175,18 @@ export var copyHTMLToClipboardPolyfill = /*#__PURE__*/function () {
|
|
|
162
175
|
}
|
|
163
176
|
}, _callee3);
|
|
164
177
|
}));
|
|
165
|
-
return function
|
|
178
|
+
return function writeHTMLToClipboardPolyfill(_x4, _x5) {
|
|
166
179
|
return _ref3.apply(this, arguments);
|
|
167
180
|
};
|
|
168
181
|
}();
|
|
169
182
|
|
|
183
|
+
// At the time of development, Firefox doesn't support ClipboardItem API
|
|
184
|
+
// Hence of use of this polyfill
|
|
185
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
186
|
+
export var copyHTMLToClipboardPolyfill = function copyHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy) {
|
|
187
|
+
return markRejectionHandled(writeHTMLToClipboardPolyfill(elementToCopy, plainTextToCopy));
|
|
188
|
+
};
|
|
189
|
+
|
|
170
190
|
// Safari can revoke transient user activation before asynchronous clipboard writes complete.
|
|
171
191
|
// Keep this helper synchronous so callers can invoke it directly from a click handler.
|
|
172
192
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
@@ -17,6 +17,7 @@ import ReactNodeView from '../react-node-view';
|
|
|
17
17
|
import { Extension } from './Extension';
|
|
18
18
|
import { ExtensionNodeWrapper } from './ExtensionNodeWrapper';
|
|
19
19
|
import { isNativeEmbedExtension } from './nativeEmbedExtension';
|
|
20
|
+
import { preserveRemixNodeView } from './preserveRemixNodeView';
|
|
20
21
|
/**
|
|
21
22
|
* Allowlists of extension keys + layout
|
|
22
23
|
* Currently, only toc with default layout allows to skip React render.
|
|
@@ -378,7 +379,7 @@ function ExtensionNodeRender(_ref2) {
|
|
|
378
379
|
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
379
380
|
export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, providerFactory, extensionHandlers, extensionLoadingHandlers, extensionNodeViewOptions, pluginInjectionApi, macroInteractionDesignFeatureFlags, showLivePagesBodiedMacrosRendererView, showUpdatedLivePages1PBodiedExtensionUI, rendererExtensionHandlers, intl) {
|
|
380
381
|
return function (node, view, getPos) {
|
|
381
|
-
|
|
382
|
+
var renderProps = {
|
|
382
383
|
providerFactory: providerFactory,
|
|
383
384
|
extensionHandlers: extensionHandlers,
|
|
384
385
|
extensionLoadingHandlers: extensionLoadingHandlers,
|
|
@@ -389,6 +390,20 @@ export default function ExtensionNodeView(portalProviderAPI, eventDispatcher, pr
|
|
|
389
390
|
showUpdatedLivePages1PBodiedExtensionUI: showUpdatedLivePages1PBodiedExtensionUI,
|
|
390
391
|
rendererExtensionHandlers: rendererExtensionHandlers,
|
|
391
392
|
intl: intl
|
|
392
|
-
}
|
|
393
|
+
};
|
|
394
|
+
var createExtensionNode = function createExtensionNode(currentNode) {
|
|
395
|
+
return new ExtensionNode(currentNode, view, getPos, portalProviderAPI, eventDispatcher, renderProps);
|
|
396
|
+
};
|
|
397
|
+
if (!isSSR() && fg('cc_maui_annotations_on_extensions')) {
|
|
398
|
+
return preserveRemixNodeView({
|
|
399
|
+
node: node,
|
|
400
|
+
view: view,
|
|
401
|
+
getPos: getPos,
|
|
402
|
+
renderProps: renderProps,
|
|
403
|
+
rendererKind: ExtensionNode,
|
|
404
|
+
createExtensionNode: createExtensionNode
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
return createExtensionNode(node).init();
|
|
393
408
|
};
|
|
394
409
|
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { NATIVE_EMBED_MAUI_EXTENSION_KEY } from '../extensions/native-embed-maui-extension-key';
|
|
2
|
+
|
|
3
|
+
// Do not polyfill with insertBefore: it disconnects an iframe and resets its browsing context.
|
|
4
|
+
|
|
5
|
+
var editors = new WeakMap();
|
|
6
|
+
/** Only block Remix embeds with a stable identity can participate in the handoff. */
|
|
7
|
+
var isRemixNodeForPreservation = function isRemixNodeForPreservation(node) {
|
|
8
|
+
return node.type.name === 'extension' && node.attrs.extensionKey === NATIVE_EMBED_MAUI_EXTENSION_KEY && typeof node.attrs.localId === 'string' && node.attrs.localId.length > 0;
|
|
9
|
+
};
|
|
10
|
+
var sameChart = function sameChart(left, right) {
|
|
11
|
+
return left.mark(left.marks.filter(function (mark) {
|
|
12
|
+
return mark.type.name !== 'annotation';
|
|
13
|
+
})).eq(right.mark(right.marks.filter(function (mark) {
|
|
14
|
+
return mark.type.name !== 'annotation';
|
|
15
|
+
})));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A disposable ProseMirror slot around a retained React portal. destroy() parks the
|
|
20
|
+
* portal before ProseMirror disconnects its mark wrapper. After reconciliation, the
|
|
21
|
+
* replacement claims the parked portal without taking one from a still-live node.
|
|
22
|
+
*/
|
|
23
|
+
export function preserveRemixNodeView(_ref) {
|
|
24
|
+
var node = _ref.node,
|
|
25
|
+
view = _ref.view,
|
|
26
|
+
getPos = _ref.getPos,
|
|
27
|
+
renderProps = _ref.renderProps,
|
|
28
|
+
rendererKind = _ref.rendererKind,
|
|
29
|
+
createExtensionNode = _ref.createExtensionNode;
|
|
30
|
+
if (!isRemixNodeForPreservation(node)) {
|
|
31
|
+
return createExtensionNode(node).init();
|
|
32
|
+
}
|
|
33
|
+
var ownerDocument = view.dom.ownerDocument;
|
|
34
|
+
var slot = ownerDocument.createElement('div');
|
|
35
|
+
if (!view.dom.isConnected || typeof getPos !== 'function' || typeof slot.moveBefore !== 'function') {
|
|
36
|
+
return createExtensionNode(node).init();
|
|
37
|
+
}
|
|
38
|
+
var owner = {
|
|
39
|
+
getPos: getPos,
|
|
40
|
+
destroyed: false
|
|
41
|
+
};
|
|
42
|
+
var entries = editors.get(view);
|
|
43
|
+
if (!entries) {
|
|
44
|
+
entries = new Set();
|
|
45
|
+
editors.set(view, entries);
|
|
46
|
+
}
|
|
47
|
+
var registry = entries;
|
|
48
|
+
var entry;
|
|
49
|
+
var latestNode = node;
|
|
50
|
+
var latestDecorations = [];
|
|
51
|
+
var latestInnerDecorations;
|
|
52
|
+
|
|
53
|
+
// Construction can precede the old slot's destroy(). Defer portal adoption until
|
|
54
|
+
// both hooks have run; no rendering opportunity occurs between these microtasks.
|
|
55
|
+
queueMicrotask(function () {
|
|
56
|
+
if (owner.destroyed || view.isDestroyed || !slot.isConnected) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
entry = Array.from(registry).find(function (existing) {
|
|
60
|
+
return existing.owner.destroyed && existing.rendererKind === rendererKind && sameChart(existing.inner.node, latestNode);
|
|
61
|
+
});
|
|
62
|
+
if (entry) {
|
|
63
|
+
var _slot$moveBefore, _entry$parking;
|
|
64
|
+
entry.owner = owner;
|
|
65
|
+
entry.inner.reactComponentProps = renderProps;
|
|
66
|
+
(_slot$moveBefore = slot.moveBefore) === null || _slot$moveBefore === void 0 || _slot$moveBefore.call(slot, entry.inner.dom, null);
|
|
67
|
+
(_entry$parking = entry.parking) === null || _entry$parking === void 0 || _entry$parking.remove();
|
|
68
|
+
entry.parking = undefined;
|
|
69
|
+
if (!entry.inner.update(latestNode, latestDecorations, latestInnerDecorations)) {
|
|
70
|
+
// A matching chart is normally accepted, but honour the NodeView contract
|
|
71
|
+
// if a renderer rejects it. Remove the old portal before creating a replacement.
|
|
72
|
+
registry.delete(entry);
|
|
73
|
+
var dom = entry.inner.dom;
|
|
74
|
+
entry.inner.destroy();
|
|
75
|
+
dom.remove();
|
|
76
|
+
entry = undefined;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!entry) {
|
|
80
|
+
// Construct only after the old slot has had a chance to park its portal.
|
|
81
|
+
var inner = createExtensionNode(latestNode);
|
|
82
|
+
var retained = {
|
|
83
|
+
inner: inner,
|
|
84
|
+
owner: owner,
|
|
85
|
+
rendererKind: rendererKind
|
|
86
|
+
};
|
|
87
|
+
entry = retained;
|
|
88
|
+
inner.getPos = function () {
|
|
89
|
+
return retained.owner.destroyed ? undefined : retained.owner.getPos();
|
|
90
|
+
};
|
|
91
|
+
inner.init();
|
|
92
|
+
slot.appendChild(inner.dom);
|
|
93
|
+
registry.add(retained);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
dom: slot,
|
|
98
|
+
// The retained extension is an atom: ProseMirror must not manage the portal's children.
|
|
99
|
+
update: function update(next, decorations, innerDecorations) {
|
|
100
|
+
if (next.type !== node.type || next.attrs.localId !== node.attrs.localId || next.attrs.extensionKey !== node.attrs.extensionKey) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
latestNode = next;
|
|
104
|
+
latestDecorations = decorations;
|
|
105
|
+
latestInnerDecorations = innerDecorations;
|
|
106
|
+
return entry ? entry.inner.update(next, decorations, innerDecorations) : true;
|
|
107
|
+
},
|
|
108
|
+
stopEvent: function stopEvent(event) {
|
|
109
|
+
var _entry$inner$stopEven, _entry;
|
|
110
|
+
return (_entry$inner$stopEven = (_entry = entry) === null || _entry === void 0 ? void 0 : _entry.inner.stopEvent(event)) !== null && _entry$inner$stopEven !== void 0 ? _entry$inner$stopEven : false;
|
|
111
|
+
},
|
|
112
|
+
ignoreMutation: function ignoreMutation(mutation) {
|
|
113
|
+
var _entry$inner$ignoreMu, _entry2;
|
|
114
|
+
return (_entry$inner$ignoreMu = (_entry2 = entry) === null || _entry2 === void 0 ? void 0 : _entry2.inner.ignoreMutation(mutation)) !== null && _entry$inner$ignoreMu !== void 0 ? _entry$inner$ignoreMu : mutation.type !== 'selection';
|
|
115
|
+
},
|
|
116
|
+
destroy: function destroy() {
|
|
117
|
+
owner.destroyed = true;
|
|
118
|
+
if (!entry) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
var retained = entry;
|
|
122
|
+
if (retained.inner.dom.isConnected) {
|
|
123
|
+
var _parking$moveBefore;
|
|
124
|
+
var parking = ownerDocument.createElement('div');
|
|
125
|
+
// Transient, outside the editable document and inaccessible while awaiting handoff.
|
|
126
|
+
parking.hidden = true;
|
|
127
|
+
ownerDocument.body.appendChild(parking);
|
|
128
|
+
(_parking$moveBefore = parking.moveBefore) === null || _parking$moveBefore === void 0 || _parking$moveBefore.call(parking, retained.inner.dom, null);
|
|
129
|
+
retained.parking = parking;
|
|
130
|
+
}
|
|
131
|
+
// Give constructors queued after destroy() a chance to claim the portal first.
|
|
132
|
+
queueMicrotask(function () {
|
|
133
|
+
return queueMicrotask(function () {
|
|
134
|
+
if (retained.owner === owner && registry.delete(retained)) {
|
|
135
|
+
var _retained$parking;
|
|
136
|
+
var dom = retained.inner.dom;
|
|
137
|
+
retained.inner.destroy();
|
|
138
|
+
dom.remove();
|
|
139
|
+
(_retained$parking = retained.parking) === null || _retained$parking === void 0 || _retained$parking.remove();
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
@@ -19,7 +19,7 @@ var NETWORK_FAILURE_REGEX = /^network failure/i;
|
|
|
19
19
|
var RESIZE_OBSERVER_LOOP_REGEX = /ResizeObserver loop completed with undelivered notifications/;
|
|
20
20
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
21
21
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
22
|
-
var packageVersion = "
|
|
22
|
+
var packageVersion = "129.0.0";
|
|
23
23
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
24
24
|
// Remove URL as it has UGC
|
|
25
25
|
// Ignored via go/ees007
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
3
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -5,6 +6,7 @@ import { getComponentIdentity, resolveSurface, willComponentRender } from '@atla
|
|
|
5
6
|
import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
|
|
6
7
|
import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
|
|
7
8
|
import { ASK_ROVO_MENU_ITEM } from './keys';
|
|
9
|
+
var SEARCH_TOP_MATCH_LIMIT = 5;
|
|
8
10
|
var getRank = function getRank(component, parentKey) {
|
|
9
11
|
var _component$parents$fi, _component$parents;
|
|
10
12
|
return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 || (_component$parents = _component$parents.find(function (parent) {
|
|
@@ -12,20 +14,38 @@ var getRank = function getRank(component, parentKey) {
|
|
|
12
14
|
})) === null || _component$parents === void 0 ? void 0 : _component$parents.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
|
|
13
15
|
};
|
|
14
16
|
var compareMatchedItems = function compareMatchedItems(a, b) {
|
|
15
|
-
return a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.identity.localeCompare(b.identity);
|
|
17
|
+
return a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
18
|
+
};
|
|
19
|
+
var compareSearchResults = function compareSearchResults(a, b) {
|
|
20
|
+
return a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
|
|
21
|
+
};
|
|
22
|
+
var getSearchResults = function getSearchResults(matches) {
|
|
23
|
+
var topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
|
|
24
|
+
var topMatchIdentities = new Set(topMatches.map(function (_ref) {
|
|
25
|
+
var identity = _ref.identity;
|
|
26
|
+
return identity;
|
|
27
|
+
}));
|
|
28
|
+
var tailMatches = matches.filter(function (_ref2) {
|
|
29
|
+
var identity = _ref2.identity;
|
|
30
|
+
return !topMatchIdentities.has(identity);
|
|
31
|
+
});
|
|
32
|
+
return [].concat(_toConsumableArray(topMatches), _toConsumableArray(tailMatches)).map(function (_ref3) {
|
|
33
|
+
var item = _ref3.item;
|
|
34
|
+
return item;
|
|
35
|
+
});
|
|
16
36
|
};
|
|
17
37
|
|
|
18
38
|
/**
|
|
19
39
|
* Resolves registered menu items for a non-empty query. This intentionally has
|
|
20
40
|
* no empty-query path so browse behavior remains owned by buildQuickInsertMenuModel.
|
|
21
41
|
*/
|
|
22
|
-
export var getMatchingQuickInsertComponents = function getMatchingQuickInsertComponents(
|
|
42
|
+
export var getMatchingQuickInsertComponents = function getMatchingQuickInsertComponents(_ref4) {
|
|
23
43
|
var _childrenMap$get2;
|
|
24
|
-
var components =
|
|
25
|
-
rootComponent =
|
|
26
|
-
query =
|
|
27
|
-
formatMessage =
|
|
28
|
-
surfaceContext =
|
|
44
|
+
var components = _ref4.components,
|
|
45
|
+
rootComponent = _ref4.rootComponent,
|
|
46
|
+
query = _ref4.query,
|
|
47
|
+
formatMessage = _ref4.formatMessage,
|
|
48
|
+
surfaceContext = _ref4.surfaceContext;
|
|
29
49
|
var _resolveSurface = resolveSurface(components, rootComponent),
|
|
30
50
|
childrenMap = _resolveSurface.childrenMap,
|
|
31
51
|
root = _resolveSurface.root,
|
|
@@ -38,6 +58,9 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
|
|
|
38
58
|
};
|
|
39
59
|
}
|
|
40
60
|
var matches = new Map();
|
|
61
|
+
var sourceIndexByComponent = new Map(components.map(function (component, index) {
|
|
62
|
+
return [component, index];
|
|
63
|
+
}));
|
|
41
64
|
var _iterator = _createForOfIteratorHelper(topLevelChildren),
|
|
42
65
|
_step;
|
|
43
66
|
try {
|
|
@@ -51,7 +74,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
|
|
|
51
74
|
_step3;
|
|
52
75
|
try {
|
|
53
76
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
54
|
-
var _item$match, _match$score;
|
|
77
|
+
var _item$match, _match$score, _sourceIndexByCompone;
|
|
55
78
|
var item = _step3.value;
|
|
56
79
|
if (item.type !== 'menu-item' || isSectionOverflowItemKey(item.key) || !willComponentRender(item, childrenMap, surfaceContext)) {
|
|
57
80
|
continue;
|
|
@@ -68,6 +91,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
|
|
|
68
91
|
item: item,
|
|
69
92
|
itemRank: getRank(item, section.key),
|
|
70
93
|
score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
|
|
94
|
+
sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
|
|
71
95
|
section: section,
|
|
72
96
|
sectionRank: getRank(section, root.key)
|
|
73
97
|
};
|
|
@@ -87,8 +111,10 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
|
|
|
87
111
|
} finally {
|
|
88
112
|
_iterator.f();
|
|
89
113
|
}
|
|
114
|
+
var uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
|
|
115
|
+
var searchResults = query !== '' ? getSearchResults(uniqueMatches) : undefined;
|
|
90
116
|
var sectionsByKey = new Map();
|
|
91
|
-
var _iterator2 = _createForOfIteratorHelper(
|
|
117
|
+
var _iterator2 = _createForOfIteratorHelper(uniqueMatches),
|
|
92
118
|
_step2;
|
|
93
119
|
try {
|
|
94
120
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
@@ -110,6 +136,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
|
|
|
110
136
|
return {
|
|
111
137
|
footer: undefined,
|
|
112
138
|
root: root,
|
|
139
|
+
searchResults: searchResults,
|
|
113
140
|
sections: sections
|
|
114
141
|
};
|
|
115
142
|
}
|
|
@@ -132,6 +159,7 @@ export var getMatchingQuickInsertComponents = function getMatchingQuickInsertCom
|
|
|
132
159
|
fallbackItems: fallbackItems,
|
|
133
160
|
footer: footer,
|
|
134
161
|
root: root,
|
|
162
|
+
searchResults: searchResults,
|
|
135
163
|
sections: sections
|
|
136
164
|
};
|
|
137
165
|
};
|