@atlaskit/editor-plugin-show-diff 20.0.11 → 21.0.1
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 +27 -0
- package/dist/cjs/pm-plugins/NodeViewSerializer.js +71 -7
- package/dist/cjs/pm-plugins/createEditorProxy.js +84 -0
- package/dist/cjs/pm-plugins/decorations/createContributorTagWidget.js +25 -6
- package/dist/cjs/pm-plugins/decorations/createNodeChangedDecorationWidget.js +35 -11
- package/dist/cjs/pm-plugins/decorations/utils/wrapBlockNodeView.js +38 -2
- package/dist/cjs/pm-plugins/markViews.js +65 -0
- package/dist/cjs/pm-plugins/resolveDiffContributors.js +3 -3
- package/dist/cjs/ui/ContributorTag/contributorAvatarRenderer.js +8 -9
- package/dist/cjs/ui/ContributorTag/contributorTagIcons.js +1 -8
- package/dist/es2019/pm-plugins/NodeViewSerializer.js +64 -8
- package/dist/es2019/pm-plugins/createEditorProxy.js +76 -0
- package/dist/es2019/pm-plugins/decorations/createContributorTagWidget.js +26 -8
- package/dist/es2019/pm-plugins/decorations/createNodeChangedDecorationWidget.js +35 -12
- package/dist/es2019/pm-plugins/decorations/utils/wrapBlockNodeView.js +36 -2
- package/dist/es2019/pm-plugins/markViews.js +61 -0
- package/dist/es2019/pm-plugins/resolveDiffContributors.js +3 -3
- package/dist/es2019/ui/ContributorTag/contributorAvatarRenderer.js +8 -9
- package/dist/es2019/ui/ContributorTag/contributorTagIcons.js +1 -8
- package/dist/esm/pm-plugins/NodeViewSerializer.js +71 -7
- package/dist/esm/pm-plugins/createEditorProxy.js +78 -0
- package/dist/esm/pm-plugins/decorations/createContributorTagWidget.js +27 -8
- package/dist/esm/pm-plugins/decorations/createNodeChangedDecorationWidget.js +37 -12
- package/dist/esm/pm-plugins/decorations/utils/wrapBlockNodeView.js +38 -2
- package/dist/esm/pm-plugins/markViews.js +60 -0
- package/dist/esm/pm-plugins/resolveDiffContributors.js +3 -3
- package/dist/esm/ui/ContributorTag/contributorAvatarRenderer.js +8 -9
- package/dist/esm/ui/ContributorTag/contributorTagIcons.js +1 -8
- package/dist/types/pm-plugins/NodeViewSerializer.d.ts +7 -2
- package/dist/types/pm-plugins/createEditorProxy.d.ts +18 -0
- package/dist/types/pm-plugins/decorations/createContributorTagWidget.d.ts +2 -1
- package/dist/types/pm-plugins/markViews.d.ts +14 -0
- package/dist/types/ui/ContributorTag/contributorTagIcons.d.ts +1 -4
- package/package.json +11 -11
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import { expandedState } from '@atlaskit/editor-common/expand';
|
|
3
4
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
+
import { contains } from '@atlaskit/editor-prosemirror/utils';
|
|
4
6
|
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
7
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
8
|
+
import { createEditorProxy } from './createEditorProxy';
|
|
9
|
+
import { wrapInMarkViews } from './markViews';
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Utilities for working with ProseMirror node views and DOM serialization within the
|
|
@@ -30,6 +35,16 @@ export function isEditorViewWithNodeViews(view) {
|
|
|
30
35
|
return view.nodeViews !== undefined;
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
/** Expand-family nodes whose expanded state lives in a node-keyed WeakMap. */
|
|
39
|
+
var EXPAND_TYPES = new Set(['expand', 'nestedExpand']);
|
|
40
|
+
|
|
41
|
+
/** Tables are the only node views that read and write positions, so only they need a preview. */
|
|
42
|
+
var containsTable = function containsTable(node) {
|
|
43
|
+
var table = node.type.schema.nodes.table;
|
|
44
|
+
// `contains` only checks descendants, so the node itself is checked separately.
|
|
45
|
+
return !!table && (node.type === table || contains(node, table));
|
|
46
|
+
};
|
|
47
|
+
|
|
33
48
|
/**
|
|
34
49
|
* Encapsulates DOM serialization and node view access/creation.
|
|
35
50
|
*
|
|
@@ -75,11 +90,18 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
75
90
|
key: "appendChildNodes",
|
|
76
91
|
value: function appendChildNodes(children, contentDOM) {
|
|
77
92
|
var _this = this;
|
|
93
|
+
var basePos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
94
|
+
var editorProxy = arguments.length > 3 ? arguments[3] : undefined;
|
|
95
|
+
// A node's first child sits one position inside it, and each subsequent
|
|
96
|
+
// child is offset by the previous child's `nodeSize`. Tracking this lets nested node
|
|
97
|
+
// views resolve to their real depth instead of every one of them seeing depth 0.
|
|
98
|
+
var childPos = basePos + 1;
|
|
78
99
|
children.forEach(function (child) {
|
|
79
|
-
var childNode = _this.
|
|
100
|
+
var childNode = _this.tryCreateNodeViewInner(child, childPos, editorProxy) || _this.serializeNode(child);
|
|
80
101
|
if (childNode) {
|
|
81
102
|
contentDOM === null || contentDOM === void 0 || contentDOM.append(childNode);
|
|
82
103
|
}
|
|
104
|
+
childPos += child.nodeSize;
|
|
83
105
|
});
|
|
84
106
|
}
|
|
85
107
|
|
|
@@ -88,11 +110,29 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
88
110
|
*
|
|
89
111
|
* Returns `null` when there is no `EditorView`, no constructor for the node type,
|
|
90
112
|
* or the node type is blocklisted. Otherwise returns the constructed node view instance.
|
|
113
|
+
*
|
|
114
|
+
* `$sourcePos` is where the node sits in the doc it came from, so nested tables keep their depth.
|
|
91
115
|
*/
|
|
92
116
|
}, {
|
|
93
117
|
key: "tryCreateNodeView",
|
|
94
118
|
value: function tryCreateNodeView(targetNode) {
|
|
119
|
+
var _preview$rootPos;
|
|
120
|
+
var basePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
121
|
+
var $sourcePos = arguments.length > 2 ? arguments[2] : undefined;
|
|
122
|
+
if (!this.editorView) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
// The preview becomes the document every nested node view resolves its position against,
|
|
126
|
+
// so positions stay internally consistent.
|
|
127
|
+
var preview = fg('platform_editor_ai_show_diff_patch_2') && containsTable(targetNode) ? createEditorProxy(this.editorView, targetNode, $sourcePos) : null;
|
|
128
|
+
return this.tryCreateNodeViewInner(targetNode, (_preview$rootPos = preview === null || preview === void 0 ? void 0 : preview.rootPos) !== null && _preview$rootPos !== void 0 ? _preview$rootPos : basePos, preview === null || preview === void 0 ? void 0 : preview.editorProxy);
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "tryCreateNodeViewInner",
|
|
132
|
+
value: function tryCreateNodeViewInner(targetNode) {
|
|
95
133
|
var _this$nodeViews;
|
|
134
|
+
var basePos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
135
|
+
var editorProxy = arguments.length > 2 ? arguments[2] : undefined;
|
|
96
136
|
if (!this.editorView) {
|
|
97
137
|
return null;
|
|
98
138
|
}
|
|
@@ -138,23 +178,47 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
138
178
|
if (!isExperimentEnabled('platform_editor_show_diff_deleted_nodeview_content') && targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
139
179
|
return this.serializeFragment(targetNode.content);
|
|
140
180
|
}
|
|
141
|
-
this.appendChildNodes(targetNode.children, _contentDOM);
|
|
181
|
+
this.appendChildNodes(targetNode.children, _contentDOM, basePos, editorProxy);
|
|
142
182
|
}
|
|
143
|
-
return _dom;
|
|
183
|
+
return this.withMarkViews(targetNode, _dom, editorProxy);
|
|
144
184
|
}
|
|
145
|
-
|
|
146
|
-
|
|
185
|
+
|
|
186
|
+
// The expand node view reads `expandedState.get(node) ?? false`, never `attrs.__expanded`.
|
|
187
|
+
// Open the preview so its tables get real layout; an existing entry is the live expand's
|
|
188
|
+
// own state, so leave it alone.
|
|
189
|
+
if (EXPAND_TYPES.has(targetNode.type.name) && !expandedState.has(targetNode) && fg('platform_editor_ai_show_diff_patch_2')) {
|
|
190
|
+
expandedState.set(targetNode, true);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// `isTableNested` is `doc.resolve(pos).depth > 0`, so the old hardcoded `0` made nested
|
|
194
|
+
// tables size as top-level. Positions are resolved against the preview document, so
|
|
195
|
+
// they are only meaningful with an editor proxy.
|
|
196
|
+
var view = editorProxy !== null && editorProxy !== void 0 ? editorProxy : this.editorView;
|
|
197
|
+
var docSize = view.state.doc.content.size;
|
|
198
|
+
var resolvedPos = editorProxy ? Math.max(0, Math.min(basePos, docSize)) : 0;
|
|
199
|
+
var _constructor = constructor(targetNode, view, function () {
|
|
200
|
+
return resolvedPos;
|
|
147
201
|
}, [], {}),
|
|
148
202
|
dom = _constructor.dom,
|
|
149
203
|
contentDOM = _constructor.contentDOM;
|
|
150
204
|
// Iteratively populate children
|
|
151
|
-
this.appendChildNodes(targetNode.children, contentDOM);
|
|
152
|
-
return dom;
|
|
205
|
+
this.appendChildNodes(targetNode.children, contentDOM, basePos, editorProxy);
|
|
206
|
+
return this.withMarkViews(targetNode, dom, editorProxy);
|
|
153
207
|
} catch (_unused) {
|
|
154
208
|
return null;
|
|
155
209
|
}
|
|
156
210
|
}
|
|
157
211
|
|
|
212
|
+
/** Wraps rendered DOM in its marks, rendered against the editor proxy when there is one. */
|
|
213
|
+
}, {
|
|
214
|
+
key: "withMarkViews",
|
|
215
|
+
value: function withMarkViews(targetNode, nodeDom, editorProxy) {
|
|
216
|
+
return wrapInMarkViews(targetNode, nodeDom, {
|
|
217
|
+
nodeViews: this.nodeViews,
|
|
218
|
+
view: editorProxy !== null && editorProxy !== void 0 ? editorProxy : this.editorView
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
158
222
|
/**
|
|
159
223
|
* Serializes a node to a DOM `Node` using the schema's `DOMSerializer`.
|
|
160
224
|
*/
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection/gap-cursor/selection';
|
|
2
|
+
/**
|
|
3
|
+
* A preview is rendered by the live view's own node views, which read `getPos()` against
|
|
4
|
+
* `view.state.doc` for both layout (`isTableNested`) and writes (`scaleTable` builds attribute
|
|
5
|
+
* steps at `getPos() + 1`). Handing them live positions makes the layout correct but points the
|
|
6
|
+
* writes at unrelated live nodes, so give them a view whose document *is* the preview instead.
|
|
7
|
+
*
|
|
8
|
+
* With `$sourcePos` (the node's position in the doc it came from) the node is swapped into a copy
|
|
9
|
+
* of its real top-level ancestor, so a table inside an expand still resolves as nested.
|
|
10
|
+
*
|
|
11
|
+
* Returns `null` when the node cannot be a top-level child (e.g. a bare `tableCell`), in which
|
|
12
|
+
* case the caller falls back to the live view and the previous stubbed positions.
|
|
13
|
+
*/
|
|
14
|
+
export function createEditorProxy(liveView, rootNode, $sourcePos) {
|
|
15
|
+
var liveState = liveView.state;
|
|
16
|
+
var createDoc = function createDoc(topLevel) {
|
|
17
|
+
return liveState.schema.topNodeType.createChecked(null, topLevel);
|
|
18
|
+
};
|
|
19
|
+
var previewDoc;
|
|
20
|
+
var rootPos = 0;
|
|
21
|
+
try {
|
|
22
|
+
var _$sourcePos$nodeAfter;
|
|
23
|
+
if ($sourcePos && $sourcePos.depth > 0 && ((_$sourcePos$nodeAfter = $sourcePos.nodeAfter) === null || _$sourcePos$nodeAfter === void 0 ? void 0 : _$sourcePos$nodeAfter.type) === rootNode.type) {
|
|
24
|
+
var topLevel = rootNode;
|
|
25
|
+
for (var depth = $sourcePos.depth; depth > 0; depth--) {
|
|
26
|
+
var ancestor = $sourcePos.node(depth);
|
|
27
|
+
topLevel = ancestor.copy(ancestor.content.replaceChild($sourcePos.index(depth), topLevel));
|
|
28
|
+
}
|
|
29
|
+
previewDoc = createDoc(topLevel);
|
|
30
|
+
rootPos = $sourcePos.pos - $sourcePos.before(1);
|
|
31
|
+
} else {
|
|
32
|
+
previewDoc = createDoc(rootNode);
|
|
33
|
+
}
|
|
34
|
+
} catch (_unused) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// A gap cursor just before the node selects nothing, so the table's node view doesn't render
|
|
39
|
+
// as selected or show its controls.
|
|
40
|
+
var previewSelection = new GapCursorSelection(previewDoc.resolve(rootPos), Side.LEFT);
|
|
41
|
+
// Proxy rather than `EditorState.create` so plugin state is shared as-is: re-initialising
|
|
42
|
+
// every plugin per preview would be costly and re-runs their side effects.
|
|
43
|
+
var stateProxy = new Proxy(liveState, {
|
|
44
|
+
get: function get(target, prop, receiver) {
|
|
45
|
+
if (prop === 'doc') {
|
|
46
|
+
return previewDoc;
|
|
47
|
+
}
|
|
48
|
+
if (prop === 'selection') {
|
|
49
|
+
return previewSelection;
|
|
50
|
+
}
|
|
51
|
+
return Reflect.get(target, prop, receiver);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
var editorProxy = new Proxy(liveView, {
|
|
55
|
+
get: function get(target, prop, receiver) {
|
|
56
|
+
if (prop === 'state') {
|
|
57
|
+
return stateProxy;
|
|
58
|
+
}
|
|
59
|
+
if (prop === 'dispatch') {
|
|
60
|
+
// Keep the transaction inside the preview. It was built against `previewDoc`, so
|
|
61
|
+
// applying it to the live state would corrupt the real document.
|
|
62
|
+
return function (tr) {
|
|
63
|
+
try {
|
|
64
|
+
stateProxy = stateProxy.apply(tr);
|
|
65
|
+
} catch (_unused2) {
|
|
66
|
+
// A preview is throwaway; a failed self-update is not worth surfacing.
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
var value = Reflect.get(target, prop, receiver);
|
|
71
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
editorProxy: editorProxy,
|
|
76
|
+
rootPos: rootPos
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -5,8 +5,8 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { ContributorTagController } from '../../ui/ContributorTag/contributorTagController';
|
|
7
7
|
import { buildCharsByOffset, isWhitespaceChar } from '../utils/charsByOffset';
|
|
8
|
-
import { clampAnchorPosIntoCell } from './createAnchorDecorationWidgets';
|
|
9
|
-
import { AnchorTypeKey, buildAnchorDecorationKey, buildContributorTagDecorationSpec } from './decorationKeys';
|
|
8
|
+
import { clampAnchorPosIntoCell, createAnchorNameSpan } from './createAnchorDecorationWidgets';
|
|
9
|
+
import { AnchorTypeKey, buildAnchorDecorationKey, buildAnchorDecorationSpec, buildContributorTagDecorationSpec } from './decorationKeys';
|
|
10
10
|
|
|
11
11
|
/** Marks the host element of one tag, so a tag can be found in the document by its own diff. */
|
|
12
12
|
export var CONTRIBUTOR_TAG_HOST_ATTRIBUTE = 'data-contributor-tag-host';
|
|
@@ -218,13 +218,14 @@ export var resolveHoistedCodeBlockAnchor = function resolveHoistedCodeBlockAncho
|
|
|
218
218
|
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
219
219
|
* hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
|
|
220
220
|
*
|
|
221
|
-
* Returns one decoration
|
|
221
|
+
* Returns one decoration when a caller-supplied `anchorName` is used, two (marker + tag)
|
|
222
|
+
* otherwise — hoisted out of a code block, or anchored to its own point marker.
|
|
222
223
|
*
|
|
223
224
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
224
225
|
* element ProseMirror drew it into — see `mountContributorTag`.
|
|
225
226
|
*/
|
|
226
227
|
export var createContributorTagWidget = function createContributorTagWidget(_ref4) {
|
|
227
|
-
var _hoisted$
|
|
228
|
+
var _hoisted$codeBlockSta, _ref5, _hoisted$anchorName;
|
|
228
229
|
var _ref4$anchorAtRangeSt = _ref4.anchorAtRangeStart,
|
|
229
230
|
anchorAtRangeStart = _ref4$anchorAtRangeSt === void 0 ? false : _ref4$anchorAtRangeSt,
|
|
230
231
|
anchorName = _ref4.anchorName,
|
|
@@ -244,15 +245,33 @@ export var createContributorTagWidget = function createContributorTagWidget(_ref
|
|
|
244
245
|
// A change inside a code block is hoisted out of it, anchored to its own marker; anything else
|
|
245
246
|
// keeps its own anchor.
|
|
246
247
|
var hoisted = resolveHoistedCodeBlockAnchor(doc, anchorPos, diffId);
|
|
247
|
-
|
|
248
|
+
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
249
|
+
var hostPos = clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1);
|
|
250
|
+
|
|
251
|
+
// Inline diffs pass no anchorName. Give them their own point anchor instead of the
|
|
252
|
+
// `position: relative` fallback, which drifts left once the range wraps a line (EDITOR-9286).
|
|
253
|
+
var ownAnchorName = buildAnchorDecorationKey({
|
|
254
|
+
diffId: diffId,
|
|
255
|
+
anchorType: AnchorTypeKey.tag
|
|
256
|
+
});
|
|
257
|
+
var effectiveAnchorName = (_ref5 = (_hoisted$anchorName = hoisted === null || hoisted === void 0 ? void 0 : hoisted.anchorName) !== null && _hoisted$anchorName !== void 0 ? _hoisted$anchorName : anchorName) !== null && _ref5 !== void 0 ? _ref5 : ownAnchorName;
|
|
248
258
|
var tagAnchorName = effectiveAnchorName && supportsAnchorPositioning() ? effectiveAnchorName : undefined;
|
|
249
259
|
var decorations = [];
|
|
250
260
|
if (hoisted) {
|
|
251
261
|
decorations.push(hoisted.marker);
|
|
262
|
+
} else if (!anchorName && tagAnchorName) {
|
|
263
|
+
decorations.push(Decoration.widget(hostPos, function () {
|
|
264
|
+
return createAnchorNameSpan(ownAnchorName);
|
|
265
|
+
}, _objectSpread(_objectSpread({}, buildAnchorDecorationSpec({
|
|
266
|
+
diffId: diffId,
|
|
267
|
+
anchorType: AnchorTypeKey.tag,
|
|
268
|
+
side: -1
|
|
269
|
+
})), {}, {
|
|
270
|
+
marks: [],
|
|
271
|
+
ignoreSelection: true
|
|
272
|
+
})));
|
|
252
273
|
}
|
|
253
|
-
decorations.push(Decoration.widget(
|
|
254
|
-
// Keep the host out of the table row's grid (EDITOR-8442).
|
|
255
|
-
clampAnchorPosIntoCell(doc, (_hoisted$codeBlockSta = hoisted === null || hoisted === void 0 ? void 0 : hoisted.codeBlockStart) !== null && _hoisted$codeBlockSta !== void 0 ? _hoisted$codeBlockSta : anchorPos, 1), function () {
|
|
274
|
+
decorations.push(Decoration.widget(hostPos, function () {
|
|
256
275
|
var host = buildContributorTagHost(diffId, tagAnchorName);
|
|
257
276
|
mount = mountContributorTag({
|
|
258
277
|
anchorName: tagAnchorName,
|
|
@@ -5,7 +5,7 @@ import { Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
6
6
|
import { countEmptyTextBlockOnlySlice } from '../utils/emptyTextBlocks';
|
|
7
7
|
import { isEmptyParagraphSlice } from '../utils/isEmptyParagraphSlice';
|
|
8
|
-
import { clampAnchorPosIntoCell, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
8
|
+
import { clampAnchorPosIntoCell, createAnchorNameSpan, createLeftAnchorWidget } from './createAnchorDecorationWidgets';
|
|
9
9
|
import { createChangedRowDecorationWidgets } from './createChangedRowDecorationWidgets';
|
|
10
10
|
import { createContributorTagHost, resolveHoistedCodeBlockAnchor, unmountContributorTag } from './createContributorTagWidget';
|
|
11
11
|
import { AnchorTypeKey, buildContributorTagDecorationSpec, buildDiffDecorationSpec, buildAnchorDecorationKey, scrollMarginTopValue } from './decorationKeys';
|
|
@@ -17,6 +17,22 @@ import { findSafeInsertPos } from './utils/findSafeInsertPos';
|
|
|
17
17
|
import { safeResolve } from './utils/safeResolve';
|
|
18
18
|
import { getTableDiffMode } from './utils/tableDiffMode';
|
|
19
19
|
import { wrapBlockNodeView, createRemovedLozenge, injectInnerWrapper, createContentWrapper } from './utils/wrapBlockNodeView';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Where a slice's `index`th child sits in `doc`: the children belong to the ancestor `openStart`
|
|
23
|
+
* levels above the change. `null` if out of range — `posAtIndex` throws past the last child.
|
|
24
|
+
*/
|
|
25
|
+
var getSourcePos = function getSourcePos(doc, $changeFrom, openStart, index) {
|
|
26
|
+
var depth = $changeFrom ? $changeFrom.depth - openStart : -1;
|
|
27
|
+
if (!$changeFrom || depth < 0) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
var childIndex = $changeFrom.index(depth) + index;
|
|
31
|
+
if (childIndex >= $changeFrom.node(depth).childCount) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return safeResolve(doc, $changeFrom.posAtIndex(childIndex, depth));
|
|
35
|
+
};
|
|
20
36
|
var isHeadingLevel = function isHeadingLevel(level) {
|
|
21
37
|
return typeof level === 'number' && level >= 1 && level <= 6;
|
|
22
38
|
};
|
|
@@ -284,7 +300,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
284
300
|
* and if it's the first or last content, we go in however many the sliced Open
|
|
285
301
|
* or sliced End depth is and match only the entire node.
|
|
286
302
|
*/
|
|
287
|
-
slice.content.forEach(function (node) {
|
|
303
|
+
slice.content.forEach(function (node, _offset, index) {
|
|
288
304
|
var isFirst = firstReplacedNode === node;
|
|
289
305
|
var isLast = lastReplacedNode === node;
|
|
290
306
|
var isOpenAtSliceBoundary = isFirst && slice.openStart > 0 || isLast && slice.openEnd > 0;
|
|
@@ -355,7 +371,8 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
355
371
|
}
|
|
356
372
|
|
|
357
373
|
// Try to create node view, fallback to serialization
|
|
358
|
-
var
|
|
374
|
+
var $sourcePos = fg('platform_editor_ai_show_diff_patch_2') ? getSourcePos(doc, $changeFromA, slice.openStart, index) : null;
|
|
375
|
+
var nodeView = serializer.tryCreateNodeView(node, 0, $sourcePos !== null && $sourcePos !== void 0 ? $sourcePos : undefined);
|
|
359
376
|
if (nodeView) {
|
|
360
377
|
if (node.isInline) {
|
|
361
378
|
var wrapper = createContentWrapper(colorScheme, isActive, isInserted, reveal);
|
|
@@ -458,18 +475,27 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
458
475
|
});
|
|
459
476
|
}
|
|
460
477
|
|
|
461
|
-
// Needed even
|
|
462
|
-
// widget.
|
|
478
|
+
// Needed even with the indicator bar off, since it anchors its top/bottom to the widget.
|
|
463
479
|
if (showIndicators || showContributorTags) {
|
|
464
480
|
dom.style.setProperty('anchor-name', "--".concat(buildAnchorDecorationKey({
|
|
465
481
|
diffId: diffId
|
|
466
482
|
})));
|
|
467
|
-
//
|
|
468
|
-
//
|
|
469
|
-
if (fg('confluence_ncs_step_diffing_version_history')) {
|
|
470
|
-
|
|
471
|
-
diffId: diffId
|
|
483
|
+
// `dom` is inline, so its box fragments across a line wrap and `anchor()` resolves to the
|
|
484
|
+
// wrong edge. The tag anchors to its own point marker instead (EDITOR-9286).
|
|
485
|
+
if (fg('confluence_ncs_step_diffing_version_history') && !contributorTagAnchorName) {
|
|
486
|
+
var tagPointAnchorName = buildAnchorDecorationKey({
|
|
487
|
+
diffId: diffId,
|
|
488
|
+
anchorType: AnchorTypeKey.tag
|
|
472
489
|
});
|
|
490
|
+
contributorTagAnchorName = tagPointAnchorName;
|
|
491
|
+
decorations.push(Decoration.widget(safeInsertPos, function () {
|
|
492
|
+
return createAnchorNameSpan(tagPointAnchorName);
|
|
493
|
+
}, {
|
|
494
|
+
key: "contributor-tag-anchor-".concat(diffId),
|
|
495
|
+
side: -1,
|
|
496
|
+
marks: [],
|
|
497
|
+
ignoreSelection: true
|
|
498
|
+
}));
|
|
473
499
|
}
|
|
474
500
|
}
|
|
475
501
|
|
|
@@ -504,8 +530,7 @@ export var createNodeChangedDecorationWidget = function createNodeChangedDecorat
|
|
|
504
530
|
}
|
|
505
531
|
})));
|
|
506
532
|
} else {
|
|
507
|
-
//
|
|
508
|
-
// the deleted content wraps its box is the union of its line fragments.
|
|
533
|
+
// Anchored to the point marker pushed above, not to `dom` (EDITOR-9286).
|
|
509
534
|
var tagHost = createContributorTagHost({
|
|
510
535
|
anchorName: contributorTagAnchorName,
|
|
511
536
|
diffId: diffId,
|
|
@@ -314,6 +314,21 @@ var applyTextLikeBlockNodeStyles = function applyTextLikeBlockNodeStyles(_ref8)
|
|
|
314
314
|
/**
|
|
315
315
|
* Creates a content wrapper with deleted styles for a block node
|
|
316
316
|
*/
|
|
317
|
+
/**
|
|
318
|
+
* The element that spans breakout width, for nodes carrying a `breakout` mark. The wrapper divs
|
|
319
|
+
* stay at editor-column width, so anything that should align to the node's visible edges —
|
|
320
|
+
* outlines, absolutely positioned lozenges — has to attach here instead.
|
|
321
|
+
*/
|
|
322
|
+
var findBreakoutElement = function findBreakoutElement(targetNode, nodeView) {
|
|
323
|
+
var _targetNode$marks;
|
|
324
|
+
var hasBreakoutMark = (_targetNode$marks = targetNode.marks) === null || _targetNode$marks === void 0 ? void 0 : _targetNode$marks.some(function (mark) {
|
|
325
|
+
return mark.type.name === 'breakout';
|
|
326
|
+
});
|
|
327
|
+
if (!hasBreakoutMark || !(nodeView instanceof HTMLElement)) {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
return nodeView.matches('[data-node-type]') ? nodeView : nodeView.querySelector('[data-node-type]');
|
|
331
|
+
};
|
|
317
332
|
var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref9) {
|
|
318
333
|
var nodeView = _ref9.nodeView,
|
|
319
334
|
targetNode = _ref9.targetNode,
|
|
@@ -331,7 +346,16 @@ var createBlockNodeContentWrapper = function createBlockNodeContentWrapper(_ref9
|
|
|
331
346
|
// should not also get the inline content style (borderBottom underline) on their container.
|
|
332
347
|
var shouldSkipContentStyle = isInserted && nodeStyle !== undefined;
|
|
333
348
|
var contentStyle = shouldSkipContentStyle ? '' : getChangedContentStyle(colorScheme, isActive, isInserted, hideAddedDiffsUnderline);
|
|
334
|
-
|
|
349
|
+
|
|
350
|
+
// A `breakout` node renders wider than the editor column while the wrapper divs
|
|
351
|
+
// stay at column width, so paint the outline on the node element that spans that width.
|
|
352
|
+
var breakoutTarget = nodeStyle ? findBreakoutElement(targetNode, nodeView) : null;
|
|
353
|
+
if (fg('platform_editor_ai_show_diff_patch_2') && breakoutTarget) {
|
|
354
|
+
appendStyleToElement(breakoutTarget, nodeStyle !== null && nodeStyle !== void 0 ? nodeStyle : '');
|
|
355
|
+
contentWrapper.setAttribute('style', contentStyle || '');
|
|
356
|
+
} else {
|
|
357
|
+
contentWrapper.setAttribute('style', "".concat(contentStyle).concat(nodeStyle || ''));
|
|
358
|
+
}
|
|
335
359
|
contentWrapper.append(nodeView);
|
|
336
360
|
return contentWrapper;
|
|
337
361
|
};
|
|
@@ -461,7 +485,19 @@ var wrapBlockNode = function wrapBlockNode(_ref10) {
|
|
|
461
485
|
})) {
|
|
462
486
|
return;
|
|
463
487
|
}
|
|
464
|
-
|
|
488
|
+
|
|
489
|
+
// `lozenge` is absolutely positioned, so it lands on the nearest positioned ancestor. For a
|
|
490
|
+
// breakout node that is the column-width wrapper, leaving the pill short of the node's
|
|
491
|
+
// right edge — host it on the breakout element, which must establish a containing block.
|
|
492
|
+
var breakoutHost = fg('platform_editor_ai_show_diff_patch_2') ? findBreakoutElement(targetNode, nodeView) : null;
|
|
493
|
+
if (breakoutHost) {
|
|
494
|
+
appendStyleToElement(breakoutHost, convertToInlineCss({
|
|
495
|
+
position: 'relative'
|
|
496
|
+
}));
|
|
497
|
+
breakoutHost.append(lozenge);
|
|
498
|
+
} else {
|
|
499
|
+
blockWrapper.append(lozenge);
|
|
500
|
+
}
|
|
465
501
|
}
|
|
466
502
|
var contentWrapper = createBlockNodeContentWrapper({
|
|
467
503
|
nodeView: nodeView,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `@atlaskit/editor-prosemirror/view` doesn't re-export prosemirror-view's `MarkViewConstructor`,
|
|
6
|
+
* so it's typed locally, as `EditorSSRRenderer` does.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Where to look up a mark's renderer, and the view to render it against. */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Renders a mark as ProseMirror does: `view.nodeViews` also holds mark views, keyed by mark name,
|
|
13
|
+
* so `breakout` resolves whether it's registered under `markViews` or `nodeViews`. Falls back to
|
|
14
|
+
* `toDOM` — they can differ: `breakout` renders `.fabric-editor-breakout-mark-dom`, which the width
|
|
15
|
+
* CSS targets.
|
|
16
|
+
*/
|
|
17
|
+
var renderMarkView = function renderMarkView(mark, inline, _ref) {
|
|
18
|
+
var nodeViews = _ref.nodeViews,
|
|
19
|
+
view = _ref.view;
|
|
20
|
+
try {
|
|
21
|
+
var markView = nodeViews === null || nodeViews === void 0 ? void 0 : nodeViews[mark.type.name];
|
|
22
|
+
if (markView && view) {
|
|
23
|
+
var rendered = markView(mark, view, inline);
|
|
24
|
+
return {
|
|
25
|
+
dom: rendered.dom,
|
|
26
|
+
contentDOM: rendered.contentDOM
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var toDOM = mark.type.spec.toDOM;
|
|
30
|
+
if (!toDOM) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return DOMSerializer.renderSpec(document, toDOM(mark, inline));
|
|
34
|
+
} catch (_unused) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Wraps rendered DOM in its marks, as ProseMirror does for the live document. Without this a
|
|
41
|
+
* block node loses `breakout`, whose wrapper supplies the width. Marks nest
|
|
42
|
+
* outside-in, so `marks[0]` is outermost.
|
|
43
|
+
*/
|
|
44
|
+
export var wrapInMarkViews = function wrapInMarkViews(targetNode, nodeDom, sources) {
|
|
45
|
+
if (targetNode.marks.length === 0 || !fg('platform_editor_ai_show_diff_patch_2')) {
|
|
46
|
+
return nodeDom;
|
|
47
|
+
}
|
|
48
|
+
var wrapped = nodeDom;
|
|
49
|
+
for (var index = targetNode.marks.length - 1; index >= 0; index--) {
|
|
50
|
+
var _mark = targetNode.marks[index];
|
|
51
|
+
var rendered = renderMarkView(_mark, targetNode.isInline, sources);
|
|
52
|
+
// No content hole means nowhere to nest the node, so skip the mark, not the node.
|
|
53
|
+
if (!(rendered !== null && rendered !== void 0 && rendered.contentDOM)) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
rendered.contentDOM.appendChild(wrapped);
|
|
57
|
+
wrapped = rendered.dom;
|
|
58
|
+
}
|
|
59
|
+
return wrapped;
|
|
60
|
+
};
|
|
@@ -24,10 +24,10 @@ var SHOW_DIFF_AGENT_BRANDS = {
|
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Brands that prefer the account's real avatar over their fixed glyph when the invoking profile
|
|
27
|
-
* has one. Claude/ChatGPT
|
|
28
|
-
*
|
|
27
|
+
* has one. Claude/ChatGPT intentionally keep their fixed glyph always (see `AGENT_KIND_ICONS` in
|
|
28
|
+
* `contributorAvatarRenderer.ts`).
|
|
29
29
|
*/
|
|
30
|
-
var AVATAR_ELIGIBLE_BRANDS = new Set(['figma', 'lovable', 'replit']);
|
|
30
|
+
var AVATAR_ELIGIBLE_BRANDS = new Set(['figma', 'lovable', 'replit', 'rovo']);
|
|
31
31
|
|
|
32
32
|
/** Known external agent types emitted by Confluence's agent identification service that carry
|
|
33
33
|
* no `@atlaskit/agent-color` brand — a generic labelled fallback. */
|
|
@@ -5,25 +5,24 @@ import { convertToInlineCss } from '@atlaskit/editor-common/lazy-node-view';
|
|
|
5
5
|
import { getContributorTagIcon } from './contributorTagIcons';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* Agent kinds with a custom contributor-tag icon
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Agent kinds with a custom contributor-tag icon, used as a fallback glyph when no `avatarUrl` is
|
|
9
|
+
* available or its image fails to load (see `showContributorIcon`). Rovo/Figma/Lovable/Replit have
|
|
10
|
+
* no entry here — they fall back to the generic `aiAgent` glyph. The declared type stays the wider
|
|
11
11
|
* `TagContributor['agentKind']` so indexing below (with `'identified' | 'external'` in play too)
|
|
12
12
|
* stays safely partial.
|
|
13
13
|
*/
|
|
14
14
|
var AGENT_KIND_ICONS = {
|
|
15
15
|
claude: 'claude',
|
|
16
|
-
chatgpt: 'chatgpt'
|
|
17
|
-
rovo: 'rovoHex'
|
|
16
|
+
chatgpt: 'chatgpt'
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
/**
|
|
21
20
|
* Brands that always render their fixed glyph, even when the contributor also carries an
|
|
22
|
-
* `avatarUrl`. Figma/Lovable/Replit are excluded here and use the real avatar when
|
|
21
|
+
* `avatarUrl`. Rovo/Figma/Lovable/Replit are excluded here and use the real avatar when
|
|
23
22
|
* `resolveDiffContributors` supplies one, falling back to the generic `aiAgent` glyph on load
|
|
24
23
|
* failure.
|
|
25
24
|
*/
|
|
26
|
-
var FIXED_GLYPH_AGENT_KINDS = new Set(['claude', 'chatgpt'
|
|
25
|
+
var FIXED_GLYPH_AGENT_KINDS = new Set(['claude', 'chatgpt']);
|
|
27
26
|
|
|
28
27
|
/** The size `@atlaskit/avatar`'s `xxsmall` rendered at. */
|
|
29
28
|
var AVATAR_SIZE = AVATAR_SIZES.xxsmall;
|
|
@@ -120,8 +119,8 @@ export var contributorAvatarRenderer = function contributorAvatarRenderer(_ref)
|
|
|
120
119
|
};
|
|
121
120
|
if (contributor.avatarUrl) {
|
|
122
121
|
var _contributor$agentKin2;
|
|
123
|
-
// Claude/ChatGPT
|
|
124
|
-
//
|
|
122
|
+
// Claude/ChatGPT always use their fixed glyph, even when the profile also has an avatar
|
|
123
|
+
// URL. Other agents (e.g. Rovo/Figma/Lovable/Replit) and users prefer the real avatar.
|
|
125
124
|
var usesFixedGlyph = isAgent && FIXED_GLYPH_AGENT_KINDS.has((_contributor$agentKin2 = contributor.agentKind) !== null && _contributor$agentKin2 !== void 0 ? _contributor$agentKin2 : 'external');
|
|
126
125
|
if (usesFixedGlyph) {
|
|
127
126
|
showContributorIcon();
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
* Neither `@atlaskit/icon`, `@atlaskit/icon-lab` nor `@atlaskit/logo` exposes a raw-SVG entry
|
|
5
5
|
* point, so the markup is copied here rather than kept as a React island for these glyphs. Keep in
|
|
6
6
|
* sync with the sources named on each constant.
|
|
7
|
-
*
|
|
8
|
-
* The Rovo hex is the `brand` appearance, whose `--rovo-*-color` variables resolve to `initial` in
|
|
9
|
-
* both themes — the fallbacks below are the rendered colours, so no theme observer is needed.
|
|
10
7
|
*/
|
|
11
8
|
|
|
12
9
|
/** `@atlaskit/icon/core/person`, at the 16px the avatar renders it. */
|
|
@@ -22,9 +19,6 @@ var AI_BOT_ICON_SVG = "<svg width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0
|
|
|
22
19
|
*/
|
|
23
20
|
var AI_AGENT_ICON_SVG = "<svg width=\"12\" height=\"12\" fill=\"none\" viewBox=\"0 0 16 16\" role=\"presentation\" style=\"display:block\"><path fill=\"currentcolor\" fill-rule=\"evenodd\" d=\"M6.971.493a2 2 0 0 1 2.058 0l5 3A2 2 0 0 1 15 5.208v5.584a2 2 0 0 1-.971 1.715l-5 3a2 2 0 0 1-2.058 0l-5-3A2 2 0 0 1 1 10.792V5.208a2 2 0 0 1 .971-1.715zm1.286 1.286a.5.5 0 0 0-.514 0l-5 3a.5.5 0 0 0-.243.429v5.584a.5.5 0 0 0 .243.429l1.098.66a4.25 4.25 0 1 1 8.318 0l1.098-.66a.5.5 0 0 0 .243-.429V5.208a.5.5 0 0 0-.243-.429zM8 8.25a2.75 2.75 0 1 0 0 5.5 2.75 2.75 0 0 0 0-5.5\" clip-rule=\"evenodd\"/></svg>";
|
|
24
21
|
|
|
25
|
-
/** `RovoHexIcon` from `@atlaskit/logo/rovo-hex/icon`, at the 16px `xxsmall` renders. */
|
|
26
|
-
var ROVO_HEX_ICON_SVG = "<svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" role=\"presentation\" style=\"display:block\"><path fill=\"#1868db\" fill-rule=\"evenodd\" d=\"m13.227 16.789-7.154 4.169-3.403-1.96a2.72 2.72 0 0 1-1.362-2.355V7.366c0-.973.518-1.87 1.361-2.354l6.044-3.487-.038.114a3.6 3.6 0 0 0-.172 1.088v9.278c0 1.274.68 2.45 1.786 3.085z\" clip-rule=\"evenodd\"/><path fill=\"#6a9a23\" fill-rule=\"evenodd\" d=\"m11.296 15.671-7.193 4.153 6.607 3.812a2.73 2.73 0 0 0 2.676.026l.048-.033a2.73 2.73 0 0 0 1.232-1.525 2.7 2.7 0 0 0 .127-.822v-3.594z\" clip-rule=\"evenodd\"/><path fill=\"#af59e1\" fill-rule=\"evenodd\" d=\"m21.477 5.003-4.404-2.539-5.904 4.89 2.69 1.556a3.56 3.56 0 0 1 1.785 3.086v9.277a3.6 3.6 0 0 1-.21 1.202l6.044-3.486a2.71 2.71 0 0 0 1.362-2.355V7.357c0-.97-.521-1.87-1.363-2.354\" clip-rule=\"evenodd\"/><path fill=\"#fca700\" fill-rule=\"evenodd\" d=\"M12.74 8.266 9.353 6.312V2.718c0-.283.044-.56.127-.821A2.73 2.73 0 0 1 10.71.372V.37a.4.4 0 0 0 .048-.033 2.73 2.73 0 0 1 2.676.026l6.499 3.75z\" clip-rule=\"evenodd\"/></svg>";
|
|
27
|
-
|
|
28
22
|
/** Claude hexagon lockup from the brand asset: the hexagon and knot glyph both baked in. */
|
|
29
23
|
var CLAUDE_ICON_SVG = "<svg width=\"16\" height=\"18\" viewBox=\"0 0 16 18\" fill=\"none\" role=\"presentation\" style=\"display:block\"><path fill=\"#D97757\" d=\"M14.5007 3.28903L9.50384 0.402344C8.5736 -0.13506 7.42701 -0.134016 6.49774 0.405082L1.49458 3.30759C0.569434 3.8443 0 4.83297 0 5.90253V11.1804C0 12.2519 0.571497 13.2421 1.49931 13.7781L6.49931 16.6666C7.42787 17.203 8.57213 17.203 9.50069 16.6666L14.5007 13.7781C15.4285 13.2421 16 12.2519 16 11.1804V5.88671C16 4.8152 15.4285 3.82504 14.5007 3.28903Z\"/><path fill=\"#FAF9F6\" d=\"M5.19791 10.055L7.0123 9.03681L7.04267 8.94806L7.0123 8.89907H6.92357L6.62 8.88034L5.58321 8.85232L4.68418 8.815L3.81317 8.76826L3.59367 8.72158L3.38818 8.4507L3.4092 8.31526L3.59367 8.1915L3.85754 8.21485L4.44133 8.25455L5.317 8.31526L5.95216 8.35262L6.89321 8.4507H7.04267L7.06368 8.38999L7.0123 8.35262L6.97261 8.31526L6.06658 7.70112L5.08582 7.05196L4.5721 6.67834L4.29422 6.48919L4.15411 6.31172L4.09339 5.92409L4.34559 5.64621L4.68418 5.66956L4.77058 5.69291L5.11384 5.95678L5.84708 6.52422L6.80448 7.22943L6.94459 7.34618L7.00063 7.30649L7.00763 7.27846L6.94459 7.17338L6.42385 6.23233L5.86809 5.27492L5.62057 4.87795L5.55519 4.63977C5.53183 4.54169 5.51549 4.45996 5.51549 4.35956L5.80271 3.96959L5.9615 3.91821L6.34446 3.96959L6.50558 4.10969L6.74377 4.65378L7.12907 5.51077L7.72686 6.676L7.90199 7.0216L7.99539 7.34152L8.0304 7.43959H8.09113V7.38354L8.14018 6.72737L8.23124 5.92175L8.31999 4.88496L8.35032 4.59307L8.49511 4.24279L8.78232 4.05365L9.00649 4.16107L9.19098 4.42494L9.16533 4.5954L9.05555 5.30762L8.84073 6.42381L8.70062 7.17105H8.78232L8.87574 7.07764L9.25401 6.57559L9.88922 5.78165L10.1694 5.4664L10.4963 5.11847L10.7065 4.95267H11.1035L11.3953 5.38701L11.2646 5.83535L10.8559 6.35375L10.5173 6.79276L10.0316 7.4466L9.72807 7.96966L9.7561 8.0117L9.82849 8.00469L10.926 7.77118L11.5191 7.66376L12.2266 7.54233L12.5466 7.69178L12.5816 7.84356L12.4555 8.15414L11.6989 8.34095L10.8116 8.51842L9.48985 8.83136L9.4735 8.84303L9.49223 8.86637L10.0877 8.92241L10.3422 8.93639H10.9657L12.1262 9.02283L12.4298 9.2236L12.612 9.46881L12.5816 9.6556L12.1146 9.89382L11.4841 9.74434L10.013 9.3941L9.50858 9.26797H9.43849V9.31004L9.85882 9.721L10.6294 10.4169L11.5938 11.3136L11.6429 11.5354L11.5191 11.7106L11.3884 11.6918L10.5407 11.0544L10.2137 10.7672L9.4735 10.1436H9.42451V10.209L9.59495 10.4589L10.4963 11.8133L10.543 12.2289L10.4776 12.3644L10.2441 12.4461L9.98726 12.3994L9.45952 11.6592L8.91544 10.8255L8.47645 10.0783L8.42271 10.1086L8.16352 12.8991L8.04207 13.0416L7.76188 13.149L7.52837 12.9715L7.40461 12.6843L7.52837 12.1168L7.67781 11.3766L7.79925 10.7881L7.90899 10.0573L7.97438 9.81443L7.96971 9.79808L7.916 9.80507L7.36491 10.5617L6.5266 11.6942L5.86342 12.4041L5.70463 12.4671L5.42909 12.3247L5.45477 12.0702L5.60889 11.8436L6.5266 10.6761L7.08002 9.95217L7.4373 9.53421L7.43497 9.47349H7.41395L4.97607 11.0567L4.54174 11.1127L4.35493 10.9376L4.37828 10.6504L4.46702 10.557L5.20024 10.0526L5.19791 10.055Z\"/></svg>";
|
|
30
24
|
|
|
@@ -35,8 +29,7 @@ var markup = {
|
|
|
35
29
|
aiBot: AI_BOT_ICON_SVG,
|
|
36
30
|
chatgpt: CHATGPT_ICON_SVG,
|
|
37
31
|
claude: CLAUDE_ICON_SVG,
|
|
38
|
-
person: PERSON_ICON_SVG
|
|
39
|
-
rovoHex: ROVO_HEX_ICON_SVG
|
|
32
|
+
person: PERSON_ICON_SVG
|
|
40
33
|
};
|
|
41
34
|
|
|
42
35
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NodeViewConstructor } from '@atlaskit/editor-common/lazy-node-view';
|
|
2
|
-
import type { Node as PMNode, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { Node as PMNode, Fragment, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
/**
|
|
5
5
|
* Utilities for working with ProseMirror node views and DOM serialization within the
|
|
@@ -58,8 +58,13 @@ export declare class NodeViewSerializer {
|
|
|
58
58
|
*
|
|
59
59
|
* Returns `null` when there is no `EditorView`, no constructor for the node type,
|
|
60
60
|
* or the node type is blocklisted. Otherwise returns the constructed node view instance.
|
|
61
|
+
*
|
|
62
|
+
* `$sourcePos` is where the node sits in the doc it came from, so nested tables keep their depth.
|
|
61
63
|
*/
|
|
62
|
-
tryCreateNodeView(targetNode: PMNode): Node | null;
|
|
64
|
+
tryCreateNodeView(targetNode: PMNode, basePos?: number, $sourcePos?: ResolvedPos): Node | null;
|
|
65
|
+
private tryCreateNodeViewInner;
|
|
66
|
+
/** Wraps rendered DOM in its marks, rendered against the editor proxy when there is one. */
|
|
67
|
+
private withMarkViews;
|
|
63
68
|
/**
|
|
64
69
|
* Serializes a node to a DOM `Node` using the schema's `DOMSerializer`.
|
|
65
70
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Node as PMNode, ResolvedPos } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
/**
|
|
4
|
+
* A preview is rendered by the live view's own node views, which read `getPos()` against
|
|
5
|
+
* `view.state.doc` for both layout (`isTableNested`) and writes (`scaleTable` builds attribute
|
|
6
|
+
* steps at `getPos() + 1`). Handing them live positions makes the layout correct but points the
|
|
7
|
+
* writes at unrelated live nodes, so give them a view whose document *is* the preview instead.
|
|
8
|
+
*
|
|
9
|
+
* With `$sourcePos` (the node's position in the doc it came from) the node is swapped into a copy
|
|
10
|
+
* of its real top-level ancestor, so a table inside an expand still resolves as nested.
|
|
11
|
+
*
|
|
12
|
+
* Returns `null` when the node cannot be a top-level child (e.g. a bare `tableCell`), in which
|
|
13
|
+
* case the caller falls back to the live view and the previous stubbed positions.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createEditorProxy(liveView: EditorView, rootNode: PMNode, $sourcePos?: ResolvedPos): {
|
|
16
|
+
editorProxy: EditorView;
|
|
17
|
+
rootPos: number;
|
|
18
|
+
} | null;
|
|
@@ -68,7 +68,8 @@ export declare const resolveHoistedCodeBlockAnchor: (doc: PMNode, pos: number, d
|
|
|
68
68
|
* highlights — or, with `anchorAtRangeStart`, at `from` itself. A host inside a code block is
|
|
69
69
|
* hoisted in front of it instead, anchored via `resolveHoistedCodeBlockAnchor` (EDITOR-9045).
|
|
70
70
|
*
|
|
71
|
-
* Returns one decoration
|
|
71
|
+
* Returns one decoration when a caller-supplied `anchorName` is used, two (marker + tag)
|
|
72
|
+
* otherwise — hoisted out of a code block, or anchored to its own point marker.
|
|
72
73
|
*
|
|
73
74
|
* The tag is mounted in `toDOM` and taken down in `destroy`, so it lives exactly as long as the host
|
|
74
75
|
* element ProseMirror drew it into — see `mountContributorTag`.
|