Skip to content

Commit 53543ce

Browse files
author
Illia Obukhau
authored
[WC-1328]: HTMLElement pre release updates (#62)
2 parents a7c406d + 5e41ce0 commit 53543ce

File tree

9 files changed

+149
-125
lines changed

9 files changed

+149
-125
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,14 @@ export function check(values: HTMLElementPreviewProps): Problem[] {
166166
return errors;
167167
}
168168

169-
export function getPreview(values: HTMLElementPreviewProps, _isDarkMode: boolean): StructurePreviewProps | null {
169+
export function getPreview(
170+
values: HTMLElementPreviewProps,
171+
_isDarkMode: boolean,
172+
spVersion: number[] = [0, 0, 0]
173+
): StructurePreviewProps | null {
170174
const tagName = prepareTag(values.tagName, values.tagNameCustom);
175+
const [x, y] = spVersion;
176+
const canHideDataSourceHeader = x >= 9 && y >= 20;
171177

172178
const voidElementPreview = (tagName: keyof JSX.IntrinsicElements): ContainerProps =>
173179
container({ padding: 4 })(text()(`<${tagName} />`));
@@ -183,7 +189,13 @@ export function getPreview(values: HTMLElementPreviewProps, _isDarkMode: boolean
183189
)
184190
: container({ padding: 0 })(
185191
text()(`<${tagName}>`),
186-
dropzone(values.tagUseRepeat ? values.tagContentRepeatContainer : values.tagContentContainer),
192+
dropzone(
193+
canHideDataSourceHeader
194+
? {
195+
showDataSourceHeader: false
196+
}
197+
: {}
198+
)(values.tagUseRepeat ? values.tagContentRepeatContainer : values.tagContentContainer),
187199
text()(`</${tagName}>`)
188200
);
189201

@@ -192,3 +204,8 @@ export function getPreview(values: HTMLElementPreviewProps, _isDarkMode: boolean
192204
isVoidElement(tagName) ? voidElementPreview(tagName) : flowElementPreview()
193205
);
194206
}
207+
208+
export function getCustomCaption(values: HTMLElementPreviewProps, _platform = "desktop"): string {
209+
const tagName = prepareTag(values.tagName, values.tagNameCustom);
210+
return `<${tagName} />`;
211+
}

packages/pluggableWidgets/html-element-web/src/HTMLElement.editorPreview.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ import { HTMLTag } from "./components/HTMLTag";
44
import { isVoidElement, prepareTag } from "./utils/props-utils";
55

66
export function preview(props: HTMLElementPreviewProps): ReactElement {
7-
console.dir(props, { depth: 4 });
87
const tag = prepareTag(props.tagName, props.tagNameCustom);
98

109
const items = props.tagUseRepeat ? [1, 2, 3] : [1];
10+
const canUseUnsafeHTML = !props.tagUseRepeat && props.tagContentHTML;
1111

1212
return (
1313
<Fragment>
1414
{items.map(i =>
1515
isVoidElement(tag) ? (
16-
createElement(tag, { className: props.className, style: props.styleObject })
16+
<div>{`<${tag} />`}</div>
1717
) : (
1818
<HTMLTag
1919
key={i}
2020
tagName={tag}
21+
unsafeHTML={canUseUnsafeHTML ? props.tagContentHTML : undefined}
2122
attributes={{
2223
className: props.className,
2324
style: props.styleObject
2425
}}
2526
>
2627
{props.tagContentRepeatHTML}
27-
{props.tagContentHTML}
2828
<props.tagContentRepeatContainer.renderer>
2929
<div />
3030
</props.tagContentRepeatContainer.renderer>
Loading
Loading
Loading
Loading

packages/pluggableWidgets/html-element-web/src/HTMLElement.xml

Lines changed: 112 additions & 112 deletions
Large diffs are not rendered by default.

packages/pluggableWidgets/html-element-web/typings/HTMLElementProps.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface AttributesType {
2121
attributeValueExpressionRepeat?: ListExpressionValue<string>;
2222
}
2323

24-
export type EventNameEnum = "onClick" | "onChange" | "onFocus" | "onLeave" | "onSubmit" | "onKeyDown" | "onKeyUp" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture";
24+
export type EventNameEnum = "onAbort" | "onAbortCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAuxClick" | "onAuxClickCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onBlur" | "onBlurCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onChange" | "onChangeCapture" | "onClick" | "onClickCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onContextMenu" | "onContextMenuCapture" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onError" | "onErrorCapture" | "onFocus" | "onFocusCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onInput" | "onInputCapture" | "onInvalid" | "onInvalidCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onLeave" | "onLoad" | "onLoadCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onPaste" | "onPasteCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerOut" | "onPointerOutCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerUp" | "onPointerUpCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onReset" | "onResetCapture" | "onScroll" | "onScrollCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onSelect" | "onSelectCapture" | "onStalled" | "onStalledCapture" | "onSubmit" | "onSubmitCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onWheel" | "onWheelCapture";
2525

2626
export interface EventsType {
2727
eventName: EventNameEnum;
@@ -67,7 +67,11 @@ export interface HTMLElementContainerProps {
6767
}
6868

6969
export interface HTMLElementPreviewProps {
70+
/**
71+
* @deprecated Deprecated since version 9.18.0. Please use class property instead.
72+
*/
7073
className: string;
74+
class: string;
7175
style: string;
7276
styleObject?: CSSProperties;
7377
readOnly: boolean;

packages/shared/pluggable-widgets-commons/src/structure-preview-api/index.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,21 @@ export function text(style?: TextStylingProps): (content: string) => TextProps {
9292
};
9393
}
9494

95-
export interface DropZoneProps extends BaseStylingProps {
95+
export interface DropZoneStylingProps extends BaseStylingProps {
96+
placeholder?: string;
97+
showDataSourceHeader?: boolean;
98+
}
99+
export interface DropZoneProps extends DropZoneStylingProps {
96100
type: "DropZone";
97101
property: object;
98-
placeholder?: string;
99102
}
100103

101-
export function dropzone(property: object, placeholder?: string): DropZoneProps {
102-
return {
104+
export function dropzone(style: DropZoneStylingProps): (prop: object) => DropZoneProps {
105+
return (property: object) => ({
103106
type: "DropZone",
104-
placeholder,
105-
property
106-
};
107+
property,
108+
...style
109+
});
107110
}
108111

109112
export interface SelectableProps extends BaseStylingProps {

0 commit comments

Comments
 (0)