@ckeditor/ckeditor5-core 43.1.0-alpha.6 → 43.1.0-alpha.7

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.
@@ -814,8 +814,8 @@ export interface EditorConfig {
814
814
  *
815
815
  * We strongly recommend overwriting the default function to avoid XSS vulnerabilities.
816
816
  *
817
- * Read more about the security aspect of this feature in the {@glink features/html/html-embed#security "Security"} section of
818
- * the {@glink features/html/html-embed HTML embed} feature guide.
817
+ * Read more about the security aspect of this feature in the {@glink getting-started/setup/html-security "HTML security"}
818
+ * guide.
819
819
  *
820
820
  * The function receives the input HTML (as a string), and should return an object
821
821
  * that matches the {@link module:core/editor/editorconfig~SanitizedOutput} interface.
@@ -845,7 +845,7 @@ export interface EditorConfig {
845
845
  * * {@glink features/merge-fields Merge fields}
846
846
  * (when {@link module:merge-fields/mergefieldsconfig~MergeFieldsConfig#previewHtmlValues `previewHtmlValues`} flag is set).
847
847
  */
848
- sanitizeHtml?: (html: string) => SanitizedOutput;
848
+ sanitizeHtml?: HtmlSanitizationCallback;
849
849
  /**
850
850
  * Label text for the `aria-label` attribute set on editor editing area. Used by assistive technologies
851
851
  * to tell apart multiple editor instances (editing areas) on the page. If not set, a default
@@ -1040,3 +1040,4 @@ export interface SanitizedOutput {
1040
1040
  */
1041
1041
  hasChanged: boolean;
1042
1042
  }
1043
+ export type HtmlSanitizationCallback = (html: string) => SanitizedOutput;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
- import { ObservableMixin, insertToPriorityArray, EmitterMixin, CKEditorError, Config, Locale, Collection, KeystrokeHandler, setDataInElement } from '@ckeditor/ckeditor5-utils/dist/index.js';
5
+ import { ObservableMixin, insertToPriorityArray, EmitterMixin, CKEditorError, Config, Locale, Collection, KeystrokeHandler, logWarning, setDataInElement } from '@ckeditor/ckeditor5-utils/dist/index.js';
6
6
  import { Model, StylesProcessor, DataController, EditingController, Conversion } from '@ckeditor/ckeditor5-engine/dist/index.js';
7
7
  import { EditorWatchdog, ContextWatchdog } from '@ckeditor/ckeditor5-watchdog/dist/index.js';
8
8
  import { isFunction } from 'lodash-es';
@@ -1844,6 +1844,21 @@ const DEFAULT_GROUP_ID = 'common';
1844
1844
  this.config = new Config(rest, defaultConfig);
1845
1845
  this.config.define('plugins', availablePlugins);
1846
1846
  this.config.define(this._context._getEditorConfig());
1847
+ this.config.define('sanitizeHtml', function(rawHtml) {
1848
+ /**
1849
+ * One of the editor features directly inserts unsanitized HTML code into the editor.
1850
+ * It is strongly recommended to define a sanitize function that will clean up the input HTML
1851
+ * in order to avoid XSS vulnerability.
1852
+ *
1853
+ * For a detailed overview, check the {@glink getting-started/setup/html-security "HTML security"} guide.
1854
+ *
1855
+ * @error provide-sanitize-function
1856
+ */ logWarning('provide-sanitize-function');
1857
+ return {
1858
+ html: rawHtml,
1859
+ hasChanged: false
1860
+ };
1861
+ });
1847
1862
  this.plugins = new PluginCollection(this, availablePlugins, this._context.plugins);
1848
1863
  this.locale = this._context.locale;
1849
1864
  this.t = this.locale.t;