@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
|
@@ -11,8 +11,10 @@ import { getBrowserInfo } from '@atlaskit/editor-common/browser';
|
|
|
11
11
|
// TODO: add back tableSharedStyle when migrate table styles
|
|
12
12
|
// import { richMediaClassName, tableSharedStyle } from '@atlaskit/editor-common/styles';
|
|
13
13
|
import { PanelSharedCssClassName } from '@atlaskit/editor-common/panel';
|
|
14
|
-
import { AnnotationSharedClassNames, richMediaClassName, expandClassNames, SmartCardSharedCssClassName, CodeBlockSharedCssClassName } from '@atlaskit/editor-common/styles';
|
|
15
|
-
import {
|
|
14
|
+
import { AnnotationSharedClassNames, richMediaClassName, expandClassNames, SmartCardSharedCssClassName, CodeBlockSharedCssClassName, tableCellBorderWidth, tableCellMinWidth } from '@atlaskit/editor-common/styles';
|
|
15
|
+
import { tableCellBackgroundStyleOverrideForCompiled } from '@atlaskit/editor-common/table-cell-background-for-compiled';
|
|
16
|
+
import { akEditorFullPageDefaultFontSize, akEditorFullPageDenseFontSize, akEditorGutterPaddingDynamic, akEditorTableNumberColumnWidth, editorFontSize } from '@atlaskit/editor-shared-styles';
|
|
17
|
+
import { overflowShadowForCompiled } from '@atlaskit/editor-shared-styles/overflow-shadow-for-compiled';
|
|
16
18
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
19
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
18
20
|
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
@@ -310,12 +312,14 @@ const editorContentStyles = {
|
|
|
310
312
|
syncBlockOverflowStyles: "",
|
|
311
313
|
syncBlockStyles: "",
|
|
312
314
|
syncBlockStylesBase: "",
|
|
313
|
-
tableCommentEditorStyles: "",
|
|
314
|
-
tableContainerStyles: "",
|
|
315
|
-
tableContentModeStyles: "",
|
|
316
|
-
tableEmptyRowStyles: "",
|
|
317
|
-
tableLayoutFixes: "",
|
|
318
|
-
tableLayoutFixesWithFontSize: "",
|
|
315
|
+
tableCommentEditorStyles: "_s9qz1mok _1quk1aqn _1tb2idpf _8vyeidpf _1igzolhs _ux48glyw _giavsm61 _axu71ibz",
|
|
316
|
+
tableContainerStyles: "_18ml1osq _9e5g1wug _uwd31osq _12wgusvi _nnhzewfl _1gbz1osq _10va1osq _lkzl1n9t _1mca1wug",
|
|
317
|
+
tableContentModeStyles: "_1lxan7od _11a2n7od _19iin7od _1vpzn7od _l6b9n7od _9v33vi1l _poet1ris _9loxvi1l _1dsv1wug _r83tvi1l _cbmx261p",
|
|
318
|
+
tableEmptyRowStyles: "_1rgmmh6f _u0mgmh6f",
|
|
319
|
+
tableLayoutFixes: "_1f5xidpf _28dsidpf _f30jidpf _jr291hrf",
|
|
320
|
+
tableLayoutFixesWithFontSize: "_1f5xidpf _156tidpf _f30jidpf _jr291hrf",
|
|
321
|
+
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",
|
|
322
|
+
tableSharedStyleBackgroundClipFix: "_m6yo1u8q _19il1u8q _10gj1u8q _tbd61u8q _12ly1u8q _1l071u8q",
|
|
319
323
|
taskItemCheckboxStyles: "",
|
|
320
324
|
taskItemStyles: "",
|
|
321
325
|
taskItemStylesWithBlockTaskItem: "",
|
|
@@ -356,6 +360,9 @@ export const EditorContentContainerCompiled = /*#__PURE__*/React.forwardRef((pro
|
|
|
356
360
|
const isChromeless = appearance === 'chromeless';
|
|
357
361
|
const baseFontSize = getBaseFontSize(appearance, contentMode);
|
|
358
362
|
const isDense = !!baseFontSize && baseFontSize !== akEditorFullPageDefaultFontSize;
|
|
363
|
+
const tableOverflowShadow = overflowShadowForCompiled({
|
|
364
|
+
leftCoverWidth: "var(--ds-space-300, 24px)"
|
|
365
|
+
});
|
|
359
366
|
const style = editorExperiment('platform_editor_preview_panel_responsiveness', true, {
|
|
360
367
|
exposure: true
|
|
361
368
|
}) ? {
|
|
@@ -363,14 +370,16 @@ export const EditorContentContainerCompiled = /*#__PURE__*/React.forwardRef((pro
|
|
|
363
370
|
theme: {
|
|
364
371
|
baseFontSize
|
|
365
372
|
}
|
|
366
|
-
})}px
|
|
373
|
+
})}px`,
|
|
374
|
+
'--ak-editor--table-overflow-shadow': tableOverflowShadow
|
|
367
375
|
} : {
|
|
368
376
|
'--ak-editor-base-font-size': `${editorFontSize({
|
|
369
377
|
theme: {
|
|
370
378
|
baseFontSize
|
|
371
379
|
}
|
|
372
380
|
})}px`,
|
|
373
|
-
'--ak-editor--large-gutter-padding': `${akEditorGutterPaddingDynamic()}px
|
|
381
|
+
'--ak-editor--large-gutter-padding': `${akEditorGutterPaddingDynamic()}px`,
|
|
382
|
+
'--ak-editor--table-overflow-shadow': tableOverflowShadow
|
|
374
383
|
};
|
|
375
384
|
const browser = getBrowserInfo();
|
|
376
385
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -438,11 +447,7 @@ export const EditorContentContainerCompiled = /*#__PURE__*/React.forwardRef((pro
|
|
|
438
447
|
// : // eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
439
448
|
// getDenseEmojiStyles(baseFontSize)
|
|
440
449
|
// : undefined,
|
|
441
|
-
editorContentStyles.panelViewStyles, editorContentStyles.mediaGroupStyles, editorContentStyles.mediaAlignmentStyles, expValEquals('platform_editor_small_font_size', 'isEnabled', true) ? editorContentStyles.tableLayoutFixesWithFontSize : editorContentStyles.tableLayoutFixes, editorContentStyles.tableContainerStyles,
|
|
442
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
443
|
-
// TODO: it was from "import { tableSharedStyle } from '@atlaskit/editor-common/styles';"
|
|
444
|
-
// tableSharedStyle(),
|
|
445
|
-
editorContentStyles.tableEmptyRowStyles, expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true) && editorContentStyles.tableContentModeStyles, editorContentStyles.hyperLinkFloatingToolbarStyles, editorContentStyles.selectionToolbarAnimationStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.blockquoteDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.textDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.listDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.dangerDateStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.emojiDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.mentionDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.decisionDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.statusDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.dangerRuleStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.mediaDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.nestedPanelDangerStyles, className]),
|
|
450
|
+
editorContentStyles.panelViewStyles, editorContentStyles.mediaGroupStyles, editorContentStyles.mediaAlignmentStyles, 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, expValEquals('platform_editor_table_fit_to_content_auto_convert', 'isEnabled', true) && editorContentStyles.tableContentModeStyles, editorContentStyles.hyperLinkFloatingToolbarStyles, editorContentStyles.selectionToolbarAnimationStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.blockquoteDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.textDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.listDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.dangerDateStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.emojiDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.mentionDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.decisionDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.statusDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.dangerRuleStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.mediaDangerStyles, editorExperiment('platform_editor_block_menu', true) && editorContentStyles.nestedPanelDangerStyles, className]),
|
|
446
451
|
ref: ref,
|
|
447
452
|
"data-editor-scroll-container": isScrollable ? 'true' : undefined,
|
|
448
453
|
"data-testid": "editor-content-container"
|
|
@@ -451,5 +456,5 @@ export const EditorContentContainerCompiled = /*#__PURE__*/React.forwardRef((pro
|
|
|
451
456
|
style: style,
|
|
452
457
|
tabIndex: isScrollable ? 0 : undefined,
|
|
453
458
|
role: isScrollable ? 'region' : undefined
|
|
454
|
-
}, children);
|
|
459
|
+
}, /*#__PURE__*/React.createElement("style", null, tableCellBackgroundStyleOverrideForCompiled), children);
|
|
455
460
|
});
|
|
@@ -18,13 +18,22 @@ export function MountPluginHooks({
|
|
|
18
18
|
if (!editorView) {
|
|
19
19
|
return null;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
|
|
22
|
+
// Key each fiber by the plugin name carried on the hook function (set by
|
|
23
|
+
// `processPluginsList`). This keeps fibers stable across `reconfigureState`
|
|
24
|
+
// calls that change the plugin set — keying by array index would let React
|
|
25
|
+
// reuse the same fiber for a different `usePluginHook`, which calls a
|
|
26
|
+
// different sequence of hooks (Rules of Hooks violation).
|
|
27
|
+
// Falls back to the array index for any hook that wasn't annotated.
|
|
28
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, pluginHooks === null || pluginHooks === void 0 ? void 0 : pluginHooks.map((usePluginHook, index) => {
|
|
29
|
+
const pluginName = usePluginHook.pluginName;
|
|
30
|
+
return /*#__PURE__*/React.createElement(MountPluginHook
|
|
31
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
32
|
+
, {
|
|
33
|
+
key: pluginName !== null && pluginName !== void 0 ? pluginName : index,
|
|
34
|
+
usePluginHook: usePluginHook,
|
|
35
|
+
editorView: editorView,
|
|
36
|
+
containerElement: containerElement
|
|
37
|
+
});
|
|
38
|
+
}));
|
|
30
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "219.
|
|
2
|
+
export const version = "219.5.1";
|
|
@@ -46,6 +46,7 @@ import { PROSEMIRROR_RENDERED_DEGRADED_SEVERITY_THRESHOLD, PROSEMIRROR_RENDERED_
|
|
|
46
46
|
import { createErrorReporter, createPMPlugins, processPluginsList } from './create-editor';
|
|
47
47
|
import createPluginsList from './create-plugins-list';
|
|
48
48
|
import { createSchema } from './create-schema';
|
|
49
|
+
import { filterPluginsForReconfigure } from './filter-plugins-for-reconfigure';
|
|
49
50
|
import { editorMessages } from './messages';
|
|
50
51
|
import { focusEditorElement } from './ReactEditorView/focusEditorElement';
|
|
51
52
|
import { getUAPrefix } from './ReactEditorView/getUAPrefix';
|
|
@@ -353,6 +354,10 @@ export function ReactEditorView(props) {
|
|
|
353
354
|
var _useState = useState(0),
|
|
354
355
|
_useState2 = _slicedToArray(_useState, 2),
|
|
355
356
|
bumpConfigVersion = _useState2[1];
|
|
357
|
+
|
|
358
|
+
// Preset reference last processed by the schema/API reconciliation below.
|
|
359
|
+
// Used to skip that work when reconfigure is called with the same preset.
|
|
360
|
+
var lastFilteredPresetRef = useRef(null);
|
|
356
361
|
var reconfigureState = useCallback(function (props) {
|
|
357
362
|
if (!viewRef.current) {
|
|
358
363
|
return;
|
|
@@ -362,7 +367,47 @@ export function ReactEditorView(props) {
|
|
|
362
367
|
// so we blur here to stop ProseMirror from trying to apply selection to detached nodes or
|
|
363
368
|
// nodes that haven't been re-rendered to the document yet.
|
|
364
369
|
blur();
|
|
370
|
+
|
|
371
|
+
// Snapshot plugin names registered before createPluginsList runs, so
|
|
372
|
+
// we can tell which plugins are newly added by the new preset vs.
|
|
373
|
+
// which ones already coexisted with the current schema.
|
|
374
|
+
var previousPluginNames = new Set(pluginInjectionAPI.current.getRegisteredPluginNames());
|
|
365
375
|
var editorPlugins = createPluginsList(props.preset, 'allowBlockType' in props.editorProps ? props.editorProps : {}, pluginInjectionAPI.current);
|
|
376
|
+
|
|
377
|
+
// `state.reconfigure` keeps the original schema, so switching presets
|
|
378
|
+
// can leave the editor inconsistent in two ways:
|
|
379
|
+
// 1. The new preset may add plugins that reference schema nodes or
|
|
380
|
+
// marks the original schema doesn't have.
|
|
381
|
+
// 2. Plugins registered by a previous preset can linger in the
|
|
382
|
+
// injection API even when the new preset doesn't re-register
|
|
383
|
+
// them, so listeners still fire against a state that no longer
|
|
384
|
+
// has their pmPlugin.
|
|
385
|
+
if (lastFilteredPresetRef.current !== props.preset && fg('platform_editor_reconfigure_filter_plugins')) {
|
|
386
|
+
var _filterPluginsForReco = filterPluginsForReconfigure(editorPlugins, viewRef.current.state.schema, previousPluginNames),
|
|
387
|
+
kept = _filterPluginsForReco.kept,
|
|
388
|
+
dropped = _filterPluginsForReco.dropped;
|
|
389
|
+
editorPlugins = kept;
|
|
390
|
+
|
|
391
|
+
// Reconcile the injection API with the post-filter plugin set.
|
|
392
|
+
// This evicts both the plugins we just dropped above (re-registered
|
|
393
|
+
// by createPluginsList but no longer in editorPlugins) AND any
|
|
394
|
+
// plugin from a previous preset that the new preset doesn't
|
|
395
|
+
// re-register.
|
|
396
|
+
var keptPluginNames = new Set(editorPlugins.map(function (p) {
|
|
397
|
+
return p === null || p === void 0 ? void 0 : p.name;
|
|
398
|
+
}).filter(function (n) {
|
|
399
|
+
return Boolean(n);
|
|
400
|
+
}));
|
|
401
|
+
var evictedFromApi = pluginInjectionAPI.current.retainPlugins(keptPluginNames);
|
|
402
|
+
if (dropped.length > 0 || evictedFromApi.length > 0) {
|
|
403
|
+
// eslint-disable-next-line no-console
|
|
404
|
+
console.warn('[reconfigureState] Cleanup summary:', {
|
|
405
|
+
dropped: dropped,
|
|
406
|
+
evictedFromApi: evictedFromApi
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
lastFilteredPresetRef.current = props.preset;
|
|
410
|
+
}
|
|
366
411
|
config.current = processPluginsList(editorPlugins);
|
|
367
412
|
if (expValEquals('platform_editor_appearance_shared_state', 'isEnabled', true)) {
|
|
368
413
|
var _config$current$pmPlu2;
|
|
@@ -61,7 +61,12 @@ export function processPluginsList(plugins) {
|
|
|
61
61
|
acc.contentComponents.push(plugin.contentComponent);
|
|
62
62
|
}
|
|
63
63
|
if (plugin.usePluginHook) {
|
|
64
|
-
|
|
64
|
+
// Wrap with .bind(null) so we can annotate the function with the
|
|
65
|
+
// plugin name without mutating the plugin's original hook reference.
|
|
66
|
+
// MountPluginHooks reads `pluginName` to derive a stable React key.
|
|
67
|
+
var named = plugin.usePluginHook.bind(null);
|
|
68
|
+
named.pluginName = plugin.name;
|
|
69
|
+
acc.pluginHooks.push(named);
|
|
65
70
|
}
|
|
66
71
|
if (plugin.primaryToolbarComponent) {
|
|
67
72
|
acc.primaryToolbarComponents.push(plugin.primaryToolbarComponent);
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
var availableNodeNames = new Set(Object.keys(schema.nodes));
|
|
10
|
+
var availableMarkNames = new Set(Object.keys(schema.marks));
|
|
11
|
+
var dropped = [];
|
|
12
|
+
var kept = editorPlugins.filter(function (plugin) {
|
|
13
|
+
if (!plugin) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (previousPluginNames.has(plugin.name)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
var missingNodes = plugin.nodes ? plugin.nodes().map(function (n) {
|
|
20
|
+
return n.name;
|
|
21
|
+
}).filter(function (n) {
|
|
22
|
+
return !availableNodeNames.has(n);
|
|
23
|
+
}) : [];
|
|
24
|
+
var missingMarks = plugin.marks ? plugin.marks().map(function (m) {
|
|
25
|
+
return m.name;
|
|
26
|
+
}).filter(function (m) {
|
|
27
|
+
return !availableMarkNames.has(m);
|
|
28
|
+
}) : [];
|
|
29
|
+
if (missingNodes.length > 0 || missingMarks.length > 0) {
|
|
30
|
+
dropped.push({
|
|
31
|
+
name: plugin.name,
|
|
32
|
+
missingNodes: missingNodes,
|
|
33
|
+
missingMarks: missingMarks
|
|
34
|
+
});
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
kept: kept,
|
|
41
|
+
dropped: dropped
|
|
42
|
+
};
|
|
43
|
+
}
|
package/dist/esm/test-utils.js
CHANGED
|
@@ -50,7 +50,9 @@ function lightProcessPluginsList(editorPlugins) {
|
|
|
50
50
|
acc.contentComponents.push(editorPlugin.contentComponent);
|
|
51
51
|
}
|
|
52
52
|
if (editorPlugin.usePluginHook) {
|
|
53
|
-
|
|
53
|
+
var named = editorPlugin.usePluginHook.bind(null);
|
|
54
|
+
named.pluginName = editorPlugin.name;
|
|
55
|
+
acc.pluginHooks.push(named);
|
|
54
56
|
}
|
|
55
57
|
if (editorPlugin.onEditorViewStateUpdated) {
|
|
56
58
|
acc.onEditorViewStateUpdatedCallbacks.push(editorPlugin.onEditorViewStateUpdated);
|
|
@@ -52,17 +52,6 @@ var SecondChildWrapper = function SecondChildWrapper(_ref3) {
|
|
|
52
52
|
className: ax([styles.secondChildWrapperOneLine])
|
|
53
53
|
}, children);
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Placeholder component that reserves the toolbar's space during hydration
|
|
58
|
-
* to prevent layout shift when the actual toolbar renders.
|
|
59
|
-
*/
|
|
60
|
-
var ToolbarPlaceholder = function ToolbarPlaceholder() {
|
|
61
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
-
"data-testid": "ak-editor-main-toolbar-placeholder",
|
|
63
|
-
className: ax([styles.toolbarPlaceholder])
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
55
|
var shouldShowToolbarContainer = function shouldShowToolbarContainer(toolbar, customPrimaryToolbarComponents) {
|
|
67
56
|
return !!toolbar || !!customPrimaryToolbarComponents;
|
|
68
57
|
};
|
|
@@ -116,41 +105,9 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
|
|
|
116
105
|
if (!shouldShowToolbarContainer(toolbar, customPrimaryToolbarComponents)) {
|
|
117
106
|
return /*#__PURE__*/React.createElement(ToolbarPortal, null, null);
|
|
118
107
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
|
|
123
|
-
editorView: editorView,
|
|
124
|
-
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
125
|
-
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
126
|
-
handleEscape: handleEscape,
|
|
127
|
-
intl: intl
|
|
128
|
-
}, /*#__PURE__*/React.createElement(ToolbarPortal, null, /*#__PURE__*/React.createElement(MainToolbarWrapper, {
|
|
129
|
-
testId: "ak-editor-main-toolbar",
|
|
130
|
-
showKeyline: showKeyline || ContextPanelWidth > 0
|
|
131
|
-
}, beforeIcon && /*#__PURE__*/React.createElement("div", {
|
|
132
|
-
className: ax([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
|
|
133
|
-
}, 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, {
|
|
134
|
-
toolbar: toolbar,
|
|
135
|
-
components: components,
|
|
136
|
-
editorView: editorView,
|
|
137
|
-
editorAPI: editorAPI,
|
|
138
|
-
popupsMountPoint: mountPoint,
|
|
139
|
-
editorAppearance: "full-page",
|
|
140
|
-
isDisabled: disabled
|
|
141
|
-
}))), /*#__PURE__*/React.createElement(SecondChildWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
142
|
-
className: ax([styles.customToolbarWrapperStyle])
|
|
143
|
-
}, !!customPrimaryToolbarComponents && 'before' in customPrimaryToolbarComponents && /*#__PURE__*/React.createElement("div", {
|
|
144
|
-
"data-testid": 'before-primary-toolbar-components-plugin',
|
|
145
|
-
className: ax([styles.beforePrimaryToolbarComponents])
|
|
146
|
-
}, customPrimaryToolbarComponents.before), !!customPrimaryToolbarComponents && 'after' in customPrimaryToolbarComponents ? customPrimaryToolbarComponents.after : customPrimaryToolbarComponents)), /*#__PURE__*/React.createElement(ToolbarPortalMountPoint, null)))));
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
return /*#__PURE__*/React.createElement(ContextPanelConsumer, null, function (_ref7) {
|
|
150
|
-
var ContextPanelWidth = _ref7.width;
|
|
151
|
-
return /*#__PURE__*/React.createElement(ExcludeFromHydration, {
|
|
152
|
-
fallback: /*#__PURE__*/React.createElement(ToolbarPlaceholder, null)
|
|
153
|
-
}, /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
|
|
108
|
+
return /*#__PURE__*/React.createElement(ContextPanelConsumer, null, function (_ref6) {
|
|
109
|
+
var ContextPanelWidth = _ref6.width;
|
|
110
|
+
return /*#__PURE__*/React.createElement(ToolbarArrowKeyNavigationProvider, {
|
|
154
111
|
editorView: editorView,
|
|
155
112
|
childComponentSelector: "[data-testid='ak-editor-main-toolbar']",
|
|
156
113
|
isShortcutToFocusToolbar: isShortcutToFocusToolbar,
|
|
@@ -161,7 +118,7 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
|
|
|
161
118
|
showKeyline: showKeyline || ContextPanelWidth > 0
|
|
162
119
|
}, beforeIcon && /*#__PURE__*/React.createElement("div", {
|
|
163
120
|
className: ax([styles.mainToolbarIconBefore, styles.mainToolbarIconBeforeNew])
|
|
164
|
-
}, beforeIcon), /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FirstChildWrapper, null, primaryToolbarDockingConfigEnabled && components && isToolbar(toolbar) && editorView && !isSSR() && /*#__PURE__*/React.createElement(ToolbarNext, {
|
|
121
|
+
}, 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, {
|
|
165
122
|
toolbar: toolbar,
|
|
166
123
|
components: components,
|
|
167
124
|
editorView: editorView,
|
|
@@ -169,11 +126,11 @@ export var FullPageToolbarNext = function FullPageToolbarNext(_ref4) {
|
|
|
169
126
|
popupsMountPoint: mountPoint,
|
|
170
127
|
editorAppearance: "full-page",
|
|
171
128
|
isDisabled: disabled
|
|
172
|
-
})), /*#__PURE__*/React.createElement(SecondChildWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
129
|
+
}))), /*#__PURE__*/React.createElement(SecondChildWrapper, null, /*#__PURE__*/React.createElement("div", {
|
|
173
130
|
className: ax([styles.customToolbarWrapperStyle])
|
|
174
131
|
}, !!customPrimaryToolbarComponents && 'before' in customPrimaryToolbarComponents && /*#__PURE__*/React.createElement("div", {
|
|
175
132
|
"data-testid": 'before-primary-toolbar-components-plugin',
|
|
176
133
|
className: ax([styles.beforePrimaryToolbarComponents])
|
|
177
|
-
}, customPrimaryToolbarComponents.before), !!customPrimaryToolbarComponents && 'after' in customPrimaryToolbarComponents ? customPrimaryToolbarComponents.after : customPrimaryToolbarComponents)), /*#__PURE__*/React.createElement(ToolbarPortalMountPoint, null)))))
|
|
134
|
+
}, customPrimaryToolbarComponents.before), !!customPrimaryToolbarComponents && 'after' in customPrimaryToolbarComponents ? customPrimaryToolbarComponents.after : customPrimaryToolbarComponents)), /*#__PURE__*/React.createElement(ToolbarPortalMountPoint, null)))));
|
|
178
135
|
});
|
|
179
136
|
};
|