@atlaskit/editor-plugin-floating-toolbar 3.0.2 → 3.1.0

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,20 @@
1
1
  # @atlaskit/editor-plugin-floating-toolbar
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#121533](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121533)
8
+ [`9efef36af09aa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9efef36af09aa) -
9
+ Wire up the copy functionality in floating toolbar overflow menu
10
+
11
+ ### Patch Changes
12
+
13
+ - [#121662](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/121662)
14
+ [`9b32bffcee007`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9b32bffcee007) -
15
+ [ux] [ED-26870] Allow toolbar height to expand
16
+ - Updated dependencies
17
+
3
18
  ## 3.0.2
4
19
 
5
20
  ### Patch Changes
@@ -21,8 +21,9 @@ var _ui = require("@atlaskit/editor-common/ui");
21
21
  var _state = require("@atlaskit/editor-prosemirror/state");
22
22
  var _utils = require("@atlaskit/editor-prosemirror/utils");
23
23
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
24
+ var _commands = require("./pm-plugins/commands");
24
25
  var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
25
- var _commands = require("./pm-plugins/toolbar-data/commands");
26
+ var _commands2 = require("./pm-plugins/toolbar-data/commands");
26
27
  var _plugin = require("./pm-plugins/toolbar-data/plugin");
27
28
  var _pluginKey = require("./pm-plugins/toolbar-data/plugin-key");
28
29
  var _utils2 = require("./pm-plugins/utils");
@@ -164,6 +165,11 @@ var floatingToolbarPlugin = exports.floatingToolbarPlugin = function floatingToo
164
165
  actions: {
165
166
  forceFocusSelector: _forceFocus.forceFocusSelector
166
167
  },
168
+ commands: {
169
+ copyNode: function copyNode(nodeType) {
170
+ return (0, _commands.copyNode)(nodeType);
171
+ }
172
+ },
167
173
  getSharedState: function getSharedState(editorState) {
168
174
  var _pluginKey$getState$g, _pluginKey$getState, _pluginKey$getState$g2;
169
175
  if (!editorState) {
@@ -399,7 +405,7 @@ function ContentComponent(_ref5) {
399
405
  }
400
406
  },
401
407
  onClose: function onClose() {
402
- dispatchCommand((0, _commands.hideConfirmDialog)());
408
+ dispatchCommand((0, _commands2.hideConfirmDialog)());
403
409
  // Need to set focus to Editor here,
404
410
  // As when the Confirmation dialog pop up, and user interacts with the dialog, Editor loses focus.
405
411
  // So when Confirmation dialog is closed, Editor does not have the focus, then cursor goes to the position 1 of the doc,
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.copyNode = void 0;
7
+ var _browser = require("@atlaskit/editor-common/browser");
8
+ var _clipboard = require("@atlaskit/editor-common/clipboard");
9
+ var _copyButton = require("@atlaskit/editor-common/copy-button");
10
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var copyNode = exports.copyNode = function copyNode(nodeType, editorAnalyticsAp) {
12
+ return function (_ref) {
13
+ var tr = _ref.tr;
14
+ // const { tr, schema } = state;
15
+
16
+ // This command should only be triggered by the Copy button in the floating toolbar
17
+ // which is only visible when selection is inside the target node
18
+ var contentNodeWithPos = (0, _copyButton.getSelectedNodeOrNodeParentByNodeType)({
19
+ nodeType: nodeType,
20
+ selection: tr.selection
21
+ });
22
+ if (!contentNodeWithPos) {
23
+ return tr;
24
+ }
25
+ var schema = tr.doc.type.schema;
26
+ var copyToClipboardTr = tr;
27
+ var domNode = (0, _copyButton.toDOM)(contentNodeWithPos.node, schema);
28
+ if (domNode) {
29
+ var div = document.createElement('div');
30
+ div.appendChild(domNode);
31
+
32
+ // if copying inline content
33
+ if (contentNodeWithPos.node.type.inlineContent) {
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
+ // Ignored via go/ees005
38
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
39
+ div.firstChild.setAttribute('data-pm-slice', '1 1 []');
40
+ } else {
41
+ // The "0 0" refers to the start and end depth of the slice
42
+ // since we're copying the block node only, it will always be 0 0
43
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
44
+ // Ignored via go/ees005
45
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
46
+ div.firstChild.setAttribute('data-pm-slice', '0 0 []');
47
+ }
48
+ // 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
49
+ // 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
50
+ if (_browser.browser.safari && tr.selection instanceof _state.NodeSelection && (tr.selection.node.type === schema.nodes.extension || tr.selection.node.type === schema.nodes.mediaSingle)) {
51
+ (0, _clipboard.copyHTMLToClipboardPolyfill)(div);
52
+ } else {
53
+ (0, _clipboard.copyHTMLToClipboard)(div);
54
+ }
55
+ }
56
+ copyToClipboardTr.setMeta('scrollIntoView', false);
57
+ return copyToClipboardTr;
58
+ };
59
+ };
@@ -433,7 +433,7 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
433
433
  (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') ?
434
434
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
435
435
  (0, _react2.css)({
436
- height: "var(--ds-space-500, 40px)"
436
+ minHeight: "var(--ds-space-500, 40px)"
437
437
  }) : undefined);
438
438
  };
439
439
 
@@ -488,7 +488,7 @@ var toolbarOverflow = function toolbarOverflow(_ref2) {
488
488
  padding: paddingFeatureFlag ? "var(--ds-space-0, 0)".concat(" 0 ", "var(--ds-space-050, 4px)") : "var(--ds-space-0, 0)".concat(" 0 ", "var(--ds-space-600, 48px)"),
489
489
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
490
490
  '> div': {
491
- height: '40px',
491
+ minHeight: "var(--ds-space-500, 40px)",
492
492
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
493
493
  '> div:has(+ [data-editor-popup="true"]:last-of-type)': {
494
494
  marginRight: "var(--ds-space-100, 8px)"
@@ -9,6 +9,7 @@ import { Popup } from '@atlaskit/editor-common/ui';
9
9
  import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
10
10
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
12
+ import { copyNode } from './pm-plugins/commands';
12
13
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
13
14
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
14
15
  import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
@@ -147,6 +148,9 @@ export const floatingToolbarPlugin = ({
147
148
  actions: {
148
149
  forceFocusSelector
149
150
  },
151
+ commands: {
152
+ copyNode: nodeType => copyNode(nodeType)
153
+ },
150
154
  getSharedState(editorState) {
151
155
  var _pluginKey$getState$g, _pluginKey$getState, _pluginKey$getState$g2;
152
156
  if (!editorState) {
@@ -0,0 +1,52 @@
1
+ import { browser } from '@atlaskit/editor-common/browser';
2
+ import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill } from '@atlaskit/editor-common/clipboard';
3
+ import { getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
4
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
+ export const copyNode = (nodeType, editorAnalyticsAp) => ({
6
+ tr
7
+ }) => {
8
+ // const { tr, schema } = state;
9
+
10
+ // This command should only be triggered by the Copy button in the floating toolbar
11
+ // which is only visible when selection is inside the target node
12
+ const contentNodeWithPos = getSelectedNodeOrNodeParentByNodeType({
13
+ nodeType,
14
+ selection: tr.selection
15
+ });
16
+ if (!contentNodeWithPos) {
17
+ return tr;
18
+ }
19
+ const schema = tr.doc.type.schema;
20
+ const copyToClipboardTr = tr;
21
+ const domNode = toDOM(contentNodeWithPos.node, schema);
22
+ if (domNode) {
23
+ const div = document.createElement('div');
24
+ div.appendChild(domNode);
25
+
26
+ // if copying inline content
27
+ if (contentNodeWithPos.node.type.inlineContent) {
28
+ // The "1 1" refers to the start and end depth of the slice
29
+ // since we're copying the text inside a paragraph, it will always be 1 1
30
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
31
+ // Ignored via go/ees005
32
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
33
+ div.firstChild.setAttribute('data-pm-slice', '1 1 []');
34
+ } else {
35
+ // The "0 0" refers to the start and end depth of the slice
36
+ // since we're copying the block node only, it will always be 0 0
37
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
38
+ // Ignored via go/ees005
39
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
40
+ div.firstChild.setAttribute('data-pm-slice', '0 0 []');
41
+ }
42
+ // 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
43
+ // 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
44
+ if (browser.safari && tr.selection instanceof NodeSelection && (tr.selection.node.type === schema.nodes.extension || tr.selection.node.type === schema.nodes.mediaSingle)) {
45
+ copyHTMLToClipboardPolyfill(div);
46
+ } else {
47
+ copyHTMLToClipboard(div);
48
+ }
49
+ }
50
+ copyToClipboardTr.setMeta('scrollIntoView', false);
51
+ return copyToClipboardTr;
52
+ };
@@ -395,7 +395,7 @@ css({
395
395
  editorExperiment('platform_editor_controls', 'variant1') ?
396
396
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
397
397
  css({
398
- height: "var(--ds-space-500, 40px)"
398
+ minHeight: "var(--ds-space-500, 40px)"
399
399
  }) : undefined);
400
400
 
401
401
  // eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
@@ -449,7 +449,7 @@ css({
449
449
  padding: paddingFeatureFlag ? `${"var(--ds-space-0, 0)"} 0 ${"var(--ds-space-050, 4px)"}` : `${"var(--ds-space-0, 0)"} 0 ${"var(--ds-space-600, 48px)"}`,
450
450
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
451
451
  '> div': {
452
- height: '40px',
452
+ minHeight: "var(--ds-space-500, 40px)",
453
453
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
454
454
  '> div:has(+ [data-editor-popup="true"]:last-of-type)': {
455
455
  marginRight: "var(--ds-space-100, 8px)"
@@ -12,6 +12,7 @@ import { Popup } from '@atlaskit/editor-common/ui';
12
12
  import { AllSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
13
13
  import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
14
14
  import { editorExperiment, unstable_editorExperimentParam } from '@atlaskit/tmp-editor-statsig/experiments';
15
+ import { copyNode as _copyNode } from './pm-plugins/commands';
15
16
  import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
16
17
  import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
17
18
  import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
@@ -152,6 +153,11 @@ export var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
152
153
  actions: {
153
154
  forceFocusSelector: forceFocusSelector
154
155
  },
156
+ commands: {
157
+ copyNode: function copyNode(nodeType) {
158
+ return _copyNode(nodeType);
159
+ }
160
+ },
155
161
  getSharedState: function getSharedState(editorState) {
156
162
  var _pluginKey$getState$g, _pluginKey$getState, _pluginKey$getState$g2;
157
163
  if (!editorState) {
@@ -0,0 +1,53 @@
1
+ import { browser } from '@atlaskit/editor-common/browser';
2
+ import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill } from '@atlaskit/editor-common/clipboard';
3
+ import { getSelectedNodeOrNodeParentByNodeType, toDOM } from '@atlaskit/editor-common/copy-button';
4
+ import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
+ export var copyNode = function copyNode(nodeType, editorAnalyticsAp) {
6
+ return function (_ref) {
7
+ var tr = _ref.tr;
8
+ // const { tr, schema } = state;
9
+
10
+ // This command should only be triggered by the Copy button in the floating toolbar
11
+ // which is only visible when selection is inside the target node
12
+ var contentNodeWithPos = getSelectedNodeOrNodeParentByNodeType({
13
+ nodeType: nodeType,
14
+ selection: tr.selection
15
+ });
16
+ if (!contentNodeWithPos) {
17
+ return tr;
18
+ }
19
+ var schema = tr.doc.type.schema;
20
+ var copyToClipboardTr = tr;
21
+ var domNode = toDOM(contentNodeWithPos.node, schema);
22
+ if (domNode) {
23
+ var div = document.createElement('div');
24
+ div.appendChild(domNode);
25
+
26
+ // if copying inline content
27
+ if (contentNodeWithPos.node.type.inlineContent) {
28
+ // The "1 1" refers to the start and end depth of the slice
29
+ // since we're copying the text inside a paragraph, it will always be 1 1
30
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
31
+ // Ignored via go/ees005
32
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
33
+ div.firstChild.setAttribute('data-pm-slice', '1 1 []');
34
+ } else {
35
+ // The "0 0" refers to the start and end depth of the slice
36
+ // since we're copying the block node only, it will always be 0 0
37
+ // https://github.com/ProseMirror/prosemirror-view/blob/master/src/clipboard.ts#L32
38
+ // Ignored via go/ees005
39
+ // eslint-disable-next-line @atlaskit/editor/no-as-casting
40
+ div.firstChild.setAttribute('data-pm-slice', '0 0 []');
41
+ }
42
+ // 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
43
+ // 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
44
+ if (browser.safari && tr.selection instanceof NodeSelection && (tr.selection.node.type === schema.nodes.extension || tr.selection.node.type === schema.nodes.mediaSingle)) {
45
+ copyHTMLToClipboardPolyfill(div);
46
+ } else {
47
+ copyHTMLToClipboard(div);
48
+ }
49
+ }
50
+ copyToClipboardTr.setMeta('scrollIntoView', false);
51
+ return copyToClipboardTr;
52
+ };
53
+ };
@@ -426,7 +426,7 @@ var toolbarContainer = function toolbarContainer(scrollable, hasSelect, firstEle
426
426
  editorExperiment('platform_editor_controls', 'variant1') ?
427
427
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
428
428
  css({
429
- height: "var(--ds-space-500, 40px)"
429
+ minHeight: "var(--ds-space-500, 40px)"
430
430
  }) : undefined);
431
431
  };
432
432
 
@@ -481,7 +481,7 @@ var toolbarOverflow = function toolbarOverflow(_ref2) {
481
481
  padding: paddingFeatureFlag ? "var(--ds-space-0, 0)".concat(" 0 ", "var(--ds-space-050, 4px)") : "var(--ds-space-0, 0)".concat(" 0 ", "var(--ds-space-600, 48px)"),
482
482
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
483
483
  '> div': {
484
- height: '40px',
484
+ minHeight: "var(--ds-space-500, 40px)",
485
485
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors
486
486
  '> div:has(+ [data-editor-popup="true"]:last-of-type)': {
487
487
  marginRight: "var(--ds-space-100, 8px)"
@@ -0,0 +1,6 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { NodeType } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ export declare const copyNode: (nodeType: NodeType | Array<NodeType>, editorAnalyticsAp?: EditorAnalyticsAPI | undefined) => ({ tr }: {
5
+ tr: Transaction;
6
+ }) => Transaction;
@@ -0,0 +1,6 @@
1
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
2
+ import type { NodeType } from '@atlaskit/editor-prosemirror/model';
3
+ import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
+ export declare const copyNode: (nodeType: NodeType | Array<NodeType>, editorAnalyticsAp?: EditorAnalyticsAPI | undefined) => ({ tr }: {
5
+ tr: Transaction;
6
+ }) => Transaction;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-floating-toolbar",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "Floating toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -25,20 +25,20 @@
25
25
  ".": "./src/index.ts"
26
26
  },
27
27
  "dependencies": {
28
- "@atlaskit/adf-utils": "^19.18.0",
28
+ "@atlaskit/adf-utils": "^19.19.0",
29
29
  "@atlaskit/button": "^21.1.0",
30
30
  "@atlaskit/checkbox": "^17.0.0",
31
- "@atlaskit/editor-common": "^100.4.0",
31
+ "@atlaskit/editor-common": "^100.5.0",
32
32
  "@atlaskit/editor-palette": "2.0.0",
33
- "@atlaskit/editor-plugin-block-controls": "^3.1.0",
33
+ "@atlaskit/editor-plugin-block-controls": "^3.2.0",
34
34
  "@atlaskit/editor-plugin-context-panel": "^3.0.0",
35
35
  "@atlaskit/editor-plugin-copy-button": "^2.0.0",
36
36
  "@atlaskit/editor-plugin-decorations": "^2.0.0",
37
37
  "@atlaskit/editor-plugin-editor-disabled": "^2.0.0",
38
38
  "@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
39
- "@atlaskit/editor-plugin-emoji": "^3.0.0",
40
- "@atlaskit/editor-plugin-extension": "^4.0.0",
41
- "@atlaskit/editor-plugin-table": "^10.2.0",
39
+ "@atlaskit/editor-plugin-emoji": "^3.1.0",
40
+ "@atlaskit/editor-plugin-extension": "^4.1.0",
41
+ "@atlaskit/editor-plugin-table": "^10.3.0",
42
42
  "@atlaskit/editor-prosemirror": "7.0.0",
43
43
  "@atlaskit/emoji": "^68.0.0",
44
44
  "@atlaskit/icon": "^24.1.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/primitives": "^14.1.0",
49
49
  "@atlaskit/select": "^20.0.0",
50
50
  "@atlaskit/theme": "^17.0.0",
51
- "@atlaskit/tmp-editor-statsig": "^3.3.0",
51
+ "@atlaskit/tmp-editor-statsig": "^3.4.0",
52
52
  "@atlaskit/tokens": "^4.3.0",
53
53
  "@atlaskit/tooltip": "^20.0.0",
54
54
  "@babel/runtime": "^7.0.0",