Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamedsalem401 committed Jan 20, 2025
1 parent 3d3e9e1 commit d5c64ff
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 71 deletions.
38 changes: 0 additions & 38 deletions packages/core/src/dom_components/model/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
ComponentDefinitionDefined,
ComponentOptions,
ComponentProperties,
DeepPropagationArray,
DragMode,
ResetComponentsOptions,
SymbolToUpOptions,
Expand Down Expand Up @@ -129,8 +128,6 @@ export const keyCollectionsStateMap = '__collections_state_map';
* @property {Array<String>} [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<String|Function>} [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<Object>} [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`).
Expand Down Expand Up @@ -177,7 +174,6 @@ export default class Component extends StyleableModel<ComponentProperties> {
attributes: {},
traits: ['id', 'title'],
propagate: '',
deepPropagate: '',
dmode: '',
toolbar: null,
delegate: null,
Expand Down Expand Up @@ -265,7 +261,6 @@ export default class Component extends StyleableModel<ComponentProperties> {
* @ts-ignore */
collection!: Components;
componentDVListener: ComponentDynamicValueWatcher;
accumulatedPropagatedProps: DeepPropagationArray = [];
collectionStateListeners: string[] = [];

constructor(props: ComponentProperties = {}, opt: ComponentOptions) {
Expand Down Expand Up @@ -352,16 +347,6 @@ export default class Component extends StyleableModel<ComponentProperties> {
}
}

getCollectionStateMap(): DataCollectionStateMap {
const collectionStateMapProp = this.get(keyCollectionsStateMap);
if (collectionStateMapProp) {
return collectionStateMapProp;
}

const parent = this.parent();
return parent?.getCollectionStateMap() || {};
}

set<A extends string>(
keyOrAttributes: A | Partial<ComponentProperties>,
valueOrOptions?: ComponentProperties[A] | ComponentSetOptions,
Expand All @@ -387,28 +372,6 @@ export default class Component extends StyleableModel<ComponentProperties> {
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<ComponentProperties> = {};
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;
Expand Down Expand Up @@ -1640,7 +1603,6 @@ export default class Component extends StyleableModel<ComponentProperties> {
delete obj[keyCollectionsStateMap];
delete obj[keyIsCollectionItem];
delete obj.attributes.id;
delete obj.deepPropagate;
}

if (!opts.fromUndo) {
Expand Down
33 changes: 0 additions & 33 deletions packages/core/src/dom_components/model/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -233,37 +231,6 @@ export interface ComponentProperties {
*/
propagate?: (keyof ComponentProperties)[];

/**
* @property {Array<String|Function>} [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' }, ... ]`.
Expand Down

0 comments on commit d5c64ff

Please sign in to comment.