@atlaskit/editor-plugin-extension 10.1.5 → 10.1.6
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 +8 -0
- package/dist/cjs/pm-plugins/toolbar.js +18 -10
- package/dist/cjs/pm-plugins/utils.js +184 -23
- package/dist/es2019/pm-plugins/toolbar.js +17 -9
- package/dist/es2019/pm-plugins/utils.js +89 -5
- package/dist/esm/pm-plugins/toolbar.js +18 -10
- package/dist/esm/pm-plugins/utils.js +183 -23
- package/dist/types/extensionPluginType.d.ts +5 -1
- package/dist/types/pm-plugins/toolbar.d.ts +14 -2
- package/dist/types/pm-plugins/utils.d.ts +5 -2
- package/dist/types-ts4.5/extensionPluginType.d.ts +5 -1
- package/dist/types-ts4.5/pm-plugins/toolbar.d.ts +9 -2
- package/dist/types-ts4.5/pm-plugins/utils.d.ts +7 -2
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-extension
|
|
2
2
|
|
|
3
|
+
## 10.1.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`abdf6c5320b01`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/abdf6c5320b01) -
|
|
8
|
+
[EDITOR-5370] Support Unsupported Content: handle copy content from nodes like mention
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 10.1.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -268,10 +268,12 @@ var calculateToolbarPosition = function calculateToolbarPosition(editorView, nex
|
|
|
268
268
|
* if the current selected extension is an unsupported content extension.
|
|
269
269
|
*/
|
|
270
270
|
var createOnClickCopyButton = exports.createOnClickCopyButton = function createOnClickCopyButton(_ref) {
|
|
271
|
-
var
|
|
271
|
+
var formatMessage = _ref.formatMessage,
|
|
272
|
+
extensionApi = _ref.extensionApi,
|
|
272
273
|
extensionProvider = _ref.extensionProvider,
|
|
273
274
|
getUnsupportedContent = _ref.getUnsupportedContent,
|
|
274
|
-
state = _ref.state
|
|
275
|
+
state = _ref.state,
|
|
276
|
+
locale = _ref.locale;
|
|
275
277
|
if (!extensionProvider) {
|
|
276
278
|
return;
|
|
277
279
|
}
|
|
@@ -298,18 +300,21 @@ var createOnClickCopyButton = exports.createOnClickCopyButton = function createO
|
|
|
298
300
|
|
|
299
301
|
// this command copies the text content of the unsupported content extension to the clipboard
|
|
300
302
|
return function (editorState) {
|
|
301
|
-
|
|
303
|
+
(0, _utils3.copyUnsupportedContentToClipboard)({
|
|
304
|
+
locale: locale,
|
|
302
305
|
unsupportedContent: adf,
|
|
303
|
-
schema: state.schema
|
|
304
|
-
|
|
305
|
-
|
|
306
|
+
schema: state.schema,
|
|
307
|
+
api: extensionApi
|
|
308
|
+
}).then(function () {
|
|
309
|
+
var _extensionApi$copyBut;
|
|
310
|
+
extensionApi === null || extensionApi === void 0 || (_extensionApi$copyBut = extensionApi.copyButton) === null || _extensionApi$copyBut === void 0 || _extensionApi$copyBut.actions.afterCopy(formatMessage(_messages.default.copiedToClipboard));
|
|
311
|
+
}).catch(function (error) {
|
|
306
312
|
(0, _utils3.onCopyFailed)({
|
|
307
313
|
error: error,
|
|
308
314
|
extensionApi: extensionApi,
|
|
309
315
|
state: editorState
|
|
310
316
|
});
|
|
311
|
-
|
|
312
|
-
}
|
|
317
|
+
});
|
|
313
318
|
return true;
|
|
314
319
|
};
|
|
315
320
|
};
|
|
@@ -320,7 +325,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(_ref
|
|
|
320
325
|
getUnsupportedContent = _ref2.getUnsupportedContent;
|
|
321
326
|
return function (state, intl) {
|
|
322
327
|
var _extensionApi$decorat, _extensionApi$context, _extensionApi$analyti, _extensionApi$connect;
|
|
323
|
-
var formatMessage = intl.formatMessage
|
|
328
|
+
var formatMessage = intl.formatMessage,
|
|
329
|
+
locale = intl.locale;
|
|
324
330
|
var extensionState = (0, _pluginFactory.getPluginState)(state);
|
|
325
331
|
var extensionProvider = extensionState.extensionProvider;
|
|
326
332
|
var hoverDecoration = extensionApi === null || extensionApi === void 0 || (_extensionApi$decorat = extensionApi.decorations) === null || _extensionApi$decorat === void 0 ? void 0 : _extensionApi$decorat.actions.hoverDecoration;
|
|
@@ -391,10 +397,12 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(_ref
|
|
|
391
397
|
formatMessage: intl.formatMessage,
|
|
392
398
|
nodeType: nodeType,
|
|
393
399
|
onClick: (0, _expValEquals.expValEquals)('platform_editor_ai_edit_unsupported_content', 'isEnabled', true) ? createOnClickCopyButton({
|
|
400
|
+
formatMessage: formatMessage,
|
|
394
401
|
extensionApi: extensionApi,
|
|
395
402
|
extensionProvider: extensionProvider,
|
|
396
403
|
getUnsupportedContent: getUnsupportedContent,
|
|
397
|
-
state: state
|
|
404
|
+
state: state,
|
|
405
|
+
locale: locale
|
|
398
406
|
}) : undefined
|
|
399
407
|
}]
|
|
400
408
|
}, shouldHideCopyButton && {
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.onCopyFailed = exports.getSelectedExtension = exports.getSelectedDomElement = exports.getNodeTypesReferenced = exports.getDataConsumerMark = exports.findNodePosWithLocalId = exports.findExtensionWithLocalId = exports.copyUnsupportedContentToClipboard = void 0;
|
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
7
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
11
|
var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
9
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
13
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
11
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
|
+
var _resource = require("@atlaskit/mention/resource");
|
|
16
|
+
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; } } }; }
|
|
17
|
+
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; } }
|
|
18
|
+
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; }
|
|
12
19
|
var getSelectedExtension = exports.getSelectedExtension = function getSelectedExtension(state) {
|
|
13
20
|
var searchParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
14
21
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -75,35 +82,189 @@ var findNodePosWithLocalId = exports.findNodePosWithLocalId = function findNodeP
|
|
|
75
82
|
return nodes.length >= 1 ? nodes[0] : undefined;
|
|
76
83
|
};
|
|
77
84
|
/**
|
|
78
|
-
*
|
|
85
|
+
* Converts a ProseMirror node to its text representation.
|
|
86
|
+
* Handles text nodes with marks (links) and inline nodes (status, mention, emoji).
|
|
87
|
+
* Returns the content for this node, with a trailing separator for text blocks.
|
|
79
88
|
*/
|
|
80
|
-
var
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
89
|
+
var convertNodeToText = function convertNodeToText(node, mentionSet, parent, locale) {
|
|
90
|
+
if (node.isInline) {
|
|
91
|
+
var schema = node.type.schema;
|
|
92
|
+
var finalText = '';
|
|
93
|
+
if (node.isText) {
|
|
94
|
+
finalText = node.text || '';
|
|
95
|
+
if (node.marks.length > 0) {
|
|
96
|
+
var _iterator = _createForOfIteratorHelper(node.marks),
|
|
97
|
+
_step;
|
|
98
|
+
try {
|
|
99
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
100
|
+
var mark = _step.value;
|
|
101
|
+
// if it's link, include the href in the text
|
|
102
|
+
if (mark.type === schema.marks.link) {
|
|
103
|
+
var href = mark.attrs.href;
|
|
104
|
+
var text = node.text || '';
|
|
105
|
+
// If the text differs from the href, include both
|
|
106
|
+
if (text && text !== href) {
|
|
107
|
+
finalText = "".concat(text, " ").concat(href);
|
|
108
|
+
} else {
|
|
109
|
+
finalText = href;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
_iterator.e(err);
|
|
115
|
+
} finally {
|
|
116
|
+
_iterator.f();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
switch (node.type) {
|
|
121
|
+
case schema.nodes.status:
|
|
122
|
+
finalText = node.attrs.text || '';
|
|
123
|
+
break;
|
|
124
|
+
case schema.nodes.mention:
|
|
125
|
+
mentionSet.add(node.attrs.id);
|
|
126
|
+
finalText = "@".concat(node.attrs.id);
|
|
127
|
+
break;
|
|
128
|
+
case schema.nodes.emoji:
|
|
129
|
+
finalText = node.attrs.shortName || '';
|
|
130
|
+
break;
|
|
131
|
+
case schema.nodes.date:
|
|
132
|
+
var timestamp = new Date(Number(node.attrs.timestamp));
|
|
133
|
+
finalText = !isNaN(timestamp.getTime()) ? timestamp.toLocaleDateString(locale !== null && locale !== void 0 ? locale : 'en-US') : String(node.attrs.timestamp);
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
finalText = node.textContent;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
86
139
|
}
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
-
version: 1,
|
|
90
|
-
type: 'doc',
|
|
91
|
-
content: [unsupportedContent]
|
|
92
|
-
};
|
|
140
|
+
if (parent && parent.isTextblock && node === parent.lastChild && parent.childCount > 0) {
|
|
141
|
+
finalText += '\n\n';
|
|
93
142
|
}
|
|
94
|
-
|
|
95
|
-
var pmNode = transformer.parse(unsupportedContent);
|
|
96
|
-
var text = pmNode.textBetween(0, pmNode.content.size, '\n\n');
|
|
97
|
-
(0, _clipboard.copyToClipboard)(text);
|
|
98
|
-
} catch (error) {
|
|
99
|
-
return error instanceof Error ? error : new Error('Failed to copy content');
|
|
143
|
+
return finalText;
|
|
100
144
|
}
|
|
145
|
+
return '';
|
|
101
146
|
};
|
|
102
|
-
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Resolves mention IDs to their display names and replaces them in the text.
|
|
150
|
+
* Returns the text with resolved mentions, or the original text if the provider is unavailable.
|
|
151
|
+
*/
|
|
152
|
+
var resolveMentionsInText = /*#__PURE__*/function () {
|
|
153
|
+
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(text, mentionSet, api) {
|
|
154
|
+
var _api$mention;
|
|
155
|
+
var mentionProvider, resolvedText, _iterator2, _step2, id, mention;
|
|
156
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
157
|
+
while (1) switch (_context.prev = _context.next) {
|
|
158
|
+
case 0:
|
|
159
|
+
mentionProvider = api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.sharedState) === null || _api$mention === void 0 || (_api$mention = _api$mention.currentState()) === null || _api$mention === void 0 ? void 0 : _api$mention.mentionProvider;
|
|
160
|
+
if (!(!mentionProvider || !(0, _resource.isResolvingMentionProvider)(mentionProvider))) {
|
|
161
|
+
_context.next = 3;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
return _context.abrupt("return", text);
|
|
165
|
+
case 3:
|
|
166
|
+
resolvedText = text;
|
|
167
|
+
_iterator2 = _createForOfIteratorHelper(mentionSet);
|
|
168
|
+
_context.prev = 5;
|
|
169
|
+
_iterator2.s();
|
|
170
|
+
case 7:
|
|
171
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
172
|
+
_context.next = 15;
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
id = _step2.value;
|
|
176
|
+
_context.next = 11;
|
|
177
|
+
return mentionProvider.resolveMentionName(id);
|
|
178
|
+
case 11:
|
|
179
|
+
mention = _context.sent;
|
|
180
|
+
resolvedText = resolvedText.replace("@".concat(id), "@".concat(mention.name) || '@…');
|
|
181
|
+
case 13:
|
|
182
|
+
_context.next = 7;
|
|
183
|
+
break;
|
|
184
|
+
case 15:
|
|
185
|
+
_context.next = 20;
|
|
186
|
+
break;
|
|
187
|
+
case 17:
|
|
188
|
+
_context.prev = 17;
|
|
189
|
+
_context.t0 = _context["catch"](5);
|
|
190
|
+
_iterator2.e(_context.t0);
|
|
191
|
+
case 20:
|
|
192
|
+
_context.prev = 20;
|
|
193
|
+
_iterator2.f();
|
|
194
|
+
return _context.finish(20);
|
|
195
|
+
case 23:
|
|
196
|
+
return _context.abrupt("return", resolvedText);
|
|
197
|
+
case 24:
|
|
198
|
+
case "end":
|
|
199
|
+
return _context.stop();
|
|
200
|
+
}
|
|
201
|
+
}, _callee, null, [[5, 17, 20, 23]]);
|
|
202
|
+
}));
|
|
203
|
+
return function resolveMentionsInText(_x, _x2, _x3) {
|
|
204
|
+
return _ref2.apply(this, arguments);
|
|
205
|
+
};
|
|
206
|
+
}();
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* copying ADF from the unsupported content extension as text to clipboard
|
|
210
|
+
*/
|
|
211
|
+
var copyUnsupportedContentToClipboard = exports.copyUnsupportedContentToClipboard = /*#__PURE__*/function () {
|
|
212
|
+
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref3) {
|
|
213
|
+
var locale, schema, unsupportedContent, api, transformer, pmNode, text, mentionSet;
|
|
214
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
215
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
216
|
+
case 0:
|
|
217
|
+
locale = _ref3.locale, schema = _ref3.schema, unsupportedContent = _ref3.unsupportedContent, api = _ref3.api;
|
|
218
|
+
_context2.prev = 1;
|
|
219
|
+
if (unsupportedContent) {
|
|
220
|
+
_context2.next = 4;
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
throw new Error('No nested content found');
|
|
224
|
+
case 4:
|
|
225
|
+
if (unsupportedContent.type !== 'doc') {
|
|
226
|
+
unsupportedContent = {
|
|
227
|
+
version: 1,
|
|
228
|
+
type: 'doc',
|
|
229
|
+
content: [unsupportedContent]
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
transformer = new _editorJsonTransformer.JSONTransformer(schema);
|
|
233
|
+
pmNode = transformer.parse(unsupportedContent);
|
|
234
|
+
text = '';
|
|
235
|
+
mentionSet = new Set();
|
|
236
|
+
pmNode.nodesBetween(0, pmNode.content.size, function (node, _pos, parent) {
|
|
237
|
+
text += convertNodeToText(node, mentionSet, parent, locale);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// Trim leading/trailing whitespace from the collected text
|
|
241
|
+
text = text.trim();
|
|
242
|
+
_context2.next = 13;
|
|
243
|
+
return resolveMentionsInText(text, mentionSet, api);
|
|
244
|
+
case 13:
|
|
245
|
+
text = _context2.sent;
|
|
246
|
+
(0, _clipboard.copyToClipboard)(text);
|
|
247
|
+
_context2.next = 20;
|
|
248
|
+
break;
|
|
249
|
+
case 17:
|
|
250
|
+
_context2.prev = 17;
|
|
251
|
+
_context2.t0 = _context2["catch"](1);
|
|
252
|
+
throw _context2.t0 instanceof Error ? _context2.t0 : new Error('Failed to copy content');
|
|
253
|
+
case 20:
|
|
254
|
+
case "end":
|
|
255
|
+
return _context2.stop();
|
|
256
|
+
}
|
|
257
|
+
}, _callee2, null, [[1, 17]]);
|
|
258
|
+
}));
|
|
259
|
+
return function copyUnsupportedContentToClipboard(_x4) {
|
|
260
|
+
return _ref4.apply(this, arguments);
|
|
261
|
+
};
|
|
262
|
+
}();
|
|
263
|
+
var onCopyFailed = exports.onCopyFailed = function onCopyFailed(_ref5) {
|
|
103
264
|
var _extensionApi$analyti;
|
|
104
|
-
var error =
|
|
105
|
-
extensionApi =
|
|
106
|
-
state =
|
|
265
|
+
var error = _ref5.error,
|
|
266
|
+
extensionApi = _ref5.extensionApi,
|
|
267
|
+
state = _ref5.state;
|
|
107
268
|
var nodeWithPos = getSelectedExtension(state, true);
|
|
108
269
|
if (!nodeWithPos) {
|
|
109
270
|
return;
|
|
@@ -266,10 +266,12 @@ const calculateToolbarPosition = (editorView, nextPos, state, extensionNode) =>
|
|
|
266
266
|
* if the current selected extension is an unsupported content extension.
|
|
267
267
|
*/
|
|
268
268
|
export const createOnClickCopyButton = ({
|
|
269
|
+
formatMessage,
|
|
269
270
|
extensionApi,
|
|
270
271
|
extensionProvider,
|
|
271
272
|
getUnsupportedContent,
|
|
272
|
-
state
|
|
273
|
+
state,
|
|
274
|
+
locale
|
|
273
275
|
}) => {
|
|
274
276
|
if (!extensionProvider) {
|
|
275
277
|
return;
|
|
@@ -300,18 +302,21 @@ export const createOnClickCopyButton = ({
|
|
|
300
302
|
|
|
301
303
|
// this command copies the text content of the unsupported content extension to the clipboard
|
|
302
304
|
return editorState => {
|
|
303
|
-
|
|
305
|
+
copyUnsupportedContentToClipboard({
|
|
306
|
+
locale,
|
|
304
307
|
unsupportedContent: adf,
|
|
305
|
-
schema: state.schema
|
|
306
|
-
|
|
307
|
-
|
|
308
|
+
schema: state.schema,
|
|
309
|
+
api: extensionApi
|
|
310
|
+
}).then(() => {
|
|
311
|
+
var _extensionApi$copyBut;
|
|
312
|
+
extensionApi === null || extensionApi === void 0 ? void 0 : (_extensionApi$copyBut = extensionApi.copyButton) === null || _extensionApi$copyBut === void 0 ? void 0 : _extensionApi$copyBut.actions.afterCopy(formatMessage(commonMessages.copiedToClipboard));
|
|
313
|
+
}).catch(error => {
|
|
308
314
|
onCopyFailed({
|
|
309
315
|
error,
|
|
310
316
|
extensionApi,
|
|
311
317
|
state: editorState
|
|
312
318
|
});
|
|
313
|
-
|
|
314
|
-
}
|
|
319
|
+
});
|
|
315
320
|
return true;
|
|
316
321
|
};
|
|
317
322
|
};
|
|
@@ -322,7 +327,8 @@ export const getToolbarConfig = ({
|
|
|
322
327
|
}) => (state, intl) => {
|
|
323
328
|
var _extensionApi$decorat, _extensionApi$context, _extensionApi$analyti, _extensionApi$connect, _extensionApi$connect2, _extensionApi$connect3;
|
|
324
329
|
const {
|
|
325
|
-
formatMessage
|
|
330
|
+
formatMessage,
|
|
331
|
+
locale
|
|
326
332
|
} = intl;
|
|
327
333
|
const extensionState = getPluginState(state);
|
|
328
334
|
const {
|
|
@@ -387,10 +393,12 @@ export const getToolbarConfig = ({
|
|
|
387
393
|
formatMessage: intl.formatMessage,
|
|
388
394
|
nodeType,
|
|
389
395
|
onClick: expValEquals('platform_editor_ai_edit_unsupported_content', 'isEnabled', true) ? createOnClickCopyButton({
|
|
396
|
+
formatMessage,
|
|
390
397
|
extensionApi,
|
|
391
398
|
extensionProvider,
|
|
392
399
|
getUnsupportedContent,
|
|
393
|
-
state
|
|
400
|
+
state,
|
|
401
|
+
locale
|
|
394
402
|
}) : undefined
|
|
395
403
|
}],
|
|
396
404
|
...(shouldHideCopyButton && {
|
|
@@ -3,6 +3,7 @@ import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
|
3
3
|
import { closestElement, findNodePosByLocalIds } from '@atlaskit/editor-common/utils';
|
|
4
4
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
5
5
|
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
6
7
|
export const getSelectedExtension = (state, searchParent = false) => {
|
|
7
8
|
const {
|
|
8
9
|
inlineExtension,
|
|
@@ -66,16 +67,91 @@ export const findNodePosWithLocalId = (state, localId) => {
|
|
|
66
67
|
const nodes = findNodePosByLocalIds(state, [localId]);
|
|
67
68
|
return nodes.length >= 1 ? nodes[0] : undefined;
|
|
68
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Converts a ProseMirror node to its text representation.
|
|
72
|
+
* Handles text nodes with marks (links) and inline nodes (status, mention, emoji).
|
|
73
|
+
* Returns the content for this node, with a trailing separator for text blocks.
|
|
74
|
+
*/
|
|
75
|
+
const convertNodeToText = (node, mentionSet, parent, locale) => {
|
|
76
|
+
if (node.isInline) {
|
|
77
|
+
const schema = node.type.schema;
|
|
78
|
+
let finalText = '';
|
|
79
|
+
if (node.isText) {
|
|
80
|
+
finalText = node.text || '';
|
|
81
|
+
if (node.marks.length > 0) {
|
|
82
|
+
for (const mark of node.marks) {
|
|
83
|
+
// if it's link, include the href in the text
|
|
84
|
+
if (mark.type === schema.marks.link) {
|
|
85
|
+
const href = mark.attrs.href;
|
|
86
|
+
const text = node.text || '';
|
|
87
|
+
// If the text differs from the href, include both
|
|
88
|
+
if (text && text !== href) {
|
|
89
|
+
finalText = `${text} ${href}`;
|
|
90
|
+
} else {
|
|
91
|
+
finalText = href;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
switch (node.type) {
|
|
98
|
+
case schema.nodes.status:
|
|
99
|
+
finalText = node.attrs.text || '';
|
|
100
|
+
break;
|
|
101
|
+
case schema.nodes.mention:
|
|
102
|
+
mentionSet.add(node.attrs.id);
|
|
103
|
+
finalText = `@${node.attrs.id}`;
|
|
104
|
+
break;
|
|
105
|
+
case schema.nodes.emoji:
|
|
106
|
+
finalText = node.attrs.shortName || '';
|
|
107
|
+
break;
|
|
108
|
+
case schema.nodes.date:
|
|
109
|
+
const timestamp = new Date(Number(node.attrs.timestamp));
|
|
110
|
+
finalText = !isNaN(timestamp.getTime()) ? timestamp.toLocaleDateString(locale !== null && locale !== void 0 ? locale : 'en-US') : String(node.attrs.timestamp);
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
finalText = node.textContent;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (parent && parent.isTextblock && node === parent.lastChild && parent.childCount > 0) {
|
|
118
|
+
finalText += '\n\n';
|
|
119
|
+
}
|
|
120
|
+
return finalText;
|
|
121
|
+
}
|
|
122
|
+
return '';
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Resolves mention IDs to their display names and replaces them in the text.
|
|
127
|
+
* Returns the text with resolved mentions, or the original text if the provider is unavailable.
|
|
128
|
+
*/
|
|
129
|
+
const resolveMentionsInText = async (text, mentionSet, api) => {
|
|
130
|
+
var _api$mention, _api$mention$sharedSt, _api$mention$sharedSt2;
|
|
131
|
+
const mentionProvider = api === null || api === void 0 ? void 0 : (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : (_api$mention$sharedSt = _api$mention.sharedState) === null || _api$mention$sharedSt === void 0 ? void 0 : (_api$mention$sharedSt2 = _api$mention$sharedSt.currentState()) === null || _api$mention$sharedSt2 === void 0 ? void 0 : _api$mention$sharedSt2.mentionProvider;
|
|
132
|
+
if (!mentionProvider || !isResolvingMentionProvider(mentionProvider)) {
|
|
133
|
+
return text;
|
|
134
|
+
}
|
|
135
|
+
let resolvedText = text;
|
|
136
|
+
for (const id of mentionSet) {
|
|
137
|
+
const mention = await mentionProvider.resolveMentionName(id);
|
|
138
|
+
resolvedText = resolvedText.replace(`@${id}`, `@${mention.name}` || '@…');
|
|
139
|
+
}
|
|
140
|
+
return resolvedText;
|
|
141
|
+
};
|
|
142
|
+
|
|
69
143
|
/**
|
|
70
144
|
* copying ADF from the unsupported content extension as text to clipboard
|
|
71
145
|
*/
|
|
72
|
-
export const copyUnsupportedContentToClipboard = ({
|
|
146
|
+
export const copyUnsupportedContentToClipboard = async ({
|
|
147
|
+
locale,
|
|
73
148
|
schema,
|
|
74
|
-
unsupportedContent
|
|
149
|
+
unsupportedContent,
|
|
150
|
+
api
|
|
75
151
|
}) => {
|
|
76
152
|
try {
|
|
77
153
|
if (!unsupportedContent) {
|
|
78
|
-
|
|
154
|
+
throw new Error('No nested content found');
|
|
79
155
|
}
|
|
80
156
|
if (unsupportedContent.type !== 'doc') {
|
|
81
157
|
unsupportedContent = {
|
|
@@ -86,10 +162,18 @@ export const copyUnsupportedContentToClipboard = ({
|
|
|
86
162
|
}
|
|
87
163
|
const transformer = new JSONTransformer(schema);
|
|
88
164
|
const pmNode = transformer.parse(unsupportedContent);
|
|
89
|
-
|
|
165
|
+
let text = '';
|
|
166
|
+
const mentionSet = new Set();
|
|
167
|
+
pmNode.nodesBetween(0, pmNode.content.size, (node, _pos, parent) => {
|
|
168
|
+
text += convertNodeToText(node, mentionSet, parent, locale);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Trim leading/trailing whitespace from the collected text
|
|
172
|
+
text = text.trim();
|
|
173
|
+
text = await resolveMentionsInText(text, mentionSet, api);
|
|
90
174
|
copyToClipboard(text);
|
|
91
175
|
} catch (error) {
|
|
92
|
-
|
|
176
|
+
throw error instanceof Error ? error : new Error('Failed to copy content');
|
|
93
177
|
}
|
|
94
178
|
};
|
|
95
179
|
export const onCopyFailed = ({
|
|
@@ -262,10 +262,12 @@ var calculateToolbarPosition = function calculateToolbarPosition(editorView, nex
|
|
|
262
262
|
* if the current selected extension is an unsupported content extension.
|
|
263
263
|
*/
|
|
264
264
|
export var createOnClickCopyButton = function createOnClickCopyButton(_ref) {
|
|
265
|
-
var
|
|
265
|
+
var formatMessage = _ref.formatMessage,
|
|
266
|
+
extensionApi = _ref.extensionApi,
|
|
266
267
|
extensionProvider = _ref.extensionProvider,
|
|
267
268
|
getUnsupportedContent = _ref.getUnsupportedContent,
|
|
268
|
-
state = _ref.state
|
|
269
|
+
state = _ref.state,
|
|
270
|
+
locale = _ref.locale;
|
|
269
271
|
if (!extensionProvider) {
|
|
270
272
|
return;
|
|
271
273
|
}
|
|
@@ -292,18 +294,21 @@ export var createOnClickCopyButton = function createOnClickCopyButton(_ref) {
|
|
|
292
294
|
|
|
293
295
|
// this command copies the text content of the unsupported content extension to the clipboard
|
|
294
296
|
return function (editorState) {
|
|
295
|
-
|
|
297
|
+
copyUnsupportedContentToClipboard({
|
|
298
|
+
locale: locale,
|
|
296
299
|
unsupportedContent: adf,
|
|
297
|
-
schema: state.schema
|
|
298
|
-
|
|
299
|
-
|
|
300
|
+
schema: state.schema,
|
|
301
|
+
api: extensionApi
|
|
302
|
+
}).then(function () {
|
|
303
|
+
var _extensionApi$copyBut;
|
|
304
|
+
extensionApi === null || extensionApi === void 0 || (_extensionApi$copyBut = extensionApi.copyButton) === null || _extensionApi$copyBut === void 0 || _extensionApi$copyBut.actions.afterCopy(formatMessage(commonMessages.copiedToClipboard));
|
|
305
|
+
}).catch(function (error) {
|
|
300
306
|
onCopyFailed({
|
|
301
307
|
error: error,
|
|
302
308
|
extensionApi: extensionApi,
|
|
303
309
|
state: editorState
|
|
304
310
|
});
|
|
305
|
-
|
|
306
|
-
}
|
|
311
|
+
});
|
|
307
312
|
return true;
|
|
308
313
|
};
|
|
309
314
|
};
|
|
@@ -314,7 +319,8 @@ export var getToolbarConfig = function getToolbarConfig(_ref2) {
|
|
|
314
319
|
getUnsupportedContent = _ref2.getUnsupportedContent;
|
|
315
320
|
return function (state, intl) {
|
|
316
321
|
var _extensionApi$decorat, _extensionApi$context, _extensionApi$analyti, _extensionApi$connect;
|
|
317
|
-
var formatMessage = intl.formatMessage
|
|
322
|
+
var formatMessage = intl.formatMessage,
|
|
323
|
+
locale = intl.locale;
|
|
318
324
|
var extensionState = getPluginState(state);
|
|
319
325
|
var extensionProvider = extensionState.extensionProvider;
|
|
320
326
|
var hoverDecoration = extensionApi === null || extensionApi === void 0 || (_extensionApi$decorat = extensionApi.decorations) === null || _extensionApi$decorat === void 0 ? void 0 : _extensionApi$decorat.actions.hoverDecoration;
|
|
@@ -385,10 +391,12 @@ export var getToolbarConfig = function getToolbarConfig(_ref2) {
|
|
|
385
391
|
formatMessage: intl.formatMessage,
|
|
386
392
|
nodeType: nodeType,
|
|
387
393
|
onClick: expValEquals('platform_editor_ai_edit_unsupported_content', 'isEnabled', true) ? createOnClickCopyButton({
|
|
394
|
+
formatMessage: formatMessage,
|
|
388
395
|
extensionApi: extensionApi,
|
|
389
396
|
extensionProvider: extensionProvider,
|
|
390
397
|
getUnsupportedContent: getUnsupportedContent,
|
|
391
|
-
state: state
|
|
398
|
+
state: state,
|
|
399
|
+
locale: locale
|
|
392
400
|
}) : undefined
|
|
393
401
|
}]
|
|
394
402
|
}, shouldHideCopyButton && {
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
|
+
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; } } }; }
|
|
4
|
+
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; } }
|
|
5
|
+
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; }
|
|
1
6
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
7
|
import { copyToClipboard } from '@atlaskit/editor-common/clipboard';
|
|
3
8
|
import { closestElement, findNodePosByLocalIds } from '@atlaskit/editor-common/utils';
|
|
4
9
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
5
10
|
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
+
import { isResolvingMentionProvider } from '@atlaskit/mention/resource';
|
|
6
12
|
export var getSelectedExtension = function getSelectedExtension(state) {
|
|
7
13
|
var searchParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
8
14
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -69,35 +75,189 @@ export var findNodePosWithLocalId = function findNodePosWithLocalId(state, local
|
|
|
69
75
|
return nodes.length >= 1 ? nodes[0] : undefined;
|
|
70
76
|
};
|
|
71
77
|
/**
|
|
72
|
-
*
|
|
78
|
+
* Converts a ProseMirror node to its text representation.
|
|
79
|
+
* Handles text nodes with marks (links) and inline nodes (status, mention, emoji).
|
|
80
|
+
* Returns the content for this node, with a trailing separator for text blocks.
|
|
73
81
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
|
|
82
|
+
var convertNodeToText = function convertNodeToText(node, mentionSet, parent, locale) {
|
|
83
|
+
if (node.isInline) {
|
|
84
|
+
var schema = node.type.schema;
|
|
85
|
+
var finalText = '';
|
|
86
|
+
if (node.isText) {
|
|
87
|
+
finalText = node.text || '';
|
|
88
|
+
if (node.marks.length > 0) {
|
|
89
|
+
var _iterator = _createForOfIteratorHelper(node.marks),
|
|
90
|
+
_step;
|
|
91
|
+
try {
|
|
92
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
93
|
+
var mark = _step.value;
|
|
94
|
+
// if it's link, include the href in the text
|
|
95
|
+
if (mark.type === schema.marks.link) {
|
|
96
|
+
var href = mark.attrs.href;
|
|
97
|
+
var text = node.text || '';
|
|
98
|
+
// If the text differs from the href, include both
|
|
99
|
+
if (text && text !== href) {
|
|
100
|
+
finalText = "".concat(text, " ").concat(href);
|
|
101
|
+
} else {
|
|
102
|
+
finalText = href;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
_iterator.e(err);
|
|
108
|
+
} finally {
|
|
109
|
+
_iterator.f();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
switch (node.type) {
|
|
114
|
+
case schema.nodes.status:
|
|
115
|
+
finalText = node.attrs.text || '';
|
|
116
|
+
break;
|
|
117
|
+
case schema.nodes.mention:
|
|
118
|
+
mentionSet.add(node.attrs.id);
|
|
119
|
+
finalText = "@".concat(node.attrs.id);
|
|
120
|
+
break;
|
|
121
|
+
case schema.nodes.emoji:
|
|
122
|
+
finalText = node.attrs.shortName || '';
|
|
123
|
+
break;
|
|
124
|
+
case schema.nodes.date:
|
|
125
|
+
var timestamp = new Date(Number(node.attrs.timestamp));
|
|
126
|
+
finalText = !isNaN(timestamp.getTime()) ? timestamp.toLocaleDateString(locale !== null && locale !== void 0 ? locale : 'en-US') : String(node.attrs.timestamp);
|
|
127
|
+
break;
|
|
128
|
+
default:
|
|
129
|
+
finalText = node.textContent;
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
80
132
|
}
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
version: 1,
|
|
84
|
-
type: 'doc',
|
|
85
|
-
content: [unsupportedContent]
|
|
86
|
-
};
|
|
133
|
+
if (parent && parent.isTextblock && node === parent.lastChild && parent.childCount > 0) {
|
|
134
|
+
finalText += '\n\n';
|
|
87
135
|
}
|
|
88
|
-
|
|
89
|
-
var pmNode = transformer.parse(unsupportedContent);
|
|
90
|
-
var text = pmNode.textBetween(0, pmNode.content.size, '\n\n');
|
|
91
|
-
copyToClipboard(text);
|
|
92
|
-
} catch (error) {
|
|
93
|
-
return error instanceof Error ? error : new Error('Failed to copy content');
|
|
136
|
+
return finalText;
|
|
94
137
|
}
|
|
138
|
+
return '';
|
|
95
139
|
};
|
|
96
|
-
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Resolves mention IDs to their display names and replaces them in the text.
|
|
143
|
+
* Returns the text with resolved mentions, or the original text if the provider is unavailable.
|
|
144
|
+
*/
|
|
145
|
+
var resolveMentionsInText = /*#__PURE__*/function () {
|
|
146
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(text, mentionSet, api) {
|
|
147
|
+
var _api$mention;
|
|
148
|
+
var mentionProvider, resolvedText, _iterator2, _step2, id, mention;
|
|
149
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
150
|
+
while (1) switch (_context.prev = _context.next) {
|
|
151
|
+
case 0:
|
|
152
|
+
mentionProvider = api === null || api === void 0 || (_api$mention = api.mention) === null || _api$mention === void 0 || (_api$mention = _api$mention.sharedState) === null || _api$mention === void 0 || (_api$mention = _api$mention.currentState()) === null || _api$mention === void 0 ? void 0 : _api$mention.mentionProvider;
|
|
153
|
+
if (!(!mentionProvider || !isResolvingMentionProvider(mentionProvider))) {
|
|
154
|
+
_context.next = 3;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
return _context.abrupt("return", text);
|
|
158
|
+
case 3:
|
|
159
|
+
resolvedText = text;
|
|
160
|
+
_iterator2 = _createForOfIteratorHelper(mentionSet);
|
|
161
|
+
_context.prev = 5;
|
|
162
|
+
_iterator2.s();
|
|
163
|
+
case 7:
|
|
164
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
165
|
+
_context.next = 15;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
id = _step2.value;
|
|
169
|
+
_context.next = 11;
|
|
170
|
+
return mentionProvider.resolveMentionName(id);
|
|
171
|
+
case 11:
|
|
172
|
+
mention = _context.sent;
|
|
173
|
+
resolvedText = resolvedText.replace("@".concat(id), "@".concat(mention.name) || '@…');
|
|
174
|
+
case 13:
|
|
175
|
+
_context.next = 7;
|
|
176
|
+
break;
|
|
177
|
+
case 15:
|
|
178
|
+
_context.next = 20;
|
|
179
|
+
break;
|
|
180
|
+
case 17:
|
|
181
|
+
_context.prev = 17;
|
|
182
|
+
_context.t0 = _context["catch"](5);
|
|
183
|
+
_iterator2.e(_context.t0);
|
|
184
|
+
case 20:
|
|
185
|
+
_context.prev = 20;
|
|
186
|
+
_iterator2.f();
|
|
187
|
+
return _context.finish(20);
|
|
188
|
+
case 23:
|
|
189
|
+
return _context.abrupt("return", resolvedText);
|
|
190
|
+
case 24:
|
|
191
|
+
case "end":
|
|
192
|
+
return _context.stop();
|
|
193
|
+
}
|
|
194
|
+
}, _callee, null, [[5, 17, 20, 23]]);
|
|
195
|
+
}));
|
|
196
|
+
return function resolveMentionsInText(_x, _x2, _x3) {
|
|
197
|
+
return _ref2.apply(this, arguments);
|
|
198
|
+
};
|
|
199
|
+
}();
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* copying ADF from the unsupported content extension as text to clipboard
|
|
203
|
+
*/
|
|
204
|
+
export var copyUnsupportedContentToClipboard = /*#__PURE__*/function () {
|
|
205
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
206
|
+
var locale, schema, unsupportedContent, api, transformer, pmNode, text, mentionSet;
|
|
207
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
208
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
209
|
+
case 0:
|
|
210
|
+
locale = _ref3.locale, schema = _ref3.schema, unsupportedContent = _ref3.unsupportedContent, api = _ref3.api;
|
|
211
|
+
_context2.prev = 1;
|
|
212
|
+
if (unsupportedContent) {
|
|
213
|
+
_context2.next = 4;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
throw new Error('No nested content found');
|
|
217
|
+
case 4:
|
|
218
|
+
if (unsupportedContent.type !== 'doc') {
|
|
219
|
+
unsupportedContent = {
|
|
220
|
+
version: 1,
|
|
221
|
+
type: 'doc',
|
|
222
|
+
content: [unsupportedContent]
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
transformer = new JSONTransformer(schema);
|
|
226
|
+
pmNode = transformer.parse(unsupportedContent);
|
|
227
|
+
text = '';
|
|
228
|
+
mentionSet = new Set();
|
|
229
|
+
pmNode.nodesBetween(0, pmNode.content.size, function (node, _pos, parent) {
|
|
230
|
+
text += convertNodeToText(node, mentionSet, parent, locale);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// Trim leading/trailing whitespace from the collected text
|
|
234
|
+
text = text.trim();
|
|
235
|
+
_context2.next = 13;
|
|
236
|
+
return resolveMentionsInText(text, mentionSet, api);
|
|
237
|
+
case 13:
|
|
238
|
+
text = _context2.sent;
|
|
239
|
+
copyToClipboard(text);
|
|
240
|
+
_context2.next = 20;
|
|
241
|
+
break;
|
|
242
|
+
case 17:
|
|
243
|
+
_context2.prev = 17;
|
|
244
|
+
_context2.t0 = _context2["catch"](1);
|
|
245
|
+
throw _context2.t0 instanceof Error ? _context2.t0 : new Error('Failed to copy content');
|
|
246
|
+
case 20:
|
|
247
|
+
case "end":
|
|
248
|
+
return _context2.stop();
|
|
249
|
+
}
|
|
250
|
+
}, _callee2, null, [[1, 17]]);
|
|
251
|
+
}));
|
|
252
|
+
return function copyUnsupportedContentToClipboard(_x4) {
|
|
253
|
+
return _ref4.apply(this, arguments);
|
|
254
|
+
};
|
|
255
|
+
}();
|
|
256
|
+
export var onCopyFailed = function onCopyFailed(_ref5) {
|
|
97
257
|
var _extensionApi$analyti;
|
|
98
|
-
var error =
|
|
99
|
-
extensionApi =
|
|
100
|
-
state =
|
|
258
|
+
var error = _ref5.error,
|
|
259
|
+
extensionApi = _ref5.extensionApi,
|
|
260
|
+
state = _ref5.state;
|
|
101
261
|
var nodeWithPos = getSelectedExtension(state, true);
|
|
102
262
|
if (!nodeWithPos) {
|
|
103
263
|
return;
|
|
@@ -9,8 +9,10 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
|
9
9
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
10
10
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
11
11
|
import type { ApplyChangeHandler, ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
12
|
+
import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
|
|
12
13
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
13
14
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
15
|
+
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
14
16
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
15
17
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
16
18
|
import type { Fragment, Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -81,7 +83,9 @@ export type ExtensionPluginDependencies = [
|
|
|
81
83
|
OptionalPlugin<ContextPanelPlugin>,
|
|
82
84
|
OptionalPlugin<ContextIdentifierPlugin>,
|
|
83
85
|
OptionalPlugin<ConnectivityPlugin>,
|
|
84
|
-
OptionalPlugin<ToolbarPlugin
|
|
86
|
+
OptionalPlugin<ToolbarPlugin>,
|
|
87
|
+
OptionalPlugin<MentionsPlugin>,
|
|
88
|
+
OptionalPlugin<CopyButtonPlugin>
|
|
85
89
|
];
|
|
86
90
|
export type ExtensionPluginActions = {
|
|
87
91
|
api: () => ExtensionAPI;
|
|
@@ -1,24 +1,36 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import { type ExtensionProvider } from '@atlaskit/editor-common/extensions';
|
|
2
3
|
import type { Command, FloatingToolbarHandler, PublicPluginAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
5
6
|
import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
7
|
+
import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
|
|
6
8
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
9
|
+
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
7
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
11
|
import type { ExtensionPluginOptions } from '../extensionPluginType';
|
|
9
12
|
/**
|
|
10
13
|
* Creates a function that copies the text content of the unsupported content extension to the clipboard
|
|
11
14
|
* if the current selected extension is an unsupported content extension.
|
|
12
15
|
*/
|
|
13
|
-
export declare const createOnClickCopyButton: ({ extensionApi, extensionProvider, getUnsupportedContent, state, }: {
|
|
16
|
+
export declare const createOnClickCopyButton: ({ formatMessage, extensionApi, extensionProvider, getUnsupportedContent, state, locale, }: {
|
|
14
17
|
extensionApi: GetToolbarConfigProps["extensionApi"];
|
|
15
18
|
extensionProvider?: ExtensionProvider;
|
|
19
|
+
formatMessage: IntlShape["formatMessage"];
|
|
16
20
|
getUnsupportedContent?: ExtensionPluginOptions["getUnsupportedContent"];
|
|
21
|
+
locale: string;
|
|
17
22
|
state: EditorState;
|
|
18
23
|
}) => Command | undefined;
|
|
19
24
|
interface GetToolbarConfigProps {
|
|
20
25
|
breakoutEnabled: boolean | undefined;
|
|
21
|
-
extensionApi?: PublicPluginAPI<[
|
|
26
|
+
extensionApi?: PublicPluginAPI<[
|
|
27
|
+
ContextPanelPlugin,
|
|
28
|
+
AnalyticsPlugin,
|
|
29
|
+
DecorationsPlugin,
|
|
30
|
+
ConnectivityPlugin,
|
|
31
|
+
MentionsPlugin,
|
|
32
|
+
CopyButtonPlugin
|
|
33
|
+
]> | undefined;
|
|
22
34
|
getUnsupportedContent?: ExtensionPluginOptions['getUnsupportedContent'];
|
|
23
35
|
}
|
|
24
36
|
export declare const getToolbarConfig: ({ breakoutEnabled, extensionApi, getUnsupportedContent, }: GetToolbarConfigProps) => FloatingToolbarHandler;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PublicPluginAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
4
5
|
import type { Mark, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import type { DomAtPos, NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -19,10 +20,12 @@ export interface Position {
|
|
|
19
20
|
/**
|
|
20
21
|
* copying ADF from the unsupported content extension as text to clipboard
|
|
21
22
|
*/
|
|
22
|
-
export declare const copyUnsupportedContentToClipboard: ({ schema, unsupportedContent, }: {
|
|
23
|
+
export declare const copyUnsupportedContentToClipboard: ({ locale, schema, unsupportedContent, api, }: {
|
|
24
|
+
api?: PublicPluginAPI<[MentionsPlugin]>;
|
|
25
|
+
locale?: string;
|
|
23
26
|
schema: Schema;
|
|
24
27
|
unsupportedContent?: JSONDocNode;
|
|
25
|
-
}) =>
|
|
28
|
+
}) => Promise<void>;
|
|
26
29
|
export declare const onCopyFailed: ({ error, extensionApi, state, }: {
|
|
27
30
|
error: Error;
|
|
28
31
|
extensionApi?: PublicPluginAPI<[AnalyticsPlugin]>;
|
|
@@ -9,8 +9,10 @@ import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
|
9
9
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
10
10
|
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
11
11
|
import type { ApplyChangeHandler, ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
12
|
+
import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
|
|
12
13
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
13
14
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
15
|
+
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
14
16
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
15
17
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
16
18
|
import type { Fragment, Node as PmNode } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -81,7 +83,9 @@ export type ExtensionPluginDependencies = [
|
|
|
81
83
|
OptionalPlugin<ContextPanelPlugin>,
|
|
82
84
|
OptionalPlugin<ContextIdentifierPlugin>,
|
|
83
85
|
OptionalPlugin<ConnectivityPlugin>,
|
|
84
|
-
OptionalPlugin<ToolbarPlugin
|
|
86
|
+
OptionalPlugin<ToolbarPlugin>,
|
|
87
|
+
OptionalPlugin<MentionsPlugin>,
|
|
88
|
+
OptionalPlugin<CopyButtonPlugin>
|
|
85
89
|
];
|
|
86
90
|
export type ExtensionPluginActions = {
|
|
87
91
|
api: () => ExtensionAPI;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import { type ExtensionProvider } from '@atlaskit/editor-common/extensions';
|
|
2
3
|
import type { Command, FloatingToolbarHandler, PublicPluginAPI } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
5
6
|
import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
7
|
+
import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
|
|
6
8
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
9
|
+
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
7
10
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
11
|
import type { ExtensionPluginOptions } from '../extensionPluginType';
|
|
9
12
|
/**
|
|
10
13
|
* Creates a function that copies the text content of the unsupported content extension to the clipboard
|
|
11
14
|
* if the current selected extension is an unsupported content extension.
|
|
12
15
|
*/
|
|
13
|
-
export declare const createOnClickCopyButton: ({ extensionApi, extensionProvider, getUnsupportedContent, state, }: {
|
|
16
|
+
export declare const createOnClickCopyButton: ({ formatMessage, extensionApi, extensionProvider, getUnsupportedContent, state, locale, }: {
|
|
14
17
|
extensionApi: GetToolbarConfigProps["extensionApi"];
|
|
15
18
|
extensionProvider?: ExtensionProvider;
|
|
19
|
+
formatMessage: IntlShape["formatMessage"];
|
|
16
20
|
getUnsupportedContent?: ExtensionPluginOptions["getUnsupportedContent"];
|
|
21
|
+
locale: string;
|
|
17
22
|
state: EditorState;
|
|
18
23
|
}) => Command | undefined;
|
|
19
24
|
interface GetToolbarConfigProps {
|
|
@@ -22,7 +27,9 @@ interface GetToolbarConfigProps {
|
|
|
22
27
|
ContextPanelPlugin,
|
|
23
28
|
AnalyticsPlugin,
|
|
24
29
|
DecorationsPlugin,
|
|
25
|
-
ConnectivityPlugin
|
|
30
|
+
ConnectivityPlugin,
|
|
31
|
+
MentionsPlugin,
|
|
32
|
+
CopyButtonPlugin
|
|
26
33
|
]> | undefined;
|
|
27
34
|
getUnsupportedContent?: ExtensionPluginOptions['getUnsupportedContent'];
|
|
28
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PublicPluginAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
+
import type { MentionsPlugin } from '@atlaskit/editor-plugin-mentions';
|
|
4
5
|
import type { Mark, Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
import type { DomAtPos, NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -19,10 +20,14 @@ export interface Position {
|
|
|
19
20
|
/**
|
|
20
21
|
* copying ADF from the unsupported content extension as text to clipboard
|
|
21
22
|
*/
|
|
22
|
-
export declare const copyUnsupportedContentToClipboard: ({ schema, unsupportedContent, }: {
|
|
23
|
+
export declare const copyUnsupportedContentToClipboard: ({ locale, schema, unsupportedContent, api, }: {
|
|
24
|
+
api?: PublicPluginAPI<[
|
|
25
|
+
MentionsPlugin
|
|
26
|
+
]>;
|
|
27
|
+
locale?: string;
|
|
23
28
|
schema: Schema;
|
|
24
29
|
unsupportedContent?: JSONDocNode;
|
|
25
|
-
}) =>
|
|
30
|
+
}) => Promise<void>;
|
|
26
31
|
export declare const onCopyFailed: ({ error, extensionApi, state, }: {
|
|
27
32
|
error: Error;
|
|
28
33
|
extensionApi?: PublicPluginAPI<[
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-extension",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.6",
|
|
4
4
|
"description": "editor-plugin-extension plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@atlaskit/heading": "^5.3.0",
|
|
46
46
|
"@atlaskit/icon": "^31.0.0",
|
|
47
47
|
"@atlaskit/link": "^3.3.0",
|
|
48
|
+
"@atlaskit/mention": "^24.4.0",
|
|
48
49
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
49
50
|
"@atlaskit/primitives": "^18.0.0",
|
|
50
51
|
"@atlaskit/radio": "^8.4.0",
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
"@atlaskit/textarea": "^8.2.0",
|
|
57
58
|
"@atlaskit/textfield": "^8.2.0",
|
|
58
59
|
"@atlaskit/theme": "^21.0.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^29.
|
|
60
|
+
"@atlaskit/tmp-editor-statsig": "^29.1.0",
|
|
60
61
|
"@atlaskit/toggle": "^15.2.0",
|
|
61
62
|
"@atlaskit/tokens": "^11.0.0",
|
|
62
63
|
"@atlaskit/tooltip": "^20.14.0",
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
"uuid": "^3.1.0"
|
|
71
72
|
},
|
|
72
73
|
"peerDependencies": {
|
|
73
|
-
"@atlaskit/editor-common": "^111.
|
|
74
|
+
"@atlaskit/editor-common": "^111.17.0",
|
|
74
75
|
"react": "^18.2.0",
|
|
75
76
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
76
77
|
},
|