Skip to content

Commit e60e5ce

Browse files
r0b1nIllia Obukhau
authored andcommitted
feat(html-element-web): add structure preview
1 parent 48d16b4 commit e60e5ce

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

packages/pluggableWidgets/html-element-web/src/HTMLElement.editorConfig.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { AttributeValueTypeEnum, HTMLElementPreviewProps } from "../typings/HTMLElementProps";
22
import { hideNestedPropertiesIn, hidePropertiesIn, Problem, Properties } from "@mendix/pluggable-widgets-tools";
3+
import { container, datasource, dropzone, StructurePreviewProps, text } from "@mendix/pluggable-widgets-commons";
4+
import { prepareTag } from "./utils/props-utils";
35

46
type TagAttributeValuePropName = keyof HTMLElementPreviewProps["attributes"][number];
57

@@ -183,3 +185,24 @@ export function check(values: HTMLElementPreviewProps): Problem[] {
183185

184186
return errors;
185187
}
188+
189+
export function getPreview(values: HTMLElementPreviewProps, _isDarkMode: boolean): StructurePreviewProps | null {
190+
const tagName = prepareTag(values.tagName, values.tagNameCustom);
191+
192+
return container({ grow: 1, borders: true, borderWidth: 1 })(
193+
values.tagContentRepeatDataSource ? datasource(values.tagContentRepeatDataSource)() : container()(),
194+
values.tagContentMode === "innerHTML"
195+
? container({ padding: 4 })(
196+
text()(
197+
`<${tagName}>${
198+
values.tagUseRepeat ? values.tagContentRepeatHTML : values.tagContentHTML
199+
}</${tagName}>`
200+
)
201+
)
202+
: container({ padding: 0 })(
203+
text()(`<${tagName}>`),
204+
dropzone(values.tagUseRepeat ? values.tagContentRepeatContainer : values.tagContentContainer),
205+
text()(`</${tagName}>`)
206+
)
207+
);
208+
}

0 commit comments

Comments
 (0)