@atlaskit/editor-plugin-primary-toolbar 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-primary-toolbar
2
2
 
3
+ ## 2.0.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#138118](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138118)
8
+ [`5e4d9eb1aefe4`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5e4d9eb1aefe4) -
9
+ NOISSUE: Upgrades editor React peer dependencies to v18
10
+ - Updated dependencies
11
+
12
+ ## 2.0.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 2.0.0
4
19
 
5
20
  ### Major Changes
@@ -12,9 +12,9 @@ var createPlugin = exports.createPlugin = function createPlugin(componentRegistr
12
12
  return new _safePlugin.SafePlugin({
13
13
  key: primaryToolbarPluginKey,
14
14
  state: {
15
- init: function init() {
15
+ init: function init(_config, editorState) {
16
16
  return {
17
- components: (0, _toolbarConfiguration.getToolbarComponents)(componentRegistry)
17
+ components: (0, _toolbarConfiguration.getToolbarComponents)(componentRegistry, editorState)
18
18
  };
19
19
  },
20
20
  apply: function apply(_tr, pluginState) {
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getToolbarComponents = void 0;
7
- var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(componentRegistry) {
7
+ var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(componentRegistry, editorState) {
8
8
  return toolbarConfiguration.filter(function (toolbarElement) {
9
- return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry);
9
+ return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry, editorState);
10
10
  }).reduce(function (acc, toolbarElement) {
11
11
  if (componentRegistry.has(toolbarElement.name)) {
12
12
  var component = componentRegistry.get(toolbarElement.name);
@@ -37,8 +37,10 @@ var blockTypeGroup = [{
37
37
  name: 'blockType'
38
38
  }, {
39
39
  name: 'separator',
40
- enabled: function enabled(componentRegistry) {
41
- return componentRegistry.has('blockType');
40
+ enabled: function enabled(componentRegistry, editorState) {
41
+ return componentRegistry.has('blockType') &&
42
+ // Use case where you want to have the block plugin but not render any toolbar items (when you exclude headings), we should be able to get rid of this when we split block type plugin up and check for the presence of the heading plugin directly
43
+ !!editorState.schema.nodes.heading;
42
44
  }
43
45
  }];
44
46
  var textFormattingGroup = [{
@@ -77,13 +79,6 @@ var listFormatting = [{
77
79
  }];
78
80
  var insertBlockGroup = [{
79
81
  name: 'insertBlock'
80
- }, {
81
- name: 'separator',
82
- enabled: function enabled(componentRegistry) {
83
- return componentRegistry.has('insertBlock') &&
84
- // is last group in the toolbar
85
- !componentRegistry.has('beforePrimaryToolbar') && !componentRegistry.has('avatarGroup') && !componentRegistry.has('findReplace') && !componentRegistry.has('aiExperience') && !componentRegistry.has('loom');
86
- }
87
82
  }];
88
83
  var others = [{
89
84
  name: 'beforePrimaryToolbar'
@@ -6,8 +6,8 @@ export const createPlugin = componentRegistry => {
6
6
  return new SafePlugin({
7
7
  key: primaryToolbarPluginKey,
8
8
  state: {
9
- init: () => ({
10
- components: getToolbarComponents(componentRegistry)
9
+ init: (_config, editorState) => ({
10
+ components: getToolbarComponents(componentRegistry, editorState)
11
11
  }),
12
12
  apply: (_tr, pluginState) => pluginState
13
13
  }
@@ -1,4 +1,4 @@
1
- export const getToolbarComponents = componentRegistry => toolbarConfiguration.filter(toolbarElement => typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry)).reduce((acc, toolbarElement) => {
1
+ export const getToolbarComponents = (componentRegistry, editorState) => toolbarConfiguration.filter(toolbarElement => typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry, editorState)).reduce((acc, toolbarElement) => {
2
2
  if (componentRegistry.has(toolbarElement.name)) {
3
3
  const component = componentRegistry.get(toolbarElement.name);
4
4
  if (!!component) {
@@ -23,7 +23,9 @@ const blockTypeGroup = [{
23
23
  name: 'blockType'
24
24
  }, {
25
25
  name: 'separator',
26
- enabled: componentRegistry => componentRegistry.has('blockType')
26
+ enabled: (componentRegistry, editorState) => componentRegistry.has('blockType') &&
27
+ // Use case where you want to have the block plugin but not render any toolbar items (when you exclude headings), we should be able to get rid of this when we split block type plugin up and check for the presence of the heading plugin directly
28
+ !!editorState.schema.nodes.heading
27
29
  }];
28
30
  const textFormattingGroup = [{
29
31
  name: 'textFormatting'
@@ -53,11 +55,6 @@ const listFormatting = [{
53
55
  }];
54
56
  const insertBlockGroup = [{
55
57
  name: 'insertBlock'
56
- }, {
57
- name: 'separator',
58
- enabled: componentRegistry => componentRegistry.has('insertBlock') &&
59
- // is last group in the toolbar
60
- !componentRegistry.has('beforePrimaryToolbar') && !componentRegistry.has('avatarGroup') && !componentRegistry.has('findReplace') && !componentRegistry.has('aiExperience') && !componentRegistry.has('loom')
61
58
  }];
62
59
  const others = [{
63
60
  name: 'beforePrimaryToolbar'
@@ -6,9 +6,9 @@ export var createPlugin = function createPlugin(componentRegistry) {
6
6
  return new SafePlugin({
7
7
  key: primaryToolbarPluginKey,
8
8
  state: {
9
- init: function init() {
9
+ init: function init(_config, editorState) {
10
10
  return {
11
- components: getToolbarComponents(componentRegistry)
11
+ components: getToolbarComponents(componentRegistry, editorState)
12
12
  };
13
13
  },
14
14
  apply: function apply(_tr, pluginState) {
@@ -1,6 +1,6 @@
1
- export var getToolbarComponents = function getToolbarComponents(componentRegistry) {
1
+ export var getToolbarComponents = function getToolbarComponents(componentRegistry, editorState) {
2
2
  return toolbarConfiguration.filter(function (toolbarElement) {
3
- return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry);
3
+ return typeof toolbarElement.enabled === 'undefined' || toolbarElement.enabled(componentRegistry, editorState);
4
4
  }).reduce(function (acc, toolbarElement) {
5
5
  if (componentRegistry.has(toolbarElement.name)) {
6
6
  var component = componentRegistry.get(toolbarElement.name);
@@ -31,8 +31,10 @@ var blockTypeGroup = [{
31
31
  name: 'blockType'
32
32
  }, {
33
33
  name: 'separator',
34
- enabled: function enabled(componentRegistry) {
35
- return componentRegistry.has('blockType');
34
+ enabled: function enabled(componentRegistry, editorState) {
35
+ return componentRegistry.has('blockType') &&
36
+ // Use case where you want to have the block plugin but not render any toolbar items (when you exclude headings), we should be able to get rid of this when we split block type plugin up and check for the presence of the heading plugin directly
37
+ !!editorState.schema.nodes.heading;
36
38
  }
37
39
  }];
38
40
  var textFormattingGroup = [{
@@ -71,13 +73,6 @@ var listFormatting = [{
71
73
  }];
72
74
  var insertBlockGroup = [{
73
75
  name: 'insertBlock'
74
- }, {
75
- name: 'separator',
76
- enabled: function enabled(componentRegistry) {
77
- return componentRegistry.has('insertBlock') &&
78
- // is last group in the toolbar
79
- !componentRegistry.has('beforePrimaryToolbar') && !componentRegistry.has('avatarGroup') && !componentRegistry.has('findReplace') && !componentRegistry.has('aiExperience') && !componentRegistry.has('loom');
80
- }
81
76
  }];
82
77
  var others = [{
83
78
  name: 'beforePrimaryToolbar'
@@ -1,3 +1,4 @@
1
1
  import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { ComponentRegistry } from './types';
3
- export declare const getToolbarComponents: (componentRegistry: ComponentRegistry) => ToolbarUIComponentFactory[];
4
+ export declare const getToolbarComponents: (componentRegistry: ComponentRegistry, editorState: EditorState) => ToolbarUIComponentFactory[];
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
3
  export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
3
4
  sharedState: PrimaryToolbarPluginState | undefined;
4
5
  actions: {
@@ -12,7 +13,7 @@ export type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
12
13
  export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight' | 'toolbarListsIndentation' | 'insertBlock' | 'beforePrimaryToolbar' | 'avatarGroup' | 'findReplace' | 'aiExperience' | 'loom' | 'spellCheck';
13
14
  export type ToolbarElementConfig = {
14
15
  name: ToolbarElementNames;
15
- enabled?: (componentRegistry: ComponentRegistry) => boolean;
16
+ enabled?: (componentRegistry: ComponentRegistry, editorState: EditorState) => boolean;
16
17
  };
17
18
  export type PrimaryToolbarPluginState = {
18
19
  components: ToolbarUIComponentFactory[];
@@ -1,3 +1,4 @@
1
1
  import type { ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
3
  import type { ComponentRegistry } from './types';
3
- export declare const getToolbarComponents: (componentRegistry: ComponentRegistry) => ToolbarUIComponentFactory[];
4
+ export declare const getToolbarComponents: (componentRegistry: ComponentRegistry, editorState: EditorState) => ToolbarUIComponentFactory[];
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin, ToolbarUIComponentFactory } from '@atlaskit/editor-common/types';
2
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
3
  export type PrimaryToolbarPlugin = NextEditorPlugin<'primaryToolbar', {
3
4
  sharedState: PrimaryToolbarPluginState | undefined;
4
5
  actions: {
@@ -12,7 +13,7 @@ export type ComponentRegistry = Map<string, ToolbarUIComponentFactory>;
12
13
  export type ToolbarElementNames = 'separator' | 'undoRedoPlugin' | 'blockType' | 'textFormatting' | 'alignment' | 'textColor' | 'highlight' | 'toolbarListsIndentation' | 'insertBlock' | 'beforePrimaryToolbar' | 'avatarGroup' | 'findReplace' | 'aiExperience' | 'loom' | 'spellCheck';
13
14
  export type ToolbarElementConfig = {
14
15
  name: ToolbarElementNames;
15
- enabled?: (componentRegistry: ComponentRegistry) => boolean;
16
+ enabled?: (componentRegistry: ComponentRegistry, editorState: EditorState) => boolean;
16
17
  };
17
18
  export type PrimaryToolbarPluginState = {
18
19
  components: ToolbarUIComponentFactory[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-primary-toolbar",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Primary toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -9,13 +9,11 @@
9
9
  },
10
10
  "atlassian": {
11
11
  "team": "Editor: Core Experiences",
12
- "inPublicMirror": false,
13
- "releaseModel": "continuous",
14
12
  "website": {
15
13
  "name": "EditorPluginPrimaryToolbar",
16
14
  "category": "Components"
17
15
  },
18
- "runReact18": false
16
+ "runReact18": true
19
17
  },
20
18
  "repository": "https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo",
21
19
  "main": "dist/cjs/index.js",
@@ -38,13 +36,13 @@
38
36
  ".": "./src/index.ts"
39
37
  },
40
38
  "dependencies": {
41
- "@atlaskit/editor-common": "^87.3.0",
39
+ "@atlaskit/editor-common": "^88.12.0",
42
40
  "@atlaskit/editor-prosemirror": "5.0.1",
43
41
  "@babel/runtime": "^7.0.0",
44
42
  "@emotion/react": "^11.7.1"
45
43
  },
46
44
  "peerDependencies": {
47
- "react": "^16.8.0"
45
+ "react": "^16.8.0 || ^17.0.0 || ~18.2.0"
48
46
  },
49
47
  "devDependencies": {
50
48
  "typescript": "~5.4.2"