From d5c64ff26161e8ca1ee7498d02842cae5967ecff Mon Sep 17 00:00:00 2001 From: mohamedsalem401 Date: Mon, 20 Jan 2025 02:35:51 +0200 Subject: [PATCH] Cleanup --- .../src/dom_components/model/Component.ts | 38 ------------------- .../core/src/dom_components/model/types.ts | 33 ---------------- 2 files changed, 71 deletions(-) diff --git a/packages/core/src/dom_components/model/Component.ts b/packages/core/src/dom_components/model/Component.ts index 599eb59c6..571f1ef08 100644 --- a/packages/core/src/dom_components/model/Component.ts +++ b/packages/core/src/dom_components/model/Component.ts @@ -26,7 +26,6 @@ import { ComponentDefinitionDefined, ComponentOptions, ComponentProperties, - DeepPropagationArray, DragMode, ResetComponentsOptions, SymbolToUpOptions, @@ -129,8 +128,6 @@ export const keyCollectionsStateMap = '__collections_state_map'; * @property {Array} [propagate=[]] Indicates an array of properties which will be inhereted by all NEW appended children. * For example if you create a component likes this: `{ removable: false, draggable: false, propagate: ['removable', 'draggable'] }` * and append some new component inside, the new added component will get the exact same properties indicated in the `propagate` array (and the `propagate` property itself). Default: `[]` - * @property {Array} [deepPropagate=[]] Indicates an array of properties or functions that will be inherited by all descendant - * components, including those nested within multiple levels of child components. * @property {Array} [toolbar=null] Set an array of items to show up inside the toolbar when the component is selected (move, clone, delete). * Eg. `toolbar: [ { attributes: {class: 'fa fa-arrows'}, command: 'tlb-move' }, ... ]`. * By default, when `toolbar` property is falsy the editor will add automatically commands `core:component-exit` (select parent component, added if there is one), `tlb-move` (added if `draggable`) , `tlb-clone` (added if `copyable`), `tlb-delete` (added if `removable`). @@ -177,7 +174,6 @@ export default class Component extends StyleableModel { attributes: {}, traits: ['id', 'title'], propagate: '', - deepPropagate: '', dmode: '', toolbar: null, delegate: null, @@ -265,7 +261,6 @@ export default class Component extends StyleableModel { * @ts-ignore */ collection!: Components; componentDVListener: ComponentDynamicValueWatcher; - accumulatedPropagatedProps: DeepPropagationArray = []; collectionStateListeners: string[] = []; constructor(props: ComponentProperties = {}, opt: ComponentOptions) { @@ -352,16 +347,6 @@ export default class Component extends StyleableModel { } } - getCollectionStateMap(): DataCollectionStateMap { - const collectionStateMapProp = this.get(keyCollectionsStateMap); - if (collectionStateMapProp) { - return collectionStateMapProp; - } - - const parent = this.parent(); - return parent?.getCollectionStateMap() || {}; - } - set( keyOrAttributes: A | Partial, valueOrOptions?: ComponentProperties[A] | ComponentSetOptions, @@ -387,28 +372,6 @@ export default class Component extends StyleableModel { return super.set(evaluatedProps, options); } - propagateDeeplyFromParent() { - const parent = this.parent(); - if (!parent) return; - const parentDeepPropagate = parent.accumulatedPropagatedProps; - - // Execute functions and set inherited properties - if (parentDeepPropagate) { - const newAttr: Partial = {}; - parentDeepPropagate.forEach((prop) => { - if (typeof prop === 'string' && isUndefined(this.get(prop))) { - newAttr[prop] = parent.get(prop as string); - } else if (typeof prop === 'function') { - prop(this); // Execute function on current component - } - }); - - this.set({ ...newAttr }); - } - - this.accumulatedPropagatedProps = [...(this.get('deepPropagate') ?? []), ...parentDeepPropagate]; - } - __postAdd(opts: { recursive?: boolean } = {}) { const { em } = this; const um = em?.UndoManager; @@ -1640,7 +1603,6 @@ export default class Component extends StyleableModel { delete obj[keyCollectionsStateMap]; delete obj[keyIsCollectionItem]; delete obj.attributes.id; - delete obj.deepPropagate; } if (!opts.fromUndo) { diff --git a/packages/core/src/dom_components/model/types.ts b/packages/core/src/dom_components/model/types.ts index 0c9cfa237..509d0dd15 100644 --- a/packages/core/src/dom_components/model/types.ts +++ b/packages/core/src/dom_components/model/types.ts @@ -83,8 +83,6 @@ export interface ComponentDelegateProps { layer?: (cmp: Component) => Component | Nullable; } -export type DeepPropagationArray = (keyof ComponentProperties | ((component: Component) => void))[]; - export interface ComponentProperties { /** * Component type, eg. `text`, `image`, `video`, etc. @@ -233,37 +231,6 @@ export interface ComponentProperties { */ propagate?: (keyof ComponentProperties)[]; - /** - * @property {Array} [deepPropagate=[]] - * - * Indicates an array of properties or functions that will be inherited by all descendant - * components, including those nested within multiple levels of child components. - * - * **Properties:** - * The names of properties (as strings) that will be inherited by all descendants. - * - * **Functions:** - * Functions that will be executed on each descendant component during the propagation process. - * Functions can optionally receive the current component as an argument, - * allowing them to interact with or modify the component's properties or behavior. - * - * **Example:** - * - * ```typescript - * { - * removable: false, - * draggable: false, - * deepPropagate: ['removable', 'draggable', applyDefaultStyles] - * } - * ``` - * - * In this example: - * - `removable` and `draggable` properties will be inherited by all descendants. - * - `applyDefaultStyles` is a function that will be executed on each descendant - * component during the propagation process. - */ - deepPropagate?: DeepPropagationArray; - /** * Set an array of items to show up inside the toolbar when the component is selected (move, clone, delete). * Eg. `toolbar: [ { attributes: {class: 'fa fa-arrows'}, command: 'tlb-move' }, ... ]`.