@atlaskit/editor-plugin-toolbar 7.0.7 → 7.0.8
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
|
@@ -94,10 +94,27 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
94
94
|
registry.register(toolbarComponents);
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
+
// EDITOR-6558: `componentFilter` is evaluated at read time (not at
|
|
98
|
+
// `registerComponents` time) so it can react to runtime state
|
|
99
|
+
// (e.g. the current markdown view mode) without forcing every
|
|
100
|
+
// plugin to re-register its components. Returning a new array on
|
|
101
|
+
// every call means React-tree consumers re-render whenever the
|
|
102
|
+
// underlying filter would change.
|
|
97
103
|
getComponents: function getComponents() {
|
|
98
|
-
return registry.components;
|
|
104
|
+
return config !== null && config !== void 0 && config.componentFilter ? registry.components.filter(config.componentFilter) : registry.components;
|
|
99
105
|
},
|
|
100
106
|
contextualFormattingMode: function contextualFormattingMode() {
|
|
107
|
+
var _config$contextualFor2;
|
|
108
|
+
// EDITOR-6558: `contextualFormattingModeOverride` lets a
|
|
109
|
+
// consumer (Markdown Mode in source/preview view) force the
|
|
110
|
+
// toolbar to a specific docking position regardless of the
|
|
111
|
+
// user's saved preference. Used to lock the toolbar to
|
|
112
|
+
// `always-pinned` while the floating toolbar would be useless
|
|
113
|
+
// (i.e. when there's no ProseMirror selection to anchor to).
|
|
114
|
+
var override = config === null || config === void 0 || (_config$contextualFor2 = config.contextualFormattingModeOverride) === null || _config$contextualFor2 === void 0 ? void 0 : _config$contextualFor2.call(config);
|
|
115
|
+
if (override) {
|
|
116
|
+
return override;
|
|
117
|
+
}
|
|
101
118
|
return contextualFormattingEnabled !== null && contextualFormattingEnabled !== void 0 ? contextualFormattingEnabled : 'always-pinned';
|
|
102
119
|
},
|
|
103
120
|
getBreakpointPreset: function getBreakpointPreset() {
|
|
@@ -79,10 +79,27 @@ export const toolbarPlugin = ({
|
|
|
79
79
|
registry.register(toolbarComponents);
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
|
+
// EDITOR-6558: `componentFilter` is evaluated at read time (not at
|
|
83
|
+
// `registerComponents` time) so it can react to runtime state
|
|
84
|
+
// (e.g. the current markdown view mode) without forcing every
|
|
85
|
+
// plugin to re-register its components. Returning a new array on
|
|
86
|
+
// every call means React-tree consumers re-render whenever the
|
|
87
|
+
// underlying filter would change.
|
|
82
88
|
getComponents: () => {
|
|
83
|
-
return registry.components;
|
|
89
|
+
return config !== null && config !== void 0 && config.componentFilter ? registry.components.filter(config.componentFilter) : registry.components;
|
|
84
90
|
},
|
|
85
91
|
contextualFormattingMode: () => {
|
|
92
|
+
var _config$contextualFor;
|
|
93
|
+
// EDITOR-6558: `contextualFormattingModeOverride` lets a
|
|
94
|
+
// consumer (Markdown Mode in source/preview view) force the
|
|
95
|
+
// toolbar to a specific docking position regardless of the
|
|
96
|
+
// user's saved preference. Used to lock the toolbar to
|
|
97
|
+
// `always-pinned` while the floating toolbar would be useless
|
|
98
|
+
// (i.e. when there's no ProseMirror selection to anchor to).
|
|
99
|
+
const override = config === null || config === void 0 ? void 0 : (_config$contextualFor = config.contextualFormattingModeOverride) === null || _config$contextualFor === void 0 ? void 0 : _config$contextualFor.call(config);
|
|
100
|
+
if (override) {
|
|
101
|
+
return override;
|
|
102
|
+
}
|
|
86
103
|
return contextualFormattingEnabled !== null && contextualFormattingEnabled !== void 0 ? contextualFormattingEnabled : 'always-pinned';
|
|
87
104
|
},
|
|
88
105
|
getBreakpointPreset: () => {
|
|
@@ -87,10 +87,27 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
87
87
|
registry.register(toolbarComponents);
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
+
// EDITOR-6558: `componentFilter` is evaluated at read time (not at
|
|
91
|
+
// `registerComponents` time) so it can react to runtime state
|
|
92
|
+
// (e.g. the current markdown view mode) without forcing every
|
|
93
|
+
// plugin to re-register its components. Returning a new array on
|
|
94
|
+
// every call means React-tree consumers re-render whenever the
|
|
95
|
+
// underlying filter would change.
|
|
90
96
|
getComponents: function getComponents() {
|
|
91
|
-
return registry.components;
|
|
97
|
+
return config !== null && config !== void 0 && config.componentFilter ? registry.components.filter(config.componentFilter) : registry.components;
|
|
92
98
|
},
|
|
93
99
|
contextualFormattingMode: function contextualFormattingMode() {
|
|
100
|
+
var _config$contextualFor2;
|
|
101
|
+
// EDITOR-6558: `contextualFormattingModeOverride` lets a
|
|
102
|
+
// consumer (Markdown Mode in source/preview view) force the
|
|
103
|
+
// toolbar to a specific docking position regardless of the
|
|
104
|
+
// user's saved preference. Used to lock the toolbar to
|
|
105
|
+
// `always-pinned` while the floating toolbar would be useless
|
|
106
|
+
// (i.e. when there's no ProseMirror selection to anchor to).
|
|
107
|
+
var override = config === null || config === void 0 || (_config$contextualFor2 = config.contextualFormattingModeOverride) === null || _config$contextualFor2 === void 0 ? void 0 : _config$contextualFor2.call(config);
|
|
108
|
+
if (override) {
|
|
109
|
+
return override;
|
|
110
|
+
}
|
|
94
111
|
return contextualFormattingEnabled !== null && contextualFormattingEnabled !== void 0 ? contextualFormattingEnabled : 'always-pinned';
|
|
95
112
|
},
|
|
96
113
|
getBreakpointPreset: function getBreakpointPreset() {
|
|
@@ -6,6 +6,29 @@ export type ToolbarPluginOptions = {
|
|
|
6
6
|
* Option to set the breakpoint preset for the toolbar.
|
|
7
7
|
*/
|
|
8
8
|
breakpointPreset?: BreakpointPreset;
|
|
9
|
+
/**
|
|
10
|
+
* EDITOR-6558: Optional predicate applied to every component returned
|
|
11
|
+
* from `getComponents` (i.e. evaluated at read time, not registration
|
|
12
|
+
* time). Components returning `false` are silently dropped. Used by
|
|
13
|
+
* Markdown Mode to hide toolbar buttons / menus whose underlying mark
|
|
14
|
+
* or node has no clean GFM round-trip (e.g. text colour, highlight,
|
|
15
|
+
* alignment, indentation, font size, etc.), and to hide ALL but the
|
|
16
|
+
* view-mode toggle when in source/preview view.
|
|
17
|
+
*
|
|
18
|
+
* The filter receives the registered component's `key` and `type` so
|
|
19
|
+
* consumers can distinguish buttons / menus / sections by their stable
|
|
20
|
+
* identifier without poking into component internals.
|
|
21
|
+
*
|
|
22
|
+
* Because the filter runs on every `getComponents` call, it can read
|
|
23
|
+
* mutable runtime state (e.g. via a closure over a sweet-state hook
|
|
24
|
+
* value) — but the consumer is responsible for ensuring the React tree
|
|
25
|
+
* re-renders when that state changes (e.g. via a parent component that
|
|
26
|
+
* subscribes to the same state and propagates re-renders).
|
|
27
|
+
*/
|
|
28
|
+
componentFilter?: (component: {
|
|
29
|
+
key: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}) => boolean;
|
|
9
32
|
/**
|
|
10
33
|
* Controls which toolbars are available for in the editor.
|
|
11
34
|
*
|
|
@@ -54,6 +77,16 @@ export type ToolbarPluginOptions = {
|
|
|
54
77
|
* @public
|
|
55
78
|
*/
|
|
56
79
|
contextualFormattingEnabled?: ContextualFormattingEnabledOptions;
|
|
80
|
+
/**
|
|
81
|
+
* EDITOR-6558: Optional override for the `contextualFormattingMode`.
|
|
82
|
+
* When the returned value is non-null it takes precedence over the
|
|
83
|
+
* `contextualFormattingEnabled` config (and over the user's saved
|
|
84
|
+
* docking preference). Used by Markdown Mode to lock the toolbar to
|
|
85
|
+
* `always-pinned` while the floating toolbar would be useless (i.e.
|
|
86
|
+
* when the source / preview view is active and there's no ProseMirror
|
|
87
|
+
* selection to anchor to).
|
|
88
|
+
*/
|
|
89
|
+
contextualFormattingModeOverride?: () => 'always-inline' | 'always-pinned' | 'controlled' | undefined;
|
|
57
90
|
/**
|
|
58
91
|
* @private
|
|
59
92
|
* @deprecated
|
|
@@ -6,6 +6,29 @@ export type ToolbarPluginOptions = {
|
|
|
6
6
|
* Option to set the breakpoint preset for the toolbar.
|
|
7
7
|
*/
|
|
8
8
|
breakpointPreset?: BreakpointPreset;
|
|
9
|
+
/**
|
|
10
|
+
* EDITOR-6558: Optional predicate applied to every component returned
|
|
11
|
+
* from `getComponents` (i.e. evaluated at read time, not registration
|
|
12
|
+
* time). Components returning `false` are silently dropped. Used by
|
|
13
|
+
* Markdown Mode to hide toolbar buttons / menus whose underlying mark
|
|
14
|
+
* or node has no clean GFM round-trip (e.g. text colour, highlight,
|
|
15
|
+
* alignment, indentation, font size, etc.), and to hide ALL but the
|
|
16
|
+
* view-mode toggle when in source/preview view.
|
|
17
|
+
*
|
|
18
|
+
* The filter receives the registered component's `key` and `type` so
|
|
19
|
+
* consumers can distinguish buttons / menus / sections by their stable
|
|
20
|
+
* identifier without poking into component internals.
|
|
21
|
+
*
|
|
22
|
+
* Because the filter runs on every `getComponents` call, it can read
|
|
23
|
+
* mutable runtime state (e.g. via a closure over a sweet-state hook
|
|
24
|
+
* value) — but the consumer is responsible for ensuring the React tree
|
|
25
|
+
* re-renders when that state changes (e.g. via a parent component that
|
|
26
|
+
* subscribes to the same state and propagates re-renders).
|
|
27
|
+
*/
|
|
28
|
+
componentFilter?: (component: {
|
|
29
|
+
key: string;
|
|
30
|
+
type: string;
|
|
31
|
+
}) => boolean;
|
|
9
32
|
/**
|
|
10
33
|
* Controls which toolbars are available for in the editor.
|
|
11
34
|
*
|
|
@@ -54,6 +77,16 @@ export type ToolbarPluginOptions = {
|
|
|
54
77
|
* @public
|
|
55
78
|
*/
|
|
56
79
|
contextualFormattingEnabled?: ContextualFormattingEnabledOptions;
|
|
80
|
+
/**
|
|
81
|
+
* EDITOR-6558: Optional override for the `contextualFormattingMode`.
|
|
82
|
+
* When the returned value is non-null it takes precedence over the
|
|
83
|
+
* `contextualFormattingEnabled` config (and over the user's saved
|
|
84
|
+
* docking preference). Used by Markdown Mode to lock the toolbar to
|
|
85
|
+
* `always-pinned` while the floating toolbar would be useless (i.e.
|
|
86
|
+
* when the source / preview view is active and there's no ProseMirror
|
|
87
|
+
* selection to anchor to).
|
|
88
|
+
*/
|
|
89
|
+
contextualFormattingModeOverride?: () => 'always-inline' | 'always-pinned' | 'controlled' | undefined;
|
|
57
90
|
/**
|
|
58
91
|
* @private
|
|
59
92
|
* @deprecated
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.8",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"@atlaskit/editor-toolbar": "^1.0.0",
|
|
41
41
|
"@atlaskit/editor-toolbar-model": "^0.4.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
43
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
43
|
+
"@atlaskit/tmp-editor-statsig": "^70.2.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"bind-event-listener": "^3.0.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@atlaskit/editor-common": "^114.
|
|
48
|
+
"@atlaskit/editor-common": "^114.11.0",
|
|
49
49
|
"react": "^18.2.0",
|
|
50
50
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
51
51
|
},
|