@atlaskit/editor-core 219.5.0 → 219.6.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 +27 -0
- package/dist/cjs/create-editor/ReactEditorView.js +45 -0
- package/dist/cjs/create-editor/create-editor.js +6 -1
- package/dist/cjs/create-editor/filter-plugins-for-reconfigure.js +49 -0
- package/dist/cjs/test-utils.js +3 -1
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbarNext.js +6 -49
- package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-compiled.compiled.css +198 -1
- package/dist/cjs/ui/EditorContentContainer/EditorContentContainer-compiled.js +19 -14
- package/dist/cjs/ui/PluginSlot/mount-plugin-hooks.js +10 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/ReactEditorView.js +43 -1
- package/dist/es2019/create-editor/create-editor.js +6 -1
- package/dist/es2019/create-editor/filter-plugins-for-reconfigure.js +35 -0
- package/dist/es2019/test-utils.js +3 -1
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbarNext.js +4 -46
- package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-compiled.compiled.css +198 -1
- package/dist/es2019/ui/EditorContentContainer/EditorContentContainer-compiled.js +21 -16
- package/dist/es2019/ui/PluginSlot/mount-plugin-hooks.js +18 -9
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/ReactEditorView.js +45 -0
- package/dist/esm/create-editor/create-editor.js +6 -1
- package/dist/esm/create-editor/filter-plugins-for-reconfigure.js +43 -0
- package/dist/esm/test-utils.js +3 -1
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbarNext.js +6 -49
- package/dist/esm/ui/EditorContentContainer/EditorContentContainer-compiled.compiled.css +198 -1
- package/dist/esm/ui/EditorContentContainer/EditorContentContainer-compiled.js +21 -16
- package/dist/esm/ui/PluginSlot/mount-plugin-hooks.js +10 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/filter-plugins-for-reconfigure.d.ts +19 -0
- package/dist/types/ui/PluginSlot/mount-plugin-hooks.d.ts +2 -2
- package/dist/types-ts4.5/create-editor/filter-plugins-for-reconfigure.d.ts +19 -0
- package/dist/types-ts4.5/ui/PluginSlot/mount-plugin-hooks.d.ts +2 -2
- package/package.json +13 -10
|
@@ -14,7 +14,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
14
14
|
var _browser = require("@atlaskit/editor-common/browser");
|
|
15
15
|
var _panel = require("@atlaskit/editor-common/panel");
|
|
16
16
|
var _styles = require("@atlaskit/editor-common/styles");
|
|
17
|
+
var _tableCellBackgroundForCompiled = require("@atlaskit/editor-common/table-cell-background-for-compiled");
|
|
17
18
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
19
|
+
var _overflowShadowForCompiled = require("@atlaskit/editor-shared-styles/overflow-shadow-for-compiled");
|
|
18
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
21
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
20
22
|
var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
|
|
@@ -258,12 +260,14 @@ var editorContentStyles = {
|
|
|
258
260
|
syncBlockOverflowStyles: "",
|
|
259
261
|
syncBlockStyles: "",
|
|
260
262
|
syncBlockStylesBase: "",
|
|
261
|
-
tableCommentEditorStyles: "",
|
|
262
|
-
tableContainerStyles: "",
|
|
263
|
-
tableContentModeStyles: "",
|
|
264
|
-
tableEmptyRowStyles: "",
|
|
265
|
-
tableLayoutFixes: "",
|
|
266
|
-
tableLayoutFixesWithFontSize: "",
|
|
263
|
+
tableCommentEditorStyles: "_s9qz1mok _1quk1aqn _1tb2idpf _8vyeidpf _1igzolhs _ux48glyw _giavsm61 _axu71ibz",
|
|
264
|
+
tableContainerStyles: "_18ml1osq _9e5g1wug _uwd31osq _12wgusvi _nnhzewfl _1gbz1osq _10va1osq _lkzl1n9t _1mca1wug",
|
|
265
|
+
tableContentModeStyles: "_1lxan7od _11a2n7od _19iin7od _1vpzn7od _l6b9n7od _9v33vi1l _poet1ris _9loxvi1l _1dsv1wug _r83tvi1l _cbmx261p",
|
|
266
|
+
tableEmptyRowStyles: "_1rgmmh6f _u0mgmh6f",
|
|
267
|
+
tableLayoutFixes: "_1f5xidpf _28dsidpf _f30jidpf _jr291hrf",
|
|
268
|
+
tableLayoutFixesWithFontSize: "_1f5xidpf _156tidpf _f30jidpf _jr291hrf",
|
|
269
|
+
tableSharedStyle: "_ad1u99ee _9d0e7qp0 _1mml7qp0 _1u4a1ule _1w721ule _1gr6t94y _ihzat94y _zi6e1vmz _1uln1vmz _wqm3stnw _1o0wstnw _1aho1ejb _uqg71ejb _g971h2mm _fzt6usvi _1nd8idpf _1j1lidpf _e364idpf _7vb2pzf8 _5cdi6z83 _kc8l11ss _9vqg11ss _up97ia51 _jz731rb6 _13ax1rb6 _b7zl1rb6 _10kw1rb6 _1u451rb6 _1gep1rb6 _14oi1rb6 _3yki1rb6 _185t1rb6 _13heu2gc _1uj1u2gc _1ssuu2gc _lqdju2gc _1waku2gc _1nzzu2gc _7xl8ckbl _1jykckbl _1m6qckbl _sellckbl _11t9ckbl _866vckbl _1dlzi7a9 _irzhi7a9 _15t1i7a9 _1ivxi7a9 _16k4i7a9 _1vo6i7a9 _q0zvjp4b _1junjp4b _ixm7jp4b _17dpjp4b _dzhmjp4b _15pyjp4b _dj9oidpf _8zz2idpf _1hwbidpf _1lxyidpf _yqeuidpf _mzo1idpf _9ex2idpf _1805idpf _1iphidpf _qkm8idpf _17v9idpf _4p8kidpf _6o4midpf _1edridpf _5908idpf _1d63idpf _1j36idpf _hlqnidpf _gw0eutpp _1n42utpp _762vutpp _g62yutpp _1y9hutpp _bjiqutpp _5dtjutpp _dclrutpp _1j94utpp _5o16utpp _946yutpp _1kffutpp _13bnglyw _1ekgglyw _nvt3glyw _v91rcfaq _byukcfaq _4oczcfaq _17xf1j28 _6ggl1j28 _wxs41j28 _1h3k1j28 _1e811j28 _w9wp1j28 _3aim1n9t _xsax1n9t _1hz91n9t _vqlp1x4e _1a0i1x4e _m5f81x4e _12j81osq _135a1osq _vkob1osq _dujf1wug _jr3h1wug _1ei91wug _kq5rusvi _31x2usvi _pavrusvi _14jm1ntv _1rfm1ntv _100i1ntv _1ciasm61 _5gm1sm61 _t176sm61 _1az4vuon _1mdwvuon _9l08vuon _vrwbysee _nwuhysee _1qxuysee _go9a1e5h _ktc91e5h _lr001e5h _komfhp5a _1lj5hp5a _96m3hp5a _s2681tsb _15bz1tsb _1skp1tsb _iley2lzm _ay9u2lzm _8zqr2lzm _qxl3i8nm _3gtki8nm _1nu9i8nm _lezgi8nm _1574i8nm _1yd8i8nm _ywut18tx _cee918tx _17h918tx _1esgtoke _1q0atoke _4waqtoke _1syri8nm _pvtri8nm _12jli8nm _dbl6pzf8 _4e711hrf _1hy1bokp _1bxo1ea5",
|
|
270
|
+
tableSharedStyleBackgroundClipFix: "_m6yo1u8q _19il1u8q _10gj1u8q _tbd61u8q _12ly1u8q _1l071u8q",
|
|
267
271
|
taskItemCheckboxStyles: "",
|
|
268
272
|
taskItemStyles: "",
|
|
269
273
|
taskItemStylesWithBlockTaskItem: "",
|
|
@@ -301,6 +305,9 @@ var EditorContentContainerCompiled = exports.EditorContentContainerCompiled = /*
|
|
|
301
305
|
var isChromeless = appearance === 'chromeless';
|
|
302
306
|
var baseFontSize = (0, _getBaseFontSize.getBaseFontSize)(appearance, contentMode);
|
|
303
307
|
var isDense = !!baseFontSize && baseFontSize !== _editorSharedStyles.akEditorFullPageDefaultFontSize;
|
|
308
|
+
var tableOverflowShadow = (0, _overflowShadowForCompiled.overflowShadowForCompiled)({
|
|
309
|
+
leftCoverWidth: "var(--ds-space-300, 24px)"
|
|
310
|
+
});
|
|
304
311
|
var style = (0, _experiments.editorExperiment)('platform_editor_preview_panel_responsiveness', true, {
|
|
305
312
|
exposure: true
|
|
306
313
|
}) ? {
|
|
@@ -308,14 +315,16 @@ var EditorContentContainerCompiled = exports.EditorContentContainerCompiled = /*
|
|
|
308
315
|
theme: {
|
|
309
316
|
baseFontSize: baseFontSize
|
|
310
317
|
}
|
|
311
|
-
}), "px")
|
|
318
|
+
}), "px"),
|
|
319
|
+
'--ak-editor--table-overflow-shadow': tableOverflowShadow
|
|
312
320
|
} : {
|
|
313
321
|
'--ak-editor-base-font-size': "".concat((0, _editorSharedStyles.editorFontSize)({
|
|
314
322
|
theme: {
|
|
315
323
|
baseFontSize: baseFontSize
|
|
316
324
|
}
|
|
317
325
|
}), "px"),
|
|
318
|
-
'--ak-editor--large-gutter-padding': "".concat((0, _editorSharedStyles.akEditorGutterPaddingDynamic)(), "px")
|
|
326
|
+
'--ak-editor--large-gutter-padding': "".concat((0, _editorSharedStyles.akEditorGutterPaddingDynamic)(), "px"),
|
|
327
|
+
'--ak-editor--table-overflow-shadow': tableOverflowShadow
|
|
319
328
|
};
|
|
320
329
|
var browser = (0, _browser.getBrowserInfo)();
|
|
321
330
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -383,11 +392,7 @@ var EditorContentContainerCompiled = exports.EditorContentContainerCompiled = /*
|
|
|
383
392
|
// : // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
384
393
|
// getDenseEmojiStyles(baseFontSize)
|
|
385
394
|
// : undefined,
|
|
386
|
-
editorContentStyles.panelViewStyles, editorContentStyles.mediaGroupStyles, editorContentStyles.mediaAlignmentStyles, (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? editorContentStyles.tableLayoutFixesWithFontSize : editorContentStyles.tableLayoutFixes, editorContentStyles.tableContainerStyles,
|
|
387
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
388
|
-
// TODO: it was from "import { tableSharedStyle } from '@atlaskit/editor-common/styles';"
|
|
389
|
-
// tableSharedStyle(),
|
|
390
|
-
editorContentStyles.tableEmptyRowStyles, (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true) && editorContentStyles.tableContentModeStyles, editorContentStyles.hyperLinkFloatingToolbarStyles, editorContentStyles.selectionToolbarAnimationStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.blockquoteDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.textDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.listDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.dangerDateStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.emojiDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.mentionDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.decisionDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.statusDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.dangerRuleStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.mediaDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.nestedPanelDangerStyles, className]),
|
|
395
|
+
editorContentStyles.panelViewStyles, editorContentStyles.mediaGroupStyles, editorContentStyles.mediaAlignmentStyles, (0, _expValEquals.expValEquals)('platform_editor_small_font_size', 'isEnabled', true) ? editorContentStyles.tableLayoutFixesWithFontSize : editorContentStyles.tableLayoutFixes, editorContentStyles.tableContainerStyles, editorContentStyles.tableSharedStyle, (browser.gecko || browser.ie || browser.mac && browser.chrome) && editorContentStyles.tableSharedStyleBackgroundClipFix, editorContentStyles.tableEmptyRowStyles, (0, _expValEquals.expValEquals)('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true) && editorContentStyles.tableContentModeStyles, editorContentStyles.hyperLinkFloatingToolbarStyles, editorContentStyles.selectionToolbarAnimationStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.blockquoteDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.textDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.listDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.dangerDateStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.emojiDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.mentionDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.decisionDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.statusDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.dangerRuleStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.mediaDangerStyles, (0, _experiments.editorExperiment)('platform_editor_block_menu', true) && editorContentStyles.nestedPanelDangerStyles, className]),
|
|
391
396
|
ref: ref,
|
|
392
397
|
"data-editor-scroll-container": isScrollable ? 'true' : undefined,
|
|
393
398
|
"data-testid": "editor-content-container"
|
|
@@ -396,5 +401,5 @@ var EditorContentContainerCompiled = exports.EditorContentContainerCompiled = /*
|
|
|
396
401
|
style: style,
|
|
397
402
|
tabIndex: isScrollable ? 0 : undefined,
|
|
398
403
|
role: isScrollable ? 'region' : undefined
|
|
399
|
-
}, children);
|
|
404
|
+
}, /*#__PURE__*/_react.default.createElement("style", null, _tableCellBackgroundForCompiled.tableCellBackgroundStyleOverrideForCompiled), children);
|
|
400
405
|
});
|
|
@@ -23,12 +23,19 @@ function MountPluginHooks(_ref2) {
|
|
|
23
23
|
if (!editorView) {
|
|
24
24
|
return null;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
// Key each fiber by the plugin name carried on the hook function (set by
|
|
28
|
+
// `processPluginsList`). This keeps fibers stable across `reconfigureState`
|
|
29
|
+
// calls that change the plugin set — keying by array index would let React
|
|
30
|
+
// reuse the same fiber for a different `usePluginHook`, which calls a
|
|
31
|
+
// different sequence of hooks (Rules of Hooks violation).
|
|
32
|
+
// Falls back to the array index for any hook that wasn't annotated.
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, pluginHooks === null || pluginHooks === void 0 ? void 0 : pluginHooks.map(function (usePluginHook, index) {
|
|
34
|
+
var pluginName = usePluginHook.pluginName;
|
|
27
35
|
return /*#__PURE__*/_react.default.createElement(MountPluginHook
|
|
28
|
-
// Ignored via go/ees005
|
|
29
36
|
// eslint-disable-next-line react/no-array-index-key
|
|
30
37
|
, {
|
|
31
|
-
key:
|
|
38
|
+
key: pluginName !== null && pluginName !== void 0 ? pluginName : index,
|
|
32
39
|
usePluginHook: usePluginHook,
|
|
33
40
|
editorView: editorView,
|
|
34
41
|
containerElement: containerElement
|
|
@@ -38,6 +38,7 @@ import { PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_
|
|
|
38
38
|
import { createErrorReporter, createPMPlugins, processPluginsList } from './create-editor';
|
|
39
39
|
import createPluginsList from './create-plugins-list';
|
|
40
40
|
import { createSchema } from './create-schema';
|
|
41
|
+
import { filterPluginsForReconfigure } from './filter-plugins-for-reconfigure';
|
|
41
42
|
import { editorMessages } from './messages';
|
|
42
43
|
import { focusEditorElement } from './ReactEditorView/focusEditorElement';
|
|
43
44
|
import { getUAPrefix } from './ReactEditorView/getUAPrefix';
|
|
@@ -336,6 +337,10 @@ export function ReactEditorView(props) {
|
|
|
336
337
|
// in-place-mutated `config.current` (contentComponents / toolbar
|
|
337
338
|
// components from the rebuilt preset).
|
|
338
339
|
const [, bumpConfigVersion] = useState(0);
|
|
340
|
+
|
|
341
|
+
// Preset reference last processed by the schema/API reconciliation below.
|
|
342
|
+
// Used to skip that work when reconfigure is called with the same preset.
|
|
343
|
+
const lastFilteredPresetRef = useRef(null);
|
|
339
344
|
const reconfigureState = useCallback(props => {
|
|
340
345
|
if (!viewRef.current) {
|
|
341
346
|
return;
|
|
@@ -345,7 +350,44 @@ export function ReactEditorView(props) {
|
|
|
345
350
|
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
346
351
|
// nodes that haven't been re-rendered to the document yet.
|
|
347
352
|
blur();
|
|
348
|
-
|
|
353
|
+
|
|
354
|
+
// Snapshot plugin names registered before createPluginsList runs, so
|
|
355
|
+
// we can tell which plugins are newly added by the new preset vs.
|
|
356
|
+
// which ones already coexisted with the current schema.
|
|
357
|
+
const previousPluginNames = new Set(pluginInjectionAPI.current.getRegisteredPluginNames());
|
|
358
|
+
let editorPlugins = createPluginsList(props.preset, 'allowBlockType' in props.editorProps ? props.editorProps : {}, pluginInjectionAPI.current);
|
|
359
|
+
|
|
360
|
+
// `state.reconfigure` keeps the original schema, so switching presets
|
|
361
|
+
// can leave the editor inconsistent in two ways:
|
|
362
|
+
// 1. The new preset may add plugins that reference schema nodes or
|
|
363
|
+
// marks the original schema doesn't have.
|
|
364
|
+
// 2. Plugins registered by a previous preset can linger in the
|
|
365
|
+
// injection API even when the new preset doesn't re-register
|
|
366
|
+
// them, so listeners still fire against a state that no longer
|
|
367
|
+
// has their pmPlugin.
|
|
368
|
+
if (lastFilteredPresetRef.current !== props.preset && fg('platform_editor_reconfigure_filter_plugins')) {
|
|
369
|
+
const {
|
|
370
|
+
kept,
|
|
371
|
+
dropped
|
|
372
|
+
} = filterPluginsForReconfigure(editorPlugins, viewRef.current.state.schema, previousPluginNames);
|
|
373
|
+
editorPlugins = kept;
|
|
374
|
+
|
|
375
|
+
// Reconcile the injection API with the post-filter plugin set.
|
|
376
|
+
// This evicts both the plugins we just dropped above (re-registered
|
|
377
|
+
// by createPluginsList but no longer in editorPlugins) AND any
|
|
378
|
+
// plugin from a previous preset that the new preset doesn't
|
|
379
|
+
// re-register.
|
|
380
|
+
const keptPluginNames = new Set(editorPlugins.map(p => p === null || p === void 0 ? void 0 : p.name).filter(n => Boolean(n)));
|
|
381
|
+
const evictedFromApi = pluginInjectionAPI.current.retainPlugins(keptPluginNames);
|
|
382
|
+
if (dropped.length > 0 || evictedFromApi.length > 0) {
|
|
383
|
+
// eslint-disable-next-line no-console
|
|
384
|
+
console.warn('[reconfigureState] Cleanup summary:', {
|
|
385
|
+
dropped,
|
|
386
|
+
evictedFromApi
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
lastFilteredPresetRef.current = props.preset;
|
|
390
|
+
}
|
|
349
391
|
config.current = processPluginsList(editorPlugins);
|
|
350
392
|
if (expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
351
393
|
config.current.pmPlugins.push(...pluginInjectionAPI.current.getInternalPMPlugins());
|
|
@@ -53,7 +53,12 @@ export function processPluginsList(plugins) {
|
|
|
53
53
|
acc.contentComponents.push(plugin.contentComponent);
|
|
54
54
|
}
|
|
55
55
|
if (plugin.usePluginHook) {
|
|
56
|
-
|
|
56
|
+
// Wrap with .bind(null) so we can annotate the function with the
|
|
57
|
+
// plugin name without mutating the plugin's original hook reference.
|
|
58
|
+
// MountPluginHooks reads `pluginName` to derive a stable React key.
|
|
59
|
+
const named = plugin.usePluginHook.bind(null);
|
|
60
|
+
named.pluginName = plugin.name;
|
|
61
|
+
acc.pluginHooks.push(named);
|
|
57
62
|
}
|
|
58
63
|
if (plugin.primaryToolbarComponent) {
|
|
59
64
|
acc.primaryToolbarComponents.push(plugin.primaryToolbarComponent);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Used by `reconfigureState` to drop plugins from a freshly-built preset that
|
|
3
|
+
* declare schema nodes/marks the current schema doesn't have. Plugins already
|
|
4
|
+
* present before this reconfigure are kept untouched: they have demonstrably
|
|
5
|
+
* coexisted with the schema (e.g. tests that mock a stripped-down schema), so
|
|
6
|
+
* removing them now would be a regression.
|
|
7
|
+
*/
|
|
8
|
+
export function filterPluginsForReconfigure(editorPlugins, schema, previousPluginNames) {
|
|
9
|
+
const availableNodeNames = new Set(Object.keys(schema.nodes));
|
|
10
|
+
const availableMarkNames = new Set(Object.keys(schema.marks));
|
|
11
|
+
const dropped = [];
|
|
12
|
+
const kept = editorPlugins.filter(plugin => {
|
|
13
|
+
if (!plugin) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (previousPluginNames.has(plugin.name)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
const missingNodes = plugin.nodes ? plugin.nodes().map(n => n.name).filter(n => !availableNodeNames.has(n)) : [];
|
|
20
|
+
const missingMarks = plugin.marks ? plugin.marks().map(m => m.name).filter(m => !availableMarkNames.has(m)) : [];
|
|
21
|
+
if (missingNodes.length > 0 || missingMarks.length > 0) {
|
|
22
|
+
dropped.push({
|
|
23
|
+
name: plugin.name,
|
|
24
|
+
missingNodes,
|
|
25
|
+
missingMarks
|
|
26
|
+
});
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
kept,
|
|
33
|
+
dropped
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -43,7 +43,9 @@ function lightProcessPluginsList(editorPlugins) {
|
|
|
43
43
|
acc.contentComponents.push(editorPlugin.contentComponent);
|
|
44
44
|
}
|
|
45
45
|
if (editorPlugin.usePluginHook) {
|
|
46
|
-
|
|
46
|
+
const named = editorPlugin.usePluginHook.bind(null);
|
|
47
|
+
named.pluginName = editorPlugin.name;
|
|
48
|
+
acc.pluginHooks.push(named);
|
|
47
49
|
}
|
|
48
50
|
if (editorPlugin.onEditorViewStateUpdated) {
|
|
49
51
|
acc.onEditorViewStateUpdatedCallbacks.push(editorPlugin.onEditorViewStateUpdated);
|
|
@@ -55,17 +55,6 @@ const SecondChildWrapper = ({
|
|
|
55
55
|
className: ax([styles.secondChildWrapperOneLine])
|
|
56
56
|
}, children);
|
|
57
57
|
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Placeholder component that reserves the toolbar's space during hydration
|
|
61
|
-
* to prevent layout shift when the actual toolbar renders.
|
|
62
|
-
*/
|
|
63
|
-
const ToolbarPlaceholder = () => {
|
|
64
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
65
|
-
"data-testid": "ak-editor-main-toolbar-placeholder",
|
|
66
|
-
className: ax([styles.toolbarPlaceholder])
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
58
|
const shouldShowToolbarContainer = (toolbar, customPrimaryToolbarComponents) => {
|
|
70
59
|
return !!toolbar || !!customPrimaryToolbarComponents;
|
|
71
60
|
};
|
|
@@ -119,40 +108,9 @@ export const FullPageToolbarNext = ({
|
|
|
119
108
|
if (!shouldShowToolbarContainer(toolbar, customPrimaryToolbarComponents)) {
|
|
120
109
|
return /*#__PURE__*/React.createElement(ToolbarPortal, null, null);
|
|
121
110
|
}
|
|
122
|
-
if (expValEquals('platform_editor_toolbar_two_stage_hydration', 'isEnabled', true)) {
|
|
123
|
-
return /*#__PURE__*/React.createElement(ContextPanelConsumer, null, ({
|
|
124
|
-
width: ContextPanelWidth
|
|
125
|
-
}) => /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
|
|
126
|
-
editorView: editorView,
|
|
127
|
-
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
128
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
129
|
-
handleEscape: handleEscape,
|
|
130
|
-
intl: intl
|
|
131
|
-
}, /*#__PURE__*/React.createElement(ToolbarPortal, null, /*#__PURE__*/React.createElement(MainToolbarWrapper, {
|
|
132
|
-
testId: "ak-editor-main-toolbar",
|
|
133
|
-
showKeyline: showKeyline || ContextPanelWidth > 0
|
|
134
|
-
}, beforeIcon && /*#__PURE__*/React.createElement("div", {
|
|
135
|
-
className: ax([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
|
|
136
|
-
}, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, /*#__PURE__*/React.createElement(ExcludeFromHydration, null, primaryToolbarDockingConfigEnabled && components && isToolbar(toolbar) && editorView && !isSSR() && /*#__PURE__*/React.createElement(ToolbarNext, {
|
|
137
|
-
toolbar: toolbar,
|
|
138
|
-
components: components,
|
|
139
|
-
editorView: editorView,
|
|
140
|
-
editorAPI: editorAPI,
|
|
141
|
-
popupsMountPoint: mountPoint,
|
|
142
|
-
editorAppearance: "full-page",
|
|
143
|
-
isDisabled: disabled
|
|
144
|
-
}))), /*#__PURE__*/React.createElement(SecondChildWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
145
|
-
className: ax([styles.customToolbarWrapperStyle])
|
|
146
|
-
}, !!customPrimaryToolbarComponents && 'before' in customPrimaryToolbarComponents && /*#__PURE__*/React.createElement("div", {
|
|
147
|
-
"data-testid": 'before-primary-toolbar-components-plugin',
|
|
148
|
-
className: ax([styles.beforePrimaryToolbarComponents])
|
|
149
|
-
}, customPrimaryToolbarComponents.before), !!customPrimaryToolbarComponents && 'after' in customPrimaryToolbarComponents ? customPrimaryToolbarComponents.after : customPrimaryToolbarComponents)), /*#__PURE__*/React.createElement(ToolbarPortalMountPoint, null))))));
|
|
150
|
-
}
|
|
151
111
|
return /*#__PURE__*/React.createElement(ContextPanelConsumer, null, ({
|
|
152
112
|
width: ContextPanelWidth
|
|
153
|
-
}) => /*#__PURE__*/React.createElement(
|
|
154
|
-
fallback: /*#__PURE__*/React.createElement(ToolbarPlaceholder, null)
|
|
155
|
-
}, /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
|
|
113
|
+
}) => /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
|
|
156
114
|
editorView: editorView,
|
|
157
115
|
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
158
116
|
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
@@ -163,7 +121,7 @@ export const FullPageToolbarNext = ({
|
|
|
163
121
|
showKeyline: showKeyline || ContextPanelWidth > 0
|
|
164
122
|
}, beforeIcon && /*#__PURE__*/React.createElement("div", {
|
|
165
123
|
className: ax([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
|
|
166
|
-
}, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, primaryToolbarDockingConfigEnabled && components && isToolbar(toolbar) && editorView && !isSSR() && /*#__PURE__*/React.createElement(ToolbarNext, {
|
|
124
|
+
}, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, /*#__PURE__*/React.createElement(ExcludeFromHydration, null, primaryToolbarDockingConfigEnabled && components && isToolbar(toolbar) && editorView && !isSSR() && /*#__PURE__*/React.createElement(ToolbarNext, {
|
|
167
125
|
toolbar: toolbar,
|
|
168
126
|
components: components,
|
|
169
127
|
editorView: editorView,
|
|
@@ -171,10 +129,10 @@ export const FullPageToolbarNext = ({
|
|
|
171
129
|
popupsMountPoint: mountPoint,
|
|
172
130
|
editorAppearance: "full-page",
|
|
173
131
|
isDisabled: disabled
|
|
174
|
-
})), /*#__PURE__*/React.createElement(SecondChildWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
132
|
+
}))), /*#__PURE__*/React.createElement(SecondChildWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
175
133
|
className: ax([styles.customToolbarWrapperStyle])
|
|
176
134
|
}, !!customPrimaryToolbarComponents && 'before' in customPrimaryToolbarComponents && /*#__PURE__*/React.createElement("div", {
|
|
177
135
|
"data-testid": 'before-primary-toolbar-components-plugin',
|
|
178
136
|
className: ax([styles.beforePrimaryToolbarComponents])
|
|
179
|
-
}, customPrimaryToolbarComponents.before), !!customPrimaryToolbarComponents && 'after' in customPrimaryToolbarComponents ? customPrimaryToolbarComponents.after : customPrimaryToolbarComponents)), /*#__PURE__*/React.createElement(ToolbarPortalMountPoint, null))))))
|
|
137
|
+
}, customPrimaryToolbarComponents.before), !!customPrimaryToolbarComponents && 'after' in customPrimaryToolbarComponents ? customPrimaryToolbarComponents.after : customPrimaryToolbarComponents)), /*#__PURE__*/React.createElement(ToolbarPortalMountPoint, null))))));
|
|
180
138
|
};
|