@atlaskit/editor-core 187.43.12 → 187.43.17
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 +13 -0
- package/dist/cjs/labs/next/presets/default.js +2 -1
- package/dist/cjs/labs/next/presets/universal.js +1 -1
- package/dist/cjs/plugins/clipboard/pm-plugins/main.js +13 -54
- package/dist/cjs/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
- package/dist/cjs/plugins/floating-toolbar/index.js +1 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/selection/utils.js +29 -80
- package/dist/cjs/plugins/type-ahead/index.js +2 -2
- package/dist/cjs/plugins/type-ahead/pm-plugins/main.js +4 -4
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadListItem.js +2 -2
- package/dist/cjs/utils/clipboard.js +19 -127
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/labs/next/presets/default.js +2 -1
- package/dist/es2019/labs/next/presets/universal.js +2 -2
- package/dist/es2019/plugins/clipboard/pm-plugins/main.js +3 -53
- package/dist/es2019/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
- package/dist/es2019/plugins/floating-toolbar/index.js +1 -2
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/selection/utils.js +3 -74
- package/dist/es2019/plugins/type-ahead/index.js +1 -1
- package/dist/es2019/plugins/type-ahead/pm-plugins/main.js +1 -1
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadListItem.js +1 -1
- package/dist/es2019/utils/clipboard.js +1 -53
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/labs/next/presets/default.js +2 -1
- package/dist/esm/labs/next/presets/universal.js +2 -2
- package/dist/esm/plugins/clipboard/pm-plugins/main.js +3 -49
- package/dist/esm/plugins/code-block/pm-plugins/codeBlockCopySelectionPlugin.js +1 -1
- package/dist/esm/plugins/floating-toolbar/index.js +1 -2
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/selection/utils.js +3 -72
- package/dist/esm/plugins/type-ahead/index.js +1 -1
- package/dist/esm/plugins/type-ahead/pm-plugins/main.js +1 -1
- package/dist/esm/plugins/type-ahead/ui/TypeAheadListItem.js +1 -1
- package/dist/esm/utils/clipboard.js +1 -119
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/labs/next/presets/default.d.ts +68 -4
- package/dist/types/plugins/clipboard/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/selection/utils.d.ts +2 -5
- package/dist/types/plugins/type-ahead/api.d.ts +1 -1
- package/dist/types/plugins/type-ahead/commands/update-list-items.d.ts +1 -1
- package/dist/types/plugins/type-ahead/commands/update-query.d.ts +1 -1
- package/dist/types/plugins/type-ahead/commands/update-selected-index.d.ts +1 -1
- package/dist/types/plugins/type-ahead/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/type-ahead/types.d.ts +1 -1
- package/dist/types/utils/clipboard.d.ts +1 -3
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +86 -0
- package/dist/types-ts4.5/plugins/clipboard/pm-plugins/main.d.ts +2 -3
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/selection/utils.d.ts +2 -5
- package/dist/types-ts4.5/plugins/type-ahead/api.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-list-items.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-query.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/commands/update-selected-index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/type-ahead/types.d.ts +1 -1
- package/dist/types-ts4.5/utils/clipboard.d.ts +1 -3
- package/package.json +12 -8
- package/report.api.md +1 -1
- package/tmp/api-report-tmp.d.ts +1 -1
- package/dist/cjs/plugins/copy-button/commands.js +0 -171
- package/dist/cjs/plugins/copy-button/index.js +0 -23
- package/dist/cjs/plugins/copy-button/pm-plugins/main.js +0 -104
- package/dist/cjs/plugins/copy-button/pm-plugins/plugin-key.js +0 -9
- package/dist/cjs/plugins/copy-button/toolbar.js +0 -99
- package/dist/cjs/plugins/copy-button/utils.js +0 -22
- package/dist/es2019/plugins/copy-button/commands.js +0 -157
- package/dist/es2019/plugins/copy-button/index.js +0 -11
- package/dist/es2019/plugins/copy-button/pm-plugins/main.js +0 -97
- package/dist/es2019/plugins/copy-button/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/copy-button/toolbar.js +0 -82
- package/dist/es2019/plugins/copy-button/utils.js +0 -15
- package/dist/esm/plugins/copy-button/commands.js +0 -159
- package/dist/esm/plugins/copy-button/index.js +0 -15
- package/dist/esm/plugins/copy-button/pm-plugins/main.js +0 -96
- package/dist/esm/plugins/copy-button/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/copy-button/toolbar.js +0 -89
- package/dist/esm/plugins/copy-button/utils.js +0 -14
- package/dist/types/plugins/copy-button/commands.d.ts +0 -9
- package/dist/types/plugins/copy-button/index.d.ts +0 -3
- package/dist/types/plugins/copy-button/pm-plugins/main.d.ts +0 -4
- package/dist/types/plugins/copy-button/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types/plugins/copy-button/toolbar.d.ts +0 -13
- package/dist/types/plugins/copy-button/utils.d.ts +0 -8
- package/dist/types-ts4.5/plugins/copy-button/commands.d.ts +0 -9
- package/dist/types-ts4.5/plugins/copy-button/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/copy-button/pm-plugins/main.d.ts +0 -4
- package/dist/types-ts4.5/plugins/copy-button/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +0 -13
- package/dist/types-ts4.5/plugins/copy-button/utils.d.ts +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "187.43.
|
|
3
|
+
"version": "187.43.17",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/code": "^14.6.0",
|
|
56
56
|
"@atlaskit/date": "^0.10.0",
|
|
57
57
|
"@atlaskit/datetime-picker": "^12.10.0",
|
|
58
|
-
"@atlaskit/editor-common": "^75.
|
|
58
|
+
"@atlaskit/editor-common": "^75.2.0",
|
|
59
59
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
60
60
|
"@atlaskit/editor-markdown-transformer": "^5.2.5",
|
|
61
61
|
"@atlaskit/editor-palette": "1.5.1",
|
|
@@ -65,13 +65,13 @@
|
|
|
65
65
|
"@atlaskit/editor-plugin-composition": "^0.1.0",
|
|
66
66
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
67
67
|
"@atlaskit/editor-plugin-context-panel": "^0.2.0",
|
|
68
|
-
"@atlaskit/editor-plugin-copy-button": "^0.
|
|
68
|
+
"@atlaskit/editor-plugin-copy-button": "^0.2.0",
|
|
69
69
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
70
70
|
"@atlaskit/editor-plugin-editor-disabled": "^0.2.0",
|
|
71
71
|
"@atlaskit/editor-plugin-emoji": "^0.3.0",
|
|
72
72
|
"@atlaskit/editor-plugin-extension": "^0.2.0",
|
|
73
73
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
74
|
-
"@atlaskit/editor-plugin-floating-toolbar": "^0.
|
|
74
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^0.5.0",
|
|
75
75
|
"@atlaskit/editor-plugin-focus": "^0.2.0",
|
|
76
76
|
"@atlaskit/editor-plugin-grid": "^0.2.0",
|
|
77
77
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"@atlaskit/radio": "^5.6.0",
|
|
112
112
|
"@atlaskit/section-message": "^6.4.0",
|
|
113
113
|
"@atlaskit/select": "^16.7.0",
|
|
114
|
-
"@atlaskit/smart-card": "^26.
|
|
114
|
+
"@atlaskit/smart-card": "^26.27.0",
|
|
115
115
|
"@atlaskit/smart-user-picker": "^6.3.0",
|
|
116
116
|
"@atlaskit/spinner": "^15.5.0",
|
|
117
117
|
"@atlaskit/status": "^1.3.0",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
"@atlaskit/textfield": "^5.6.0",
|
|
122
122
|
"@atlaskit/theme": "^12.6.0",
|
|
123
123
|
"@atlaskit/toggle": "^12.6.0",
|
|
124
|
-
"@atlaskit/tokens": "^1.
|
|
124
|
+
"@atlaskit/tokens": "^1.24.0",
|
|
125
125
|
"@atlaskit/tooltip": "^17.8.0",
|
|
126
126
|
"@atlaskit/width-detector": "^4.1.0",
|
|
127
127
|
"@babel/runtime": "^7.0.0",
|
|
@@ -129,7 +129,6 @@
|
|
|
129
129
|
"@types/react-loadable": "^5.4.1",
|
|
130
130
|
"@types/react-virtualized": "^9.18.12",
|
|
131
131
|
"classnames": "^2.2.5",
|
|
132
|
-
"clipboard-polyfill": "2.4.3",
|
|
133
132
|
"date-fns": "^2.17.0",
|
|
134
133
|
"is-number": "^7.0.0",
|
|
135
134
|
"lodash": "^4.17.21",
|
|
@@ -180,7 +179,7 @@
|
|
|
180
179
|
"@atlaskit/visual-regression": "*",
|
|
181
180
|
"@atlaskit/webdriver-runner": "*",
|
|
182
181
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
183
|
-
"@atlassian/editor-extension-link-create": "^0.
|
|
182
|
+
"@atlassian/editor-extension-link-create": "^0.3.0",
|
|
184
183
|
"@atlassian/feature-flags-test-utils": "^0.1.1",
|
|
185
184
|
"@atlassian/link-picker-plugins": "^23.0.0",
|
|
186
185
|
"@atlassian/search-provider": "2.4.7",
|
|
@@ -199,6 +198,7 @@
|
|
|
199
198
|
"@types/raf-schd": "^4.0.1",
|
|
200
199
|
"@types/rison": "^0.0.6",
|
|
201
200
|
"async-retry": "^1.2.3",
|
|
201
|
+
"clipboard-polyfill": "2.4.3",
|
|
202
202
|
"diff": "^4.0.1",
|
|
203
203
|
"enzyme": "^3.10.0",
|
|
204
204
|
"eslint-import-resolver-typescript": "^3.5.1",
|
|
@@ -263,6 +263,10 @@
|
|
|
263
263
|
"type": "boolean",
|
|
264
264
|
"referenceOnly": "true"
|
|
265
265
|
},
|
|
266
|
+
"platform.design-system-team.update-border-radio-checkbox_7askv": {
|
|
267
|
+
"type": "boolean",
|
|
268
|
+
"referenceOnly": "true"
|
|
269
|
+
},
|
|
266
270
|
"platform.editor.disable-chrome-88-selection-fix_uk53m": {
|
|
267
271
|
"type": "boolean"
|
|
268
272
|
},
|
package/report.api.md
CHANGED
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createToolbarCopyCommandForMark = createToolbarCopyCommandForMark;
|
|
7
|
-
exports.createToolbarCopyCommandForNode = void 0;
|
|
8
|
-
exports.getProvideMarkVisualFeedbackForCopyButtonCommand = getProvideMarkVisualFeedbackForCopyButtonCommand;
|
|
9
|
-
exports.removeMarkVisualFeedbackForCopyButtonCommand = removeMarkVisualFeedbackForCopyButtonCommand;
|
|
10
|
-
exports.resetCopiedState = void 0;
|
|
11
|
-
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
12
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
-
var _clipboard = require("../../utils/clipboard");
|
|
14
|
-
var _utils = require("./utils");
|
|
15
|
-
var _analytics = require("../analytics");
|
|
16
|
-
var _main = require("../clipboard/pm-plugins/main");
|
|
17
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
18
|
-
function createToolbarCopyCommandForMark(markType) {
|
|
19
|
-
function command(state, dispatch) {
|
|
20
|
-
var textNode = state.tr.selection.$head.parent.maybeChild(state.tr.selection.$head.index());
|
|
21
|
-
if (!textNode) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
if (dispatch) {
|
|
25
|
-
// As calling copyHTMLToClipboard causes side effects -- we only run this when
|
|
26
|
-
// dispatch is provided -- as otherwise the consumer is only testing to see if
|
|
27
|
-
// the action is availble.
|
|
28
|
-
var domNode = (0, _utils.toDOM)(textNode, state.schema);
|
|
29
|
-
if (domNode) {
|
|
30
|
-
var div = document.createElement('div');
|
|
31
|
-
var p = document.createElement('p');
|
|
32
|
-
div.appendChild(p);
|
|
33
|
-
p.appendChild(domNode);
|
|
34
|
-
// The "1 1" refers to the start and end depth of the slice
|
|
35
|
-
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
36
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
37
|
-
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
38
|
-
|
|
39
|
-
// If we're copying a hyperlink, we'd copy the url as the fallback plain text
|
|
40
|
-
var linkUrl = domNode.getAttribute('href');
|
|
41
|
-
(0, _clipboard.copyHTMLToClipboard)(div, markType.name === 'link' && linkUrl ? linkUrl : undefined);
|
|
42
|
-
}
|
|
43
|
-
var copyToClipboardTr = state.tr;
|
|
44
|
-
copyToClipboardTr.setMeta(_pluginKey.copyButtonPluginKey, {
|
|
45
|
-
copied: true
|
|
46
|
-
});
|
|
47
|
-
var analyticsPayload = (0, _main.getAnalyticsPayload)(state, _analytics.ACTION.COPIED);
|
|
48
|
-
if (analyticsPayload) {
|
|
49
|
-
analyticsPayload.attributes.inputMethod = _analytics.INPUT_METHOD.FLOATING_TB;
|
|
50
|
-
analyticsPayload.attributes.markType = markType.name;
|
|
51
|
-
(0, _analytics.addAnalytics)(state, copyToClipboardTr, analyticsPayload);
|
|
52
|
-
}
|
|
53
|
-
dispatch(copyToClipboardTr);
|
|
54
|
-
}
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return command;
|
|
58
|
-
}
|
|
59
|
-
function getProvideMarkVisualFeedbackForCopyButtonCommand(markType) {
|
|
60
|
-
function provideMarkVisualFeedbackForCopyButtonCommand(state, dispatch) {
|
|
61
|
-
var tr = state.tr;
|
|
62
|
-
tr.setMeta(_pluginKey.copyButtonPluginKey, {
|
|
63
|
-
showSelection: true,
|
|
64
|
-
markType: markType
|
|
65
|
-
});
|
|
66
|
-
if (dispatch) {
|
|
67
|
-
dispatch(tr);
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
return provideMarkVisualFeedbackForCopyButtonCommand;
|
|
72
|
-
}
|
|
73
|
-
function removeMarkVisualFeedbackForCopyButtonCommand(state, dispatch) {
|
|
74
|
-
var tr = state.tr;
|
|
75
|
-
tr.setMeta(_pluginKey.copyButtonPluginKey, {
|
|
76
|
-
removeSelection: true
|
|
77
|
-
});
|
|
78
|
-
var copyButtonState = _pluginKey.copyButtonPluginKey.getState(state);
|
|
79
|
-
if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
|
|
80
|
-
tr.setMeta(_pluginKey.copyButtonPluginKey, {
|
|
81
|
-
copied: false
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (dispatch) {
|
|
85
|
-
dispatch(tr);
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
var createToolbarCopyCommandForNode = function createToolbarCopyCommandForNode(nodeType) {
|
|
90
|
-
return function (state, dispatch) {
|
|
91
|
-
var tr = state.tr,
|
|
92
|
-
schema = state.schema;
|
|
93
|
-
|
|
94
|
-
// This command should only be triggered by the Copy button in the floating toolbar
|
|
95
|
-
// which is only visible when selection is inside the target node
|
|
96
|
-
var contentNodeWithPos = (0, _utils.getSelectedNodeOrNodeParentByNodeType)({
|
|
97
|
-
nodeType: nodeType,
|
|
98
|
-
selection: tr.selection
|
|
99
|
-
});
|
|
100
|
-
if (!contentNodeWithPos) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
var copyToClipboardTr = tr;
|
|
104
|
-
copyToClipboardTr.setMeta(_pluginKey.copyButtonPluginKey, {
|
|
105
|
-
copied: true
|
|
106
|
-
});
|
|
107
|
-
var analyticsPayload = (0, _main.getAnalyticsPayload)(state, _analytics.ACTION.COPIED);
|
|
108
|
-
if (analyticsPayload) {
|
|
109
|
-
analyticsPayload.attributes.inputMethod = _analytics.INPUT_METHOD.FLOATING_TB;
|
|
110
|
-
analyticsPayload.attributes.nodeType = contentNodeWithPos.node.type.name;
|
|
111
|
-
(0, _analytics.addAnalytics)(state, copyToClipboardTr, analyticsPayload);
|
|
112
|
-
}
|
|
113
|
-
if (dispatch) {
|
|
114
|
-
// As calling copyHTMLToClipboard causes side effects -- we only run this when
|
|
115
|
-
// dispatch is provided -- as otherwise the consumer is only testing to see if
|
|
116
|
-
// the action is availble.
|
|
117
|
-
var domNode = (0, _utils.toDOM)(contentNodeWithPos.node, schema);
|
|
118
|
-
if (domNode) {
|
|
119
|
-
var div = document.createElement('div');
|
|
120
|
-
div.appendChild(domNode);
|
|
121
|
-
|
|
122
|
-
// if copying inline content
|
|
123
|
-
if (contentNodeWithPos.node.type.inlineContent) {
|
|
124
|
-
// The "1 1" refers to the start and end depth of the slice
|
|
125
|
-
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
126
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
127
|
-
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
128
|
-
} else {
|
|
129
|
-
// The "0 0" refers to the start and end depth of the slice
|
|
130
|
-
// since we're copying the block node only, it will always be 0 0
|
|
131
|
-
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
132
|
-
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
133
|
-
}
|
|
134
|
-
// ED-17083 safari seems have bugs for extension copy because exntension do not have a child text(innerText) and it will not recognized as html in clipboard, this could be merge into one if this extension fixed children issue or safari fix the copy bug
|
|
135
|
-
// MEX-2528 safari has a bug related to the mediaSingle node with border or link. The image tag within the clipboard is not recognized as HTML when using the ClipboardItem API. To address this, we have to switch to ClipboardPolyfill
|
|
136
|
-
if (_utils2.browser.safari && state.selection instanceof _state.NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
|
|
137
|
-
(0, _clipboard.copyHTMLToClipboardPolyfill)(div);
|
|
138
|
-
} else {
|
|
139
|
-
(0, _clipboard.copyHTMLToClipboard)(div);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
copyToClipboardTr.setMeta('scrollIntoView', false);
|
|
143
|
-
dispatch(copyToClipboardTr);
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
|
-
};
|
|
147
|
-
};
|
|
148
|
-
exports.createToolbarCopyCommandForNode = createToolbarCopyCommandForNode;
|
|
149
|
-
var resetCopiedState = function resetCopiedState(nodeType, hoverDecoration, onMouseLeave) {
|
|
150
|
-
return function (state, dispatch) {
|
|
151
|
-
var customTr = state.tr;
|
|
152
|
-
|
|
153
|
-
// Avoid multipe dispatch
|
|
154
|
-
// https://product-fabric.atlassian.net/wiki/spaces/E/pages/2241659456/All+about+dispatch+and+why+there+shouldn+t+be+multiple#How-do-I-avoid-them%3F
|
|
155
|
-
var customDispatch = function customDispatch(tr) {
|
|
156
|
-
customTr = tr;
|
|
157
|
-
};
|
|
158
|
-
onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false)(state, customDispatch);
|
|
159
|
-
var copyButtonState = _pluginKey.copyButtonPluginKey.getState(state);
|
|
160
|
-
if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
|
|
161
|
-
customTr.setMeta(_pluginKey.copyButtonPluginKey, {
|
|
162
|
-
copied: false
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
if (dispatch) {
|
|
166
|
-
dispatch(customTr);
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
169
|
-
};
|
|
170
|
-
};
|
|
171
|
-
exports.resetCopiedState = resetCopiedState;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _main = _interopRequireDefault(require("./pm-plugins/main"));
|
|
9
|
-
var copyButtonPlugin = function copyButtonPlugin() {
|
|
10
|
-
return {
|
|
11
|
-
name: 'copyButton',
|
|
12
|
-
pmPlugins: function pmPlugins() {
|
|
13
|
-
return [{
|
|
14
|
-
name: 'copyButton',
|
|
15
|
-
plugin: function plugin() {
|
|
16
|
-
return (0, _main.default)();
|
|
17
|
-
}
|
|
18
|
-
}];
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
var _default = copyButtonPlugin;
|
|
23
|
-
exports.default = _default;
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.copyButtonPlugin = copyButtonPlugin;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
|
-
var _pluginKey = require("./plugin-key");
|
|
11
|
-
function getMarkSelectionDecorationStartAndEnd(_ref) {
|
|
12
|
-
var markType = _ref.markType,
|
|
13
|
-
transaction = _ref.transaction;
|
|
14
|
-
var headResolvedPos = transaction.selection.$head;
|
|
15
|
-
var textNodeIndex = transaction.selection.$head.index();
|
|
16
|
-
var textNode = headResolvedPos.parent.maybeChild(textNodeIndex);
|
|
17
|
-
var textNodeOffset = 0;
|
|
18
|
-
headResolvedPos.parent.forEach(function (_node, nodeOffset, index) {
|
|
19
|
-
if (index === textNodeIndex) {
|
|
20
|
-
textNodeOffset = nodeOffset;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var start = headResolvedPos.start(headResolvedPos.depth) + textNodeOffset;
|
|
24
|
-
var end = start + textNode.text.length;
|
|
25
|
-
return {
|
|
26
|
-
start: start,
|
|
27
|
-
end: end,
|
|
28
|
-
markType: markType
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function copyButtonPlugin() {
|
|
32
|
-
return new _safePlugin.SafePlugin({
|
|
33
|
-
key: _pluginKey.copyButtonPluginKey,
|
|
34
|
-
state: {
|
|
35
|
-
init: function init() {
|
|
36
|
-
return {
|
|
37
|
-
copied: false,
|
|
38
|
-
markSelection: undefined
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
apply: function apply(tr, currentPluginState) {
|
|
42
|
-
var meta = tr.getMeta(_pluginKey.copyButtonPluginKey);
|
|
43
|
-
if ((meta === null || meta === void 0 ? void 0 : meta.copied) !== undefined) {
|
|
44
|
-
return {
|
|
45
|
-
copied: meta.copied,
|
|
46
|
-
markSelection: undefined
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
if (meta !== null && meta !== void 0 && meta.showSelection) {
|
|
50
|
-
return {
|
|
51
|
-
copied: currentPluginState.copied,
|
|
52
|
-
markSelection: getMarkSelectionDecorationStartAndEnd({
|
|
53
|
-
markType: meta.markType,
|
|
54
|
-
transaction: tr
|
|
55
|
-
})
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
if (meta !== null && meta !== void 0 && meta.removeSelection) {
|
|
59
|
-
return {
|
|
60
|
-
copied: currentPluginState.copied,
|
|
61
|
-
markSelection: undefined
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
if (currentPluginState.markSelection) {
|
|
65
|
-
return {
|
|
66
|
-
copied: currentPluginState.copied,
|
|
67
|
-
markSelection: getMarkSelectionDecorationStartAndEnd({
|
|
68
|
-
markType: currentPluginState.markSelection.markType,
|
|
69
|
-
transaction: tr
|
|
70
|
-
})
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return currentPluginState;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
props: {
|
|
77
|
-
decorations: function decorations(_state) {
|
|
78
|
-
// Showing visual hints for the hyperlink copy button has been disabled
|
|
79
|
-
// due to an issue where invalid hyperlink marks cause the floating toolbar
|
|
80
|
-
// to jump around when the copy button is hovered.
|
|
81
|
-
// See the following bug for details -- once that is resolved -- the visual
|
|
82
|
-
// hints can be re enabled.
|
|
83
|
-
// https://product-fabric.atlassian.net/browse/DTR-722
|
|
84
|
-
|
|
85
|
-
// const copyButtonPluginState = copyButtonPluginKey.getState(
|
|
86
|
-
// state,
|
|
87
|
-
// ) as CopyButtonPluginState;
|
|
88
|
-
// if (copyButtonPluginState.markSelection) {
|
|
89
|
-
// const { start, end } = copyButtonPluginState.markSelection;
|
|
90
|
-
|
|
91
|
-
// return DecorationSet.create(state.doc, [
|
|
92
|
-
// Decoration.inline(start, end, {
|
|
93
|
-
// class: 'ProseMirror-fake-text-selection',
|
|
94
|
-
// }),
|
|
95
|
-
// ]);
|
|
96
|
-
// }
|
|
97
|
-
|
|
98
|
-
return _view.DecorationSet.empty;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
var _default = copyButtonPlugin;
|
|
104
|
-
exports.default = _default;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.copyButtonPluginKey = void 0;
|
|
7
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var copyButtonPluginKey = new _state.PluginKey('copyButtonPlugin');
|
|
9
|
-
exports.copyButtonPluginKey = copyButtonPluginKey;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.getCopyButtonConfig = getCopyButtonConfig;
|
|
8
|
-
exports.processCopyButtonItems = processCopyButtonItems;
|
|
9
|
-
exports.showCopyButton = void 0;
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var _copy = _interopRequireDefault(require("@atlaskit/icon/glyph/copy"));
|
|
12
|
-
var _messages = _interopRequireDefault(require("../../messages"));
|
|
13
|
-
var _commands = require("./commands");
|
|
14
|
-
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
15
|
-
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
|
-
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; }
|
|
17
|
-
function isSeparator(item) {
|
|
18
|
-
return (item === null || item === void 0 ? void 0 : item.type) === 'separator';
|
|
19
|
-
}
|
|
20
|
-
function isNodeOptions(options) {
|
|
21
|
-
return 'nodeType' in options && options.nodeType !== undefined;
|
|
22
|
-
}
|
|
23
|
-
function getCopyButtonConfig(options, hoverDecoration) {
|
|
24
|
-
var state = options.state,
|
|
25
|
-
formatMessage = options.formatMessage,
|
|
26
|
-
onMouseEnter = options.onMouseEnter,
|
|
27
|
-
onMouseLeave = options.onMouseLeave,
|
|
28
|
-
onFocus = options.onFocus,
|
|
29
|
-
onBlur = options.onBlur;
|
|
30
|
-
var copyButtonState = _pluginKey.copyButtonPluginKey.getState(state);
|
|
31
|
-
var buttonActionHandlers;
|
|
32
|
-
if (isNodeOptions(options)) {
|
|
33
|
-
buttonActionHandlers = {
|
|
34
|
-
onClick: (0, _commands.createToolbarCopyCommandForNode)(options.nodeType),
|
|
35
|
-
// Note for future changes: these two handlers should perform
|
|
36
|
-
// the same action.
|
|
37
|
-
onMouseEnter: onMouseEnter || (hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(options.nodeType, true, 'ak-editor-selected-node')),
|
|
38
|
-
onFocus: onFocus || (hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(options.nodeType, true, 'ak-editor-selected-node')),
|
|
39
|
-
// Note for future changes: these two handlers should perform
|
|
40
|
-
// the same action.
|
|
41
|
-
onMouseLeave: (0, _commands.resetCopiedState)(options.nodeType, hoverDecoration, onMouseLeave),
|
|
42
|
-
onBlur: (0, _commands.resetCopiedState)(options.nodeType, hoverDecoration, onBlur)
|
|
43
|
-
};
|
|
44
|
-
} else {
|
|
45
|
-
buttonActionHandlers = {
|
|
46
|
-
onClick: (0, _commands.createToolbarCopyCommandForMark)(options.markType),
|
|
47
|
-
onMouseEnter: (0, _commands.getProvideMarkVisualFeedbackForCopyButtonCommand)(options.markType),
|
|
48
|
-
onFocus: (0, _commands.getProvideMarkVisualFeedbackForCopyButtonCommand)(options.markType),
|
|
49
|
-
onMouseLeave: _commands.removeMarkVisualFeedbackForCopyButtonCommand,
|
|
50
|
-
onBlur: _commands.removeMarkVisualFeedbackForCopyButtonCommand
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return _objectSpread(_objectSpread({
|
|
54
|
-
id: 'editor.floatingToolbar.copy',
|
|
55
|
-
type: 'button',
|
|
56
|
-
appearance: 'subtle',
|
|
57
|
-
icon: _copy.default,
|
|
58
|
-
title: formatMessage(copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied ? _messages.default.copiedToClipboard : _messages.default.copyToClipboard)
|
|
59
|
-
}, buttonActionHandlers), {}, {
|
|
60
|
-
hideTooltipOnClick: false,
|
|
61
|
-
tabIndex: null
|
|
62
|
-
// TODO select and delete styling needs to be removed when keyboard cursor moves away
|
|
63
|
-
// problem already exist with delete as well
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
var showCopyButton = function showCopyButton(state) {
|
|
68
|
-
return state &&
|
|
69
|
-
// Check if the Copy button plugin is enabled
|
|
70
|
-
// @ts-ignore copyButtonPluginKey.key
|
|
71
|
-
state.plugins.find(function (p) {
|
|
72
|
-
return p.key === _pluginKey.copyButtonPluginKey.key;
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Process floatingToolbar items for copyButton
|
|
78
|
-
*
|
|
79
|
-
* If copy button plugin not enabled, remove copy button item from toolbar items
|
|
80
|
-
* else process copy button to standard floatingtoobarbutton
|
|
81
|
-
*/
|
|
82
|
-
exports.showCopyButton = showCopyButton;
|
|
83
|
-
function processCopyButtonItems(state) {
|
|
84
|
-
return function (items, hoverDecoration) {
|
|
85
|
-
return items.flatMap(function (item) {
|
|
86
|
-
switch (item.type) {
|
|
87
|
-
case 'copy-button':
|
|
88
|
-
if (item !== null && item !== void 0 && item.hidden || !showCopyButton(state)) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
return item === null || item === void 0 ? void 0 : item.items.map(function (copyButtonItem) {
|
|
92
|
-
return isSeparator(copyButtonItem) ? copyButtonItem : getCopyButtonConfig(copyButtonItem, hoverDecoration);
|
|
93
|
-
});
|
|
94
|
-
default:
|
|
95
|
-
return [item];
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSelectedNodeOrNodeParentByNodeType = getSelectedNodeOrNodeParentByNodeType;
|
|
7
|
-
exports.toDOM = void 0;
|
|
8
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
-
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
|
-
function getSelectedNodeOrNodeParentByNodeType(_ref) {
|
|
11
|
-
var nodeType = _ref.nodeType,
|
|
12
|
-
selection = _ref.selection;
|
|
13
|
-
var node = (0, _utils.findSelectedNodeOfType)(nodeType)(selection);
|
|
14
|
-
if (!node) {
|
|
15
|
-
node = (0, _utils.findParentNodeOfType)(nodeType)(selection);
|
|
16
|
-
}
|
|
17
|
-
return node;
|
|
18
|
-
}
|
|
19
|
-
var toDOM = function toDOM(node, schema) {
|
|
20
|
-
return _model.DOMSerializer.fromSchema(schema).serializeNode(node);
|
|
21
|
-
};
|
|
22
|
-
exports.toDOM = toDOM;
|