@atlaskit/editor-plugin-copy-button 2.0.11 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/cjs/pm-plugins/commands.js +30 -25
- package/dist/es2019/pm-plugins/commands.js +31 -26
- package/dist/esm/pm-plugins/commands.js +31 -26
- package/dist/types/copyButtonPluginType.d.ts +1 -1
- package/dist/types-ts4.5/copyButtonPluginType.d.ts +1 -1
- package/package.json +9 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-copy-button
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.0.0
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- [#181024](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/181024)
|
|
14
|
+
[`8e80c487ca307`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8e80c487ca307) - ##
|
|
15
|
+
Make `@atlaskit/editor-common` a peer dependency
|
|
16
|
+
|
|
17
|
+
**WHAT:** `@atlaskit/editor-common` has been moved from `dependencies` to `peerDependencies` in
|
|
18
|
+
all editor plugin packages.
|
|
19
|
+
|
|
20
|
+
**WHY:** This change ensures that only a single version of `@atlaskit/editor-common` is used in
|
|
21
|
+
consuming applications, preventing issues caused by multiple versions of singleton libraries (such
|
|
22
|
+
as context mismatches or duplicated state). This is especially important for packages that rely on
|
|
23
|
+
shared context or singletons.
|
|
24
|
+
|
|
25
|
+
**HOW TO ADJUST:**
|
|
26
|
+
|
|
27
|
+
- Consumers must now explicitly install `@atlaskit/editor-common` in their own project if they use
|
|
28
|
+
any of these editor plugins.
|
|
29
|
+
- Ensure the version you install matches the version required by the plugins.
|
|
30
|
+
- You can use the
|
|
31
|
+
[`check-peer-dependencies`](https://www.npmjs.com/package/check-peer-dependencies) package to
|
|
32
|
+
verify that all required peer dependencies are installed and compatible.
|
|
33
|
+
- Example install command:
|
|
34
|
+
```
|
|
35
|
+
npm install @atlaskit/editor-common
|
|
36
|
+
```
|
|
37
|
+
or
|
|
38
|
+
```
|
|
39
|
+
yarn add @atlaskit/editor-common
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Note:** This is a breaking change. If `@atlaskit/editor-common` is not installed at the
|
|
43
|
+
application level, you may see errors or unexpected behavior.
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies
|
|
48
|
+
|
|
3
49
|
## 2.0.11
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@ var _clipboard = require("@atlaskit/editor-common/clipboard");
|
|
|
14
14
|
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
15
15
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
+
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
17
18
|
var _pluginKey = require("./plugin-key");
|
|
18
19
|
function createToolbarCopyCommandForMark(markType, editorAnalyticsApi) {
|
|
19
20
|
function command(state, dispatch) {
|
|
@@ -121,32 +122,36 @@ var createToolbarCopyCommandForNode = exports.createToolbarCopyCommandForNode =
|
|
|
121
122
|
// dispatch is provided -- as otherwise the consumer is only testing to see if
|
|
122
123
|
// the action is availble.
|
|
123
124
|
var domNode = (0, _copyButton.toDOM)(contentNodeWithPos.node, schema);
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
|
|
126
|
+
(0, _copyButton.copyDomNode)(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
127
|
+
} else {
|
|
128
|
+
if (domNode) {
|
|
129
|
+
var div = document.createElement('div');
|
|
130
|
+
div.appendChild(domNode);
|
|
127
131
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
132
|
+
// if copying inline content
|
|
133
|
+
if (contentNodeWithPos.node.type.inlineContent) {
|
|
134
|
+
// The "1 1" refers to the start and end depth of the slice
|
|
135
|
+
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
136
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
137
|
+
// Ignored via go/ees005
|
|
138
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
139
|
+
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
140
|
+
} else {
|
|
141
|
+
// The "0 0" refers to the start and end depth of the slice
|
|
142
|
+
// since we're copying the block node only, it will always be 0 0
|
|
143
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
144
|
+
// Ignored via go/ees005
|
|
145
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
146
|
+
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
147
|
+
}
|
|
148
|
+
// 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
|
|
149
|
+
// 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
|
|
150
|
+
if (_browser.browser.safari && state.selection instanceof _state.NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
|
|
151
|
+
(0, _clipboard.copyHTMLToClipboardPolyfill)(div);
|
|
152
|
+
} else {
|
|
153
|
+
(0, _clipboard.copyHTMLToClipboard)(div);
|
|
154
|
+
}
|
|
150
155
|
}
|
|
151
156
|
}
|
|
152
157
|
copyToClipboardTr.setMeta('scrollIntoView', false);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
3
3
|
import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill, getAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
4
|
-
import { getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
4
|
+
import { copyDomNode, getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
8
|
import { copyButtonPluginKey } from './plugin-key';
|
|
8
9
|
export function createToolbarCopyCommandForMark(markType, editorAnalyticsApi) {
|
|
9
10
|
function command(state, dispatch) {
|
|
@@ -112,32 +113,36 @@ export const createToolbarCopyCommandForNode = (nodeType, editorAnalyticsApi, ap
|
|
|
112
113
|
// dispatch is provided -- as otherwise the consumer is only testing to see if
|
|
113
114
|
// the action is availble.
|
|
114
115
|
const domNode = toDOM(contentNodeWithPos.node, schema);
|
|
115
|
-
if (
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
117
|
+
copyDomNode(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
118
|
+
} else {
|
|
119
|
+
if (domNode) {
|
|
120
|
+
const div = document.createElement('div');
|
|
121
|
+
div.appendChild(domNode);
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
123
|
+
// if copying inline content
|
|
124
|
+
if (contentNodeWithPos.node.type.inlineContent) {
|
|
125
|
+
// The "1 1" refers to the start and end depth of the slice
|
|
126
|
+
// since we're copying the text inside a paragraph, it will always be 1 1
|
|
127
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
128
|
+
// Ignored via go/ees005
|
|
129
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
130
|
+
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
131
|
+
} else {
|
|
132
|
+
// The "0 0" refers to the start and end depth of the slice
|
|
133
|
+
// since we're copying the block node only, it will always be 0 0
|
|
134
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
135
|
+
// Ignored via go/ees005
|
|
136
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
137
|
+
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
138
|
+
}
|
|
139
|
+
// 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
|
|
140
|
+
// 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
|
|
141
|
+
if (browser.safari && state.selection instanceof NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
|
|
142
|
+
copyHTMLToClipboardPolyfill(div);
|
|
143
|
+
} else {
|
|
144
|
+
copyHTMLToClipboard(div);
|
|
145
|
+
}
|
|
141
146
|
}
|
|
142
147
|
}
|
|
143
148
|
copyToClipboardTr.setMeta('scrollIntoView', false);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
3
3
|
import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill, getAnalyticsPayload } from '@atlaskit/editor-common/clipboard';
|
|
4
|
-
import { getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
4
|
+
import { copyDomNode, getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
5
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
7
8
|
import { copyButtonPluginKey } from './plugin-key';
|
|
8
9
|
export function createToolbarCopyCommandForMark(markType, editorAnalyticsApi) {
|
|
9
10
|
function command(state, dispatch) {
|
|
@@ -111,32 +112,36 @@ export var createToolbarCopyCommandForNode = function createToolbarCopyCommandFo
|
|
|
111
112
|
// dispatch is provided -- as otherwise the consumer is only testing to see if
|
|
112
113
|
// the action is availble.
|
|
113
114
|
var domNode = toDOM(contentNodeWithPos.node, schema);
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
|
|
116
|
+
copyDomNode(domNode, contentNodeWithPos.node.type, tr.selection);
|
|
117
|
+
} else {
|
|
118
|
+
if (domNode) {
|
|
119
|
+
var div = document.createElement('div');
|
|
120
|
+
div.appendChild(domNode);
|
|
117
121
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
129
|
+
div.firstChild.setAttribute('data-pm-slice', '1 1 []');
|
|
130
|
+
} else {
|
|
131
|
+
// The "0 0" refers to the start and end depth of the slice
|
|
132
|
+
// since we're copying the block node only, it will always be 0 0
|
|
133
|
+
// https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
|
|
134
|
+
// Ignored via go/ees005
|
|
135
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
136
|
+
div.firstChild.setAttribute('data-pm-slice', '0 0 []');
|
|
137
|
+
}
|
|
138
|
+
// 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
|
|
139
|
+
// 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
|
|
140
|
+
if (browser.safari && state.selection instanceof NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
|
|
141
|
+
copyHTMLToClipboardPolyfill(div);
|
|
142
|
+
} else {
|
|
143
|
+
copyHTMLToClipboard(div);
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
142
147
|
copyToClipboardTr.setMeta('scrollIntoView', false);
|
|
@@ -2,7 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
|
|
|
2
2
|
import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
declare const processCopyButtonItemsWithAnalytics: (state: import("prosemirror-state").EditorState) => (items: import("@atlaskit/editor-common/types").FloatingToolbarItem<import("@atlaskit/editor-common/types").Command
|
|
5
|
+
declare const processCopyButtonItemsWithAnalytics: (state: import("prosemirror-state").EditorState) => (items: Array<import("@atlaskit/editor-common/types").FloatingToolbarItem<import("@atlaskit/editor-common/types").Command>>, hoverDecoration: import("@atlaskit/editor-plugin-decorations").HoverDecorationHandler | undefined) => Array<import("@atlaskit/editor-common/types").FloatingToolbarItem<import("@atlaskit/editor-common/types").Command>>;
|
|
6
6
|
export type CopyButtonPlugin = NextEditorPlugin<'copyButton', {
|
|
7
7
|
dependencies: [OptionalPlugin<AnalyticsPlugin>, OptionalPlugin<AccessibilityUtilsPlugin>];
|
|
8
8
|
actions: {
|
|
@@ -2,7 +2,7 @@ import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/t
|
|
|
2
2
|
import type { AccessibilityUtilsPlugin } from '@atlaskit/editor-plugin-accessibility-utils';
|
|
3
3
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type { MarkType } from '@atlaskit/editor-prosemirror/model';
|
|
5
|
-
declare const processCopyButtonItemsWithAnalytics: (state: import("prosemirror-state").EditorState) => (items: import("@atlaskit/editor-common/types").FloatingToolbarItem<import("@atlaskit/editor-common/types").Command
|
|
5
|
+
declare const processCopyButtonItemsWithAnalytics: (state: import("prosemirror-state").EditorState) => (items: Array<import("@atlaskit/editor-common/types").FloatingToolbarItem<import("@atlaskit/editor-common/types").Command>>, hoverDecoration: import("@atlaskit/editor-plugin-decorations").HoverDecorationHandler | undefined) => Array<import("@atlaskit/editor-common/types").FloatingToolbarItem<import("@atlaskit/editor-common/types").Command>>;
|
|
6
6
|
export type CopyButtonPlugin = NextEditorPlugin<'copyButton', {
|
|
7
7
|
dependencies: [
|
|
8
8
|
OptionalPlugin<AnalyticsPlugin>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-copy-button",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "editor-plugin-copy-button for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor: Lego",
|
|
12
|
-
"singleton": true
|
|
13
|
-
"runReact18": true
|
|
12
|
+
"singleton": true
|
|
14
13
|
},
|
|
15
14
|
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
16
15
|
"main": "dist/cjs/index.js",
|
|
@@ -31,23 +30,23 @@
|
|
|
31
30
|
".": "./src/index.ts"
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-
|
|
35
|
-
"@atlaskit/editor-plugin-
|
|
36
|
-
"@atlaskit/editor-plugin-
|
|
37
|
-
"@atlaskit/editor-plugin-decorations": "^2.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-accessibility-utils": "^3.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-decorations": "^3.0.0",
|
|
38
36
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
39
|
-
"@atlaskit/icon": "^
|
|
37
|
+
"@atlaskit/icon": "^28.0.0",
|
|
40
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
39
|
+
"@atlaskit/tmp-editor-statsig": "^11.3.0",
|
|
41
40
|
"@babel/runtime": "^7.0.0"
|
|
42
41
|
},
|
|
43
42
|
"peerDependencies": {
|
|
43
|
+
"@atlaskit/editor-common": "^107.26.0",
|
|
44
44
|
"react": "^18.2.0",
|
|
45
45
|
"react-dom": "^18.2.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
49
|
-
"@testing-library/react": "^13.4.0"
|
|
50
|
-
"typescript": "~5.4.2"
|
|
49
|
+
"@testing-library/react": "^13.4.0"
|
|
51
50
|
},
|
|
52
51
|
"techstack": {
|
|
53
52
|
"@atlassian/frontend": {
|