From 6760566726a66701af68eb6d37789d88feb9e8e4 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 23 Aug 2024 16:57:13 +0400 Subject: [PATCH 1/3] Remove the border update in handleDrop. Fixes https://github.com/GrapesJS/mjml/issues/338 --- src/utils/Droppable.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/Droppable.ts b/src/utils/Droppable.ts index 6d0e5947ec..37bfd2d5f0 100644 --- a/src/utils/Droppable.ts +++ b/src/utils/Droppable.ts @@ -215,7 +215,6 @@ export default class Droppable { const { dragContent } = this; const dt = (ev as DragEvent).dataTransfer; const content = this.getContentByData(dt).content; - (ev.target as HTMLElement).style.border = ''; content && dragContent && dragContent(content); this.endDrop(!content, ev); } From 6422c7050b31648d0198dc8a86d37b40c775b9f2 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 25 Aug 2024 18:51:10 +0400 Subject: [PATCH 2/3] Allow custom parser options in component text view `disableEditing` --- src/common/index.ts | 3 +++ src/dom_components/model/Components.ts | 8 ++++---- src/dom_components/types.ts | 5 +++++ src/dom_components/view/ComponentTextView.ts | 4 ++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/common/index.ts b/src/common/index.ts index 6f9f74c931..5f1307bc0e 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 878ae0b077..452fd30eee 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 fbca116581..e62ce15144 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 d67ec35219..8fcd424936 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 Date: Mon, 26 Aug 2024 15:50:36 +0400 Subject: [PATCH 3/3] Format --- src/common/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/index.ts b/src/common/index.ts index 5f1307bc0e..943d4ad02a 100644 --- a/src/common/index.ts +++ b/src/common/index.ts @@ -14,7 +14,7 @@ export type DisableOptions = { fromMove?: boolean }; export type LocaleOptions = { locale?: boolean }; -export type WithHTMLParserOptions = { parserOptions?: HTMLParserOptions; }; +export type WithHTMLParserOptions = { parserOptions?: HTMLParserOptions }; export type RemoveOptions = Backbone.Silenceable;