Skip to content

Commit 0b60cf2

Browse files
fix: Raw style copy
1 parent 6828773 commit 0b60cf2

5 files changed

Lines changed: 22 additions & 7 deletions

File tree

frontend/src/builder.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ declare interface BlockStyleMap {
55
}
66

77
declare interface BlockAttributeMap {
8-
[key: string]: string;
8+
[key: string]: string | number | null | undefined;
99
}
1010

1111
declare interface BlockOptions {

frontend/src/components/BlockEditor.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ watchEffect(() => {
114114
props.block.getStyle("bottom");
115115
props.block.getStyle("right");
116116
props.block.getStyle("position");
117+
props.block.rawStyles;
117118
const parentBlock = props.block.getParentBlock();
118119
parentBlock?.getStyle("display");
119120
parentBlock?.getStyle("justifyContent");

frontend/src/components/ObjectEditor.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const pasteObj = (e: ClipboardEvent) => {
7474
const map = new Map(Object.entries(props.obj));
7575
try {
7676
const objString = text.match(/{[^{}]+}/)?.[0];
77-
if (!objString) return new Error("Invalid object");
77+
if (!objString) throw new Error("Invalid object");
7878
const obj = new Function("return " + objString)();
7979
if (typeof obj === "object") {
8080
for (const [key, value] of Object.entries(obj)) {
@@ -91,7 +91,6 @@ const pasteObj = (e: ClipboardEvent) => {
9191
}
9292
map.delete("");
9393
}
94-
e.preventDefault();
9594
emit("update:obj", mapToObject(map));
9695
}
9796
};

frontend/src/utils/block.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Block implements BlockOptions {
3333
referenceBlockId?: string;
3434
isRepeaterBlock?: boolean;
3535
visibilityCondition?: string;
36-
customAttributes?: BlockAttributeMap;
36+
customAttributes: BlockAttributeMap;
3737
constructor(options: BlockOptions) {
3838
this.element = options.element;
3939
this.innerHTML = options.innerHTML;
@@ -409,7 +409,12 @@ class Block implements BlockOptions {
409409
return store.findParentBlock(this.blockId);
410410
}
411411
canHaveChildren(): boolean {
412-
return (this.isContainer() || this.isRoot() || this.isDiv()) && !this.isExtendedFromComponent();
412+
return !(
413+
this.isImage() ||
414+
this.isSVG() ||
415+
(this.isText() && !this.isLink()) ||
416+
this.isExtendedFromComponent()
417+
);
413418
}
414419
updateStyles(styles: BlockStyleObjects) {
415420
this.baseStyles = Object.assign({}, this.baseStyles, styles.baseStyles);

frontend/src/utils/blockController.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,25 @@ const blockController = {
110110
},
111111
setRawStyles: (rawStyles: BlockStyleMap) => {
112112
store.selectedBlocks.forEach((block) => {
113-
block.rawStyles = rawStyles;
113+
Object.keys(block.rawStyles).forEach((key) => {
114+
if (!rawStyles[key]) {
115+
delete block.rawStyles[key];
116+
}
117+
});
118+
Object.assign(block.rawStyles, rawStyles);
114119
});
115120
},
116121
getCustomAttributes: () => {
117122
return blockController.isBLockSelected() && store.selectedBlocks[0].customAttributes;
118123
},
119124
setCustomAttributes: (customAttributes: BlockAttributeMap) => {
120125
store.selectedBlocks.forEach((block) => {
121-
block.customAttributes = customAttributes;
126+
Object.keys(block.customAttributes).forEach((key) => {
127+
if (!customAttributes[key]) {
128+
delete block.customAttributes[key];
129+
}
130+
});
131+
Object.assign(block.customAttributes, customAttributes);
122132
});
123133
},
124134
getParentBlock: () => {

0 commit comments

Comments
 (0)