@ckeditor/ckeditor5-core 43.0.0-alpha.5 → 43.0.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/dist/editor/editorconfig.d.ts +50 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/editor/editorconfig.d.ts +50 -0
- package/src/index.d.ts +1 -1
|
@@ -809,6 +809,43 @@ export interface EditorConfig {
|
|
|
809
809
|
* Translations to be used in the editor.
|
|
810
810
|
*/
|
|
811
811
|
translations?: ArrayOrItem<Translations>;
|
|
812
|
+
/**
|
|
813
|
+
* Callback used to sanitize the HTML provided by the user when generating previews of it in the editor.
|
|
814
|
+
*
|
|
815
|
+
* We strongly recommend overwriting the default function to avoid XSS vulnerabilities.
|
|
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.
|
|
819
|
+
*
|
|
820
|
+
* The function receives the input HTML (as a string), and should return an object
|
|
821
|
+
* that matches the {@link module:core/editor/editorconfig~SanitizedOutput} interface.
|
|
822
|
+
*
|
|
823
|
+
* ```ts
|
|
824
|
+
* ClassicEditor
|
|
825
|
+
* .create( editorElement, {
|
|
826
|
+
* sanitizeHtml( inputHtml ) {
|
|
827
|
+
* // Strip unsafe elements and attributes, e.g.:
|
|
828
|
+
* // the `<script>` elements and `on*` attributes.
|
|
829
|
+
* const outputHtml = sanitize( inputHtml );
|
|
830
|
+
*
|
|
831
|
+
* return {
|
|
832
|
+
* html: outputHtml,
|
|
833
|
+
* // `true` or `false` depending on whether the sanitizer stripped anything.
|
|
834
|
+
* hasChanged: inputHtml !== outputHtml
|
|
835
|
+
* };
|
|
836
|
+
* } )
|
|
837
|
+
* .then( ... )
|
|
838
|
+
* .catch( ... );
|
|
839
|
+
* ```
|
|
840
|
+
*
|
|
841
|
+
* This function is used by following features:
|
|
842
|
+
*
|
|
843
|
+
* * {@glink features/html/html-embed HTML embed}
|
|
844
|
+
* (when {@link module:html-embed/htmlembedconfig~HtmlEmbedConfig#showPreviews `showPreviews`} flag is set).
|
|
845
|
+
* * {@glink features/merge-fields Merge fields}
|
|
846
|
+
* (when {@link module:merge-fields/mergefieldsconfig~MergeFieldsConfig#previewHtmlValues `previewHtmlValues`} flag is set).
|
|
847
|
+
*/
|
|
848
|
+
sanitizeHtml?: (html: string) => SanitizedOutput;
|
|
812
849
|
}
|
|
813
850
|
/**
|
|
814
851
|
* The `config.initialData` option cannot be used together with the initial data passed as the first parameter of
|
|
@@ -949,3 +986,16 @@ export interface UiConfig {
|
|
|
949
986
|
**/
|
|
950
987
|
poweredBy?: PoweredByConfig;
|
|
951
988
|
}
|
|
989
|
+
/**
|
|
990
|
+
* An object returned by the {@link module:core/editor/editorconfig~EditorConfig#sanitizeHtml} function.
|
|
991
|
+
*/
|
|
992
|
+
export interface SanitizedOutput {
|
|
993
|
+
/**
|
|
994
|
+
* An output (safe) HTML that will be inserted into the {@glink framework/architecture/editing-engine editing view}.
|
|
995
|
+
*/
|
|
996
|
+
html: string;
|
|
997
|
+
/**
|
|
998
|
+
* A flag that indicates whether the output HTML is different than the input value.
|
|
999
|
+
*/
|
|
1000
|
+
hasChanged: boolean;
|
|
1001
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export { default as ContextPlugin, type ContextPluginDependencies } from './cont
|
|
|
19
19
|
export { type EditingKeystrokeCallback } from './editingkeystrokehandler.js';
|
|
20
20
|
export type { PartialBy, NonEmptyArray, HexColor } from './typings.js';
|
|
21
21
|
export { default as Editor, type EditorReadyEvent, type EditorDestroyEvent } from './editor/editor.js';
|
|
22
|
-
export type { EditorConfig, LanguageConfig, ToolbarConfig, ToolbarConfigItem, UiConfig } from './editor/editorconfig.js';
|
|
22
|
+
export type { EditorConfig, LanguageConfig, ToolbarConfig, ToolbarConfigItem, UiConfig, SanitizedOutput } from './editor/editorconfig.js';
|
|
23
23
|
export { default as attachToForm } from './editor/utils/attachtoform.js';
|
|
24
24
|
export { default as DataApiMixin, type DataApi } from './editor/utils/dataapimixin.js';
|
|
25
25
|
export { default as ElementApiMixin, type ElementApi } from './editor/utils/elementapimixin.js';
|