@atlaskit/editor-plugin-clipboard 1.3.14 → 1.3.16
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 +18 -0
- package/dist/cjs/pm-plugins/main.js +23 -4
- package/dist/es2019/pm-plugins/main.js +22 -4
- package/dist/esm/pm-plugins/main.js +23 -4
- package/package.json +8 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-clipboard
|
|
2
2
|
|
|
3
|
+
## 1.3.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#102971](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102971)
|
|
8
|
+
[`a87c6952a44b1`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a87c6952a44b1) -
|
|
9
|
+
ED-25451 Support copy of media caption and fix range error when pasting a caption into another
|
|
10
|
+
caption
|
|
11
|
+
- [#102971](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/102971)
|
|
12
|
+
[`d5851f824b396`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d5851f824b396) -
|
|
13
|
+
ED-25451 support copy of media caption in editor
|
|
14
|
+
|
|
15
|
+
## 1.3.15
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 1.3.14
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.setLastEventType = exports.sendClipboardAnalytics = exports.createPlugin = exports.createClipboardSerializer = exports.ClipboardEventType = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
8
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
11
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
13
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
13
14
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
var _pluginKey = require("./plugin-key");
|
|
15
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -108,16 +110,33 @@ var createClipboardSerializer = exports.createClipboardSerializer = function cre
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
// Remove annotations from media nodes when copying to clipboard, only do this for copy operations
|
|
113
|
+
// and keep existing content nodes from the parent.
|
|
114
|
+
|
|
111
115
|
if (lastEventType === ClipboardEventType.COPY && ((_content$firstChild2 = content.firstChild) === null || _content$firstChild2 === void 0 ? void 0 : _content$firstChild2.type.name) === 'media') {
|
|
112
116
|
var _mediaNode$marks;
|
|
113
117
|
var mediaNode = content.firstChild;
|
|
114
118
|
var strippedMediaNode = schema.nodes.media.createChecked(mediaNode.attrs, mediaNode.content, (_mediaNode$marks = mediaNode.marks) === null || _mediaNode$marks === void 0 ? void 0 : _mediaNode$marks.filter(function (mark) {
|
|
115
119
|
return mark.type.name !== 'annotation';
|
|
116
120
|
}));
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_captions_on_copy')) {
|
|
122
|
+
// Content for media parents can include multiple content nodes (media and captions). We now take that
|
|
123
|
+
// into consideration when we are stripping annotations
|
|
124
|
+
var contentArray = [strippedMediaNode];
|
|
125
|
+
content.forEach(function (node) {
|
|
126
|
+
if (node.type.name !== 'media') {
|
|
127
|
+
contentArray = [].concat((0, _toConsumableArray2.default)(contentArray), [node]);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
var _newContent = _model.Fragment.fromArray(contentArray);
|
|
131
|
+
// Currently incorrectly typed, see comment above
|
|
132
|
+
//@ts-ignore
|
|
133
|
+
return originalSerializeFragment(_newContent, options, target);
|
|
134
|
+
} else {
|
|
135
|
+
var _newContent2 = _model.Fragment.from(strippedMediaNode);
|
|
136
|
+
// Currently incorrectly typed, see comment above
|
|
137
|
+
//@ts-ignore
|
|
138
|
+
return originalSerializeFragment(_newContent2, options, target);
|
|
139
|
+
}
|
|
121
140
|
}
|
|
122
141
|
|
|
123
142
|
// If we're not copying any rows or media nodes, just run default serializeFragment function.
|
|
@@ -3,6 +3,7 @@ import { getAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { DOMSerializer, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { clipboardPluginKey } from './plugin-key';
|
|
7
8
|
export let ClipboardEventType = /*#__PURE__*/function (ClipboardEventType) {
|
|
8
9
|
ClipboardEventType["CUT"] = "CUT";
|
|
@@ -99,14 +100,31 @@ export const createClipboardSerializer = (schema, getEditorView) => {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
// Remove annotations from media nodes when copying to clipboard, only do this for copy operations
|
|
103
|
+
// and keep existing content nodes from the parent.
|
|
104
|
+
|
|
102
105
|
if (lastEventType === ClipboardEventType.COPY && ((_content$firstChild2 = content.firstChild) === null || _content$firstChild2 === void 0 ? void 0 : _content$firstChild2.type.name) === 'media') {
|
|
103
106
|
var _mediaNode$marks;
|
|
104
107
|
const mediaNode = content.firstChild;
|
|
105
108
|
const strippedMediaNode = schema.nodes.media.createChecked(mediaNode.attrs, mediaNode.content, (_mediaNode$marks = mediaNode.marks) === null || _mediaNode$marks === void 0 ? void 0 : _mediaNode$marks.filter(mark => mark.type.name !== 'annotation'));
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
if (fg('platform_editor_fix_captions_on_copy')) {
|
|
110
|
+
// Content for media parents can include multiple content nodes (media and captions). We now take that
|
|
111
|
+
// into consideration when we are stripping annotations
|
|
112
|
+
let contentArray = [strippedMediaNode];
|
|
113
|
+
content.forEach(node => {
|
|
114
|
+
if (node.type.name !== 'media') {
|
|
115
|
+
contentArray = [...contentArray, node];
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const newContent = Fragment.fromArray(contentArray);
|
|
119
|
+
// Currently incorrectly typed, see comment above
|
|
120
|
+
//@ts-ignore
|
|
121
|
+
return originalSerializeFragment(newContent, options, target);
|
|
122
|
+
} else {
|
|
123
|
+
const newContent = Fragment.from(strippedMediaNode);
|
|
124
|
+
// Currently incorrectly typed, see comment above
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
return originalSerializeFragment(newContent, options, target);
|
|
127
|
+
}
|
|
110
128
|
}
|
|
111
129
|
|
|
112
130
|
// If we're not copying any rows or media nodes, just run default serializeFragment function.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -6,6 +7,7 @@ import { getAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
|
6
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
8
|
import { DOMSerializer, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
8
9
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
10
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
11
|
import { clipboardPluginKey } from './plugin-key';
|
|
10
12
|
export var ClipboardEventType = /*#__PURE__*/function (ClipboardEventType) {
|
|
11
13
|
ClipboardEventType["CUT"] = "CUT";
|
|
@@ -101,16 +103,33 @@ export var createClipboardSerializer = function createClipboardSerializer(schema
|
|
|
101
103
|
}
|
|
102
104
|
|
|
103
105
|
// Remove annotations from media nodes when copying to clipboard, only do this for copy operations
|
|
106
|
+
// and keep existing content nodes from the parent.
|
|
107
|
+
|
|
104
108
|
if (lastEventType === ClipboardEventType.COPY && ((_content$firstChild2 = content.firstChild) === null || _content$firstChild2 === void 0 ? void 0 : _content$firstChild2.type.name) === 'media') {
|
|
105
109
|
var _mediaNode$marks;
|
|
106
110
|
var mediaNode = content.firstChild;
|
|
107
111
|
var strippedMediaNode = schema.nodes.media.createChecked(mediaNode.attrs, mediaNode.content, (_mediaNode$marks = mediaNode.marks) === null || _mediaNode$marks === void 0 ? void 0 : _mediaNode$marks.filter(function (mark) {
|
|
108
112
|
return mark.type.name !== 'annotation';
|
|
109
113
|
}));
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
if (fg('platform_editor_fix_captions_on_copy')) {
|
|
115
|
+
// Content for media parents can include multiple content nodes (media and captions). We now take that
|
|
116
|
+
// into consideration when we are stripping annotations
|
|
117
|
+
var contentArray = [strippedMediaNode];
|
|
118
|
+
content.forEach(function (node) {
|
|
119
|
+
if (node.type.name !== 'media') {
|
|
120
|
+
contentArray = [].concat(_toConsumableArray(contentArray), [node]);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
var _newContent = Fragment.fromArray(contentArray);
|
|
124
|
+
// Currently incorrectly typed, see comment above
|
|
125
|
+
//@ts-ignore
|
|
126
|
+
return originalSerializeFragment(_newContent, options, target);
|
|
127
|
+
} else {
|
|
128
|
+
var _newContent2 = Fragment.from(strippedMediaNode);
|
|
129
|
+
// Currently incorrectly typed, see comment above
|
|
130
|
+
//@ts-ignore
|
|
131
|
+
return originalSerializeFragment(_newContent2, options, target);
|
|
132
|
+
}
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
// If we're not copying any rows or media nodes, just run default serializeFragment function.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-clipboard",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.16",
|
|
4
4
|
"description": "Clipboard plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,8 +31,9 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
34
|
+
"@atlaskit/editor-common": "^99.3.0",
|
|
35
35
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
36
|
+
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
36
37
|
"@babel/runtime": "^7.0.0"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
@@ -82,5 +83,10 @@
|
|
|
82
83
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
83
84
|
]
|
|
84
85
|
}
|
|
86
|
+
},
|
|
87
|
+
"platform-feature-flags": {
|
|
88
|
+
"platform_editor_fix_captions_on_copy": {
|
|
89
|
+
"type": "boolean"
|
|
90
|
+
}
|
|
85
91
|
}
|
|
86
92
|
}
|