@atlaskit/editor-plugin-primary-toolbar 1.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.
Files changed (40) hide show
  1. package/.eslintrc.js +6 -0
  2. package/CHANGELOG.md +1 -0
  3. package/LICENSE.md +13 -0
  4. package/README.md +9 -0
  5. package/dist/cjs/commands.js +20 -0
  6. package/dist/cjs/index.js +12 -0
  7. package/dist/cjs/plugin.js +30 -0
  8. package/dist/cjs/pm-plugin.js +52 -0
  9. package/dist/cjs/toolbar-configuration.js +62 -0
  10. package/dist/cjs/types.js +5 -0
  11. package/dist/cjs/ui/separator.js +16 -0
  12. package/dist/es2019/commands.js +14 -0
  13. package/dist/es2019/index.js +1 -0
  14. package/dist/es2019/plugin.js +18 -0
  15. package/dist/es2019/pm-plugin.js +44 -0
  16. package/dist/es2019/toolbar-configuration.js +42 -0
  17. package/dist/es2019/types.js +1 -0
  18. package/dist/es2019/ui/separator.js +8 -0
  19. package/dist/esm/commands.js +14 -0
  20. package/dist/esm/index.js +1 -0
  21. package/dist/esm/plugin.js +24 -0
  22. package/dist/esm/pm-plugin.js +45 -0
  23. package/dist/esm/toolbar-configuration.js +56 -0
  24. package/dist/esm/types.js +1 -0
  25. package/dist/esm/ui/separator.js +10 -0
  26. package/dist/types/commands.d.ts +6 -0
  27. package/dist/types/index.d.ts +2 -0
  28. package/dist/types/plugin.d.ts +2 -0
  29. package/dist/types/pm-plugin.d.ts +8 -0
  30. package/dist/types/toolbar-configuration.d.ts +3 -0
  31. package/dist/types/types.d.ts +21 -0
  32. package/dist/types/ui/separator.d.ts +4 -0
  33. package/dist/types-ts4.5/commands.d.ts +6 -0
  34. package/dist/types-ts4.5/index.d.ts +2 -0
  35. package/dist/types-ts4.5/plugin.d.ts +2 -0
  36. package/dist/types-ts4.5/pm-plugin.d.ts +8 -0
  37. package/dist/types-ts4.5/toolbar-configuration.d.ts +3 -0
  38. package/dist/types-ts4.5/types.d.ts +21 -0
  39. package/dist/types-ts4.5/ui/separator.d.ts +4 -0
  40. package/package.json +88 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ rules: {
3
+ '@typescript-eslint/no-duplicate-imports': 'error',
4
+ '@typescript-eslint/no-explicit-any': 'error',
5
+ },
6
+ };
package/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # @atlaskit/editor-plugin-primary-toolbar
package/LICENSE.md ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Atlassian Pty Ltd
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # EditorPluginPrimaryToolbar
2
+
3
+ Primary toolbar plugin for @atlaskit/editor-core
4
+
5
+ ## Usage
6
+
7
+ `import EditorPluginPrimaryToolbar from '@atlaskit/editor-plugin-primary-toolbar';`
8
+
9
+ Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/editor/editor-plugin-primary-toolbar).
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.registerComponent = void 0;
7
+ var _pmPlugin = require("./pm-plugin");
8
+ var registerComponent = exports.registerComponent = function registerComponent(_ref) {
9
+ var name = _ref.name,
10
+ component = _ref.component;
11
+ return function (_ref2) {
12
+ var tr = _ref2.tr;
13
+ tr.setMeta(_pmPlugin.primaryToolbarPluginKey, {
14
+ type: _pmPlugin.PrimaryToolbarPluginAction.REGISTER,
15
+ name: name,
16
+ component: component
17
+ });
18
+ return tr;
19
+ };
20
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "primaryToolbarPlugin", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _plugin.primaryToolbarPlugin;
10
+ }
11
+ });
12
+ var _plugin = require("./plugin");
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.primaryToolbarPlugin = void 0;
7
+ var _commands = require("./commands");
8
+ var _pmPlugin = require("./pm-plugin");
9
+ var primaryToolbarPlugin = exports.primaryToolbarPlugin = function primaryToolbarPlugin() {
10
+ return {
11
+ name: 'primaryToolbar',
12
+ commands: {
13
+ registerComponent: _commands.registerComponent
14
+ },
15
+ pmPlugins: function pmPlugins() {
16
+ return [{
17
+ name: 'primaryToolbar',
18
+ plugin: function plugin() {
19
+ return (0, _pmPlugin.createPlugin)();
20
+ }
21
+ }];
22
+ },
23
+ getSharedState: function getSharedState(editorState) {
24
+ if (!editorState) {
25
+ return;
26
+ }
27
+ return _pmPlugin.primaryToolbarPluginKey.getState(editorState);
28
+ }
29
+ };
30
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.primaryToolbarPluginKey = exports.createPlugin = exports.PrimaryToolbarPluginAction = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
+ var _state = require("@atlaskit/editor-prosemirror/state");
11
+ var _toolbarConfiguration = require("./toolbar-configuration");
12
+ var _separator = _interopRequireDefault(require("./ui/separator"));
13
+ 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; }
14
+ 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; }
15
+ var primaryToolbarPluginKey = exports.primaryToolbarPluginKey = new _state.PluginKey('primaryToolbar');
16
+ var PrimaryToolbarPluginAction = exports.PrimaryToolbarPluginAction = /*#__PURE__*/function (PrimaryToolbarPluginAction) {
17
+ PrimaryToolbarPluginAction[PrimaryToolbarPluginAction["REGISTER"] = 0] = "REGISTER";
18
+ return PrimaryToolbarPluginAction;
19
+ }({});
20
+ var createPlugin = exports.createPlugin = function createPlugin() {
21
+ return new _safePlugin.SafePlugin({
22
+ key: primaryToolbarPluginKey,
23
+ state: {
24
+ init: function init() {
25
+ var componentRegistry = new Map();
26
+
27
+ // Pre-fill registry with the separator component
28
+ componentRegistry.set('separator', _separator.default);
29
+ return {
30
+ componentRegistry: componentRegistry,
31
+ components: []
32
+ };
33
+ },
34
+ apply: function apply(tr, pluginState) {
35
+ var _tr$getMeta;
36
+ var action = (_tr$getMeta = tr.getMeta(primaryToolbarPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
37
+ switch (action) {
38
+ case PrimaryToolbarPluginAction.REGISTER:
39
+ var _tr$getMeta2 = tr.getMeta(primaryToolbarPluginKey),
40
+ name = _tr$getMeta2.name,
41
+ component = _tr$getMeta2.component;
42
+ pluginState.componentRegistry.set(name, component);
43
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
44
+ components: (0, _toolbarConfiguration.getToolbarComponents)(pluginState)
45
+ });
46
+ default:
47
+ return pluginState;
48
+ }
49
+ }
50
+ }
51
+ });
52
+ };
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getToolbarComponents = void 0;
7
+ var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(pluginState) {
8
+ return toolbarConfiguration.filter(function (toolbarElement) {
9
+ return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(pluginState.componentRegistry);
10
+ }).reduce(function (acc, toolbarElement) {
11
+ if (pluginState.componentRegistry.has(toolbarElement.name)) {
12
+ var component = pluginState.componentRegistry.get(toolbarElement.name);
13
+ if (!!component) {
14
+ acc.push(component);
15
+ }
16
+ }
17
+ return acc;
18
+ }, []);
19
+ };
20
+ var undoRedoGroup = [{
21
+ name: 'undoRedoPlugin'
22
+ }, {
23
+ name: 'separator',
24
+ enabled: function enabled(componentRegistry) {
25
+ return componentRegistry.has('undoRedoPlugin');
26
+ }
27
+ }];
28
+ var blockTypeGroup = [{
29
+ name: 'blockType'
30
+ }, {
31
+ name: 'separator',
32
+ enabled: function enabled(componentRegistry) {
33
+ return componentRegistry.has('blockType');
34
+ }
35
+ }];
36
+ var textFormattingGroup = [{
37
+ name: 'textFormatting'
38
+ }, {
39
+ name: 'separator',
40
+ enabled: function enabled(componentRegistry) {
41
+ return componentRegistry.has('textFormatting');
42
+ }
43
+ }];
44
+ var alignmentGroup = [{
45
+ name: 'alignment'
46
+ }, {
47
+ name: 'separator',
48
+ enabled: function enabled(componentRegistry) {
49
+ return componentRegistry.has('alignment');
50
+ }
51
+ }];
52
+ var textColorGroup = [{
53
+ name: 'textColor'
54
+ }, {
55
+ name: 'highlight'
56
+ }, {
57
+ name: 'separator',
58
+ enabled: function enabled(componentRegistry) {
59
+ return componentRegistry.has('textColor') || componentRegistry.has('highlight');
60
+ }
61
+ }];
62
+ var toolbarConfiguration = [].concat(undoRedoGroup, blockTypeGroup, textFormattingGroup, alignmentGroup, textColorGroup);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("@emotion/react");
8
+ var _styles = require("@atlaskit/editor-common/styles");
9
+ /** @jsx jsx */
10
+ var _default = exports.default = function _default() {
11
+ return (0, _react.jsx)("span", {
12
+ css: _styles.wrapperStyle
13
+ }, (0, _react.jsx)("span", {
14
+ css: _styles.separatorStyles
15
+ }));
16
+ };
@@ -0,0 +1,14 @@
1
+ import { PrimaryToolbarPluginAction, primaryToolbarPluginKey } from './pm-plugin';
2
+ export const registerComponent = ({
3
+ name,
4
+ component
5
+ }) => ({
6
+ tr
7
+ }) => {
8
+ tr.setMeta(primaryToolbarPluginKey, {
9
+ type: PrimaryToolbarPluginAction.REGISTER,
10
+ name,
11
+ component
12
+ });
13
+ return tr;
14
+ };
@@ -0,0 +1 @@
1
+ export { primaryToolbarPlugin } from './plugin';
@@ -0,0 +1,18 @@
1
+ import { registerComponent } from './commands';
2
+ import { createPlugin, primaryToolbarPluginKey } from './pm-plugin';
3
+ export const primaryToolbarPlugin = () => ({
4
+ name: 'primaryToolbar',
5
+ commands: {
6
+ registerComponent
7
+ },
8
+ pmPlugins: () => [{
9
+ name: 'primaryToolbar',
10
+ plugin: () => createPlugin()
11
+ }],
12
+ getSharedState(editorState) {
13
+ if (!editorState) {
14
+ return;
15
+ }
16
+ return primaryToolbarPluginKey.getState(editorState);
17
+ }
18
+ });
@@ -0,0 +1,44 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import { getToolbarComponents } from './toolbar-configuration';
4
+ import Separator from './ui/separator';
5
+ export const primaryToolbarPluginKey = new PluginKey('primaryToolbar');
6
+ export let PrimaryToolbarPluginAction = /*#__PURE__*/function (PrimaryToolbarPluginAction) {
7
+ PrimaryToolbarPluginAction[PrimaryToolbarPluginAction["REGISTER"] = 0] = "REGISTER";
8
+ return PrimaryToolbarPluginAction;
9
+ }({});
10
+ export const createPlugin = () => {
11
+ return new SafePlugin({
12
+ key: primaryToolbarPluginKey,
13
+ state: {
14
+ init: () => {
15
+ const componentRegistry = new Map();
16
+
17
+ // Pre-fill registry with the separator component
18
+ componentRegistry.set('separator', Separator);
19
+ return {
20
+ componentRegistry,
21
+ components: []
22
+ };
23
+ },
24
+ apply: (tr, pluginState) => {
25
+ var _tr$getMeta;
26
+ const action = (_tr$getMeta = tr.getMeta(primaryToolbarPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
27
+ switch (action) {
28
+ case PrimaryToolbarPluginAction.REGISTER:
29
+ const {
30
+ name,
31
+ component
32
+ } = tr.getMeta(primaryToolbarPluginKey);
33
+ pluginState.componentRegistry.set(name, component);
34
+ return {
35
+ ...pluginState,
36
+ components: getToolbarComponents(pluginState)
37
+ };
38
+ default:
39
+ return pluginState;
40
+ }
41
+ }
42
+ }
43
+ });
44
+ };
@@ -0,0 +1,42 @@
1
+ export const getToolbarComponents = pluginState => toolbarConfiguration.filter(toolbarElement => typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(pluginState.componentRegistry)).reduce((acc, toolbarElement) => {
2
+ if (pluginState.componentRegistry.has(toolbarElement.name)) {
3
+ const component = pluginState.componentRegistry.get(toolbarElement.name);
4
+ if (!!component) {
5
+ acc.push(component);
6
+ }
7
+ }
8
+ return acc;
9
+ }, []);
10
+ const undoRedoGroup = [{
11
+ name: 'undoRedoPlugin'
12
+ }, {
13
+ name: 'separator',
14
+ enabled: componentRegistry => componentRegistry.has('undoRedoPlugin')
15
+ }];
16
+ const blockTypeGroup = [{
17
+ name: 'blockType'
18
+ }, {
19
+ name: 'separator',
20
+ enabled: componentRegistry => componentRegistry.has('blockType')
21
+ }];
22
+ const textFormattingGroup = [{
23
+ name: 'textFormatting'
24
+ }, {
25
+ name: 'separator',
26
+ enabled: componentRegistry => componentRegistry.has('textFormatting')
27
+ }];
28
+ const alignmentGroup = [{
29
+ name: 'alignment'
30
+ }, {
31
+ name: 'separator',
32
+ enabled: componentRegistry => componentRegistry.has('alignment')
33
+ }];
34
+ const textColorGroup = [{
35
+ name: 'textColor'
36
+ }, {
37
+ name: 'highlight'
38
+ }, {
39
+ name: 'separator',
40
+ enabled: componentRegistry => componentRegistry.has('textColor') || componentRegistry.has('highlight')
41
+ }];
42
+ const toolbarConfiguration = [...undoRedoGroup, ...blockTypeGroup, ...textFormattingGroup, ...alignmentGroup, ...textColorGroup];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
4
+ export default (() => jsx("span", {
5
+ css: wrapperStyle
6
+ }, jsx("span", {
7
+ css: separatorStyles
8
+ })));
@@ -0,0 +1,14 @@
1
+ import { PrimaryToolbarPluginAction, primaryToolbarPluginKey } from './pm-plugin';
2
+ export var registerComponent = function registerComponent(_ref) {
3
+ var name = _ref.name,
4
+ component = _ref.component;
5
+ return function (_ref2) {
6
+ var tr = _ref2.tr;
7
+ tr.setMeta(primaryToolbarPluginKey, {
8
+ type: PrimaryToolbarPluginAction.REGISTER,
9
+ name: name,
10
+ component: component
11
+ });
12
+ return tr;
13
+ };
14
+ };
@@ -0,0 +1 @@
1
+ export { primaryToolbarPlugin } from './plugin';
@@ -0,0 +1,24 @@
1
+ import { registerComponent } from './commands';
2
+ import { createPlugin, primaryToolbarPluginKey } from './pm-plugin';
3
+ export var primaryToolbarPlugin = function primaryToolbarPlugin() {
4
+ return {
5
+ name: 'primaryToolbar',
6
+ commands: {
7
+ registerComponent: registerComponent
8
+ },
9
+ pmPlugins: function pmPlugins() {
10
+ return [{
11
+ name: 'primaryToolbar',
12
+ plugin: function plugin() {
13
+ return createPlugin();
14
+ }
15
+ }];
16
+ },
17
+ getSharedState: function getSharedState(editorState) {
18
+ if (!editorState) {
19
+ return;
20
+ }
21
+ return primaryToolbarPluginKey.getState(editorState);
22
+ }
23
+ };
24
+ };
@@ -0,0 +1,45 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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) { _defineProperty(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; }
4
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
+ import { getToolbarComponents } from './toolbar-configuration';
7
+ import Separator from './ui/separator';
8
+ export var primaryToolbarPluginKey = new PluginKey('primaryToolbar');
9
+ export var PrimaryToolbarPluginAction = /*#__PURE__*/function (PrimaryToolbarPluginAction) {
10
+ PrimaryToolbarPluginAction[PrimaryToolbarPluginAction["REGISTER"] = 0] = "REGISTER";
11
+ return PrimaryToolbarPluginAction;
12
+ }({});
13
+ export var createPlugin = function createPlugin() {
14
+ return new SafePlugin({
15
+ key: primaryToolbarPluginKey,
16
+ state: {
17
+ init: function init() {
18
+ var componentRegistry = new Map();
19
+
20
+ // Pre-fill registry with the separator component
21
+ componentRegistry.set('separator', Separator);
22
+ return {
23
+ componentRegistry: componentRegistry,
24
+ components: []
25
+ };
26
+ },
27
+ apply: function apply(tr, pluginState) {
28
+ var _tr$getMeta;
29
+ var action = (_tr$getMeta = tr.getMeta(primaryToolbarPluginKey)) === null || _tr$getMeta === void 0 ? void 0 : _tr$getMeta.type;
30
+ switch (action) {
31
+ case PrimaryToolbarPluginAction.REGISTER:
32
+ var _tr$getMeta2 = tr.getMeta(primaryToolbarPluginKey),
33
+ name = _tr$getMeta2.name,
34
+ component = _tr$getMeta2.component;
35
+ pluginState.componentRegistry.set(name, component);
36
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
37
+ components: getToolbarComponents(pluginState)
38
+ });
39
+ default:
40
+ return pluginState;
41
+ }
42
+ }
43
+ }
44
+ });
45
+ };
@@ -0,0 +1,56 @@
1
+ export var getToolbarComponents = function getToolbarComponents(pluginState) {
2
+ return toolbarConfiguration.filter(function (toolbarElement) {
3
+ return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(pluginState.componentRegistry);
4
+ }).reduce(function (acc, toolbarElement) {
5
+ if (pluginState.componentRegistry.has(toolbarElement.name)) {
6
+ var component = pluginState.componentRegistry.get(toolbarElement.name);
7
+ if (!!component) {
8
+ acc.push(component);
9
+ }
10
+ }
11
+ return acc;
12
+ }, []);
13
+ };
14
+ var undoRedoGroup = [{
15
+ name: 'undoRedoPlugin'
16
+ }, {
17
+ name: 'separator',
18
+ enabled: function enabled(componentRegistry) {
19
+ return componentRegistry.has('undoRedoPlugin');
20
+ }
21
+ }];
22
+ var blockTypeGroup = [{
23
+ name: 'blockType'
24
+ }, {
25
+ name: 'separator',
26
+ enabled: function enabled(componentRegistry) {
27
+ return componentRegistry.has('blockType');
28
+ }
29
+ }];
30
+ var textFormattingGroup = [{
31
+ name: 'textFormatting'
32
+ }, {
33
+ name: 'separator',
34
+ enabled: function enabled(componentRegistry) {
35
+ return componentRegistry.has('textFormatting');
36
+ }
37
+ }];
38
+ var alignmentGroup = [{
39
+ name: 'alignment'
40
+ }, {
41
+ name: 'separator',
42
+ enabled: function enabled(componentRegistry) {
43
+ return componentRegistry.has('alignment');
44
+ }
45
+ }];
46
+ var textColorGroup = [{
47
+ name: 'textColor'
48
+ }, {
49
+ name: 'highlight'
50
+ }, {
51
+ name: 'separator',
52
+ enabled: function enabled(componentRegistry) {
53
+ return componentRegistry.has('textColor') || componentRegistry.has('highlight');
54
+ }
55
+ }];
56
+ var toolbarConfiguration = [].concat(undoRedoGroup, blockTypeGroup, textFormattingGroup, alignmentGroup, textColorGroup);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
4
+ export default (function () {
5
+ return jsx("span", {
6
+ css: wrapperStyle
7
+ }, jsx("span", {
8
+ css: separatorStyles
9
+ }));
10
+ });
@@ -0,0 +1,6 @@
1
+ import type { EditorCommand, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { ToolbarElementNames } from './types';
3
+ export declare const registerComponent: ({ name, component, }: {
4
+ name: ToolbarElementNames;
5
+ component: ToolbarUIComponentFactory;
6
+ }) => EditorCommand;
@@ -0,0 +1,2 @@
1
+ export { primaryToolbarPlugin } from './plugin';
2
+ export type { PrimaryToolbarPlugin, PrimaryToolbarPluginState, ToolbarElementNames, } from './types';
@@ -0,0 +1,2 @@
1
+ import type { PrimaryToolbarPlugin } from './types';
2
+ export declare const primaryToolbarPlugin: PrimaryToolbarPlugin;
@@ -0,0 +1,8 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import type { PrimaryToolbarPluginState } from './types';
4
+ export declare const primaryToolbarPluginKey: PluginKey<PrimaryToolbarPluginState>;
5
+ export declare enum PrimaryToolbarPluginAction {
6
+ REGISTER = 0
7
+ }
8
+ export declare const createPlugin: () => SafePlugin<PrimaryToolbarPluginState>;
@@ -0,0 +1,3 @@
1
+ import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { PrimaryToolbarPluginState } from './types';
3
+ export declare const getToolbarComponents: (pluginState: PrimaryToolbarPluginState) => ToolbarUIComponentFactory[];
@@ -0,0 +1,21 @@
1
+ import type { EditorCommand, NextEditorPlugin, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
3
+ sharedState: PrimaryToolbarPluginState | undefined;
4
+ commands: {
5
+ registerComponent: ({ name, component, }: {
6
+ name: ToolbarElementNames;
7
+ component: ToolbarUIComponentFactory;
8
+ }) => EditorCommand;
9
+ };
10
+ }>;
11
+ type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
12
+ export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight';
13
+ export type ToolbarElementConfig = {
14
+ name: ToolbarElementNames;
15
+ enabled?: (componentRegistry: ComponentRegistry) => boolean;
16
+ };
17
+ export type PrimaryToolbarPluginState = {
18
+ componentRegistry: ComponentRegistry;
19
+ components: ToolbarUIComponentFactory[];
20
+ };
21
+ export {};
@@ -0,0 +1,4 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ declare const _default: () => jsx.JSX.Element;
4
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import type { EditorCommand, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { ToolbarElementNames } from './types';
3
+ export declare const registerComponent: ({ name, component, }: {
4
+ name: ToolbarElementNames;
5
+ component: ToolbarUIComponentFactory;
6
+ }) => EditorCommand;
@@ -0,0 +1,2 @@
1
+ export { primaryToolbarPlugin } from './plugin';
2
+ export type { PrimaryToolbarPlugin, PrimaryToolbarPluginState, ToolbarElementNames, } from './types';
@@ -0,0 +1,2 @@
1
+ import type { PrimaryToolbarPlugin } from './types';
2
+ export declare const primaryToolbarPlugin: PrimaryToolbarPlugin;
@@ -0,0 +1,8 @@
1
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
+ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
+ import type { PrimaryToolbarPluginState } from './types';
4
+ export declare const primaryToolbarPluginKey: PluginKey<PrimaryToolbarPluginState>;
5
+ export declare enum PrimaryToolbarPluginAction {
6
+ REGISTER = 0
7
+ }
8
+ export declare const createPlugin: () => SafePlugin<PrimaryToolbarPluginState>;
@@ -0,0 +1,3 @@
1
+ import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { PrimaryToolbarPluginState } from './types';
3
+ export declare const getToolbarComponents: (pluginState: PrimaryToolbarPluginState) => ToolbarUIComponentFactory[];
@@ -0,0 +1,21 @@
1
+ import type { EditorCommand, NextEditorPlugin, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
3
+ sharedState: PrimaryToolbarPluginState | undefined;
4
+ commands: {
5
+ registerComponent: ({ name, component, }: {
6
+ name: ToolbarElementNames;
7
+ component: ToolbarUIComponentFactory;
8
+ }) => EditorCommand;
9
+ };
10
+ }>;
11
+ type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
12
+ export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight';
13
+ export type ToolbarElementConfig = {
14
+ name: ToolbarElementNames;
15
+ enabled?: (componentRegistry: ComponentRegistry) => boolean;
16
+ };
17
+ export type PrimaryToolbarPluginState = {
18
+ componentRegistry: ComponentRegistry;
19
+ components: ToolbarUIComponentFactory[];
20
+ };
21
+ export {};
@@ -0,0 +1,4 @@
1
+ /** @jsx jsx */
2
+ import { jsx } from '@emotion/react';
3
+ declare const _default: () => jsx.JSX.Element;
4
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@atlaskit/editor-plugin-primary-toolbar",
3
+ "version": "1.1.0",
4
+ "description": "Primary toolbar plugin for @atlaskit/editor-core",
5
+ "author": "Atlassian Pty Ltd",
6
+ "license": "Apache-2.0",
7
+ "publishConfig": {
8
+ "registry": "https://registry.npmjs.org/"
9
+ },
10
+ "atlassian": {
11
+ "team": "Editor: Core Experiences",
12
+ "inPublicMirror": false,
13
+ "releaseModel": "continuous",
14
+ "website": {
15
+ "name": "EditorPluginPrimaryToolbar",
16
+ "category": "Components"
17
+ },
18
+ "runReact18": false
19
+ },
20
+ "repository": "https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo",
21
+ "main": "dist/cjs/index.js",
22
+ "module": "dist/esm/index.js",
23
+ "module:es2019": "dist/es2019/index.js",
24
+ "types": "dist/types/index.d.ts",
25
+ "typesVersions": {
26
+ ">=4.5 <5.4": {
27
+ "*": [
28
+ "dist/types-ts4.5/*",
29
+ "dist/types-ts4.5/index.d.ts"
30
+ ]
31
+ }
32
+ },
33
+ "sideEffects": [
34
+ "*.compiled.css"
35
+ ],
36
+ "atlaskit:src": "src/index.ts",
37
+ "af:exports": {
38
+ ".": "./src/index.ts"
39
+ },
40
+ "dependencies": {
41
+ "@atlaskit/editor-common": "^81.0.0",
42
+ "@atlaskit/editor-prosemirror": "4.0.1",
43
+ "@babel/runtime": "^7.0.0",
44
+ "@emotion/react": "^11.7.1"
45
+ },
46
+ "peerDependencies": {
47
+ "react": "^16.8.0"
48
+ },
49
+ "devDependencies": {
50
+ "@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
51
+ "typescript": "~5.4.2"
52
+ },
53
+ "techstack": {
54
+ "@atlassian/frontend": {
55
+ "import-structure": [
56
+ "atlassian-conventions"
57
+ ],
58
+ "circular-dependencies": [
59
+ "file-and-folder-level"
60
+ ]
61
+ },
62
+ "@repo/internal": {
63
+ "dom-events": "use-bind-event-listener",
64
+ "analytics": [
65
+ "analytics-next"
66
+ ],
67
+ "design-tokens": [
68
+ "color"
69
+ ],
70
+ "theming": [
71
+ "react-context"
72
+ ],
73
+ "ui-components": [
74
+ "lite-mode"
75
+ ],
76
+ "deprecation": [
77
+ "no-deprecated-imports"
78
+ ],
79
+ "styling": [
80
+ "emotion"
81
+ ],
82
+ "imports": [
83
+ "import-no-extraneous-disable-for-examples-and-docs"
84
+ ]
85
+ }
86
+ },
87
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
88
+ }