@ckeditor/ckeditor5-core 47.6.1 → 48.0.0-alpha.1

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.
Files changed (122) hide show
  1. package/LICENSE.md +1 -1
  2. package/{src → dist}/editor/editorconfig.d.ts +295 -20
  3. package/dist/editor/utils/normalizerootsconfig.d.ts +50 -0
  4. package/dist/index-content.css +10 -10
  5. package/dist/index-editor.css +5 -5
  6. package/dist/index.css +10 -16
  7. package/dist/index.css.map +1 -1
  8. package/{src → dist}/index.d.ts +2 -1
  9. package/dist/index.js +161 -6
  10. package/dist/index.js.map +1 -1
  11. package/package.json +23 -43
  12. package/lang/contexts.json +0 -38
  13. package/lang/translations/af.po +0 -156
  14. package/lang/translations/ar.po +0 -156
  15. package/lang/translations/ast.po +0 -156
  16. package/lang/translations/az.po +0 -156
  17. package/lang/translations/be.po +0 -156
  18. package/lang/translations/bg.po +0 -156
  19. package/lang/translations/bn.po +0 -156
  20. package/lang/translations/bs.po +0 -156
  21. package/lang/translations/ca.po +0 -156
  22. package/lang/translations/cs.po +0 -156
  23. package/lang/translations/da.po +0 -156
  24. package/lang/translations/de-ch.po +0 -156
  25. package/lang/translations/de.po +0 -156
  26. package/lang/translations/el.po +0 -156
  27. package/lang/translations/en-au.po +0 -156
  28. package/lang/translations/en-gb.po +0 -156
  29. package/lang/translations/en.po +0 -156
  30. package/lang/translations/eo.po +0 -156
  31. package/lang/translations/es-co.po +0 -156
  32. package/lang/translations/es.po +0 -156
  33. package/lang/translations/et.po +0 -156
  34. package/lang/translations/eu.po +0 -156
  35. package/lang/translations/fa.po +0 -156
  36. package/lang/translations/fi.po +0 -156
  37. package/lang/translations/fr.po +0 -156
  38. package/lang/translations/gl.po +0 -156
  39. package/lang/translations/gu.po +0 -156
  40. package/lang/translations/he.po +0 -156
  41. package/lang/translations/hi.po +0 -156
  42. package/lang/translations/hr.po +0 -156
  43. package/lang/translations/hu.po +0 -156
  44. package/lang/translations/hy.po +0 -156
  45. package/lang/translations/id.po +0 -156
  46. package/lang/translations/it.po +0 -156
  47. package/lang/translations/ja.po +0 -156
  48. package/lang/translations/jv.po +0 -156
  49. package/lang/translations/kk.po +0 -156
  50. package/lang/translations/km.po +0 -156
  51. package/lang/translations/kn.po +0 -156
  52. package/lang/translations/ko.po +0 -156
  53. package/lang/translations/ku.po +0 -156
  54. package/lang/translations/lt.po +0 -156
  55. package/lang/translations/lv.po +0 -156
  56. package/lang/translations/ms.po +0 -156
  57. package/lang/translations/nb.po +0 -156
  58. package/lang/translations/ne.po +0 -156
  59. package/lang/translations/nl.po +0 -156
  60. package/lang/translations/no.po +0 -156
  61. package/lang/translations/oc.po +0 -156
  62. package/lang/translations/pl.po +0 -156
  63. package/lang/translations/pt-br.po +0 -156
  64. package/lang/translations/pt.po +0 -156
  65. package/lang/translations/ro.po +0 -156
  66. package/lang/translations/ru.po +0 -156
  67. package/lang/translations/si.po +0 -156
  68. package/lang/translations/sk.po +0 -156
  69. package/lang/translations/sl.po +0 -156
  70. package/lang/translations/sq.po +0 -156
  71. package/lang/translations/sr-latn.po +0 -156
  72. package/lang/translations/sr.po +0 -156
  73. package/lang/translations/sv.po +0 -156
  74. package/lang/translations/th.po +0 -156
  75. package/lang/translations/ti.po +0 -156
  76. package/lang/translations/tk.po +0 -156
  77. package/lang/translations/tr.po +0 -156
  78. package/lang/translations/tt.po +0 -156
  79. package/lang/translations/ug.po +0 -156
  80. package/lang/translations/uk.po +0 -156
  81. package/lang/translations/ur.po +0 -156
  82. package/lang/translations/uz.po +0 -156
  83. package/lang/translations/vi.po +0 -156
  84. package/lang/translations/zh-cn.po +0 -156
  85. package/lang/translations/zh.po +0 -156
  86. package/src/accessibility.js +0 -332
  87. package/src/augmentation.js +0 -5
  88. package/src/command.js +0 -221
  89. package/src/commandcollection.js +0 -87
  90. package/src/context.js +0 -315
  91. package/src/contextplugin.js +0 -59
  92. package/src/editingkeystrokehandler.js +0 -61
  93. package/src/editor/editor.js +0 -1010
  94. package/src/editor/editorconfig.js +0 -5
  95. package/src/editor/utils/attachtoform.js +0 -57
  96. package/src/editor/utils/editorusagedata.js +0 -127
  97. package/src/editor/utils/elementapimixin.js +0 -42
  98. package/src/editor/utils/securesourceelement.js +0 -35
  99. package/src/index.js +0 -22
  100. package/src/multicommand.js +0 -79
  101. package/src/pendingactions.js +0 -127
  102. package/src/plugin.js +0 -132
  103. package/src/plugincollection.js +0 -506
  104. package/src/typings.js +0 -5
  105. package/theme/core.css +0 -21
  106. /package/{src → dist}/accessibility.d.ts +0 -0
  107. /package/{src → dist}/augmentation.d.ts +0 -0
  108. /package/{src → dist}/command.d.ts +0 -0
  109. /package/{src → dist}/commandcollection.d.ts +0 -0
  110. /package/{src → dist}/context.d.ts +0 -0
  111. /package/{src → dist}/contextplugin.d.ts +0 -0
  112. /package/{src → dist}/editingkeystrokehandler.d.ts +0 -0
  113. /package/{src → dist}/editor/editor.d.ts +0 -0
  114. /package/{src → dist}/editor/utils/attachtoform.d.ts +0 -0
  115. /package/{src → dist}/editor/utils/editorusagedata.d.ts +0 -0
  116. /package/{src → dist}/editor/utils/elementapimixin.d.ts +0 -0
  117. /package/{src → dist}/editor/utils/securesourceelement.d.ts +0 -0
  118. /package/{src → dist}/multicommand.d.ts +0 -0
  119. /package/{src → dist}/pendingactions.d.ts +0 -0
  120. /package/{src → dist}/plugin.d.ts +0 -0
  121. /package/{src → dist}/plugincollection.d.ts +0 -0
  122. /package/{src → dist}/typings.d.ts +0 -0
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
4
  */
