@lowdefy/blocks-basic 5.6.0 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks/Anchor/gallery.yaml +316 -0
- package/dist/blocks/Anchor/tests/Anchor.e2e.yaml +78 -0
- package/dist/blocks/Anchor/tests.yaml +109 -0
- package/dist/blocks/Box/gallery.yaml +1369 -0
- package/dist/blocks/Box/tests/Box.e2e.yaml +78 -0
- package/dist/blocks/Box/tests.yaml +43 -0
- package/dist/blocks/ClickableHtml/ClickableHtml.js +53 -0
- package/dist/blocks/ClickableHtml/e2e.js +23 -0
- package/dist/blocks/ClickableHtml/gallery.yaml +113 -0
- package/dist/blocks/ClickableHtml/meta.js +40 -0
- package/dist/blocks/ClickableHtml/tests/ClickableHtml.e2e.yaml +69 -0
- package/dist/blocks/ClickableHtml/tests.yaml +35 -0
- package/dist/blocks/DangerousHtml/gallery.yaml +182 -0
- package/dist/blocks/DangerousHtml/tests/DangerousHtml.e2e.yaml +33 -0
- package/dist/blocks/DangerousHtml/tests.yaml +83 -0
- package/dist/blocks/Dynamic/Dynamic.js +35 -0
- package/dist/blocks/Dynamic/e2e.js +16 -0
- package/dist/blocks/Dynamic/meta.js +76 -0
- package/dist/blocks/Html/gallery.yaml +239 -0
- package/dist/blocks/Html/tests/Html.e2e.yaml +56 -0
- package/dist/blocks/Html/tests.yaml +75 -0
- package/dist/blocks/Icon/gallery.yaml +702 -0
- package/dist/blocks/Icon/tests/Icon.e2e.yaml +43 -0
- package/dist/blocks/Icon/tests.yaml +54 -0
- package/dist/blocks/Img/gallery.yaml +446 -0
- package/dist/blocks/Img/tests/Img.e2e.yaml +61 -0
- package/dist/blocks/Img/tests.yaml +74 -0
- package/dist/blocks/List/gallery.yaml +523 -0
- package/dist/blocks/List/tests/List.e2e.yaml +199 -0
- package/dist/blocks/List/tests.yaml +471 -0
- package/dist/blocks/Span/gallery.yaml +664 -0
- package/dist/blocks/Span/tests/Span.e2e.yaml +59 -0
- package/dist/blocks/Span/tests.yaml +43 -0
- package/dist/blocks/Throw/gallery.yaml +40 -0
- package/dist/blocks/Throw/tests.yaml +20 -0
- package/dist/blocks.js +2 -0
- package/dist/e2e.js +2 -0
- package/dist/metas.js +2 -0
- package/package.json +10 -10
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
id: box
|
|
16
|
+
type: Box
|
|
17
|
+
properties:
|
|
18
|
+
style:
|
|
19
|
+
padding: 20px
|
|
20
|
+
|
|
21
|
+
blocks:
|
|
22
|
+
# Test 1: Basic Box renders
|
|
23
|
+
- id: box_basic
|
|
24
|
+
type: Box
|
|
25
|
+
|
|
26
|
+
# Test 2: Box with content property
|
|
27
|
+
- id: box_content
|
|
28
|
+
type: Box
|
|
29
|
+
properties:
|
|
30
|
+
content: Hello from Box
|
|
31
|
+
|
|
32
|
+
# Test 3: Box with style property
|
|
33
|
+
- id: box_styled
|
|
34
|
+
type: Box
|
|
35
|
+
properties:
|
|
36
|
+
content: Styled Box
|
|
37
|
+
style:
|
|
38
|
+
backgroundColor: rgb(0, 128, 255)
|
|
39
|
+
color: white
|
|
40
|
+
padding: 10px
|
|
41
|
+
|
|
42
|
+
# Test 4: Box with nested child block
|
|
43
|
+
- id: box_with_children
|
|
44
|
+
type: Box
|
|
45
|
+
blocks:
|
|
46
|
+
- id: child_span
|
|
47
|
+
type: Span
|
|
48
|
+
properties:
|
|
49
|
+
content: Child content
|
|
50
|
+
|
|
51
|
+
# Test 5: Box with dotted block ID (regression test for CSS selector escaping)
|
|
52
|
+
- id: form.field.name
|
|
53
|
+
type: Box
|
|
54
|
+
properties:
|
|
55
|
+
content: Dotted ID Box
|
|
56
|
+
|
|
57
|
+
# Test 6: Box with onClick event using SetState
|
|
58
|
+
- id: box_clickable
|
|
59
|
+
type: Box
|
|
60
|
+
properties:
|
|
61
|
+
content:
|
|
62
|
+
_if:
|
|
63
|
+
test:
|
|
64
|
+
_eq:
|
|
65
|
+
- _state: clicked
|
|
66
|
+
- true
|
|
67
|
+
then: Clicked!
|
|
68
|
+
else: Click me
|
|
69
|
+
style:
|
|
70
|
+
cursor: pointer
|
|
71
|
+
padding: 10px
|
|
72
|
+
border: 1px solid gray
|
|
73
|
+
events:
|
|
74
|
+
onClick:
|
|
75
|
+
- id: set_clicked
|
|
76
|
+
type: SetState
|
|
77
|
+
params:
|
|
78
|
+
clicked: true
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
- id: default
|
|
16
|
+
type: Box
|
|
17
|
+
- id: properties.content
|
|
18
|
+
type: Box
|
|
19
|
+
properties:
|
|
20
|
+
content: Foo
|
|
21
|
+
- id: properties.style
|
|
22
|
+
type: Box
|
|
23
|
+
properties:
|
|
24
|
+
style:
|
|
25
|
+
border: '1px solid blue'
|
|
26
|
+
- id: areas.content
|
|
27
|
+
type: Box
|
|
28
|
+
areas:
|
|
29
|
+
content:
|
|
30
|
+
blocks:
|
|
31
|
+
- id: testArea
|
|
32
|
+
type: Test
|
|
33
|
+
- id: events.onClick
|
|
34
|
+
type: Box
|
|
35
|
+
areas:
|
|
36
|
+
content:
|
|
37
|
+
blocks:
|
|
38
|
+
- id: testArea
|
|
39
|
+
type: Test
|
|
40
|
+
events:
|
|
41
|
+
onClick:
|
|
42
|
+
- id: testAction
|
|
43
|
+
type: Text
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { withBlockDefaults, HtmlComponent } from '@lowdefy/block-utils';
|
|
17
|
+
// dataset keys are camelCase (data-record-id → recordId); config authors
|
|
18
|
+
// write the attributes in kebab-case, so hand them back as snake_case.
|
|
19
|
+
function toSnakeCase(key) {
|
|
20
|
+
return key.replace(/[A-Z]/g, (match)=>`_${match.toLowerCase()}`);
|
|
21
|
+
}
|
|
22
|
+
const ClickableHtml = ({ blockId, classNames, events, properties, methods, styles })=>{
|
|
23
|
+
// Each clickable element names the event it fires in its data-event
|
|
24
|
+
// attribute (data-event="onEditClick" → events.onEditClick), so every
|
|
25
|
+
// target in the markup has its own action chain. Its other data-*
|
|
26
|
+
// attributes are the event object.
|
|
27
|
+
function onClick(clickEvent) {
|
|
28
|
+
const target = clickEvent.target.closest('[data-event]');
|
|
29
|
+
if (!target || !clickEvent.currentTarget.contains(target)) return;
|
|
30
|
+
const { event: name, ...data } = target.dataset;
|
|
31
|
+
if (!name) return;
|
|
32
|
+
clickEvent.preventDefault();
|
|
33
|
+
const event = {};
|
|
34
|
+
Object.keys(data).forEach((key)=>{
|
|
35
|
+
event[toSnakeCase(key)] = data[key];
|
|
36
|
+
});
|
|
37
|
+
methods.triggerEvent({
|
|
38
|
+
name,
|
|
39
|
+
event
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/ React.createElement(HtmlComponent, {
|
|
43
|
+
div: true,
|
|
44
|
+
events: events,
|
|
45
|
+
html: properties.html,
|
|
46
|
+
id: blockId,
|
|
47
|
+
methods: methods,
|
|
48
|
+
className: classNames?.element,
|
|
49
|
+
style: styles?.element,
|
|
50
|
+
onClick: onClick
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
export default withBlockDefaults(ClickableHtml);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import { createBlockHelper, escapeId } from '@lowdefy/e2e-utils';
|
|
16
|
+
import { expect } from '@playwright/test';
|
|
17
|
+
const locator = (page, blockId)=>page.locator(`#${escapeId(blockId)}`);
|
|
18
|
+
export default createBlockHelper({
|
|
19
|
+
locator,
|
|
20
|
+
expect: {
|
|
21
|
+
containsText: (page, blockId, text)=>expect(locator(page, blockId)).toContainText(text)
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
- title: A named event per button
|
|
15
|
+
blocks:
|
|
16
|
+
- id: buttons_basic
|
|
17
|
+
type: ClickableHtml
|
|
18
|
+
properties:
|
|
19
|
+
html: '<p>Pick a size: <button data-event="onSmallClick">Small</button> <button data-event="onLargeClick">Large</button></p>'
|
|
20
|
+
events:
|
|
21
|
+
onSmallClick:
|
|
22
|
+
- id: set_small
|
|
23
|
+
type: SetState
|
|
24
|
+
params:
|
|
25
|
+
buttons_basic_selected: small
|
|
26
|
+
onLargeClick:
|
|
27
|
+
- id: set_large
|
|
28
|
+
type: SetState
|
|
29
|
+
params:
|
|
30
|
+
buttons_basic_selected: large
|
|
31
|
+
- id: buttons_basic_result
|
|
32
|
+
type: Html
|
|
33
|
+
properties:
|
|
34
|
+
html:
|
|
35
|
+
_string.concat:
|
|
36
|
+
- '<p>State: <code>'
|
|
37
|
+
- _state:
|
|
38
|
+
key: buttons_basic_selected
|
|
39
|
+
default: 'nothing yet'
|
|
40
|
+
- '</code></p>'
|
|
41
|
+
|
|
42
|
+
- title: Data attributes are the event object
|
|
43
|
+
blocks:
|
|
44
|
+
- id: list_rows
|
|
45
|
+
type: ClickableHtml
|
|
46
|
+
properties:
|
|
47
|
+
html: '<ul style="list-style: none; padding: 0; margin: 0;"><li data-event="onRowClick" data-record-id="rec_1" style="padding: 8px; cursor: pointer; border-bottom: 1px solid var(--ant-color-border);">First record</li><li data-event="onRowClick" data-record-id="rec_2" style="padding: 8px; cursor: pointer; border-bottom: 1px solid var(--ant-color-border);">Second record</li><li data-event="onRowClick" data-record-id="rec_3" style="padding: 8px; cursor: pointer;">Third record</li></ul>'
|
|
48
|
+
events:
|
|
49
|
+
onRowClick:
|
|
50
|
+
- id: set_clicked
|
|
51
|
+
type: SetState
|
|
52
|
+
params:
|
|
53
|
+
list_rows_clicked:
|
|
54
|
+
_event: true
|
|
55
|
+
- id: list_rows_result
|
|
56
|
+
type: Html
|
|
57
|
+
properties:
|
|
58
|
+
html:
|
|
59
|
+
_string.concat:
|
|
60
|
+
- '<p>Last event: <code>'
|
|
61
|
+
- _json.stringify:
|
|
62
|
+
_state:
|
|
63
|
+
key: list_rows_clicked
|
|
64
|
+
default: {}
|
|
65
|
+
- '</code></p>'
|
|
66
|
+
|
|
67
|
+
- title: Links and plain markup are left to the browser
|
|
68
|
+
blocks:
|
|
69
|
+
- id: mixed_content
|
|
70
|
+
type: ClickableHtml
|
|
71
|
+
properties:
|
|
72
|
+
html: '<p>This <a href="https://lowdefy.com" target="_blank">link</a> navigates normally, but <a href="#" data-event="onCommentClick" data-thread-id="t_9">this one</a> fires onCommentClick instead.</p>'
|
|
73
|
+
events:
|
|
74
|
+
onCommentClick:
|
|
75
|
+
- id: set_mixed
|
|
76
|
+
type: SetState
|
|
77
|
+
params:
|
|
78
|
+
mixed_content_thread:
|
|
79
|
+
_event: thread_id
|
|
80
|
+
- id: mixed_content_result
|
|
81
|
+
type: Html
|
|
82
|
+
properties:
|
|
83
|
+
html:
|
|
84
|
+
_string.concat:
|
|
85
|
+
- '<p>Thread: <code>'
|
|
86
|
+
- _state:
|
|
87
|
+
key: mixed_content_thread
|
|
88
|
+
default: 'none'
|
|
89
|
+
- '</code></p>'
|
|
90
|
+
|
|
91
|
+
- title: Style Overrides
|
|
92
|
+
blocks:
|
|
93
|
+
- id: style_card
|
|
94
|
+
type: ClickableHtml
|
|
95
|
+
style:
|
|
96
|
+
.element:
|
|
97
|
+
padding: 16
|
|
98
|
+
borderRadius: 8
|
|
99
|
+
border: 1px solid var(--ant-color-border)
|
|
100
|
+
background: var(--ant-color-bg-container)
|
|
101
|
+
properties:
|
|
102
|
+
html: '<h4 style="margin: 0 0 8px 0;">Card</h4><p style="margin: 0 0 8px 0; color: var(--ant-color-text-secondary);">Yours to change or remove until tomorrow.</p><button data-event="onEditClick">Edit</button> <button data-event="onRemoveClick">Remove</button>'
|
|
103
|
+
events:
|
|
104
|
+
onEditClick:
|
|
105
|
+
- id: set_card_edit
|
|
106
|
+
type: SetState
|
|
107
|
+
params:
|
|
108
|
+
style_card_action: edit
|
|
109
|
+
onRemoveClick:
|
|
110
|
+
- id: set_card_remove
|
|
111
|
+
type: SetState
|
|
112
|
+
params:
|
|
113
|
+
style_card_action: remove
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
category: 'display',
|
|
17
|
+
icons: [],
|
|
18
|
+
valueType: null,
|
|
19
|
+
cssKeys: {
|
|
20
|
+
element: 'The Html element.'
|
|
21
|
+
},
|
|
22
|
+
// Each clickable element names its event in a data-event attribute, so the
|
|
23
|
+
// event names this block fires are authored in its html.
|
|
24
|
+
events: {
|
|
25
|
+
onTextSelection: 'Trigger action when text is selected and pass selected text to the event object.'
|
|
26
|
+
},
|
|
27
|
+
properties: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
properties: {
|
|
31
|
+
html: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Content to be rendered as Html. An element with a data-event attribute fires the event it names when clicked (data-event="onEditClick" fires events.onEditClick), and its default browser action is prevented. The event object holds the element\'s other data-* attributes with snake_case keys, so data-event="onEditClick" data-record-id="42" gives { record_id: "42" }.',
|
|
34
|
+
docs: {
|
|
35
|
+
displayType: 'text-area'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
id: clickablehtml
|
|
15
|
+
type: Box
|
|
16
|
+
|
|
17
|
+
blocks:
|
|
18
|
+
- id: clickable_basic
|
|
19
|
+
type: ClickableHtml
|
|
20
|
+
properties:
|
|
21
|
+
html: '<p>Hello <button data-event="onGreetClick" data-user-id="u_1">World</button> <button data-event="onWaveClick" data-user-id="u_2">Wave</button></p>'
|
|
22
|
+
events:
|
|
23
|
+
onGreetClick:
|
|
24
|
+
- id: set_greeted
|
|
25
|
+
type: SetState
|
|
26
|
+
params:
|
|
27
|
+
clicked:
|
|
28
|
+
event: greet
|
|
29
|
+
user_id:
|
|
30
|
+
_event: user_id
|
|
31
|
+
onWaveClick:
|
|
32
|
+
- id: set_waved
|
|
33
|
+
type: SetState
|
|
34
|
+
params:
|
|
35
|
+
clicked:
|
|
36
|
+
event: wave
|
|
37
|
+
user_id:
|
|
38
|
+
_event: user_id
|
|
39
|
+
|
|
40
|
+
- id: clickable_result
|
|
41
|
+
type: Html
|
|
42
|
+
properties:
|
|
43
|
+
html:
|
|
44
|
+
_string.concat:
|
|
45
|
+
- '<span id="clicked_event">'
|
|
46
|
+
- _state:
|
|
47
|
+
key: clicked.event
|
|
48
|
+
default: ''
|
|
49
|
+
- '</span><span id="clicked_user_id">'
|
|
50
|
+
- _state:
|
|
51
|
+
key: clicked.user_id
|
|
52
|
+
default: ''
|
|
53
|
+
- '</span>'
|
|
54
|
+
|
|
55
|
+
- id: clickable_no_event
|
|
56
|
+
type: ClickableHtml
|
|
57
|
+
properties:
|
|
58
|
+
html: '<p><button>Plain button</button></p>'
|
|
59
|
+
events:
|
|
60
|
+
onPlainClick:
|
|
61
|
+
- id: set_plain
|
|
62
|
+
type: SetState
|
|
63
|
+
params:
|
|
64
|
+
plain_clicked: true
|
|
65
|
+
|
|
66
|
+
- id: clickable_sanitized
|
|
67
|
+
type: ClickableHtml
|
|
68
|
+
properties:
|
|
69
|
+
html: <p>Safe content</p><script>alert('xss')</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
- id: default
|
|
15
|
+
type: ClickableHtml
|
|
16
|
+
- id: properties.html
|
|
17
|
+
type: ClickableHtml
|
|
18
|
+
properties:
|
|
19
|
+
html: |
|
|
20
|
+
<p>Plain markup <button data-event="onGoClick" data-item-id="1">Go</button></p>
|
|
21
|
+
- id: properties.html-no-events
|
|
22
|
+
type: ClickableHtml
|
|
23
|
+
properties:
|
|
24
|
+
html: |
|
|
25
|
+
<p>No data-event here, clicks do nothing.</p>
|
|
26
|
+
- id: properties.html-bad-code
|
|
27
|
+
type: ClickableHtml
|
|
28
|
+
properties:
|
|
29
|
+
html: |
|
|
30
|
+
<button data-event="onOkClick" onclick="alert('inline handler stripped')">Ok</button>
|
|
31
|
+
<script>alert('script tag');</script>
|
|
32
|
+
- id: properties.html is number 0
|
|
33
|
+
type: ClickableHtml
|
|
34
|
+
properties:
|
|
35
|
+
html: 0
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Copyright 2020-2026 Lowdefy, Inc
|
|
2
|
+
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
- title: Basic HTML
|
|
16
|
+
blocks:
|
|
17
|
+
- id: basic_paragraph
|
|
18
|
+
type: DangerousHtml
|
|
19
|
+
properties:
|
|
20
|
+
html: '<p>This is a basic paragraph rendered as HTML.</p>'
|
|
21
|
+
- id: basic_heading
|
|
22
|
+
type: DangerousHtml
|
|
23
|
+
properties:
|
|
24
|
+
html: '<h3>Heading rendered with DangerousHtml</h3>'
|
|
25
|
+
- id: basic_link
|
|
26
|
+
type: DangerousHtml
|
|
27
|
+
properties:
|
|
28
|
+
html: '<p>Visit <a href="https://lowdefy.com" target="_blank" rel="noopener noreferrer">Lowdefy</a> for more info.</p>'
|
|
29
|
+
- id: basic_multiple_headings
|
|
30
|
+
type: DangerousHtml
|
|
31
|
+
properties:
|
|
32
|
+
html: '<h4>Section Title</h4><p>Some paragraph text below the heading.</p><h5>Sub-section</h5><p>More text in the sub-section.</p>'
|
|
33
|
+
|
|
34
|
+
- title: Styled HTML
|
|
35
|
+
blocks:
|
|
36
|
+
- id: styled_colored
|
|
37
|
+
type: DangerousHtml
|
|
38
|
+
properties:
|
|
39
|
+
html: '<p style="color: var(--ant-color-primary); font-weight: bold; font-size: 18px;">Blue bold text with inline styles</p>'
|
|
40
|
+
- id: styled_box_success
|
|
41
|
+
type: DangerousHtml
|
|
42
|
+
properties:
|
|
43
|
+
html: '<div style="padding: 16px; background-color: var(--ant-color-success-bg); border: 1px solid var(--ant-color-success-border); border-radius: 6px;"><strong>Success:</strong> Your changes have been saved.</div>'
|
|
44
|
+
- id: styled_box_warning
|
|
45
|
+
type: DangerousHtml
|
|
46
|
+
properties:
|
|
47
|
+
html: '<div style="padding: 16px; background-color: var(--ant-color-warning-bg); border: 1px solid var(--ant-color-warning-border); border-radius: 6px;"><strong>Warning:</strong> Please review your settings before proceeding.</div>'
|
|
48
|
+
- id: styled_box_error
|
|
49
|
+
type: DangerousHtml
|
|
50
|
+
properties:
|
|
51
|
+
html: '<div style="padding: 16px; background-color: var(--ant-color-error-bg); border: 1px solid var(--ant-color-error-border); border-radius: 6px;"><strong>Error:</strong> Unable to complete the operation.</div>'
|
|
52
|
+
- id: styled_box_info
|
|
53
|
+
type: DangerousHtml
|
|
54
|
+
properties:
|
|
55
|
+
html: '<div style="padding: 16px; background-color: var(--ant-color-info-bg); border: 1px solid var(--ant-color-info-border); border-radius: 6px;"><strong>Info:</strong> The system will undergo maintenance at midnight.</div>'
|
|
56
|
+
|
|
57
|
+
- title: Lists
|
|
58
|
+
blocks:
|
|
59
|
+
- id: list_unordered
|
|
60
|
+
type: DangerousHtml
|
|
61
|
+
properties:
|
|
62
|
+
html: '<ul style="list-style-type: disc; padding-left: 20px;"><li>First item</li><li>Second item</li><li>Third item</li></ul>'
|
|
63
|
+
- id: list_ordered
|
|
64
|
+
type: DangerousHtml
|
|
65
|
+
properties:
|
|
66
|
+
html: '<ol style="padding-left: 20px;"><li>Step one</li><li>Step two</li><li>Step three</li></ol>'
|
|
67
|
+
- id: list_colored
|
|
68
|
+
type: DangerousHtml
|
|
69
|
+
properties:
|
|
70
|
+
html: '<ul style="list-style-type: disc; padding-left: 20px;"><li style="color: var(--ant-color-success);">Completed</li><li style="color: var(--ant-color-warning);">In Progress</li><li style="color: var(--ant-color-error);">Overdue</li></ul>'
|
|
71
|
+
- id: list_nested
|
|
72
|
+
type: DangerousHtml
|
|
73
|
+
properties:
|
|
74
|
+
html: '<ul style="padding-left: 20px;"><li>Parent item<ul style="padding-left: 20px;"><li>Child item 1</li><li>Child item 2</li></ul></li><li>Another parent item</li></ul>'
|
|
75
|
+
- id: list_definition
|
|
76
|
+
type: DangerousHtml
|
|
77
|
+
properties:
|
|
78
|
+
html: '<dl><dt style="font-weight: bold;">Term 1</dt><dd style="margin-left: 20px; color: var(--ant-color-text-secondary);">Definition of the first term.</dd><dt style="font-weight: bold;">Term 2</dt><dd style="margin-left: 20px; color: var(--ant-color-text-secondary);">Definition of the second term.</dd></dl>'
|
|
79
|
+
|
|
80
|
+
- title: HTML Table
|
|
81
|
+
blocks:
|
|
82
|
+
- id: table_simple
|
|
83
|
+
type: DangerousHtml
|
|
84
|
+
properties:
|
|
85
|
+
html: '<table style="width: 100%; border-collapse: collapse;"><thead><tr><th style="border: 1px solid var(--ant-color-border); padding: 8px; background: var(--ant-color-fill-quaternary); text-align: left;">Name</th><th style="border: 1px solid var(--ant-color-border); padding: 8px; background: var(--ant-color-fill-quaternary); text-align: left;">Role</th><th style="border: 1px solid var(--ant-color-border); padding: 8px; background: var(--ant-color-fill-quaternary); text-align: left;">Status</th></tr></thead><tbody><tr><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Alice</td><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Developer</td><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Active</td></tr><tr><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Bob</td><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Designer</td><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Active</td></tr><tr><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Charlie</td><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Manager</td><td style="border: 1px solid var(--ant-color-border); padding: 8px;">Away</td></tr></tbody></table>'
|
|
86
|
+
- id: table_striped
|
|
87
|
+
type: DangerousHtml
|
|
88
|
+
properties:
|
|
89
|
+
html: '<table style="width: 100%; border-collapse: collapse;"><thead><tr><th style="border: 1px solid var(--ant-color-border); padding: 10px; background: var(--ant-color-primary); color: white; text-align: left;">Product</th><th style="border: 1px solid var(--ant-color-border); padding: 10px; background: var(--ant-color-primary); color: white; text-align: right;">Price</th><th style="border: 1px solid var(--ant-color-border); padding: 10px; background: var(--ant-color-primary); color: white; text-align: center;">Stock</th></tr></thead><tbody><tr><td style="border: 1px solid var(--ant-color-border); padding: 10px;">Widget A</td><td style="border: 1px solid var(--ant-color-border); padding: 10px; text-align: right;">$29.99</td><td style="border: 1px solid var(--ant-color-border); padding: 10px; text-align: center;">150</td></tr><tr style="background: var(--ant-color-fill-quaternary);"><td style="border: 1px solid var(--ant-color-border); padding: 10px;">Widget B</td><td style="border: 1px solid var(--ant-color-border); padding: 10px; text-align: right;">$49.99</td><td style="border: 1px solid var(--ant-color-border); padding: 10px; text-align: center;">85</td></tr><tr><td style="border: 1px solid var(--ant-color-border); padding: 10px;">Widget C</td><td style="border: 1px solid var(--ant-color-border); padding: 10px; text-align: right;">$19.99</td><td style="border: 1px solid var(--ant-color-border); padding: 10px; text-align: center;">320</td></tr></tbody></table>'
|
|
90
|
+
|
|
91
|
+
- title: Embedded Media Placeholders
|
|
92
|
+
blocks:
|
|
93
|
+
- id: media_video_placeholder
|
|
94
|
+
type: DangerousHtml
|
|
95
|
+
properties:
|
|
96
|
+
html: '<div style="width: 100%; max-width: 560px; aspect-ratio: 16/9; background: var(--ant-color-fill-tertiary); border: 2px dashed var(--ant-color-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--ant-color-text-tertiary); font-size: 16px;">Video Placeholder (16:9)</div>'
|
|
97
|
+
- id: media_iframe_placeholder
|
|
98
|
+
type: DangerousHtml
|
|
99
|
+
properties:
|
|
100
|
+
html: '<div style="width: 100%; max-width: 400px; height: 300px; background: var(--ant-color-fill-quaternary); border: 2px dashed var(--ant-color-border); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--ant-color-text-tertiary);">Embedded Content Area</div>'
|
|
101
|
+
|
|
102
|
+
- title: Complex Layout
|
|
103
|
+
blocks:
|
|
104
|
+
- id: layout_card
|
|
105
|
+
type: DangerousHtml
|
|
106
|
+
properties:
|
|
107
|
+
html: '<div style="max-width: 400px; border: 1px solid var(--ant-color-border); border-radius: 8px; overflow: hidden;"><div style="padding: 16px; background: var(--ant-color-fill-quaternary); border-bottom: 1px solid var(--ant-color-border);"><h4 style="margin: 0;">Card Title</h4></div><div style="padding: 16px;"><p style="margin: 0 0 12px 0; color: var(--ant-color-text-secondary);">This is a card-like layout created purely with HTML and inline styles.</p><div style="display: flex; gap: 8px;"><span style="background: var(--ant-color-primary-bg); color: var(--ant-color-primary); padding: 2px 8px; border-radius: 4px; font-size: 12px;">Tag 1</span><span style="background: var(--ant-color-success-bg); color: var(--ant-color-success); padding: 2px 8px; border-radius: 4px; font-size: 12px;">Tag 2</span></div></div></div>'
|
|
108
|
+
- id: layout_flex_row
|
|
109
|
+
type: DangerousHtml
|
|
110
|
+
properties:
|
|
111
|
+
html: '<div style="display: flex; gap: 16px; flex-wrap: wrap;"><div style="flex: 1; min-width: 150px; padding: 16px; background: var(--ant-color-primary-bg); border-radius: 8px; text-align: center;"><div style="font-size: 24px; font-weight: bold; color: var(--ant-color-primary);">42</div><div style="color: var(--ant-color-text-secondary); font-size: 12px;">Active Users</div></div><div style="flex: 1; min-width: 150px; padding: 16px; background: var(--ant-color-success-bg); border-radius: 8px; text-align: center;"><div style="font-size: 24px; font-weight: bold; color: var(--ant-color-success);">128</div><div style="color: var(--ant-color-text-secondary); font-size: 12px;">Completed</div></div><div style="flex: 1; min-width: 150px; padding: 16px; background: var(--ant-color-warning-bg); border-radius: 8px; text-align: center;"><div style="font-size: 24px; font-weight: bold; color: var(--ant-color-warning);">7</div><div style="color: var(--ant-color-text-secondary); font-size: 12px;">Pending</div></div></div>'
|
|
112
|
+
- id: layout_timeline
|
|
113
|
+
type: DangerousHtml
|
|
114
|
+
properties:
|
|
115
|
+
html: '<div style="padding-left: 20px; border-left: 2px solid var(--ant-color-primary);"><div style="position: relative; padding-bottom: 16px;"><div style="position: absolute; left: -26px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--ant-color-primary);"></div><div style="font-weight: bold;">Step 1: Setup</div><div style="color: var(--ant-color-text-secondary); font-size: 13px;">Configure your project settings.</div></div><div style="position: relative; padding-bottom: 16px;"><div style="position: absolute; left: -26px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--ant-color-primary);"></div><div style="font-weight: bold;">Step 2: Build</div><div style="color: var(--ant-color-text-secondary); font-size: 13px;">Run the build pipeline.</div></div><div style="position: relative;"><div style="position: absolute; left: -26px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--ant-color-border);"></div><div style="font-weight: bold; color: var(--ant-color-text-tertiary);">Step 3: Deploy</div><div style="color: var(--ant-color-text-quaternary); font-size: 13px;">Deploy to production.</div></div></div>'
|
|
116
|
+
|
|
117
|
+
- title: DOMPurify Options
|
|
118
|
+
blocks:
|
|
119
|
+
- id: purify_default_label
|
|
120
|
+
type: Markdown
|
|
121
|
+
properties:
|
|
122
|
+
content: '**Default (scripts and event handlers stripped):**'
|
|
123
|
+
- id: purify_default
|
|
124
|
+
type: DangerousHtml
|
|
125
|
+
properties:
|
|
126
|
+
html: '<p>Safe content rendered. <script>alert("removed")</script></p>'
|
|
127
|
+
- id: purify_allow_target_label
|
|
128
|
+
type: Markdown
|
|
129
|
+
properties:
|
|
130
|
+
content: '**With ADD_ATTR to allow target attribute:**'
|
|
131
|
+
- id: purify_allow_target
|
|
132
|
+
type: DangerousHtml
|
|
133
|
+
properties:
|
|
134
|
+
html: '<a href="https://lowdefy.com" target="_blank">Link with target=_blank allowed</a>'
|
|
135
|
+
DOMPurifyOptions:
|
|
136
|
+
ADD_ATTR:
|
|
137
|
+
- target
|
|
138
|
+
|
|
139
|
+
- title: Style Overrides
|
|
140
|
+
blocks:
|
|
141
|
+
- id: style_padded
|
|
142
|
+
type: DangerousHtml
|
|
143
|
+
style:
|
|
144
|
+
.element:
|
|
145
|
+
padding: 20
|
|
146
|
+
background: var(--ant-color-fill-quaternary)
|
|
147
|
+
borderRadius: 8
|
|
148
|
+
border: 1px solid var(--ant-color-border)
|
|
149
|
+
properties:
|
|
150
|
+
html: '<p style="margin: 0;">Content inside a styled DangerousHtml container with padding and background.</p>'
|
|
151
|
+
- id: style_max_width
|
|
152
|
+
type: DangerousHtml
|
|
153
|
+
style:
|
|
154
|
+
.element:
|
|
155
|
+
maxWidth: 400
|
|
156
|
+
margin: 0 auto
|
|
157
|
+
padding: 16
|
|
158
|
+
background: var(--ant-color-primary-bg)
|
|
159
|
+
borderRadius: 8
|
|
160
|
+
textAlign: center
|
|
161
|
+
properties:
|
|
162
|
+
html: '<p style="margin: 0; color: var(--ant-color-primary); font-weight: bold;">Centered container with max-width constraint.</p>'
|
|
163
|
+
- id: style_shadow
|
|
164
|
+
type: DangerousHtml
|
|
165
|
+
style:
|
|
166
|
+
.element:
|
|
167
|
+
padding: 20
|
|
168
|
+
borderRadius: 12
|
|
169
|
+
boxShadow: var(--ant-box-shadow)
|
|
170
|
+
background: var(--ant-color-bg-container)
|
|
171
|
+
properties:
|
|
172
|
+
html: '<h4 style="margin: 0 0 8px 0;">Elevated Card</h4><p style="margin: 0; color: var(--ant-color-text-secondary);">A DangerousHtml block styled with a box shadow for an elevated card appearance.</p>'
|
|
173
|
+
- id: style_border_left
|
|
174
|
+
type: DangerousHtml
|
|
175
|
+
style:
|
|
176
|
+
.element:
|
|
177
|
+
borderLeft: 4px solid var(--ant-color-primary)
|
|
178
|
+
paddingLeft: 16
|
|
179
|
+
paddingTop: 8
|
|
180
|
+
paddingBottom: 8
|
|
181
|
+
properties:
|
|
182
|
+
html: '<p style="margin: 0; color: var(--ant-color-primary); font-weight: 500;">Highlighted with a primary color left border accent.</p>'
|