Skip to content

Commit f8a87d1

Browse files
feat: Input to add custom class
1 parent 56a3e14 commit f8a87d1

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

frontend/src/components/BlockProperties.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,14 @@
243243
v-if="blockController.isImage()"
244244
:modelValue="blockController.getAttribute('alt')"
245245
@update:modelValue="(val) => blockController.setAttribute('alt', val)" />
246+
247+
<!-- class -->
248+
<InlineInput
249+
label="Class"
250+
v-if="!blockController.multipleBlocksSelected()"
251+
:modelValue="getClasses()"
252+
@update:modelValue="(val) => setClasses(val)" />
253+
246254
<CodeEditor
247255
class="mt-8"
248256
label="RAW Styles (as JSON)"
@@ -287,4 +295,13 @@ const setFont = (font: string) => {
287295
blockController.setFontFamily(font);
288296
});
289297
};
298+
299+
const getClasses = () => {
300+
return blockController.getClasses().join(", ");
301+
};
302+
303+
const setClasses = (val: string) => {
304+
const classes = val.split(",").map((c) => c.trim());
305+
blockController.setClasses(classes);
306+
};
290307
</script>

frontend/src/components/BoxResizer.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ const handleRightResize = (ev: MouseEvent) => {
9797
// movement / scale * speed
9898
const movement = (mouseMoveEvent.clientX - startX) / canvasProps.scale;
9999
const finalWidth = Math.abs(guides.getFinalWidth(startWidth + movement));
100-
console.log(startFontSize, movement);
101100
if (targetBlock.isText() && !mouseMoveEvent.shiftKey) {
102101
const fontSize = clamp(Math.round(startFontSize + 0.5 * movement), 10, 150);
103102
targetBlock.setStyle("fontSize", `${fontSize}px`);

frontend/src/utils/blockController.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ const blockController = {
9393
block[key] = value;
9494
});
9595
},
96+
getClasses: () => {
97+
let classes = [] as string[];
98+
classes = store.selectedBlocks[0].getClasses();
99+
return classes;
100+
},
101+
setClasses: (classes: string[]) => {
102+
store.selectedBlocks[0].classes = classes;
103+
},
96104
getRawStyles: () => {
97105
return blockController.isBLockSelected() && store.selectedBlocks[0].rawStyles;
98106
},

0 commit comments

Comments
 (0)