You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Document String and Object type formats with clear sections
- Add structured record format with extends, attributes, children,
padEmpty, and componentUrl properties
- Add @global attribute preset section and tables for html4/html5 schemas
- Fix componentsUrl to componentUrl (correct API name)
- Update example with padEmpty and componentUrl usage
Copy file name to clipboardExpand all lines: modules/ROOT/partials/configuration/custom_elements.adoc
+41-13Lines changed: 41 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,9 @@ This option enables you to specify non-HTML elements for the editor.
5
5
6
6
This way you can handle non-HTML elements inside an HTML editor. You can prefix the element names with a `+~+` if you want the element to behave as a `+span+` element and not a `+div+` element.
7
7
8
-
*Type:* `+String+`
8
+
*Type:* `+String+` or `+Object+`
9
+
10
+
=== Simple string format
9
11
10
12
[source,js]
11
13
----
@@ -16,12 +18,29 @@ tinymce.init({
16
18
});
17
19
----
18
20
19
-
* **Custom Element Structure:** The custom_elements option and the `addCustomElements` API supports more complex structures. This structure is defined by a record where the key represents the name of the element, and the value corresponds to a detailed specification.
20
-
* **Attributes and Inheritance:** Elements inherit attributes and children from other specified elements using the `+extends: "div"+` property in the `custom_elements` spec.
21
-
* **Attribute and Children Specifications:** The `custom_elements` spec includes properties such as `attributes` which lists attribute names, or `children` which lists valid child element names. The `children` property includes presets like `@global`, `@blocks`, `@phrasing`, and `@flow`.
22
-
* **Web Components Support:** Custom elements can specify a `+componentsUrl+` property to load web component scripts into the editor.
21
+
=== Record format
22
+
23
+
The `custom_elements` option and the `addCustomElements` API support a record structure. The key is the element name, and the value is a specification object with the following properties:
24
+
25
+
`+extends+` (string)::
26
+
The element name from which the new element inherits its default properties. Using `extends` also adds the new element as a valid child wherever the extended element is valid. For example, `extends: "div"` makes the custom element block-level and allows it wherever `div` is allowed.
27
+
28
+
`+attributes+` (array of strings)::
29
+
List of attribute names or the preset `@global`. Each string is either an attribute name or the preset `@global`, which expands to the schema's global attributes (see <<attribute-preset-global>>). For example: `["@global", "data-type", "data-id"]`.
30
+
31
+
`+children+` (array of strings)::
32
+
List of valid child element names or presets. Each string is either an element name or one of the presets `@blocks`, `@phrasing`, or `@flow`. See <<html4>>, <<html5>>, and <<html5-strict>> for the exact element sets per schema.
33
+
34
+
`+padEmpty+` (boolean)::
35
+
Defaults to `false`. When `true`, the element is padded with content (for example, a non-breaking space) when saved so that it always has some content. Use for elements that must not be empty.
23
36
24
-
HTML Element Sets: The exact element sets for each preset, depending on the schema set (html4, html5, or html5-strict), can be found in the below tables.
37
+
`+componentUrl+` (string)::
38
+
URL of the web component script to load into the editor. Use when the custom element is a web component that requires its script to render.
39
+
40
+
[[attribute-preset-global]]
41
+
=== Attribute preset: `@global`
42
+
43
+
The `@global` preset in the `attributes` array expands to the schema's global attributes. The exact set depends on the schema type:
25
44
26
45
[[html4]]
27
46
=== HTML Element Sets: `html4`
@@ -32,6 +51,7 @@ HTML Element Sets: The exact element sets for each preset, depending on the sche
0 commit comments