diff --git a/package.json b/package.json index 4fec3c264..b69cbaae9 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "dependencies": { "@types/backbone": "1.4.15", "backbone": "1.4.1", - "backbone-undo": "0.2.5", + "backbone-undo": "0.2.6", "codemirror": "5.63.0", "codemirror-formatting": "1.0.0", "promise-polyfill": "8.1.3", @@ -64,7 +64,7 @@ "sass": "1.42.1", "typescript": "5.5.4", "vuepress": "1.9.10", - "whatwg-fetch": "3.6.2" + "whatwg-fetch": "3.6.20" }, "resolutions": { "backbone-undo/backbone": "1.3.3", diff --git a/src/common/index.ts b/src/common/index.ts index e7a1826ae..93a15345f 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -1,4 +1,5 @@ import Backbone from 'backbone'; +import { HTMLParserOptions } from '../parser/config/config'; export { default as $ } from '../utils/cash-dom'; interface NOOP {} @@ -13,6 +14,8 @@ export type DisableOptions = { fromMove?: boolean }; export type LocaleOptions = { locale?: boolean }; +export type WithHTMLParserOptions = { parserOptions?: HTMLParserOptions }; + export type RemoveOptions = Backbone.Silenceable; export type EventHandler = Backbone.EventHandler; diff --git a/src/dom_components/model/Components.ts b/src/dom_components/model/Components.ts index 878ae0b07..452fd30ee 100644 --- a/src/dom_components/model/Components.ts +++ b/src/dom_components/model/Components.ts @@ -1,6 +1,6 @@ import { isEmpty, isArray, isString, isFunction, each, includes, extend, flatten, keys } from 'underscore'; import Component from './Component'; -import { AddOptions, Collection, OptionAsDocument } from '../../common'; +import { AddOptions, Collection } from '../../common'; import { DomComponentsConfig } from '../config/config'; import EditorModel from '../../editor/model/Editor'; import ComponentManager from '..'; @@ -15,7 +15,7 @@ import { } from './types'; import ComponentText from './ComponentText'; import ComponentWrapper from './ComponentWrapper'; -import { ComponentsEvents } from '../types'; +import { ComponentsEvents, ParseStringOptions } from '../types'; import { isSymbolInstance, isSymbolRoot, updateSymbolComps } from './SymbolUtils'; export const getComponentIds = (cmp?: Component | Component[] | Components, res: string[] = []) => { @@ -252,11 +252,11 @@ Component> { return new model(attrs, options) as Component; } - parseString(value: string, opt: AddOptions & OptionAsDocument & { temporary?: boolean; keepIds?: string[] } = {}) { + parseString(value: string, opt: ParseStringOptions = {}) { const { em, domc, parent } = this; const asDocument = opt.asDocument && parent?.is('wrapper'); const cssc = em.Css; - const parsed = em.Parser.parseHtml(value, { asDocument }); + const parsed = em.Parser.parseHtml(value, { asDocument, ...opt.parserOptions }); let components = parsed.html; if (asDocument) { diff --git a/src/dom_components/types.ts b/src/dom_components/types.ts index fbca11658..e62ce1514 100644 --- a/src/dom_components/types.ts +++ b/src/dom_components/types.ts @@ -1,3 +1,4 @@ +import { AddOptions, OptionAsDocument, WithHTMLParserOptions } from '../common'; import Component from './model/Component'; export enum ActionLabelComponents { @@ -16,6 +17,10 @@ export interface SymbolInfo { relatives: Component[]; } +export interface ParseStringOptions extends AddOptions, OptionAsDocument, WithHTMLParserOptions { + keepIds?: string[]; +} + export enum ComponentsEvents { /** * @event `component:add` New component added. diff --git a/src/dom_components/view/ComponentTextView.ts b/src/dom_components/view/ComponentTextView.ts index d67ec3521..8fcd42493 100644 --- a/src/dom_components/view/ComponentTextView.ts +++ b/src/dom_components/view/ComponentTextView.ts @@ -1,5 +1,5 @@ import { bindAll } from 'underscore'; -import { AddOptions, DisableOptions, ObjectAny } from '../../common'; +import { AddOptions, DisableOptions, ObjectAny, WithHTMLParserOptions } from '../../common'; import RichTextEditorModule from '../../rich_text_editor'; import RichTextEditor from '../../rich_text_editor/model/RichTextEditor'; import { off, on } from '../../utils/dom'; @@ -108,7 +108,7 @@ export default class ComponentTextView=1.0.0" + underscore ">=1.4.4" -"backbone@1.0.0 - 1.2.1", backbone@1.3.3: +backbone@1.3.3, backbone@>=1.0.0: version "1.3.3" resolved "https://registry.npmjs.org/backbone/-/backbone-1.3.3.tgz#4cc80ea7cb1631ac474889ce40f2f8bc683b2999" integrity sha512-aK+k3TiU4tQDUrRCymDDE7XDFnMVuyE6zbZ4JX7mb4pJbQTVOH997/kyBzb8wB2s5Y/Oh7EUfj+sZhwRPxWwow== @@ -13508,7 +13508,7 @@ unc-path-regex@^0.1.2: resolved "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" integrity sha512-eXL4nmJT7oCpkZsHZUOJo8hcX3GbsiDOa0Qu9F646fi8dT3XuSVopVqAcEiVzSKKH7UoDti23wNX3qGFxcW5Qg== -underscore@1.13.1, "underscore@1.4.4 - 1.8.3": +underscore@1.13.1, underscore@>=1.4.4: version "1.13.1" resolved "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz#0c1c6bd2df54b6b69f2314066d65b6cde6fcf9d1" integrity sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g== @@ -14401,10 +14401,10 @@ whatwg-encoding@^3.1.1: dependencies: iconv-lite "0.6.3" -whatwg-fetch@3.6.2: - version "3.6.2" - resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c" - integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA== +whatwg-fetch@3.6.20: + version "3.6.20" + resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70" + integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg== whatwg-mimetype@^3.0.0: version "3.0.0"