5
- import { ObservableMixin, insertToPriorityArray, CKEditorError, EmitterMixin, Config, Locale, Collection, KeystrokeHandler, env, global, uid, decodeLicenseKey, toArray, crc32, releaseDate, logError, isFeatureBlockedByLicenseKey, setDataInElement } from '@ckeditor/ckeditor5-utils/dist/index.js';
6
- import { get, set, isFunction } from 'es-toolkit/compat';
5
+ import { ObservableMixin, insertToPriorityArray, CKEditorError, EmitterMixin, Config, Locale, Collection, KeystrokeHandler, env, global, uid, decodeLicenseKey, toArray, crc32, releaseDate, logError, isFeatureBlockedByLicenseKey, setDataInElement, getDataFromElement } from '@ckeditor/ckeditor5-utils/dist/index.js';
6
+ import { get, set, isFunction, isElement as isElement$1 } from 'es-toolkit/compat';
7
7
  import { Model, StylesProcessor, DataController, EditingController, Conversion } from '@ckeditor/ckeditor5-engine/dist/index.js';
8
8
  import { EditorWatchdog, ContextWatchdog } from '@ckeditor/ckeditor5-watchdog/dist/index.js';
9
9
 
@@ -726,8 +726,8 @@ import { EditorWatchdog, ContextWatchdog } from '@ckeditor/ckeditor5-watchdog/di
726
726
  * current list of plugins (`Editor.builtinPlugins` or `config.plugins`/`config.extraPlugins`).
