Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Components dynamic values ( props - attributes ) #6351

Merged
merged 50 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b1c80f0
Remove unwanted paramter from datavariables
mohamedsalem401 Nov 11, 2024
2b3af46
Replace dynamic traits with dynamic attributes and props
mohamedsalem401 Nov 11, 2024
45ba340
Add tests for dynamic attributes
mohamedsalem401 Nov 11, 2024
e6d2d55
check if attributes are not changed if dynamic trait has `chageProp:t…
mohamedsalem401 Nov 11, 2024
1d8aca9
Merge branch 'dev' of https://github.com/GrapesJS/grapesjs into compo…
mohamedsalem401 Dec 4, 2024
9093bf7
Add dynamic variables to component properties and attributes
mohamedsalem401 Dec 9, 2024
948aeac
Refactor with ObjectAny
mohamedsalem401 Dec 9, 2024
d1876f6
Add component dynamic variables serialization
mohamedsalem401 Dec 9, 2024
a652a6d
fix component attributes
mohamedsalem401 Dec 10, 2024
3196771
Fix component properties
mohamedsalem401 Dec 10, 2024
8e52815
refactor getStaticValues
mohamedsalem401 Dec 10, 2024
5d99c6b
cleanup
mohamedsalem401 Dec 10, 2024
2511bfd
skip trait tests
mohamedsalem401 Dec 10, 2024
770a316
Merge branch 'dev' into components-dynamic-values
mohamedsalem401 Dec 10, 2024
d46fa1f
fix watching dynamic values in addAttributes
mohamedsalem401 Dec 11, 2024
f00e14c
Add unit test for addAttribute and setAttributes
mohamedsalem401 Dec 11, 2024
33980f7
fix component properties continue to watch old dynamic variables
mohamedsalem401 Dec 11, 2024
2b534c5
Fix watching props on components
mohamedsalem401 Dec 11, 2024
f6e87d4
update component types to allow dynamic values
mohamedsalem401 Dec 11, 2024
0806812
Add tests for props dynamic variables
mohamedsalem401 Dec 11, 2024
67fec9b
Fix failing tests for symbols
mohamedsalem401 Dec 11, 2024
7b7258b
Remove the new type changes to fix typescript
mohamedsalem401 Dec 11, 2024
a2905cf
Merge branch 'dev' of https://github.com/GrapesJS/grapesjs into compo…
mohamedsalem401 Dec 18, 2024
9093df6
Allow traits to be dynamic ( again )
mohamedsalem401 Dec 20, 2024
a399bf7
Remove dynamic value listeners on component.destroy()
mohamedsalem401 Dec 20, 2024
1e4a576
Fix dynamic attributes stops watching after a single update
mohamedsalem401 Dec 20, 2024
45873fc
Update dynamic attributes tests
mohamedsalem401 Dec 23, 2024
ba5e509
Fix unset a dynamic value for a component
mohamedsalem401 Dec 23, 2024
ab3b790
Fix test for dynamic traits ( remove default value for an attribute )
mohamedsalem401 Dec 23, 2024
2ac49bb
format
mohamedsalem401 Dec 23, 2024
43b8b9d
Update tests for dynamic component traits
mohamedsalem401 Dec 23, 2024
e93c033
Add tests fpr serializing dynamic props
mohamedsalem401 Dec 23, 2024
30d3e9e
Refactor ComponentDynamicValueListener
mohamedsalem401 Dec 23, 2024
a74854f
cleanup and refactor
mohamedsalem401 Dec 23, 2024
4fdb39a
Refactor dynamic traits serialization
mohamedsalem401 Dec 23, 2024
97a9776
fix component.set method
mohamedsalem401 Dec 26, 2024
05ea198
Fix attribute watcher
mohamedsalem401 Dec 26, 2024
56f6c13
Update test name and fix tests
mohamedsalem401 Dec 26, 2024
726acef
set avoidStore to true when updating a dynamic property
mohamedsalem401 Dec 26, 2024
765b5ba
format
mohamedsalem401 Dec 26, 2024
0f0eff4
Rename ComponentDynamicValueWatcher
mohamedsalem401 Dec 26, 2024
bbbeee4
Refactor component dynamic values
mohamedsalem401 Dec 26, 2024
9dc773a
Remove watching and serialization of dynamic traits
mohamedsalem401 Dec 27, 2024
361a8a6
Fix attributes not watching after refactor
mohamedsalem401 Dec 27, 2024
463399b
Fix style serialization test
mohamedsalem401 Dec 27, 2024
64469d7
Format
mohamedsalem401 Dec 27, 2024
9530442
Add tests for dynamic attributes serialization
mohamedsalem401 Dec 27, 2024
e40b3f2
Update attributes tests
mohamedsalem401 Dec 27, 2024
644c357
Update props tests
mohamedsalem401 Dec 27, 2024
1f0b939
cleanup
mohamedsalem401 Dec 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix failing tests for symbols
  • Loading branch information
mohamedsalem401 committed Dec 11, 2024
commit 67fec9b95811ef51da513bd0821a2c8113a274d6
8 changes: 5 additions & 3 deletions packages/core/src/dom_components/model/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ export default class Component extends StyleableModel<ComponentProperties> {
const areStaticAttributes = DynamicValueWatcher.areStaticValues(attrs);
const evaluatedAttributes = areStaticAttributes ? attrs : DynamicValueWatcher.getStaticValues(attrs, this.em);
this.componentDVListener.setAttributes(attrs);
this.set('attributes', evaluatedAttributes, opts);
this.set('attributes', { ...evaluatedAttributes }, opts);

return this;
}
Expand Down Expand Up @@ -1304,14 +1304,15 @@ export default class Component extends StyleableModel<ComponentProperties> {
* @ts-ignore */
clone(opt: { symbol?: boolean; symbolInv?: boolean } = {}): this {
const em = this.em;
const attr = { ...this.attributes };
const attr = {
...this.componentDVListener.getPropsDefsOrValues(this.attributes),
};
const opts = { ...this.opt };
const id = this.getId();
const cssc = em?.Css;
attr.attributes = {
...(attr.attributes ? this.componentDVListener.getAttributesDefsOrValues(attr.attributes) : undefined),
};
delete attr.attributes.id;
// @ts-ignore
attr.components = [];
// @ts-ignore
Expand Down Expand Up @@ -1569,6 +1570,7 @@ export default class Component extends StyleableModel<ComponentProperties> {
let obj = Model.prototype.toJSON.call(this, opts);
obj = { ...obj, ...this.componentDVListener.getDynamicPropsDefs() };
obj.attributes = this.componentDVListener.getAttributesDefsOrValues(this.getAttributes({ noClass: true }));
delete obj.componentDVListener;
delete obj.traits;
delete obj.attributes.class;
delete obj.toolbar;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ export class ComponentDynamicValueListener {
getAttributesDefsOrValues(attributes: ObjectAny) {
return this.attributeWatchClass.getSerializableValues(attributes);
}

getPropsDefsOrValues(props: ObjectAny) {
return this.propertyWatchClass.getSerializableValues(props);
}
}
Loading