@atlaskit/editor-plugin-floating-toolbar 0.5.1 → 0.6.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 +22 -10
- package/README.md +1 -1
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/plugin.js +385 -0
- package/dist/cjs/pm-plugins/force-focus/index.js +73 -0
- package/dist/cjs/pm-plugins/toolbar-data/commands.js +26 -0
- package/dist/cjs/pm-plugins/toolbar-data/plugin-factory.js +16 -0
- package/dist/cjs/pm-plugins/toolbar-data/plugin-key.js +9 -0
- package/dist/cjs/pm-plugins/toolbar-data/plugin.js +16 -0
- package/dist/cjs/pm-plugins/toolbar-data/reducer.js +25 -0
- package/dist/cjs/pm-plugins/toolbar-data/types.js +5 -0
- package/dist/cjs/ui/CheckboxModal.js +83 -0
- package/dist/cjs/ui/ConfirmationModal.js +22 -0
- package/dist/cjs/ui/Dropdown.js +212 -0
- package/dist/cjs/ui/DropdownMenu.js +218 -0
- package/dist/cjs/ui/EditorEmojiAddIcon.js +32 -0
- package/dist/cjs/ui/EmojiPickerButton.js +121 -0
- package/dist/cjs/ui/ExtensionsPlaceholder.js +179 -0
- package/dist/cjs/ui/Input.js +80 -0
- package/dist/cjs/ui/ScrollButtons.js +155 -0
- package/dist/cjs/ui/Select.js +74 -0
- package/dist/cjs/ui/Separator.js +9 -0
- package/dist/cjs/ui/SimpleModal.js +42 -0
- package/dist/cjs/ui/Toolbar.js +436 -0
- package/dist/cjs/ui/ToolbarLoader.js +25 -0
- package/dist/cjs/ui/messages.js +55 -0
- package/dist/cjs/ui/styles.js +79 -0
- package/dist/cjs/utils.js +22 -0
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/plugin.js +366 -0
- package/dist/es2019/pm-plugins/force-focus/index.js +63 -0
- package/dist/es2019/pm-plugins/toolbar-data/commands.js +10 -0
- package/dist/es2019/pm-plugins/toolbar-data/plugin-factory.js +8 -0
- package/dist/es2019/pm-plugins/toolbar-data/plugin-key.js +2 -0
- package/dist/es2019/pm-plugins/toolbar-data/plugin.js +9 -0
- package/dist/es2019/pm-plugins/toolbar-data/reducer.js +16 -0
- package/dist/es2019/pm-plugins/toolbar-data/types.js +1 -0
- package/dist/es2019/ui/CheckboxModal.js +71 -0
- package/dist/es2019/ui/ConfirmationModal.js +13 -0
- package/dist/es2019/ui/Dropdown.js +185 -0
- package/dist/es2019/ui/DropdownMenu.js +205 -0
- package/dist/es2019/ui/EditorEmojiAddIcon.js +25 -0
- package/dist/es2019/ui/EmojiPickerButton.js +108 -0
- package/dist/es2019/ui/ExtensionsPlaceholder.js +100 -0
- package/dist/es2019/ui/Input.js +54 -0
- package/dist/es2019/ui/ScrollButtons.js +141 -0
- package/dist/es2019/ui/Select.js +62 -0
- package/dist/es2019/ui/Separator.js +2 -0
- package/dist/es2019/ui/SimpleModal.js +35 -0
- package/dist/es2019/ui/Toolbar.js +428 -0
- package/dist/es2019/ui/ToolbarLoader.js +6 -0
- package/dist/es2019/ui/messages.js +48 -0
- package/dist/es2019/ui/styles.js +64 -0
- package/dist/es2019/utils.js +16 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/plugin.js +373 -0
- package/dist/esm/pm-plugins/force-focus/index.js +64 -0
- package/dist/esm/pm-plugins/toolbar-data/commands.js +18 -0
- package/dist/esm/pm-plugins/toolbar-data/plugin-factory.js +8 -0
- package/dist/esm/pm-plugins/toolbar-data/plugin-key.js +2 -0
- package/dist/esm/pm-plugins/toolbar-data/plugin.js +9 -0
- package/dist/esm/pm-plugins/toolbar-data/reducer.js +17 -0
- package/dist/esm/pm-plugins/toolbar-data/types.js +1 -0
- package/dist/esm/ui/CheckboxModal.js +72 -0
- package/dist/esm/ui/ConfirmationModal.js +14 -0
- package/dist/esm/ui/Dropdown.js +204 -0
- package/dist/esm/ui/DropdownMenu.js +211 -0
- package/dist/esm/ui/EditorEmojiAddIcon.js +25 -0
- package/dist/esm/ui/EmojiPickerButton.js +114 -0
- package/dist/esm/ui/ExtensionsPlaceholder.js +168 -0
- package/dist/esm/ui/Input.js +72 -0
- package/dist/esm/ui/ScrollButtons.js +145 -0
- package/dist/esm/ui/Select.js +64 -0
- package/dist/esm/ui/Separator.js +2 -0
- package/dist/esm/ui/SimpleModal.js +31 -0
- package/dist/esm/ui/Toolbar.js +426 -0
- package/dist/esm/ui/ToolbarLoader.js +12 -0
- package/dist/esm/ui/messages.js +48 -0
- package/dist/esm/ui/styles.js +68 -0
- package/dist/esm/utils.js +16 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugin.d.ts +12 -0
- package/dist/types/pm-plugins/force-focus/index.d.ts +21 -0
- package/dist/types/pm-plugins/toolbar-data/commands.d.ts +3 -0
- package/dist/types/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -0
- package/dist/types/pm-plugins/toolbar-data/plugin-key.d.ts +3 -0
- package/dist/types/pm-plugins/toolbar-data/plugin.d.ts +3 -0
- package/dist/types/pm-plugins/toolbar-data/reducer.d.ts +3 -0
- package/dist/types/pm-plugins/toolbar-data/types.d.ts +8 -0
- package/dist/types/ui/CheckboxModal.d.ts +4 -0
- package/dist/types/ui/ConfirmationModal.d.ts +6 -0
- package/dist/types/ui/Dropdown.d.ts +41 -0
- package/dist/types/ui/DropdownMenu.d.ts +29 -0
- package/dist/types/ui/EditorEmojiAddIcon.d.ts +2 -0
- package/dist/types/ui/EmojiPickerButton.d.ts +16 -0
- package/dist/types/ui/ExtensionsPlaceholder.d.ts +16 -0
- package/dist/types/ui/Input.d.ts +23 -0
- package/dist/types/ui/ScrollButtons.d.ts +13 -0
- package/dist/types/ui/Select.d.ts +21 -0
- package/dist/types/ui/Separator.d.ts +2 -0
- package/dist/types/ui/SimpleModal.d.ts +4 -0
- package/dist/types/ui/Toolbar.d.ts +44 -0
- package/dist/types/ui/ToolbarLoader.d.ts +4 -0
- package/dist/types/ui/messages.d.ts +48 -0
- package/dist/types/ui/styles.d.ts +20 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/plugin.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/force-focus/index.d.ts +21 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/commands.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/plugin-factory.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/plugin.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/reducer.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/toolbar-data/types.d.ts +8 -0
- package/dist/types-ts4.5/ui/CheckboxModal.d.ts +4 -0
- package/dist/types-ts4.5/ui/ConfirmationModal.d.ts +6 -0
- package/dist/types-ts4.5/ui/Dropdown.d.ts +41 -0
- package/dist/types-ts4.5/ui/DropdownMenu.d.ts +29 -0
- package/dist/types-ts4.5/ui/EditorEmojiAddIcon.d.ts +2 -0
- package/dist/types-ts4.5/ui/EmojiPickerButton.d.ts +16 -0
- package/dist/types-ts4.5/ui/ExtensionsPlaceholder.d.ts +16 -0
- package/dist/types-ts4.5/ui/Input.d.ts +23 -0
- package/dist/types-ts4.5/ui/ScrollButtons.d.ts +13 -0
- package/dist/types-ts4.5/ui/Select.d.ts +21 -0
- package/dist/types-ts4.5/ui/Separator.d.ts +2 -0
- package/dist/types-ts4.5/ui/SimpleModal.d.ts +4 -0
- package/dist/types-ts4.5/ui/Toolbar.d.ts +44 -0
- package/dist/types-ts4.5/ui/ToolbarLoader.d.ts +4 -0
- package/dist/types-ts4.5/ui/messages.d.ts +48 -0
- package/dist/types-ts4.5/ui/styles.d.ts +20 -0
- package/dist/types-ts4.5/utils.d.ts +2 -0
- package/package.json +32 -3
- package/report.api.md +3 -0
- package/tmp/api-report-tmp.d.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#39749](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39749) [`e6b69f455c3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e6b69f455c3) - Connect yarn changeset to packages, upgrade adf-schema
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#40754](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40754) [`fc1c299c926`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fc1c299c926) - ED-20017 Extract Floating toolbar plugin to its own package
|
|
14
|
+
|
|
3
15
|
## 0.5.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -10,7 +22,7 @@
|
|
|
10
22
|
|
|
11
23
|
### Minor Changes
|
|
12
24
|
|
|
13
|
-
- [`9f2365fabcc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9f2365fabcc) - ED-19617 - Initial creation of editor-plugin-copy-button package
|
|
25
|
+
- [#40092](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40092) [`9f2365fabcc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9f2365fabcc) - ED-19617 - Initial creation of editor-plugin-copy-button package
|
|
14
26
|
|
|
15
27
|
### Patch Changes
|
|
16
28
|
|
|
@@ -26,13 +38,13 @@
|
|
|
26
38
|
|
|
27
39
|
### Patch Changes
|
|
28
40
|
|
|
29
|
-
- [`308ead2410b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/308ead2410b) - add missing dependency to @atlaskit/editor-plugin-floating-toolbar
|
|
41
|
+
- [#39989](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39989) [`308ead2410b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/308ead2410b) - add missing dependency to @atlaskit/editor-plugin-floating-toolbar
|
|
30
42
|
|
|
31
43
|
## 0.4.2
|
|
32
44
|
|
|
33
45
|
### Patch Changes
|
|
34
46
|
|
|
35
|
-
- [`da629b62ef9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/da629b62ef9) - ED-19617 Refactor actions to remove createExtenstionAPI and call it instead during initialisation
|
|
47
|
+
- [#39743](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39743) [`da629b62ef9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/da629b62ef9) - ED-19617 Refactor actions to remove createExtenstionAPI and call it instead during initialisation
|
|
36
48
|
|
|
37
49
|
## 0.4.1
|
|
38
50
|
|
|
@@ -44,7 +56,7 @@
|
|
|
44
56
|
|
|
45
57
|
### Minor Changes
|
|
46
58
|
|
|
47
|
-
- [`ad3c5c21079`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ad3c5c21079) - Updating all plugins with minor version to correct issue with semver.
|
|
59
|
+
- [#39325](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39325) [`ad3c5c21079`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ad3c5c21079) - Updating all plugins with minor version to correct issue with semver.
|
|
48
60
|
|
|
49
61
|
### Patch Changes
|
|
50
62
|
|
|
@@ -54,7 +66,7 @@
|
|
|
54
66
|
|
|
55
67
|
### Patch Changes
|
|
56
68
|
|
|
57
|
-
- [`24e27147cbd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/24e27147cbd) - Added atlaskit docs to all existing plugins.
|
|
69
|
+
- [#39177](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/39177) [`24e27147cbd`](https://bitbucket.org/atlassian/atlassian-frontend/commits/24e27147cbd) - Added atlaskit docs to all existing plugins.
|
|
58
70
|
|
|
59
71
|
## 0.3.2
|
|
60
72
|
|
|
@@ -66,13 +78,13 @@
|
|
|
66
78
|
|
|
67
79
|
### Patch Changes
|
|
68
80
|
|
|
69
|
-
- [`3413f770f2b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3413f770f2b) - Moving references to floating-toolbar types to `editor-common`
|
|
81
|
+
- [#38389](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/38389) [`3413f770f2b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3413f770f2b) - Moving references to floating-toolbar types to `editor-common`
|
|
70
82
|
|
|
71
83
|
## 0.3.0
|
|
72
84
|
|
|
73
85
|
### Minor Changes
|
|
74
86
|
|
|
75
|
-
- [`31405891e32`](https://bitbucket.org/atlassian/atlassian-frontend/commits/31405891e32) - Extract editor disabled plugin as separate package.
|
|
87
|
+
- [#37702](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/37702) [`31405891e32`](https://bitbucket.org/atlassian/atlassian-frontend/commits/31405891e32) - Extract editor disabled plugin as separate package.
|
|
76
88
|
|
|
77
89
|
### Patch Changes
|
|
78
90
|
|
|
@@ -82,18 +94,18 @@
|
|
|
82
94
|
|
|
83
95
|
### Patch Changes
|
|
84
96
|
|
|
85
|
-
- [`4e6f1bf8511`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6f1bf8511) - [ED-19233] Import prosemirror libraries from internal facade package
|
|
97
|
+
- [#37785](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/37785) [`4e6f1bf8511`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6f1bf8511) - [ED-19233] Import prosemirror libraries from internal facade package
|
|
86
98
|
|
|
87
99
|
## 0.2.2
|
|
88
100
|
|
|
89
101
|
### Patch Changes
|
|
90
102
|
|
|
91
|
-
- [`73b5128036b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73b5128036b) - [ED-17082] Mark package as a singleton one
|
|
103
|
+
- [#35782](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/35782) [`73b5128036b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/73b5128036b) - [ED-17082] Mark package as a singleton one
|
|
92
104
|
- Updated dependencies
|
|
93
105
|
|
|
94
106
|
## 0.2.1
|
|
95
107
|
|
|
96
108
|
### Patch Changes
|
|
97
109
|
|
|
98
|
-
- [`87366c84531`](https://bitbucket.org/atlassian/atlassian-frontend/commits/87366c84531) - Extract context panel plugin to new package @atlaskit/editor-plugin-context-panel
|
|
110
|
+
- [#35475](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/35475) [`87366c84531`](https://bitbucket.org/atlassian/atlassian-frontend/commits/87366c84531) - Extract context panel plugin to new package @atlaskit/editor-plugin-context-panel
|
|
99
111
|
- Updated dependencies
|
package/README.md
CHANGED
|
@@ -27,4 +27,4 @@ Please see [Atlaskit - Editor plugin floating toolbar](https://atlaskit.atlassia
|
|
|
27
27
|
For internal Atlassian, visit the slack channel [#help-editor](https://atlassian.slack.com/archives/CFG3PSQ9E) for support or visit [go/editor-help](https://go/editor-help) to submit a bug.
|
|
28
28
|
## License
|
|
29
29
|
---
|
|
30
|
-
Please see [Atlassian Frontend - License](https://
|
|
30
|
+
Please see [Atlassian Frontend - License](https://hello.atlassian.net/wiki/spaces/AF/pages/2589099144/Documentation#License) for more licensing information.
|
package/dist/cjs/index.js
CHANGED
|
@@ -2,4 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
|
-
});
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "floatingToolbarPlugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _plugin.floatingToolbarPlugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _plugin = require("./plugin");
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.pluginKey = exports.getRelevantConfig = exports.floatingToolbarPlugin = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
12
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
+
var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
14
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
15
|
+
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
16
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
17
|
+
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
20
|
+
var _forceFocus = _interopRequireWildcard(require("./pm-plugins/force-focus"));
|
|
21
|
+
var _commands = require("./pm-plugins/toolbar-data/commands");
|
|
22
|
+
var _plugin = require("./pm-plugins/toolbar-data/plugin");
|
|
23
|
+
var _pluginKey = require("./pm-plugins/toolbar-data/plugin-key");
|
|
24
|
+
var _ConfirmationModal = require("./ui/ConfirmationModal");
|
|
25
|
+
var _ToolbarLoader = require("./ui/ToolbarLoader");
|
|
26
|
+
var _utils2 = require("./utils");
|
|
27
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
31
|
+
// AFP-2532 TODO: Fix automatic suppressions below
|
|
32
|
+
var getRelevantConfig = function getRelevantConfig(selection, configs) {
|
|
33
|
+
// node selections always take precedence, see if
|
|
34
|
+
var configPair;
|
|
35
|
+
configs.find(function (config) {
|
|
36
|
+
var node = (0, _utils.findSelectedNodeOfType)(config.nodeType)(selection);
|
|
37
|
+
if (node) {
|
|
38
|
+
configPair = {
|
|
39
|
+
node: node.node,
|
|
40
|
+
pos: node.pos,
|
|
41
|
+
config: config
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return !!node;
|
|
45
|
+
});
|
|
46
|
+
if (configPair) {
|
|
47
|
+
return configPair;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// create mapping of node type name to configs
|
|
51
|
+
var configByNodeType = {};
|
|
52
|
+
configs.forEach(function (config) {
|
|
53
|
+
if (Array.isArray(config.nodeType)) {
|
|
54
|
+
config.nodeType.forEach(function (nodeType) {
|
|
55
|
+
configByNodeType[nodeType.name] = config;
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
configByNodeType[config.nodeType.name] = config;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// search up the tree from selection
|
|
63
|
+
var $from = selection.$from;
|
|
64
|
+
for (var i = $from.depth; i > 0; i--) {
|
|
65
|
+
var node = $from.node(i);
|
|
66
|
+
var matchedConfig = configByNodeType[node.type.name];
|
|
67
|
+
if (matchedConfig) {
|
|
68
|
+
return {
|
|
69
|
+
config: matchedConfig,
|
|
70
|
+
node: node,
|
|
71
|
+
pos: $from.pos
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// if it is AllSelection (can be result of Cmd+A) - use first node
|
|
77
|
+
if (selection instanceof _state.AllSelection) {
|
|
78
|
+
var docNode = $from.node(0);
|
|
79
|
+
var _matchedConfig = null;
|
|
80
|
+
var firstChild = (0, _utils2.findNode)(docNode, function (node) {
|
|
81
|
+
_matchedConfig = configByNodeType[node.type.name];
|
|
82
|
+
return !!_matchedConfig;
|
|
83
|
+
});
|
|
84
|
+
if (firstChild && _matchedConfig) {
|
|
85
|
+
return {
|
|
86
|
+
config: _matchedConfig,
|
|
87
|
+
node: firstChild,
|
|
88
|
+
pos: $from.pos
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
};
|
|
94
|
+
exports.getRelevantConfig = getRelevantConfig;
|
|
95
|
+
var getDomRefFromSelection = function getDomRefFromSelection(view, dispatchAnalyticsEvent) {
|
|
96
|
+
try {
|
|
97
|
+
return (0, _utils.findDomRefAtPos)(view.state.selection.from, view.domAtPos.bind(view));
|
|
98
|
+
} catch (error) {
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.warn(error);
|
|
101
|
+
if (dispatchAnalyticsEvent) {
|
|
102
|
+
var payload = {
|
|
103
|
+
action: _analytics.ACTION.ERRORED,
|
|
104
|
+
actionSubject: _analytics.ACTION_SUBJECT.CONTENT_COMPONENT,
|
|
105
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
106
|
+
attributes: {
|
|
107
|
+
component: _analytics.CONTENT_COMPONENT.FLOATING_TOOLBAR,
|
|
108
|
+
selection: view.state.selection.toJSON(),
|
|
109
|
+
position: view.state.selection.from,
|
|
110
|
+
docSize: view.state.doc.nodeSize,
|
|
111
|
+
error: error.toString(),
|
|
112
|
+
errorStack: error.stack || undefined
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
dispatchAnalyticsEvent(payload);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function filterUndefined(x) {
|
|
120
|
+
return !!x;
|
|
121
|
+
}
|
|
122
|
+
var floatingToolbarPlugin = function floatingToolbarPlugin(_ref) {
|
|
123
|
+
var api = _ref.api;
|
|
124
|
+
return {
|
|
125
|
+
name: 'floatingToolbar',
|
|
126
|
+
pmPlugins: function pmPlugins() {
|
|
127
|
+
var floatingToolbarHandlers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
128
|
+
return [{
|
|
129
|
+
// Should be after all toolbar plugins
|
|
130
|
+
name: 'floatingToolbar',
|
|
131
|
+
plugin: function plugin(_ref2) {
|
|
132
|
+
var dispatch = _ref2.dispatch,
|
|
133
|
+
providerFactory = _ref2.providerFactory,
|
|
134
|
+
getIntl = _ref2.getIntl;
|
|
135
|
+
return floatingToolbarPluginFactory({
|
|
136
|
+
floatingToolbarHandlers: floatingToolbarHandlers,
|
|
137
|
+
dispatch: dispatch,
|
|
138
|
+
providerFactory: providerFactory,
|
|
139
|
+
getIntl: getIntl
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}, {
|
|
143
|
+
name: 'floatingToolbarData',
|
|
144
|
+
plugin: function plugin(_ref3) {
|
|
145
|
+
var dispatch = _ref3.dispatch;
|
|
146
|
+
return (0, _plugin.createPlugin)(dispatch);
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
name: 'forceFocus',
|
|
150
|
+
plugin: function plugin() {
|
|
151
|
+
return (0, _forceFocus.default)();
|
|
152
|
+
}
|
|
153
|
+
}];
|
|
154
|
+
},
|
|
155
|
+
actions: {
|
|
156
|
+
forceFocusSelector: _forceFocus.forceFocusSelector
|
|
157
|
+
},
|
|
158
|
+
getSharedState: function getSharedState(editorState) {
|
|
159
|
+
var _pluginKey$getState$g, _pluginKey$getState, _pluginKey$getState$g2;
|
|
160
|
+
if (!editorState) {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
var configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
|
|
164
|
+
return {
|
|
165
|
+
configWithNodeInfo: configWithNodeInfo,
|
|
166
|
+
floatingToolbarData: _pluginKey.pluginKey.getState(editorState)
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
contentComponent: function contentComponent(_ref4) {
|
|
170
|
+
var popupsMountPoint = _ref4.popupsMountPoint,
|
|
171
|
+
popupsBoundariesElement = _ref4.popupsBoundariesElement,
|
|
172
|
+
popupsScrollableElement = _ref4.popupsScrollableElement,
|
|
173
|
+
editorView = _ref4.editorView,
|
|
174
|
+
providerFactory = _ref4.providerFactory,
|
|
175
|
+
dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
176
|
+
return /*#__PURE__*/_react.default.createElement(ContentComponent, {
|
|
177
|
+
editorView: editorView,
|
|
178
|
+
pluginInjectionApi: api,
|
|
179
|
+
popupsMountPoint: popupsMountPoint,
|
|
180
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
181
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
182
|
+
providerFactory: providerFactory,
|
|
183
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
exports.floatingToolbarPlugin = floatingToolbarPlugin;
|
|
189
|
+
function ContentComponent(_ref5) {
|
|
190
|
+
var _pluginInjectionApi$f, _configWithNodeInfo$c, _configWithNodeInfo$c2;
|
|
191
|
+
var pluginInjectionApi = _ref5.pluginInjectionApi,
|
|
192
|
+
editorView = _ref5.editorView,
|
|
193
|
+
popupsMountPoint = _ref5.popupsMountPoint,
|
|
194
|
+
popupsBoundariesElement = _ref5.popupsBoundariesElement,
|
|
195
|
+
popupsScrollableElement = _ref5.popupsScrollableElement,
|
|
196
|
+
providerFactory = _ref5.providerFactory,
|
|
197
|
+
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
198
|
+
var featureFlags = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.sharedState.currentState()) || {};
|
|
199
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled']),
|
|
200
|
+
floatingToolbarState = _useSharedPluginState.floatingToolbarState,
|
|
201
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState;
|
|
202
|
+
var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
|
|
203
|
+
configWithNodeInfo = _ref6.configWithNodeInfo,
|
|
204
|
+
floatingToolbarData = _ref6.floatingToolbarData;
|
|
205
|
+
if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
var config = configWithNodeInfo.config,
|
|
209
|
+
node = configWithNodeInfo.node;
|
|
210
|
+
var title = config.title,
|
|
211
|
+
_config$getDomRef = config.getDomRef,
|
|
212
|
+
getDomRef = _config$getDomRef === void 0 ? getDomRefFromSelection : _config$getDomRef,
|
|
213
|
+
items = config.items,
|
|
214
|
+
_config$align = config.align,
|
|
215
|
+
align = _config$align === void 0 ? 'center' : _config$align,
|
|
216
|
+
_config$className = config.className,
|
|
217
|
+
className = _config$className === void 0 ? '' : _config$className,
|
|
218
|
+
height = config.height,
|
|
219
|
+
width = config.width,
|
|
220
|
+
zIndex = config.zIndex,
|
|
221
|
+
_config$offset = config.offset,
|
|
222
|
+
offset = _config$offset === void 0 ? [0, 12] : _config$offset,
|
|
223
|
+
forcePlacement = config.forcePlacement,
|
|
224
|
+
preventPopupOverflow = config.preventPopupOverflow,
|
|
225
|
+
onPositionCalculated = config.onPositionCalculated,
|
|
226
|
+
_config$absoluteOffse = config.absoluteOffset,
|
|
227
|
+
absoluteOffset = _config$absoluteOffse === void 0 ? {
|
|
228
|
+
top: 0,
|
|
229
|
+
left: 0,
|
|
230
|
+
right: 0,
|
|
231
|
+
bottom: 0
|
|
232
|
+
} : _config$absoluteOffse,
|
|
233
|
+
focusTrap = config.focusTrap;
|
|
234
|
+
var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
235
|
+
if (!targetRef || editorDisabledState && editorDisabledState.editorDisabled) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
var customPositionCalculation;
|
|
239
|
+
var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.copyButton.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions.hoverDecoration);
|
|
240
|
+
if (onPositionCalculated) {
|
|
241
|
+
customPositionCalculation = function customPositionCalculation(nextPos) {
|
|
242
|
+
return onPositionCalculated(editorView, nextPos);
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
var dispatchCommand = function dispatchCommand(fn) {
|
|
246
|
+
return fn && fn(editorView.state, editorView.dispatch, editorView);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
// Confirm dialog
|
|
250
|
+
var _ref7 = floatingToolbarData || {},
|
|
251
|
+
confirmDialogForItem = _ref7.confirmDialogForItem;
|
|
252
|
+
var confirmButtonItem = confirmDialogForItem ? toolbarItems[confirmDialogForItem] : undefined;
|
|
253
|
+
var scrollable = config.scrollable;
|
|
254
|
+
var confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
|
|
255
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
256
|
+
component: _analytics.ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
|
|
257
|
+
componentId: (0, _camelCase.default)(title),
|
|
258
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
259
|
+
fallbackComponent: null
|
|
260
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Popup, {
|
|
261
|
+
ariaLabel: title,
|
|
262
|
+
offset: offset,
|
|
263
|
+
target: targetRef,
|
|
264
|
+
alignY: "bottom",
|
|
265
|
+
forcePlacement: forcePlacement,
|
|
266
|
+
fitHeight: height,
|
|
267
|
+
fitWidth: width,
|
|
268
|
+
absoluteOffset: absoluteOffset,
|
|
269
|
+
alignX: align,
|
|
270
|
+
stick: true,
|
|
271
|
+
zIndex: zIndex,
|
|
272
|
+
mountTo: popupsMountPoint,
|
|
273
|
+
boundariesElement: popupsBoundariesElement,
|
|
274
|
+
scrollableElement: popupsScrollableElement,
|
|
275
|
+
onPositionCalculated: customPositionCalculation,
|
|
276
|
+
style: scrollable ? {
|
|
277
|
+
maxWidth: '100%'
|
|
278
|
+
} : {},
|
|
279
|
+
focusTrap: focusTrap,
|
|
280
|
+
preventOverflow: preventPopupOverflow
|
|
281
|
+
}, /*#__PURE__*/_react.default.createElement(_providerFactory.WithProviders, {
|
|
282
|
+
providerFactory: providerFactory,
|
|
283
|
+
providers: ['extensionProvider'],
|
|
284
|
+
renderNode: function renderNode(providers) {
|
|
285
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarLoader.ToolbarLoader, {
|
|
286
|
+
target: targetRef,
|
|
287
|
+
items: toolbarItems,
|
|
288
|
+
node: node,
|
|
289
|
+
dispatchCommand: dispatchCommand,
|
|
290
|
+
editorView: editorView,
|
|
291
|
+
className: className,
|
|
292
|
+
focusEditor: function focusEditor() {
|
|
293
|
+
return editorView.focus();
|
|
294
|
+
},
|
|
295
|
+
providerFactory: providerFactory,
|
|
296
|
+
popupsMountPoint: popupsMountPoint,
|
|
297
|
+
popupsBoundariesElement: popupsBoundariesElement,
|
|
298
|
+
popupsScrollableElement: popupsScrollableElement,
|
|
299
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
300
|
+
extensionsProvider: providers.extensionProvider,
|
|
301
|
+
scrollable: scrollable,
|
|
302
|
+
featureFlags: featureFlags,
|
|
303
|
+
api: pluginInjectionApi
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
})), /*#__PURE__*/_react.default.createElement(_ConfirmationModal.ConfirmationModal, {
|
|
307
|
+
testId: "ak-floating-toolbar-confirmation-modal",
|
|
308
|
+
options: confirmDialogOptions,
|
|
309
|
+
onConfirm: function onConfirm() {
|
|
310
|
+
var isChecked = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
311
|
+
if (!!confirmDialogOptions.onConfirm) {
|
|
312
|
+
dispatchCommand(confirmDialogOptions.onConfirm(isChecked));
|
|
313
|
+
} else {
|
|
314
|
+
dispatchCommand(confirmButtonItem.onClick);
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
onClose: function onClose() {
|
|
318
|
+
dispatchCommand((0, _commands.hideConfirmDialog)());
|
|
319
|
+
// Need to set focus to Editor here,
|
|
320
|
+
// As when the Confirmation dialog pop up, and user interacts with the dialog, Editor loses focus.
|
|
321
|
+
// So when Confirmation dialog is closed, Editor does not have the focus, then cursor goes to the position 1 of the doc,
|
|
322
|
+
// instead of the cursor position before the dialog pop up.
|
|
323
|
+
if (!editorView.hasFocus()) {
|
|
324
|
+
editorView.focus();
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
*
|
|
332
|
+
* ProseMirror Plugin
|
|
333
|
+
*
|
|
334
|
+
*/
|
|
335
|
+
// We throttle update of this plugin with RAF.
|
|
336
|
+
// So from other plugins you will always get the previous state.
|
|
337
|
+
var pluginKey = new _state.PluginKey('floatingToolbarPluginKey');
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Clean up floating toolbar configs from undesired properties.
|
|
341
|
+
*/
|
|
342
|
+
exports.pluginKey = pluginKey;
|
|
343
|
+
function sanitizeFloatingToolbarConfig(config) {
|
|
344
|
+
// Cleanup from non existing node types
|
|
345
|
+
if (Array.isArray(config.nodeType)) {
|
|
346
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
347
|
+
nodeType: config.nodeType.filter(filterUndefined)
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
return config;
|
|
351
|
+
}
|
|
352
|
+
function floatingToolbarPluginFactory(options) {
|
|
353
|
+
var floatingToolbarHandlers = options.floatingToolbarHandlers,
|
|
354
|
+
providerFactory = options.providerFactory,
|
|
355
|
+
getIntl = options.getIntl;
|
|
356
|
+
var intl = getIntl();
|
|
357
|
+
var getConfigWithNodeInfo = function getConfigWithNodeInfo(editorState) {
|
|
358
|
+
var activeConfigs = floatingToolbarHandlers.map(function (handler) {
|
|
359
|
+
return handler(editorState, intl, providerFactory);
|
|
360
|
+
}).filter(filterUndefined).map(function (config) {
|
|
361
|
+
return sanitizeFloatingToolbarConfig(config);
|
|
362
|
+
});
|
|
363
|
+
var relevantConfig = activeConfigs && getRelevantConfig(editorState.selection, activeConfigs);
|
|
364
|
+
return relevantConfig;
|
|
365
|
+
};
|
|
366
|
+
var apply = function apply(tr, pluginState) {
|
|
367
|
+
var newPluginState = {
|
|
368
|
+
getConfigWithNodeInfo: getConfigWithNodeInfo
|
|
369
|
+
};
|
|
370
|
+
return newPluginState;
|
|
371
|
+
};
|
|
372
|
+
return new _safePlugin.SafePlugin({
|
|
373
|
+
key: pluginKey,
|
|
374
|
+
state: {
|
|
375
|
+
init: function init() {
|
|
376
|
+
// Use this point to preload the UI
|
|
377
|
+
_ToolbarLoader.ToolbarLoader.preload();
|
|
378
|
+
return {
|
|
379
|
+
getConfigWithNodeInfo: getConfigWithNodeInfo
|
|
380
|
+
};
|
|
381
|
+
},
|
|
382
|
+
apply: apply
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkShouldForceFocusAndApply = checkShouldForceFocusAndApply;
|
|
7
|
+
exports.forceFocusStateKey = exports.forceFocusSelector = exports.default = void 0;
|
|
8
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var forceFocusStateKey = new _state.PluginKey('forceFocusStatePlugin');
|
|
11
|
+
/**
|
|
12
|
+
* Used in cases where a floating toolbar button opens a submenu which destroys
|
|
13
|
+
* the button, but the user has pressed ESC to close the submenu and focus needs
|
|
14
|
+
* to move back to the button. */
|
|
15
|
+
exports.forceFocusStateKey = forceFocusStateKey;
|
|
16
|
+
var _default = function _default() {
|
|
17
|
+
return new _safePlugin.SafePlugin({
|
|
18
|
+
key: forceFocusStateKey,
|
|
19
|
+
state: {
|
|
20
|
+
init: function init() {
|
|
21
|
+
return {
|
|
22
|
+
selector: null
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
apply: function apply(tr, prevState) {
|
|
26
|
+
var meta = tr.getMeta(forceFocusStateKey);
|
|
27
|
+
if (meta && 'selector' in meta) {
|
|
28
|
+
return {
|
|
29
|
+
selector: meta.selector
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return prevState;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The provided selector should be the floating toolbar button that needs focus.
|
|
39
|
+
*/
|
|
40
|
+
exports.default = _default;
|
|
41
|
+
var forceFocusSelector = function forceFocusSelector(selector) {
|
|
42
|
+
return function (tr) {
|
|
43
|
+
return tr.setMeta(forceFocusStateKey, {
|
|
44
|
+
selector: selector
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* If a selector is set and the element exists, focus it.
|
|
51
|
+
*/
|
|
52
|
+
exports.forceFocusSelector = forceFocusSelector;
|
|
53
|
+
function checkShouldForceFocusAndApply(view) {
|
|
54
|
+
var state = view === null || view === void 0 ? void 0 : view.state;
|
|
55
|
+
if (state) {
|
|
56
|
+
var _forceFocusStateKey$g = forceFocusStateKey.getState(state),
|
|
57
|
+
selector = _forceFocusStateKey$g.selector;
|
|
58
|
+
if (selector) {
|
|
59
|
+
var focusableElement = document.querySelector(selector);
|
|
60
|
+
if (focusableElement) {
|
|
61
|
+
focusableElement.scrollIntoView({
|
|
62
|
+
behavior: 'smooth',
|
|
63
|
+
block: 'center',
|
|
64
|
+
inline: 'nearest'
|
|
65
|
+
});
|
|
66
|
+
focusableElement.focus();
|
|
67
|
+
var tr = view.state.tr,
|
|
68
|
+
dispatch = view.dispatch;
|
|
69
|
+
dispatch(forceFocusSelector(null)(tr));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.showConfirmDialog = exports.hideConfirmDialog = void 0;
|
|
7
|
+
var _pluginFactory = require("./plugin-factory");
|
|
8
|
+
var showConfirmDialog = function showConfirmDialog(buttonIndex) {
|
|
9
|
+
return (0, _pluginFactory.createCommand)({
|
|
10
|
+
type: 'SHOW_CONFIRM_DIALOG',
|
|
11
|
+
data: {
|
|
12
|
+
buttonIndex: buttonIndex
|
|
13
|
+
}
|
|
14
|
+
}, function (tr) {
|
|
15
|
+
return tr.setMeta('addToHistory', false);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
exports.showConfirmDialog = showConfirmDialog;
|
|
19
|
+
var hideConfirmDialog = function hideConfirmDialog() {
|
|
20
|
+
return (0, _pluginFactory.createCommand)({
|
|
21
|
+
type: 'HIDE_CONFIRM_DIALOG'
|
|
22
|
+
}, function (tr) {
|
|
23
|
+
return tr.setMeta('addToHistory', false);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.hideConfirmDialog = hideConfirmDialog;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var _pluginKey = require("./plugin-key");
|
|
9
|
+
var _reducer = require("./reducer");
|
|
10
|
+
var _pluginFactory = (0, _utils.pluginFactory)(_pluginKey.pluginKey, _reducer.reducer),
|
|
11
|
+
createPluginState = _pluginFactory.createPluginState,
|
|
12
|
+
createCommand = _pluginFactory.createCommand,
|
|
13
|
+
getPluginState = _pluginFactory.getPluginState;
|
|
14
|
+
exports.getPluginState = getPluginState;
|
|
15
|
+
exports.createCommand = createCommand;
|
|
16
|
+
exports.createPluginState = createPluginState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pluginKey = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var pluginKey = new _state.PluginKey('floatingToolbarData');
|
|
9
|
+
exports.pluginKey = pluginKey;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPlugin = void 0;
|
|
7
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _pluginFactory = require("./plugin-factory");
|
|
9
|
+
var _pluginKey = require("./plugin-key");
|
|
10
|
+
var createPlugin = function createPlugin(dispatch) {
|
|
11
|
+
return new _safePlugin.SafePlugin({
|
|
12
|
+
state: (0, _pluginFactory.createPluginState)(dispatch, {}),
|
|
13
|
+
key: _pluginKey.pluginKey
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
exports.createPlugin = createPlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.reducer = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
var reducer = function reducer(pluginState, action) {
|
|
12
|
+
switch (action.type) {
|
|
13
|
+
case 'SHOW_CONFIRM_DIALOG':
|
|
14
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
15
|
+
confirmDialogForItem: action.data.buttonIndex
|
|
16
|
+
});
|
|
17
|
+
case 'HIDE_CONFIRM_DIALOG':
|
|
18
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
19
|
+
confirmDialogForItem: undefined
|
|
20
|
+
});
|
|
21
|
+
default:
|
|
22
|
+
return pluginState;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.reducer = reducer;
|