727
727
  *
728
728
  * Soft requirements were introduced in version 26.0.0. If you happen to stumble upon this error
729
- * when upgrading to version 26.0.0, read also the
730
- * {@glink updating/guides/update-to-26 Migration to 26.0.0} guide.
729
+ * when upgrading to version 26.0.0, read also the `Update to v26.x` section in the
730
+ * {@glink updating/guides/updating-from-older-versions updating from older versions} guide.
731
731
  *
732
732
  * @error plugincollection-soft-required
733
733
  * @param {string} missingPlugin The name of the required plugin.
@@ -2111,7 +2111,8 @@ function getPageSessionID() {
2111
2111
  * use the 'GPL' license key instead.
2112
2112
  *
2113
2113
  * ```js
2114
- * ClassicEditor.create( document.querySelector( '#editor' ), {
2114
+ * ClassicEditor.create( {
2115
+ * attachTo: document.querySelector( '#editor' ),
2115
2116
  * licenseKey: '<YOUR_LICENSE_KEY>', // Or 'GPL'.
2116
2117
  * // ... Other configuration options ...
2117
2118
  * } ) ;
@@ -2880,6 +2881,160 @@ function isTextArea(sourceElement) {
2880
2881
  });
2881
2882
  }
2882
2883
 
2884
+ /**
2885
+ * Normalizes the editor roots configuration. It ensures that all root configurations are defined in `config.roots`
2886
+ * and that they have `initialData` defined.
2887
+ *
2888
+ * It normalizes a single-root configuration (where `config.root` is used) to a multi-root configuration
2889
+ * (where all roots are defined in `config.roots`). This is considered a standard configuration format,
2890
+ * so the editor features can always expect roots to be defined in `config.roots`.
2891
+ *
2892
+ * It also handles legacy configuration options, such as `config.initialData`, `config.placeholder`, and `config.label`.
2893
+ *
2894
+ * @internal
2895
+ */ function normalizeRootsConfig(sourceElementsOrData, config, defaultRootName = 'main', separateAttachTo = false) {
2896
+ const mainRootConfig = config.get('root');
2897
+ const rootsConfig = config.get('roots') || Object.create(null);
2898
+ // Avoid mixing `config.root` and `config.roots.main`.
2899
+ if (mainRootConfig && (!defaultRootName || defaultRootName in rootsConfig)) {
2900
+ // Documented in core/editor/editorconfig.ts.
2901
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
2902
+ throw new CKEditorError('editor-create-roots-initial-data');
2903
+ }
2904
+ // Move `config.root` to `config.roots.main`.
2905
+ // This makes access to root configuration more consistent as all roots will be defined in `config.roots`.
2906
+ if (defaultRootName && !rootsConfig[defaultRootName]) {
2907
+ rootsConfig[defaultRootName] = mainRootConfig || Object.create(null);
2908
+ }
2909
+ const sourceElementIsPlainObject = isPlainObject(sourceElementsOrData);
2910
+ // Collect legacy configuration values for `initialData`, `placeholder`, and `label` from the config.
2911
+ const legacyInitialData = getLegacyInitialData(config, sourceElementIsPlainObject, defaultRootName);
2912
+ // Collect root names. This includes root names from the source element (if it's an object),
2913
+ // from `config.roots`, and from legacy config. This ensures that all roots are processed in the next step.
2914
+ const rootNames = Array.from(new Set([
2915
+ ...sourceElementIsPlainObject ? Object.keys(sourceElementsOrData) : [],
2916
+ ...Object.keys(rootsConfig),
2917
+ ...Object.keys(legacyInitialData)
2918
+ ]));
2919
+ // Ensure that all roots have `initialData` defined. If not, try to get it from the source element or data.
2920
+ for (const rootName of rootNames){
2921
+ const rootConfig = rootsConfig[rootName] || Object.create(null);
2922
+ const sourceElementOrDataForRoot = sourceElementIsPlainObject ? sourceElementsOrData[rootName] : sourceElementsOrData;
2923
+ // No dedicated initial data for the root.
2924
+ if (rootConfig.initialData === undefined) {
2925
+ // No legacy initial data for the root, either.
2926
+ if (legacyInitialData[rootName] === undefined) {
2927
+ // Use source element data or data itself as a string.
2928
+ // Fall back to `rootConfig.element` or `config.attachTo` (for ClassicEditor) for data extraction.
2929
+ rootConfig.initialData = getInitialData(sourceElementOrDataForRoot || rootConfig.element || separateAttachTo && config.get('attachTo') || '');
2930
+ } else if (sourceElementOrDataForRoot && !isElement(sourceElementOrDataForRoot)) {
2931
+ // Documented in core/editor/editorconfig.ts.
2932
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
2933
+ throw new CKEditorError('editor-create-initial-data', null);
2934
+ } else {
2935
+ rootConfig.initialData = legacyInitialData[rootName];
2936
+ }
2937
+ } else if (sourceElementOrDataForRoot && !isElement(sourceElementOrDataForRoot)) {
2938
+ // Documented in core/editor/editorconfig.ts.
2939
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
2940
+ throw new CKEditorError('editor-create-initial-data', null);
2941
+ } else if (legacyInitialData[rootName] !== undefined) {
2942
+ // Documented in core/editor/editorconfig.ts.
2943
+ // eslint-disable-next-line ckeditor5-rules/ckeditor-error-message
2944
+ throw new CKEditorError('editor-create-roots-initial-data');
2945
+ }
2946
+ // Assign `sourceElement` to root config if it's an element.
2947
+ if (!separateAttachTo && isElement(sourceElementOrDataForRoot)) {
2948
+ rootConfig.element = sourceElementOrDataForRoot;
2949
+ }
2950
+ // Handle legacy `config.placeholder` and `config.label` for the root.
2951
+ rootConfig.placeholder ??= getLegacyPlainConfigValue(config, 'placeholder', rootName);
2952
+ rootConfig.label ??= getLegacyPlainConfigValue(config, 'label', rootName);
2953
+ rootsConfig[rootName] = rootConfig;
2954
+ }
2955
+ // The ClassicEditor has a special separate config option `attachTo`.
2956
+ // It is used as a source of editor data and attachment element, but not the root element.
2957
+ if (separateAttachTo && config.get('attachTo') === undefined && isElement(sourceElementsOrData)) {
2958
+ config.set('attachTo', sourceElementsOrData);
2959
+ }
2960
+ config.set('roots', rootsConfig);
2961
+ }
2962
+ /**
2963
+ * Normalizes the parameters passed to the editor constructor when a single root is used. It supports both of the following signatures:
2964
+ *
2965
+ * ```ts
2966
+ * new Editor( editorConfig: EditorConfig );
2967
+ * new Editor( sourceElementOrData: HTMLElement | string, editorConfig: EditorConfig );
2968
+ * ```
2969
+ *
2970
+ * @internal
2971
+ */ function normalizeSingleRootEditorConstructorParams(sourceElementOrDataOrConfig, editorConfig) {
2972
+ if (typeof sourceElementOrDataOrConfig === 'string' || isElement(sourceElementOrDataOrConfig) || editorConfig && Object.keys(editorConfig).length) {
2973
+ return {
2974
+ sourceElementOrData: sourceElementOrDataOrConfig,
2975
+ editorConfig
2976
+ };
2977
+ } else {
2978
+ return {
2979
+ sourceElementOrData: '',
2980
+ editorConfig: sourceElementOrDataOrConfig
2981
+ };
2982
+ }
2983
+ }
2984
+ /**
2985
+ * Normalizes the parameters passed to the editor constructor when a multi root is used. It supports both of the following signatures:
2986
+ *
2987
+ * ```ts
2988
+ * new Editor( editorConfig: EditorConfig );
2989
+ * new Editor( sourceElementsOrData: Record<string, string> | Record<string, HTMLElement>, editorConfig: EditorConfig );
2990
+ * ```
2991
+ *
2992
+ * @internal
2993
+ */ function normalizeMultiRootEditorConstructorParams(sourceElementOrDataOrConfig, editorConfig) {
2994
+ if (editorConfig && Object.keys(editorConfig).length || Object.keys(sourceElementOrDataOrConfig).length == 0 || Object.values(sourceElementOrDataOrConfig).every((value)=>typeof value === 'string' || isElement(value))) {
2995
+ return {
2996
+ sourceElementsOrData: sourceElementOrDataOrConfig,
2997
+ editorConfig
2998
+ };
2999
+ } else {
3000
+ return {
3001
+ sourceElementsOrData: {},
3002
+ editorConfig: sourceElementOrDataOrConfig
3003
+ };
3004
+ }
3005
+ }
3006
+ /**
3007
+ * Type guard to check if the provided value is a plain object.
3008
+ */ function isPlainObject(sourceElementsOrData) {
3009
+ return !!sourceElementsOrData && typeof sourceElementsOrData == 'object' && !Array.isArray(sourceElementsOrData) && !isElement(sourceElementsOrData);
3010
+ }
3011
+ /**
3012
+ * Retrieve data from source element or return the string data as is.
3013
+ */ function getInitialData(sourceElementOrData) {
3014
+ return isElement(sourceElementOrData) ? getDataFromElement(sourceElementOrData) : sourceElementOrData;
3015
+ }
3016
+ /**
3017
+ * Retrieve legacy configuration value for `initialData` from the config.
3018
+ * Normalize single-root config so returned value is always an object with root names as keys.
3019
+ */ function getLegacyInitialData(config, sourceElementIsObject, defaultRootName) {
3020
+ return sourceElementIsObject || !defaultRootName ? config.get('initialData') || Object.create(null) : {
3021
+ [defaultRootName]: config.get('initialData')
3022
+ };
3023
+ }
3024
+ /**
3025
+ * Retrieve legacy configuration value for `placeholder` or `label` from the config for a specific root.
3026
+ */ function getLegacyPlainConfigValue(config, key, rootName) {
3027
+ const legacyValue = config.get(key);
3028
+ if (legacyValue) {
3029
+ return typeof legacyValue == 'string' ? legacyValue : legacyValue[rootName];
3030
+ }
3031
+ }
3032
+ /**
3033
+ * An alias for `isElement` from `es-toolkit/compat` with additional type guard.
3034
+ */ function isElement(value) {
3035
+ return isElement$1(value);
3036
+ }
3037
+
2883
3038
  /**
2884
3039
  * The list of pending editor actions.
2885
3040
  *
@@ -2991,5 +3146,5 @@ function isTextArea(sourceElement) {
2991
3146
  }
2992
3147
  }
2993
3148
 
2994
- export { Accessibility, Command, CommandCollection, Context, ContextPlugin, EditingKeystrokeHandler, Editor, ElementApiMixin, MultiCommand, PendingActions, Plugin, DEFAULT_GROUP_ID as _DEFAULT_ACCESSIBILITY_GROUP_ID, getEditorUsageData as _getEditorUsageData, attachToForm, secureSourceElement };
3149
+ export { Accessibility, Command, CommandCollection, Context, ContextPlugin, EditingKeystrokeHandler, Editor, ElementApiMixin, MultiCommand, PendingActions, Plugin, DEFAULT_GROUP_ID as _DEFAULT_ACCESSIBILITY_GROUP_ID, getEditorUsageData as _getEditorUsageData, attachToForm, normalizeMultiRootEditorConstructorParams, normalizeRootsConfig, normalizeSingleRootEditorConstructorParams, secureSourceElement };
2995
3150
  //# sourceMappingURL=index.js.map