@atlaskit/editor-plugin-copy-button 3.0.0 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-copy-button
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
3
9
  ## 3.0.0
4
10
 
5
11
  ### Major 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 (domNode) {
125
- var div = document.createElement('div');
126
- div.appendChild(domNode);
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
- // if copying inline content
129
- if (contentNodeWithPos.node.type.inlineContent) {
130
- // The "1 1" refers to the start and end depth of the slice
131
- // since we're copying the text inside a paragraph, it will always be 1 1
132
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
133
- // Ignored via go/ees005
134
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
135
- div.firstChild.setAttribute('data-pm-slice', '1 1 []');
136
- } else {
137
- // The "0 0" refers to the start and end depth of the slice
138
- // since we're copying the block node only, it will always be 0 0
139
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
140
- // Ignored via go/ees005
141
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
142
- div.firstChild.setAttribute('data-pm-slice', '0 0 []');
143
- }
144
- // 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
145
- // 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
146
- 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)) {
147
- (0, _clipboard.copyHTMLToClipboardPolyfill)(div);
148
- } else {
149
- (0, _clipboard.copyHTMLToClipboard)(div);
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 (domNode) {
116
- const div = document.createElement('div');
117
- div.appendChild(domNode);
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
- // if copying inline content
120
- if (contentNodeWithPos.node.type.inlineContent) {
121
- // The "1 1" refers to the start and end depth of the slice
122
- // since we're copying the text inside a paragraph, it will always be 1 1
123
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
124
- // Ignored via go/ees005
125
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
126
- div.firstChild.setAttribute('data-pm-slice', '1 1 []');
127
- } else {
128
- // The "0 0" refers to the start and end depth of the slice
129
- // since we're copying the block node only, it will always be 0 0
130
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
131
- // Ignored via go/ees005
132
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
133
- div.firstChild.setAttribute('data-pm-slice', '0 0 []');
134
- }
135
- // 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
136
- // 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
137
- if (browser.safari && state.selection instanceof NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
138
- copyHTMLToClipboardPolyfill(div);
139
- } else {
140
- copyHTMLToClipboard(div);
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 (domNode) {
115
- var div = document.createElement('div');
116
- div.appendChild(domNode);
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
- // if copying inline content
119
- if (contentNodeWithPos.node.type.inlineContent) {
120
- // The "1 1" refers to the start and end depth of the slice
121
- // since we're copying the text inside a paragraph, it will always be 1 1
122
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
123
- // Ignored via go/ees005
124
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
125
- div.firstChild.setAttribute('data-pm-slice', '1 1 []');
126
- } else {
127
- // The "0 0" refers to the start and end depth of the slice
128
- // since we're copying the block node only, it will always be 0 0
129
- // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
130
- // Ignored via go/ees005
131
- // eslint-disable-next-line @atlaskit/editor/no-as-casting
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 (browser.safari && state.selection instanceof NodeSelection && (state.selection.node.type === state.schema.nodes.extension || state.selection.node.type === state.schema.nodes.mediaSingle)) {
137
- copyHTMLToClipboardPolyfill(div);
138
- } else {
139
- copyHTMLToClipboard(div);
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>[], hoverDecoration: ((nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command) | undefined) => 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>[], hoverDecoration: ((nodeType: import("prosemirror-model").NodeType | import("prosemirror-model").NodeType[], add: boolean, className?: string | undefined) => import("@atlaskit/editor-common/types").Command) | undefined) => 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.0.0",
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",
@@ -34,19 +34,19 @@
34
34
  "@atlaskit/editor-plugin-analytics": "^3.0.0",
35
35
  "@atlaskit/editor-plugin-decorations": "^3.0.0",
36
36
  "@atlaskit/editor-prosemirror": "7.0.0",
37
- "@atlaskit/icon": "^27.2.0",
37
+ "@atlaskit/icon": "^28.0.0",
38
38
  "@atlaskit/platform-feature-flags": "^1.1.0",
39
+ "@atlaskit/tmp-editor-statsig": "^11.3.0",
39
40
  "@babel/runtime": "^7.0.0"
40
41
  },
41
42
  "peerDependencies": {
42
- "@atlaskit/editor-common": "^107.6.0",
43
+ "@atlaskit/editor-common": "^107.26.0",
43
44
  "react": "^18.2.0",
44
45
  "react-dom": "^18.2.0"
45
46
  },
46
47
  "devDependencies": {
47
48
  "@atlaskit/analytics-next": "^11.1.0",
48
- "@testing-library/react": "^13.4.0",
49
- "typescript": "~5.4.2"
49
+ "@testing-library/react": "^13.4.0"
50
50
  },
51
51
  "techstack": {
52
52
  "@atlassian/frontend": {