Wiki source code of Syntax

Last modified by superadmin on 2026/07/22 09:19

Hide last authors
Clément Eraud 1.1 1 Syntaxes can be declared as components and registered in the dependency injection service. The editor will automatically pick all the registered syntaxes through the container.
2
3
4 Example definition for the Markdown syntax:
5
6
7 {{code language="typescript"}}
8 import { injectable } from "inversify";
9 import type {
10 SyntaxAllowedFeatures,
11 SyntaxConfig,
12 } from "@xwiki/platform-syntaxes-config";
13
14 /**
15 * Configuration for the `markdown/1.2` syntax
16 *
17 * @since 18.6.0RC1
18 * @beta
19 */
20 @injectable()
21 export class MarkdownSyntaxConfig implements SyntaxConfig {
22 id = "markdown/1.2";
23
24 features: SyntaxAllowedFeatures = {
25 blocks: {
26 headings: {
27 levels1To3: true,
28 levels4To6: true,
29 },
30 images: {
31 basicImages: true,
32 altText: true,
33 caption: true,
34 customBorder: false,
35 customDimensions: false,
36 insideLinks: true,
37 },
38 lists: {
39 bulletLists: true,
40 blockInListItems: true,
41 checkableLists: true,
42 contiguousNumberedLists: true,
43 contiguousNumberedListsAnyStartIndex: true,
44 mixableCheckableListItems: false,
45 multipleBlocksInListItems: true,
46 unorderedNumberedLists: false,
47 listsNesting: true,
48 },
49 quotes: true,
50 code: {
51 basicCodeBlocks: true,
52 language: true,
53 },
54 dividers: true,
55 macros: true,
56 nesting: true,
57 styling: {
58 justifyAlignment: false,
59 lcrAlignment: false,
60 },
61 tables: {
62 basicTables: true,
63 blockInTableCells: false,
64 colRows: false,
65 colSpan: false,
66 headerColumns: false,
67 multipleBlocksInTableCells: false,
68 multipleFooterRows: false,
69 multipleHeaderRows: false,
70 noHeaderRowTable: false,
71 singleFooterRow: false,
72 singleHeaderRow: true,
73 },
74 },
75 inlineContents: {
76 images: true,
77 links: {
78 basicLinks: true,
79 customText: true,
80 customTextStyling: true,
81 descriptiveTooltip: true,
82 metadata: false,
83 },
84 code: {
85 basicInlineCode: true,
86 language: false,
87 },
88 macros: true,
89 rawHtml: true,
90 textStyles: {
91 bold: true,
92 italic: true,
93 strikethrough: true,
94 underline: true,
95 nesting: true,
96 fontFamily: false,
97 fontSize: false,
98 subscript: true,
99 superscript: true,
100 },
101 },
102 };
103 }
104
105 {{/code}}
106
107
108 To register the syntax:
109
110
111 {{code language="typescript"}}
112 import { MarkdownSyntaxConfig } from "./config";
113 import { SYNTAX_CONFIG_COMPONENT_GROUP_NAME } from "@xwiki/platform-syntaxes-config";
114 import { Container } from "inversify";
115
116 /**
117 * @since 18.6.0RC1
118 * @beta
119 */
120 export class ComponentInit {
121 constructor(container: Container) {
122 container.bind(SYNTAX_CONFIG_COMPONENT_GROUP_NAME).to(MarkdownSyntaxConfig);
123 }
124 }
125
126 {{/code}}
Manuel Leduc 2.1 127
128

Get Connected