@atlaskit/editor-plugin-primary-toolbar 3.0.4 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/pm-plugins/pm-plugin.js +8 -2
- package/dist/cjs/pm-plugins/toolbar-configuration.js +8 -4
- package/dist/cjs/primaryToolbarPlugin.js +7 -3
- package/dist/es2019/pm-plugins/pm-plugin.js +9 -2
- package/dist/es2019/pm-plugins/toolbar-configuration.js +9 -4
- package/dist/es2019/primaryToolbarPlugin.js +8 -3
- package/dist/esm/pm-plugins/pm-plugin.js +8 -2
- package/dist/esm/pm-plugins/toolbar-configuration.js +8 -4
- package/dist/esm/primaryToolbarPlugin.js +7 -3
- package/dist/types/pm-plugins/pm-plugin.d.ts +6 -1
- package/dist/types/pm-plugins/toolbar-configuration.d.ts +7 -1
- package/dist/types/primaryToolbarPluginType.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/pm-plugin.d.ts +6 -1
- package/dist/types-ts4.5/pm-plugins/toolbar-configuration.d.ts +7 -1
- package/dist/types-ts4.5/primaryToolbarPluginType.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-primary-toolbar
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#130044](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/130044)
|
|
8
|
+
[`cad348d512cdf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cad348d512cdf) -
|
|
9
|
+
[ux] ED-26802 contextual formatting configuration
|
|
10
|
+
|
|
11
|
+
## 3.0.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 3.0.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -8,13 +8,19 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
9
|
var _toolbarConfiguration = require("./toolbar-configuration");
|
|
10
10
|
var primaryToolbarPluginKey = exports.primaryToolbarPluginKey = new _state.PluginKey('primaryToolbar');
|
|
11
|
-
var createPlugin = exports.createPlugin = function createPlugin(
|
|
11
|
+
var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
12
|
+
var componentRegistry = _ref.componentRegistry,
|
|
13
|
+
contextualFormattingEnabled = _ref.contextualFormattingEnabled;
|
|
12
14
|
return new _safePlugin.SafePlugin({
|
|
13
15
|
key: primaryToolbarPluginKey,
|
|
14
16
|
state: {
|
|
15
17
|
init: function init(_config, editorState) {
|
|
16
18
|
return {
|
|
17
|
-
components: (0, _toolbarConfiguration.getToolbarComponents)(
|
|
19
|
+
components: (0, _toolbarConfiguration.getToolbarComponents)({
|
|
20
|
+
componentRegistry: componentRegistry,
|
|
21
|
+
editorState: editorState,
|
|
22
|
+
contextualFormattingEnabled: contextualFormattingEnabled
|
|
23
|
+
})
|
|
18
24
|
};
|
|
19
25
|
},
|
|
20
26
|
apply: function apply(_tr, pluginState) {
|
|
@@ -5,10 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getToolbarComponents = void 0;
|
|
7
7
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
8
|
-
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(
|
|
9
|
-
|
|
8
|
+
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(_ref) {
|
|
9
|
+
var componentRegistry = _ref.componentRegistry,
|
|
10
|
+
editorState = _ref.editorState,
|
|
11
|
+
contextualFormattingEnabled = _ref.contextualFormattingEnabled;
|
|
12
|
+
var configuration = contextualFormattingEnabled && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
|
|
10
13
|
exposure: true
|
|
11
|
-
}) ? toolbarConfigurationV2 : toolbarConfiguration
|
|
14
|
+
}) ? toolbarConfigurationV2 : toolbarConfiguration;
|
|
15
|
+
return configuration.filter(function (toolbarElement) {
|
|
12
16
|
return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry, editorState);
|
|
13
17
|
}).reduce(function (acc, toolbarElement) {
|
|
14
18
|
if (componentRegistry.has(toolbarElement.name)) {
|
|
@@ -98,7 +102,7 @@ var others = [{
|
|
|
98
102
|
}, {
|
|
99
103
|
name: 'findReplace'
|
|
100
104
|
}, {
|
|
101
|
-
// TODO: Should likely be split into three: spelling & grammar, separator, and AI trigger
|
|
105
|
+
// TODO: ED-26962 - Should likely be split into three: spelling & grammar, separator, and AI trigger
|
|
102
106
|
name: 'aiExperience'
|
|
103
107
|
}, {
|
|
104
108
|
name: 'loom'
|
|
@@ -8,10 +8,11 @@ exports.primaryToolbarPlugin = void 0;
|
|
|
8
8
|
var _actions = require("./editor-actions/actions");
|
|
9
9
|
var _pmPlugin = require("./pm-plugins/pm-plugin");
|
|
10
10
|
var _separator = _interopRequireDefault(require("./ui/separator"));
|
|
11
|
-
var primaryToolbarPlugin = exports.primaryToolbarPlugin = function primaryToolbarPlugin() {
|
|
11
|
+
var primaryToolbarPlugin = exports.primaryToolbarPlugin = function primaryToolbarPlugin(_ref) {
|
|
12
|
+
var config = _ref.config;
|
|
12
13
|
// We use a plugin variable to store the component registry to avoid having to use
|
|
13
14
|
// 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
|
+
// TODO: ED-26962 - Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation
|
|
15
16
|
var componentRegistry = new Map();
|
|
16
17
|
|
|
17
18
|
// Pre-fill registry with the separator component
|
|
@@ -25,7 +26,10 @@ var primaryToolbarPlugin = exports.primaryToolbarPlugin = function primaryToolba
|
|
|
25
26
|
return [{
|
|
26
27
|
name: 'primaryToolbar',
|
|
27
28
|
plugin: function plugin() {
|
|
28
|
-
return (0, _pmPlugin.createPlugin)(
|
|
29
|
+
return (0, _pmPlugin.createPlugin)({
|
|
30
|
+
componentRegistry: componentRegistry,
|
|
31
|
+
contextualFormattingEnabled: config === null || config === void 0 ? void 0 : config.contextualFormattingEnabled
|
|
32
|
+
});
|
|
29
33
|
}
|
|
30
34
|
}];
|
|
31
35
|
},
|
|
@@ -2,12 +2,19 @@ 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
4
|
export const primaryToolbarPluginKey = new PluginKey('primaryToolbar');
|
|
5
|
-
export const createPlugin =
|
|
5
|
+
export const createPlugin = ({
|
|
6
|
+
componentRegistry,
|
|
7
|
+
contextualFormattingEnabled
|
|
8
|
+
}) => {
|
|
6
9
|
return new SafePlugin({
|
|
7
10
|
key: primaryToolbarPluginKey,
|
|
8
11
|
state: {
|
|
9
12
|
init: (_config, editorState) => ({
|
|
10
|
-
components: getToolbarComponents(
|
|
13
|
+
components: getToolbarComponents({
|
|
14
|
+
componentRegistry,
|
|
15
|
+
editorState,
|
|
16
|
+
contextualFormattingEnabled
|
|
17
|
+
})
|
|
11
18
|
}),
|
|
12
19
|
apply: (_tr, pluginState) => pluginState
|
|
13
20
|
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
|
-
export const getToolbarComponents = (
|
|
3
|
-
|
|
2
|
+
export const getToolbarComponents = ({
|
|
3
|
+
componentRegistry,
|
|
4
|
+
editorState,
|
|
5
|
+
contextualFormattingEnabled
|
|
6
|
+
}) => {
|
|
7
|
+
const configuration = contextualFormattingEnabled && editorExperiment('platform_editor_controls', 'variant1', {
|
|
4
8
|
exposure: true
|
|
5
|
-
}) ? toolbarConfigurationV2 : toolbarConfiguration
|
|
9
|
+
}) ? toolbarConfigurationV2 : toolbarConfiguration;
|
|
10
|
+
return configuration.filter(toolbarElement => typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry, editorState)).reduce((acc, toolbarElement) => {
|
|
6
11
|
if (componentRegistry.has(toolbarElement.name)) {
|
|
7
12
|
const component = componentRegistry.get(toolbarElement.name);
|
|
8
13
|
if (!!component) {
|
|
@@ -74,7 +79,7 @@ const others = [{
|
|
|
74
79
|
}, {
|
|
75
80
|
name: 'findReplace'
|
|
76
81
|
}, {
|
|
77
|
-
// TODO: Should likely be split into three: spelling & grammar, separator, and AI trigger
|
|
82
|
+
// TODO: ED-26962 - Should likely be split into three: spelling & grammar, separator, and AI trigger
|
|
78
83
|
name: 'aiExperience'
|
|
79
84
|
}, {
|
|
80
85
|
name: 'loom'
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { registerComponent } from './editor-actions/actions';
|
|
2
2
|
import { createPlugin, primaryToolbarPluginKey } from './pm-plugins/pm-plugin';
|
|
3
3
|
import Separator from './ui/separator';
|
|
4
|
-
export const primaryToolbarPlugin = (
|
|
4
|
+
export const primaryToolbarPlugin = ({
|
|
5
|
+
config
|
|
6
|
+
}) => {
|
|
5
7
|
// We use a plugin variable to store the component registry to avoid having to use
|
|
6
8
|
// 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
|
|
9
|
+
// TODO: ED-26962 - Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation
|
|
8
10
|
const componentRegistry = new Map();
|
|
9
11
|
|
|
10
12
|
// Pre-fill registry with the separator component
|
|
@@ -16,7 +18,10 @@ export const primaryToolbarPlugin = () => {
|
|
|
16
18
|
},
|
|
17
19
|
pmPlugins: () => [{
|
|
18
20
|
name: 'primaryToolbar',
|
|
19
|
-
plugin: () => createPlugin(
|
|
21
|
+
plugin: () => createPlugin({
|
|
22
|
+
componentRegistry,
|
|
23
|
+
contextualFormattingEnabled: config === null || config === void 0 ? void 0 : config.contextualFormattingEnabled
|
|
24
|
+
})
|
|
20
25
|
}],
|
|
21
26
|
getSharedState(editorState) {
|
|
22
27
|
if (!editorState) {
|
|
@@ -2,13 +2,19 @@ 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
4
|
export var primaryToolbarPluginKey = new PluginKey('primaryToolbar');
|
|
5
|
-
export var createPlugin = function createPlugin(
|
|
5
|
+
export var createPlugin = function createPlugin(_ref) {
|
|
6
|
+
var componentRegistry = _ref.componentRegistry,
|
|
7
|
+
contextualFormattingEnabled = _ref.contextualFormattingEnabled;
|
|
6
8
|
return new SafePlugin({
|
|
7
9
|
key: primaryToolbarPluginKey,
|
|
8
10
|
state: {
|
|
9
11
|
init: function init(_config, editorState) {
|
|
10
12
|
return {
|
|
11
|
-
components: getToolbarComponents(
|
|
13
|
+
components: getToolbarComponents({
|
|
14
|
+
componentRegistry: componentRegistry,
|
|
15
|
+
editorState: editorState,
|
|
16
|
+
contextualFormattingEnabled: contextualFormattingEnabled
|
|
17
|
+
})
|
|
12
18
|
};
|
|
13
19
|
},
|
|
14
20
|
apply: function apply(_tr, pluginState) {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
2
|
-
export var getToolbarComponents = function getToolbarComponents(
|
|
3
|
-
|
|
2
|
+
export var getToolbarComponents = function getToolbarComponents(_ref) {
|
|
3
|
+
var componentRegistry = _ref.componentRegistry,
|
|
4
|
+
editorState = _ref.editorState,
|
|
5
|
+
contextualFormattingEnabled = _ref.contextualFormattingEnabled;
|
|
6
|
+
var configuration = contextualFormattingEnabled && editorExperiment('platform_editor_controls', 'variant1', {
|
|
4
7
|
exposure: true
|
|
5
|
-
}) ? toolbarConfigurationV2 : toolbarConfiguration
|
|
8
|
+
}) ? toolbarConfigurationV2 : toolbarConfiguration;
|
|
9
|
+
return configuration.filter(function (toolbarElement) {
|
|
6
10
|
return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry, editorState);
|
|
7
11
|
}).reduce(function (acc, toolbarElement) {
|
|
8
12
|
if (componentRegistry.has(toolbarElement.name)) {
|
|
@@ -92,7 +96,7 @@ var others = [{
|
|
|
92
96
|
}, {
|
|
93
97
|
name: 'findReplace'
|
|
94
98
|
}, {
|
|
95
|
-
// TODO: Should likely be split into three: spelling & grammar, separator, and AI trigger
|
|
99
|
+
// TODO: ED-26962 - Should likely be split into three: spelling & grammar, separator, and AI trigger
|
|
96
100
|
name: 'aiExperience'
|
|
97
101
|
}, {
|
|
98
102
|
name: 'loom'
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { registerComponent } from './editor-actions/actions';
|
|
2
2
|
import { createPlugin, primaryToolbarPluginKey } from './pm-plugins/pm-plugin';
|
|
3
3
|
import Separator from './ui/separator';
|
|
4
|
-
export var primaryToolbarPlugin = function primaryToolbarPlugin() {
|
|
4
|
+
export var primaryToolbarPlugin = function primaryToolbarPlugin(_ref) {
|
|
5
|
+
var config = _ref.config;
|
|
5
6
|
// We use a plugin variable to store the component registry to avoid having to use
|
|
6
7
|
// 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
|
+
// TODO: ED-26962 - Replace this with something in plugin state once we have a way to initialise across plugins on plugin initialisation
|
|
8
9
|
var componentRegistry = new Map();
|
|
9
10
|
|
|
10
11
|
// Pre-fill registry with the separator component
|
|
@@ -18,7 +19,10 @@ export var primaryToolbarPlugin = function primaryToolbarPlugin() {
|
|
|
18
19
|
return [{
|
|
19
20
|
name: 'primaryToolbar',
|
|
20
21
|
plugin: function plugin() {
|
|
21
|
-
return createPlugin(
|
|
22
|
+
return createPlugin({
|
|
23
|
+
componentRegistry: componentRegistry,
|
|
24
|
+
contextualFormattingEnabled: config === null || config === void 0 ? void 0 : config.contextualFormattingEnabled
|
|
25
|
+
});
|
|
22
26
|
}
|
|
23
27
|
}];
|
|
24
28
|
},
|
|
@@ -2,4 +2,9 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { ComponentRegistry, PrimaryToolbarPluginState } from '../primaryToolbarPluginType';
|
|
4
4
|
export declare const primaryToolbarPluginKey: PluginKey<PrimaryToolbarPluginState>;
|
|
5
|
-
|
|
5
|
+
type PluginConfig = {
|
|
6
|
+
componentRegistry: ComponentRegistry;
|
|
7
|
+
contextualFormattingEnabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const createPlugin: ({ componentRegistry, contextualFormattingEnabled }: PluginConfig) => SafePlugin<PrimaryToolbarPluginState>;
|
|
10
|
+
export {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { ComponentRegistry } from '../primaryToolbarPluginType';
|
|
4
|
-
|
|
4
|
+
type GetToolbarComponentsOptions = {
|
|
5
|
+
componentRegistry: ComponentRegistry;
|
|
6
|
+
editorState: EditorState;
|
|
7
|
+
contextualFormattingEnabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const getToolbarComponents: ({ componentRegistry, editorState, contextualFormattingEnabled, }: GetToolbarComponentsOptions) => ToolbarUIComponentFactory[];
|
|
10
|
+
export {};
|
|
@@ -8,6 +8,9 @@ export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
|
|
|
8
8
|
component: ToolbarUIComponentFactory;
|
|
9
9
|
}) => void;
|
|
10
10
|
};
|
|
11
|
+
pluginConfiguration?: {
|
|
12
|
+
contextualFormattingEnabled?: boolean;
|
|
13
|
+
};
|
|
11
14
|
}>;
|
|
12
15
|
export type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
|
|
13
16
|
export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight' | 'hyperlink' | 'toolbarListsIndentation' | 'insertBlock' | 'beforePrimaryToolbar' | 'avatarGroup' | 'findReplace' | 'aiExperience' | 'aiSimplified' | 'loom' | 'spellCheck' | 'overflowMenu';
|
|
@@ -2,4 +2,9 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { ComponentRegistry, PrimaryToolbarPluginState } from '../primaryToolbarPluginType';
|
|
4
4
|
export declare const primaryToolbarPluginKey: PluginKey<PrimaryToolbarPluginState>;
|
|
5
|
-
|
|
5
|
+
type PluginConfig = {
|
|
6
|
+
componentRegistry: ComponentRegistry;
|
|
7
|
+
contextualFormattingEnabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const createPlugin: ({ componentRegistry, contextualFormattingEnabled }: PluginConfig) => SafePlugin<PrimaryToolbarPluginState>;
|
|
10
|
+
export {};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { ComponentRegistry } from '../primaryToolbarPluginType';
|
|
4
|
-
|
|
4
|
+
type GetToolbarComponentsOptions = {
|
|
5
|
+
componentRegistry: ComponentRegistry;
|
|
6
|
+
editorState: EditorState;
|
|
7
|
+
contextualFormattingEnabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const getToolbarComponents: ({ componentRegistry, editorState, contextualFormattingEnabled, }: GetToolbarComponentsOptions) => ToolbarUIComponentFactory[];
|
|
10
|
+
export {};
|
|
@@ -8,6 +8,9 @@ export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
|
|
|
8
8
|
component: ToolbarUIComponentFactory;
|
|
9
9
|
}) => void;
|
|
10
10
|
};
|
|
11
|
+
pluginConfiguration?: {
|
|
12
|
+
contextualFormattingEnabled?: boolean;
|
|
13
|
+
};
|
|
11
14
|
}>;
|
|
12
15
|
export type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
|
|
13
16
|
export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight' | 'hyperlink' | 'toolbarListsIndentation' | 'insertBlock' | 'beforePrimaryToolbar' | 'avatarGroup' | 'findReplace' | 'aiExperience' | 'aiSimplified' | 'loom' | 'spellCheck' | 'overflowMenu';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-primary-toolbar",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Primary toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
".": "./src/index.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@atlaskit/editor-common": "^102.
|
|
39
|
+
"@atlaskit/editor-common": "^102.12.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^4.1.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"@emotion/react": "^11.7.1"
|
|
44
44
|
},
|