@atlaskit/editor-plugin-primary-toolbar 1.3.2 → 2.0.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 +10 -0
- package/dist/cjs/actions.js +13 -0
- package/dist/cjs/plugin.js +13 -4
- package/dist/cjs/pm-plugin.js +5 -32
- package/dist/cjs/toolbar-configuration.js +4 -4
- package/dist/es2019/actions.js +6 -0
- package/dist/es2019/plugin.js +25 -15
- package/dist/es2019/pm-plugin.js +5 -34
- package/dist/es2019/toolbar-configuration.js +3 -3
- package/dist/esm/actions.js +7 -0
- package/dist/esm/plugin.js +12 -4
- package/dist/esm/pm-plugin.js +4 -30
- package/dist/esm/toolbar-configuration.js +4 -4
- package/dist/types/actions.d.ts +6 -0
- package/dist/types/pm-plugin.d.ts +2 -5
- package/dist/types/toolbar-configuration.d.ts +2 -2
- package/dist/types/types.d.ts +4 -6
- package/dist/types-ts4.5/actions.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugin.d.ts +2 -5
- package/dist/types-ts4.5/toolbar-configuration.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +4 -6
- package/package.json +2 -2
- package/dist/cjs/commands.js +0 -20
- package/dist/es2019/commands.js +0 -14
- package/dist/esm/commands.js +0 -14
- package/dist/types/commands.d.ts +0 -6
- package/dist/types-ts4.5/commands.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-primary-toolbar
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#126478](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/126478)
|
|
8
|
+
[`ca1665ebbfe4d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ca1665ebbfe4d) -
|
|
9
|
+
[ED-23435] Store primary toolbar component registry in a plugin variable instead of in plugin
|
|
10
|
+
state to avoid having to add effects to all plugins and enable SSR for the toolbar. [Breaking
|
|
11
|
+
change] Converted registerComponent from the primary toolbar plugin into an action.
|
|
12
|
+
|
|
3
13
|
## 1.3.2
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.registerComponent = void 0;
|
|
7
|
+
var registerComponent = exports.registerComponent = function registerComponent(componentRegistry) {
|
|
8
|
+
return function (_ref) {
|
|
9
|
+
var name = _ref.name,
|
|
10
|
+
component = _ref.component;
|
|
11
|
+
componentRegistry.set(name, component);
|
|
12
|
+
};
|
|
13
|
+
};
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.primaryToolbarPlugin = void 0;
|
|
7
|
-
var
|
|
8
|
+
var _actions = require("./actions");
|
|
8
9
|
var _pmPlugin = require("./pm-plugin");
|
|
10
|
+
var _separator = _interopRequireDefault(require("./ui/separator"));
|
|
9
11
|
var primaryToolbarPlugin = exports.primaryToolbarPlugin = function primaryToolbarPlugin() {
|
|
12
|
+
// We use a plugin variable to store the component registry to avoid having to use
|
|
13
|
+
// effects in each plugin, and to enable rendering the toolbar in SSR
|
|
14
|
+
// TODO: Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation
|
|
15
|
+
var componentRegistry = new Map();
|
|
16
|
+
|
|
17
|
+
// Pre-fill registry with the separator component
|
|
18
|
+
componentRegistry.set('separator', _separator.default);
|
|
10
19
|
return {
|
|
11
20
|
name: 'primaryToolbar',
|
|
12
|
-
|
|
13
|
-
registerComponent:
|
|
21
|
+
actions: {
|
|
22
|
+
registerComponent: (0, _actions.registerComponent)(componentRegistry)
|
|
14
23
|
},
|
|
15
24
|
pmPlugins: function pmPlugins() {
|
|
16
25
|
return [{
|
|
17
26
|
name: 'primaryToolbar',
|
|
18
27
|
plugin: function plugin() {
|
|
19
|
-
return (0, _pmPlugin.createPlugin)();
|
|
28
|
+
return (0, _pmPlugin.createPlugin)(componentRegistry);
|
|
20
29
|
}
|
|
21
30
|
}];
|
|
22
31
|
},
|
package/dist/cjs/pm-plugin.js
CHANGED
|
@@ -1,51 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.primaryToolbarPluginKey = exports.createPlugin =
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
6
|
+
exports.primaryToolbarPluginKey = exports.createPlugin = void 0;
|
|
9
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
9
|
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
10
|
var primaryToolbarPluginKey = exports.primaryToolbarPluginKey = new _state.PluginKey('primaryToolbar');
|
|
16
|
-
var
|
|
17
|
-
PrimaryToolbarPluginAction[PrimaryToolbarPluginAction["REGISTER"] = 0] = "REGISTER";
|
|
18
|
-
return PrimaryToolbarPluginAction;
|
|
19
|
-
}({});
|
|
20
|
-
var createPlugin = exports.createPlugin = function createPlugin() {
|
|
11
|
+
var createPlugin = exports.createPlugin = function createPlugin(componentRegistry) {
|
|
21
12
|
return new _safePlugin.SafePlugin({
|
|
22
13
|
key: primaryToolbarPluginKey,
|
|
23
14
|
state: {
|
|
24
15
|
init: function init() {
|
|
25
|
-
var componentRegistry = new Map();
|
|
26
|
-
|
|
27
|
-
// Pre-fill registry with the separator component
|
|
28
|
-
componentRegistry.set('separator', _separator.default);
|
|
29
16
|
return {
|
|
30
|
-
|
|
31
|
-
components: []
|
|
17
|
+
components: (0, _toolbarConfiguration.getToolbarComponents)(componentRegistry)
|
|
32
18
|
};
|
|
33
19
|
},
|
|
34
|
-
apply: function apply(
|
|
35
|
-
|
|
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
|
-
}
|
|
20
|
+
apply: function apply(_tr, pluginState) {
|
|
21
|
+
return pluginState;
|
|
49
22
|
}
|
|
50
23
|
}
|
|
51
24
|
});
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getToolbarComponents = void 0;
|
|
7
|
-
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(
|
|
7
|
+
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(componentRegistry) {
|
|
8
8
|
return toolbarConfiguration.filter(function (toolbarElement) {
|
|
9
|
-
return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(
|
|
9
|
+
return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry);
|
|
10
10
|
}).reduce(function (acc, toolbarElement) {
|
|
11
|
-
if (
|
|
12
|
-
var component =
|
|
11
|
+
if (componentRegistry.has(toolbarElement.name)) {
|
|
12
|
+
var component = componentRegistry.get(toolbarElement.name);
|
|
13
13
|
if (!!component) {
|
|
14
14
|
acc.push(component);
|
|
15
15
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
import { registerComponent } from './
|
|
1
|
+
import { registerComponent } from './actions';
|
|
2
2
|
import { createPlugin, primaryToolbarPluginKey } from './pm-plugin';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import Separator from './ui/separator';
|
|
4
|
+
export const primaryToolbarPlugin = () => {
|
|
5
|
+
// We use a plugin variable to store the component registry to avoid having to use
|
|
6
|
+
// effects in each plugin, and to enable rendering the toolbar in SSR
|
|
7
|
+
// TODO: Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation
|
|
8
|
+
const componentRegistry = new Map();
|
|
9
|
+
|
|
10
|
+
// Pre-fill registry with the separator component
|
|
11
|
+
componentRegistry.set('separator', Separator);
|
|
12
|
+
return {
|
|
9
13
|
name: 'primaryToolbar',
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
actions: {
|
|
15
|
+
registerComponent: registerComponent(componentRegistry)
|
|
16
|
+
},
|
|
17
|
+
pmPlugins: () => [{
|
|
18
|
+
name: 'primaryToolbar',
|
|
19
|
+
plugin: () => createPlugin(componentRegistry)
|
|
20
|
+
}],
|
|
21
|
+
getSharedState(editorState) {
|
|
22
|
+
if (!editorState) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
return primaryToolbarPluginKey.getState(editorState);
|
|
15
26
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
27
|
+
};
|
|
28
|
+
};
|
package/dist/es2019/pm-plugin.js
CHANGED
|
@@ -1,44 +1,15 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { getToolbarComponents } from './toolbar-configuration';
|
|
4
|
-
import Separator from './ui/separator';
|
|
5
4
|
export const primaryToolbarPluginKey = new PluginKey('primaryToolbar');
|
|
6
|
-
export
|
|
7
|
-
PrimaryToolbarPluginAction[PrimaryToolbarPluginAction["REGISTER"] = 0] = "REGISTER";
|
|
8
|
-
return PrimaryToolbarPluginAction;
|
|
9
|
-
}({});
|
|
10
|
-
export const createPlugin = () => {
|
|
5
|
+
export const createPlugin = componentRegistry => {
|
|
11
6
|
return new SafePlugin({
|
|
12
7
|
key: primaryToolbarPluginKey,
|
|
13
8
|
state: {
|
|
14
|
-
init: () => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
}
|
|
9
|
+
init: () => ({
|
|
10
|
+
components: getToolbarComponents(componentRegistry)
|
|
11
|
+
}),
|
|
12
|
+
apply: (_tr, pluginState) => pluginState
|
|
42
13
|
}
|
|
43
14
|
});
|
|
44
15
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const getToolbarComponents =
|
|
2
|
-
if (
|
|
3
|
-
const component =
|
|
1
|
+
export const getToolbarComponents = componentRegistry => toolbarConfiguration.filter(toolbarElement => typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry)).reduce((acc, toolbarElement) => {
|
|
2
|
+
if (componentRegistry.has(toolbarElement.name)) {
|
|
3
|
+
const component = componentRegistry.get(toolbarElement.name);
|
|
4
4
|
if (!!component) {
|
|
5
5
|
acc.push(component);
|
|
6
6
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { registerComponent } from './
|
|
1
|
+
import { registerComponent } from './actions';
|
|
2
2
|
import { createPlugin, primaryToolbarPluginKey } from './pm-plugin';
|
|
3
|
+
import Separator from './ui/separator';
|
|
3
4
|
export var primaryToolbarPlugin = function primaryToolbarPlugin() {
|
|
5
|
+
// We use a plugin variable to store the component registry to avoid having to use
|
|
6
|
+
// effects in each plugin, and to enable rendering the toolbar in SSR
|
|
7
|
+
// TODO: Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation
|
|
8
|
+
var componentRegistry = new Map();
|
|
9
|
+
|
|
10
|
+
// Pre-fill registry with the separator component
|
|
11
|
+
componentRegistry.set('separator', Separator);
|
|
4
12
|
return {
|
|
5
13
|
name: 'primaryToolbar',
|
|
6
|
-
|
|
7
|
-
registerComponent: registerComponent
|
|
14
|
+
actions: {
|
|
15
|
+
registerComponent: registerComponent(componentRegistry)
|
|
8
16
|
},
|
|
9
17
|
pmPlugins: function pmPlugins() {
|
|
10
18
|
return [{
|
|
11
19
|
name: 'primaryToolbar',
|
|
12
20
|
plugin: function plugin() {
|
|
13
|
-
return createPlugin();
|
|
21
|
+
return createPlugin(componentRegistry);
|
|
14
22
|
}
|
|
15
23
|
}];
|
|
16
24
|
},
|
package/dist/esm/pm-plugin.js
CHANGED
|
@@ -1,44 +1,18 @@
|
|
|
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
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
3
|
import { getToolbarComponents } from './toolbar-configuration';
|
|
7
|
-
import Separator from './ui/separator';
|
|
8
4
|
export var primaryToolbarPluginKey = new PluginKey('primaryToolbar');
|
|
9
|
-
export var
|
|
10
|
-
PrimaryToolbarPluginAction[PrimaryToolbarPluginAction["REGISTER"] = 0] = "REGISTER";
|
|
11
|
-
return PrimaryToolbarPluginAction;
|
|
12
|
-
}({});
|
|
13
|
-
export var createPlugin = function createPlugin() {
|
|
5
|
+
export var createPlugin = function createPlugin(componentRegistry) {
|
|
14
6
|
return new SafePlugin({
|
|
15
7
|
key: primaryToolbarPluginKey,
|
|
16
8
|
state: {
|
|
17
9
|
init: function init() {
|
|
18
|
-
var componentRegistry = new Map();
|
|
19
|
-
|
|
20
|
-
// Pre-fill registry with the separator component
|
|
21
|
-
componentRegistry.set('separator', Separator);
|
|
22
10
|
return {
|
|
23
|
-
|
|
24
|
-
components: []
|
|
11
|
+
components: getToolbarComponents(componentRegistry)
|
|
25
12
|
};
|
|
26
13
|
},
|
|
27
|
-
apply: function apply(
|
|
28
|
-
|
|
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
|
-
}
|
|
14
|
+
apply: function apply(_tr, pluginState) {
|
|
15
|
+
return pluginState;
|
|
42
16
|
}
|
|
43
17
|
}
|
|
44
18
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export var getToolbarComponents = function getToolbarComponents(
|
|
1
|
+
export var getToolbarComponents = function getToolbarComponents(componentRegistry) {
|
|
2
2
|
return toolbarConfiguration.filter(function (toolbarElement) {
|
|
3
|
-
return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(
|
|
3
|
+
return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry);
|
|
4
4
|
}).reduce(function (acc, toolbarElement) {
|
|
5
|
-
if (
|
|
6
|
-
var component =
|
|
5
|
+
if (componentRegistry.has(toolbarElement.name)) {
|
|
6
|
+
var component = componentRegistry.get(toolbarElement.name);
|
|
7
7
|
if (!!component) {
|
|
8
8
|
acc.push(component);
|
|
9
9
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ComponentRegistry, ToolbarElementNames } from './types';
|
|
3
|
+
export declare const registerComponent: (componentRegistry: ComponentRegistry) => ({ name, component, }: {
|
|
4
|
+
name: ToolbarElementNames;
|
|
5
|
+
component: ToolbarUIComponentFactory;
|
|
6
|
+
}) => void;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { PrimaryToolbarPluginState } from './types';
|
|
3
|
+
import type { ComponentRegistry, PrimaryToolbarPluginState } from './types';
|
|
4
4
|
export declare const primaryToolbarPluginKey: PluginKey<PrimaryToolbarPluginState>;
|
|
5
|
-
export declare
|
|
6
|
-
REGISTER = 0
|
|
7
|
-
}
|
|
8
|
-
export declare const createPlugin: () => SafePlugin<PrimaryToolbarPluginState>;
|
|
5
|
+
export declare const createPlugin: (componentRegistry: ComponentRegistry) => SafePlugin<PrimaryToolbarPluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const getToolbarComponents: (
|
|
2
|
+
import type { ComponentRegistry } from './types';
|
|
3
|
+
export declare const getToolbarComponents: (componentRegistry: ComponentRegistry) => ToolbarUIComponentFactory[];
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NextEditorPlugin, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
2
|
export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
|
|
3
3
|
sharedState: PrimaryToolbarPluginState | undefined;
|
|
4
|
-
|
|
4
|
+
actions: {
|
|
5
5
|
registerComponent: ({ name, component, }: {
|
|
6
6
|
name: ToolbarElementNames;
|
|
7
7
|
component: ToolbarUIComponentFactory;
|
|
8
|
-
}) =>
|
|
8
|
+
}) => void;
|
|
9
9
|
};
|
|
10
10
|
}>;
|
|
11
|
-
type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
|
|
11
|
+
export type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
|
|
12
12
|
export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight' | 'toolbarListsIndentation' | 'insertBlock' | 'beforePrimaryToolbar' | 'avatarGroup' | 'findReplace' | 'aiExperience' | 'loom' | 'spellCheck';
|
|
13
13
|
export type ToolbarElementConfig = {
|
|
14
14
|
name: ToolbarElementNames;
|
|
15
15
|
enabled?: (componentRegistry: ComponentRegistry) => boolean;
|
|
16
16
|
};
|
|
17
17
|
export type PrimaryToolbarPluginState = {
|
|
18
|
-
componentRegistry: ComponentRegistry;
|
|
19
18
|
components: ToolbarUIComponentFactory[];
|
|
20
19
|
};
|
|
21
|
-
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { ComponentRegistry, ToolbarElementNames } from './types';
|
|
3
|
+
export declare const registerComponent: (componentRegistry: ComponentRegistry) => ({ name, component, }: {
|
|
4
|
+
name: ToolbarElementNames;
|
|
5
|
+
component: ToolbarUIComponentFactory;
|
|
6
|
+
}) => void;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { PrimaryToolbarPluginState } from './types';
|
|
3
|
+
import type { ComponentRegistry, PrimaryToolbarPluginState } from './types';
|
|
4
4
|
export declare const primaryToolbarPluginKey: PluginKey<PrimaryToolbarPluginState>;
|
|
5
|
-
export declare
|
|
6
|
-
REGISTER = 0
|
|
7
|
-
}
|
|
8
|
-
export declare const createPlugin: () => SafePlugin<PrimaryToolbarPluginState>;
|
|
5
|
+
export declare const createPlugin: (componentRegistry: ComponentRegistry) => SafePlugin<PrimaryToolbarPluginState>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const getToolbarComponents: (
|
|
2
|
+
import type { ComponentRegistry } from './types';
|
|
3
|
+
export declare const getToolbarComponents: (componentRegistry: ComponentRegistry) => ToolbarUIComponentFactory[];
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NextEditorPlugin, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
2
|
export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
|
|
3
3
|
sharedState: PrimaryToolbarPluginState | undefined;
|
|
4
|
-
|
|
4
|
+
actions: {
|
|
5
5
|
registerComponent: ({ name, component, }: {
|
|
6
6
|
name: ToolbarElementNames;
|
|
7
7
|
component: ToolbarUIComponentFactory;
|
|
8
|
-
}) =>
|
|
8
|
+
}) => void;
|
|
9
9
|
};
|
|
10
10
|
}>;
|
|
11
|
-
type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
|
|
11
|
+
export type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
|
|
12
12
|
export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight' | 'toolbarListsIndentation' | 'insertBlock' | 'beforePrimaryToolbar' | 'avatarGroup' | 'findReplace' | 'aiExperience' | 'loom' | 'spellCheck';
|
|
13
13
|
export type ToolbarElementConfig = {
|
|
14
14
|
name: ToolbarElementNames;
|
|
15
15
|
enabled?: (componentRegistry: ComponentRegistry) => boolean;
|
|
16
16
|
};
|
|
17
17
|
export type PrimaryToolbarPluginState = {
|
|
18
|
-
componentRegistry: ComponentRegistry;
|
|
19
18
|
components: ToolbarUIComponentFactory[];
|
|
20
19
|
};
|
|
21
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-primary-toolbar",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Primary toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
".": "./src/index.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@atlaskit/editor-common": "^87.
|
|
41
|
+
"@atlaskit/editor-common": "^87.3.0",
|
|
42
42
|
"@atlaskit/editor-prosemirror": "5.0.1",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@emotion/react": "^11.7.1"
|
package/dist/cjs/commands.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/es2019/commands.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/esm/commands.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/types/commands.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
@@ -1,6 +0,0 @@
|
|
|
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;
|