@nerd-bible/wordgard 0.3.3
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/LICENSE +22 -0
- package/README.md +24 -0
- package/dist/collab.d.ts +105 -0
- package/dist/collab.js +218 -0
- package/dist/command.d.ts +796 -0
- package/dist/command.js +1451 -0
- package/dist/doc.d.ts +2210 -0
- package/dist/doc.js +3814 -0
- package/dist/editor.d.ts +1920 -0
- package/dist/editor.js +7154 -0
- package/dist/history.d.ts +90 -0
- package/dist/history.js +278 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/phrases.d.ts +90 -0
- package/dist/phrases.js +141 -0
- package/dist/schema.d.ts +579 -0
- package/dist/schema.js +1341 -0
- package/dist/state.d.ts +1388 -0
- package/dist/state.js +2024 -0
- package/dist/table.d.ts +215 -0
- package/dist/table.js +1302 -0
- package/dist/types.d.ts +196 -0
- package/dist/types.js +288 -0
- package/package.json +52 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Mark, Plot, Leaf } from 'wordgard/doc';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
A paragraph. Part of the {@link Node.Group.Content | `Content`}
|
|
5
|
+
group, allowing inline content, rendered as `<p>`.
|
|
6
|
+
*/
|
|
7
|
+
declare const Paragraph: Plot.Tag<null>;
|
|
8
|
+
/**
|
|
9
|
+
Heading plot. Its parameter indicates the heading level. In the
|
|
10
|
+
{@link Node.Group.Content | `Content`} group, allows inline
|
|
11
|
+
content, rendered as `<h1>` to `<h6>`.
|
|
12
|
+
*/
|
|
13
|
+
declare const Heading: Plot.Type<number>;
|
|
14
|
+
/**
|
|
15
|
+
A code block. Part of the {@link Node.Group.Content | `Content`}
|
|
16
|
+
group, with the {@link Node.Role.Code | `Code`} role. Rendered
|
|
17
|
+
as `<pre>`.
|
|
18
|
+
*/
|
|
19
|
+
declare const CodeBlock: Plot.Tag<null>;
|
|
20
|
+
/**
|
|
21
|
+
A mark that assigns a language identifier (any string) to a code
|
|
22
|
+
block. Stored in the `data-language` attribute.
|
|
23
|
+
*/
|
|
24
|
+
declare const CodeBlockLanguage: Mark.Type<string>;
|
|
25
|
+
/**
|
|
26
|
+
Blockquote plot. Allows any {@link Node.Group.Content | `Content`}
|
|
27
|
+
blocks inside of it, and is itself part of that group. Rendered as
|
|
28
|
+
`<blockquote>`.
|
|
29
|
+
*/
|
|
30
|
+
declare const Blockquote: Plot.Tag<null>;
|
|
31
|
+
/**
|
|
32
|
+
Block list item. Allows any {@link Node.Group.Content | `Content`}
|
|
33
|
+
blocks as content. Rendered as `<li>`.
|
|
34
|
+
*/
|
|
35
|
+
declare const ListItem: Plot.Tag<null>;
|
|
36
|
+
/**
|
|
37
|
+
List item with inline content. You'll want to have either this
|
|
38
|
+
plot type or {@link ListItem} in your schema, not both. Rendered
|
|
39
|
+
as `<li>`.
|
|
40
|
+
*/
|
|
41
|
+
declare const InlineListItem: Plot.Tag<null>;
|
|
42
|
+
/**
|
|
43
|
+
Ordered list plot. Part of the {@link Node.Group.Content |
|
|
44
|
+
`Content`} group, allows either {@link ListItem} or {@link
|
|
45
|
+
InlineListItem} as content. Rendered as `<ol>`, with the parameter
|
|
46
|
+
providing the `start` attribute.
|
|
47
|
+
*/
|
|
48
|
+
declare const OrderedList: Plot.Type<number>;
|
|
49
|
+
/**
|
|
50
|
+
An unordered list. Defaults to the {@link Node.Group.Content |
|
|
51
|
+
`Content`} group. Allows {@link ListItem} or {@link
|
|
52
|
+
InlineListItem} as content. Rendered as `<ul>`.
|
|
53
|
+
*/
|
|
54
|
+
declare const BulletList: Plot.Tag<null>;
|
|
55
|
+
/**
|
|
56
|
+
A horizontal separator. Part of the {@link Node.Group.Content |
|
|
57
|
+
`Content`} group. Renders as `<hr>`.
|
|
58
|
+
*/
|
|
59
|
+
declare const HorizontalRule: Leaf<null>;
|
|
60
|
+
/**
|
|
61
|
+
A hard line break. Renders as `<br>` and has the {@link
|
|
62
|
+
Node.Role.LineBreak | `LineBreak`} role.
|
|
63
|
+
*/
|
|
64
|
+
declare const LineBreak: Leaf<null>;
|
|
65
|
+
/**
|
|
66
|
+
Table cell plot. Allows inline content, and is in the {@link
|
|
67
|
+
Node.Group.TableCell | `TableCell`} group. Rendered as `<td>`
|
|
68
|
+
*/
|
|
69
|
+
declare const Cell: Plot.Tag<null>;
|
|
70
|
+
/**
|
|
71
|
+
Table header cell. Like {@link Cell}, but rendered as `<th>`.
|
|
72
|
+
*/
|
|
73
|
+
declare const HeaderCell: Plot.Tag<null>;
|
|
74
|
+
/**
|
|
75
|
+
Table cell with block content. Rendered as `<td>`. You can use
|
|
76
|
+
either this one or {@link Cell} in your schema, not both.
|
|
77
|
+
*/
|
|
78
|
+
declare const BlockCell: Plot.Tag<null>;
|
|
79
|
+
/**
|
|
80
|
+
Table header cell with block content. Rendered as `<th>`.
|
|
81
|
+
*/
|
|
82
|
+
declare const BlockHeaderCell: Plot.Tag<null>;
|
|
83
|
+
/**
|
|
84
|
+
Table row. Allows nodes with the {@link Node.Group.TableCell |
|
|
85
|
+
`TableCell`} group as content. Rendered as `<tr>`.
|
|
86
|
+
*/
|
|
87
|
+
declare const TableRow: Plot.Tag<null>;
|
|
88
|
+
/**
|
|
89
|
+
A table. Contains {@link TableRow}s, is part of the {@link
|
|
90
|
+
Node.Group.Content | `Content`} group. Rendered as
|
|
91
|
+
`<table><tbody>`.
|
|
92
|
+
*/
|
|
93
|
+
declare const Table: Plot.Tag<null>;
|
|
94
|
+
/**
|
|
95
|
+
Table cell column span. Rendered with the `colspan` attribute.
|
|
96
|
+
Must hold a positive integer. Is assumed
|
|
97
|
+
to be 1 when missing.
|
|
98
|
+
*/
|
|
99
|
+
declare const ColSpan: Mark.Type<number>;
|
|
100
|
+
/**
|
|
101
|
+
Table cell row span. Rendered with the `rowspan` attribute.
|
|
102
|
+
Is assumed to be 1 when missing.
|
|
103
|
+
*/
|
|
104
|
+
declare const RowSpan: Mark.Type<number>;
|
|
105
|
+
/**
|
|
106
|
+
An inline image leaf. The string parameter is the image's source
|
|
107
|
+
URI. Rendered as `<img>`.
|
|
108
|
+
*/
|
|
109
|
+
declare const Image: Leaf.Type<string>;
|
|
110
|
+
/**
|
|
111
|
+
A block image leaf. Renders as a `<figure>` element with an
|
|
112
|
+
`<img>` in it. The parameter holds the image URI.
|
|
113
|
+
*/
|
|
114
|
+
declare const Figure: Leaf.Type<string>;
|
|
115
|
+
/**
|
|
116
|
+
A textblock plot representing a captioned image. The image URI is
|
|
117
|
+
the plot's parameter, and the caption the content (inline).
|
|
118
|
+
Assigned to the {@link Node.Group.Content | `Content`} group by
|
|
119
|
+
default. Renders as a `<figure>` element with `<img>` and
|
|
120
|
+
`<figcaption>` elements as children.
|
|
121
|
+
*/
|
|
122
|
+
declare const CaptionedFigure: Plot.Type<string>;
|
|
123
|
+
/**
|
|
124
|
+
Image alt text. Renders as an `alt` attribute.
|
|
125
|
+
*/
|
|
126
|
+
declare const ImageAlt: Mark.Type<string>;
|
|
127
|
+
/**
|
|
128
|
+
Image size, as a width in pixels. Renders as a `width` style.
|
|
129
|
+
*/
|
|
130
|
+
declare const ImageSize: Mark.Type<number>;
|
|
131
|
+
/**
|
|
132
|
+
Text alignment. Applies to any textblock or figure. Not having
|
|
133
|
+
this mark implies aligning to the start of the block. Renders as a
|
|
134
|
+
`text-align` style.
|
|
135
|
+
*/
|
|
136
|
+
declare const Alignment: Mark.Type<"center" | "end">;
|
|
137
|
+
/**
|
|
138
|
+
The text direction for a textblock. Not having this mark means the
|
|
139
|
+
document's base direction is used. `"auto"` means the direction is
|
|
140
|
+
derived from the first character in the block that has a strong
|
|
141
|
+
direction. Rendered using the `dir` attribute.
|
|
142
|
+
*/
|
|
143
|
+
declare const Direction: Mark.Type<"auto" | "ltr" | "rtl">;
|
|
144
|
+
/**
|
|
145
|
+
Emphasis mark. Rendered using the `<em>` element.
|
|
146
|
+
*/
|
|
147
|
+
declare const Emphasis: Mark<null>;
|
|
148
|
+
/**
|
|
149
|
+
Strong emphasis mark. Rendered using the `<strong>` element.
|
|
150
|
+
*/
|
|
151
|
+
declare const Strong: Mark<null>;
|
|
152
|
+
/**
|
|
153
|
+
Underline mark. Rendered using `<u>`.
|
|
154
|
+
*/
|
|
155
|
+
declare const Underline: Mark<null>;
|
|
156
|
+
/**
|
|
157
|
+
Strikethrough mark. Rendered as an `<s>` element.
|
|
158
|
+
*/
|
|
159
|
+
declare const Strikethrough: Mark<null>;
|
|
160
|
+
/**
|
|
161
|
+
Superscript text. Rendered using `<sup>`.
|
|
162
|
+
*/
|
|
163
|
+
declare const Superscript: Mark<null>;
|
|
164
|
+
/**
|
|
165
|
+
Subscript text. Rendered using `<sub>`.
|
|
166
|
+
*/
|
|
167
|
+
declare const Subscript: Mark<null>;
|
|
168
|
+
/**
|
|
169
|
+
Link markup. The parameter is the link's target. Rendered as an
|
|
170
|
+
`<a>` element with the target in `href`.
|
|
171
|
+
*/
|
|
172
|
+
declare const Link: Mark.Type<string>;
|
|
173
|
+
/**
|
|
174
|
+
Code font text. Rendered as `<code>`.
|
|
175
|
+
*/
|
|
176
|
+
declare const Code: Mark<null>;
|
|
177
|
+
/**
|
|
178
|
+
Text color mark. Rendered with the `color` style.
|
|
179
|
+
*/
|
|
180
|
+
declare const Color: Mark.Type<string>;
|
|
181
|
+
/**
|
|
182
|
+
Text background color. Rendered with the `background-color` style.
|
|
183
|
+
*/
|
|
184
|
+
declare const BackgroundColor: Mark.Type<string>;
|
|
185
|
+
/**
|
|
186
|
+
A document type that allows any {@link Node.Group.Content |
|
|
187
|
+
`Content` group} nodes as content.
|
|
188
|
+
*/
|
|
189
|
+
declare const Doc: Plot.Type<null>;
|
|
190
|
+
/**
|
|
191
|
+
A document type that has inline content, so the entire document is
|
|
192
|
+
a single textblock.
|
|
193
|
+
*/
|
|
194
|
+
declare const InlineDoc: Plot.Type<null>;
|
|
195
|
+
|
|
196
|
+
export { Alignment, BackgroundColor, BlockCell, BlockHeaderCell, Blockquote, BulletList, CaptionedFigure, Cell, Code, CodeBlock, CodeBlockLanguage, ColSpan, Color, Direction, Doc, Emphasis, Figure, HeaderCell, Heading, HorizontalRule, Image, ImageAlt, ImageSize, InlineDoc, InlineListItem, LineBreak, Link, ListItem, OrderedList, Paragraph, RowSpan, Strikethrough, Strong, Subscript, Superscript, Table, TableRow, Underline };
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { Node, Plot, Elt, ValidationError, Mark, Leaf, parse } from 'wordgard/doc';
|
|
2
|
+
|
|
3
|
+
const G = /*@__PURE__*/(() => Node.Group)();
|
|
4
|
+
const Paragraph = /*@__PURE__*/(() => Plot.define("Paragraph", {
|
|
5
|
+
inlineContent: true,
|
|
6
|
+
group: G.Content,
|
|
7
|
+
defaultBlock: true,
|
|
8
|
+
shape: { element: "p" }
|
|
9
|
+
}))();
|
|
10
|
+
const Heading = /*@__PURE__*/(() => Plot.Type.define("Heading", {
|
|
11
|
+
defaultParam: 1,
|
|
12
|
+
validate: value => {
|
|
13
|
+
if (typeof value != "number" || Math.floor(value) != value || value < 1 || value > 6)
|
|
14
|
+
throw new ValidationError(`Invalid heading level: ${value}`);
|
|
15
|
+
},
|
|
16
|
+
inlineContent: true,
|
|
17
|
+
group: G.Content,
|
|
18
|
+
shape: { structure: level => Elt.mk("h" + level, [0]), atom: false },
|
|
19
|
+
defining: true,
|
|
20
|
+
parseRules: [
|
|
21
|
+
{ selector: "h1", param: 1 },
|
|
22
|
+
{ selector: "h2", param: 2 },
|
|
23
|
+
{ selector: "h3", param: 3 },
|
|
24
|
+
{ selector: "h4", param: 4 },
|
|
25
|
+
{ selector: "h5", param: 5 },
|
|
26
|
+
{ selector: "h6", param: 6 },
|
|
27
|
+
]
|
|
28
|
+
}))();
|
|
29
|
+
const CodeBlock = /*@__PURE__*/(() => Plot.define("CodeBlock", {
|
|
30
|
+
inlineContent: true,
|
|
31
|
+
group: G.Content,
|
|
32
|
+
role: Node.Role.Code,
|
|
33
|
+
shape: { element: "pre" },
|
|
34
|
+
}))();
|
|
35
|
+
const CodeBlockLanguage = /*@__PURE__*/Mark.Type.define("CodeBlockLanguage", {
|
|
36
|
+
target: CodeBlock,
|
|
37
|
+
validate: "string",
|
|
38
|
+
shape: { attribute: "data-language", value: 0 }
|
|
39
|
+
});
|
|
40
|
+
const Blockquote = /*@__PURE__*/(() => Plot.define("Blockquote", {
|
|
41
|
+
blockContent: G.Content,
|
|
42
|
+
group: G.Content,
|
|
43
|
+
shape: { element: "blockquote" },
|
|
44
|
+
autoJoin: true
|
|
45
|
+
}))();
|
|
46
|
+
const ListItem = /*@__PURE__*/(() => Plot.define("ListItem", {
|
|
47
|
+
blockContent: G.Content,
|
|
48
|
+
shape: { element: "li" },
|
|
49
|
+
defining: true,
|
|
50
|
+
}))();
|
|
51
|
+
const InlineListItem = /*@__PURE__*/Plot.define("ListItem", {
|
|
52
|
+
inlineContent: true,
|
|
53
|
+
shape: { element: "li" },
|
|
54
|
+
defining: true,
|
|
55
|
+
});
|
|
56
|
+
const OrderedList = /*@__PURE__*/(() => Plot.Type.define("OrderedList", {
|
|
57
|
+
defaultParam: 1,
|
|
58
|
+
validate: "number",
|
|
59
|
+
blockContent: [ListItem, InlineListItem],
|
|
60
|
+
group: G.Content,
|
|
61
|
+
role: Node.Role.List,
|
|
62
|
+
defining: true,
|
|
63
|
+
shape: {
|
|
64
|
+
element: "ol",
|
|
65
|
+
attributes: start => start == 1 ? {} : { start: String(start) },
|
|
66
|
+
readElement: elt => Number(elt.getAttribute("start") || "1")
|
|
67
|
+
},
|
|
68
|
+
autoJoin: (_a, b) => b.param == 1
|
|
69
|
+
}))();
|
|
70
|
+
const BulletList = /*@__PURE__*/(() => Plot.define("BulletList", {
|
|
71
|
+
blockContent: [ListItem, InlineListItem],
|
|
72
|
+
group: G.Content,
|
|
73
|
+
role: Node.Role.List,
|
|
74
|
+
defining: true,
|
|
75
|
+
shape: { element: "ul" },
|
|
76
|
+
autoJoin: true
|
|
77
|
+
}))();
|
|
78
|
+
const HorizontalRule = /*@__PURE__*/(() => Leaf.define("HorizontalRule", {
|
|
79
|
+
group: G.Content,
|
|
80
|
+
shape: { element: "hr" },
|
|
81
|
+
toText: () => "---",
|
|
82
|
+
selectable: true
|
|
83
|
+
}))();
|
|
84
|
+
const LineBreak = /*@__PURE__*/(() => Leaf.define("LineBreak", {
|
|
85
|
+
inline: true,
|
|
86
|
+
role: Node.Role.LineBreak,
|
|
87
|
+
toText: () => "\n",
|
|
88
|
+
shape: { element: "br" }
|
|
89
|
+
}))();
|
|
90
|
+
const Cell = /*@__PURE__*/(() => Plot.define("Cell", {
|
|
91
|
+
inlineContent: true,
|
|
92
|
+
group: G.TableCell,
|
|
93
|
+
isolating: true,
|
|
94
|
+
cursorBarrier: false,
|
|
95
|
+
shape: { element: "td" }
|
|
96
|
+
}))();
|
|
97
|
+
const HeaderCell = /*@__PURE__*/(() => Plot.define("HeaderCell", {
|
|
98
|
+
inlineContent: true,
|
|
99
|
+
group: G.TableCell,
|
|
100
|
+
isolating: true,
|
|
101
|
+
cursorBarrier: false,
|
|
102
|
+
shape: { element: "th" }
|
|
103
|
+
}))();
|
|
104
|
+
const BlockCell = /*@__PURE__*/(() => Plot.define("Cell", {
|
|
105
|
+
blockContent: G.Content,
|
|
106
|
+
group: G.TableCell,
|
|
107
|
+
isolating: true,
|
|
108
|
+
cursorBarrier: false,
|
|
109
|
+
shape: { element: "td" }
|
|
110
|
+
}))();
|
|
111
|
+
const BlockHeaderCell = /*@__PURE__*/(() => Plot.define("HeaderCell", {
|
|
112
|
+
blockContent: G.Content,
|
|
113
|
+
group: G.TableCell,
|
|
114
|
+
isolating: true,
|
|
115
|
+
cursorBarrier: false,
|
|
116
|
+
shape: { element: "th" }
|
|
117
|
+
}))();
|
|
118
|
+
const TableRow = /*@__PURE__*/(() => Plot.define("TableRow", {
|
|
119
|
+
blockContent: G.TableCell,
|
|
120
|
+
canBeEmpty: true,
|
|
121
|
+
orientation: "row",
|
|
122
|
+
shape: { element: "tr" }
|
|
123
|
+
}))();
|
|
124
|
+
const Table = /*@__PURE__*/(() => Plot.define("Table", {
|
|
125
|
+
blockContent: TableRow,
|
|
126
|
+
isolating: true,
|
|
127
|
+
group: G.Content,
|
|
128
|
+
shape: { structure: Elt.mk("table", [Elt.mk("tbody", [0])]) },
|
|
129
|
+
parseRules: [{ selector: "table" }]
|
|
130
|
+
}))();
|
|
131
|
+
function validatePosInt(value) {
|
|
132
|
+
if (typeof value != "number" || Math.round(value) != value || value < 1)
|
|
133
|
+
throw new RangeError(`${value} is not a positive integer`);
|
|
134
|
+
}
|
|
135
|
+
function readPosInt(value) {
|
|
136
|
+
let num = Number.parseInt(value);
|
|
137
|
+
if (Number.isNaN(num) || num < 1)
|
|
138
|
+
return parse.Reject;
|
|
139
|
+
return num;
|
|
140
|
+
}
|
|
141
|
+
const ColSpan = /*@__PURE__*/(() => Mark.Type.define("ColSpan", {
|
|
142
|
+
target: G.TableCell,
|
|
143
|
+
validate: validatePosInt,
|
|
144
|
+
shape: { attribute: "colspan", value: span => String(span), readAttribute: readPosInt }
|
|
145
|
+
}))();
|
|
146
|
+
const RowSpan = /*@__PURE__*/(() => Mark.Type.define("RowSpan", {
|
|
147
|
+
target: G.TableCell,
|
|
148
|
+
validate: validatePosInt,
|
|
149
|
+
shape: { attribute: "rowspan", value: span => String(span), readAttribute: readPosInt }
|
|
150
|
+
}))();
|
|
151
|
+
const Image = /*@__PURE__*/Leaf.Type.define("Image", {
|
|
152
|
+
inline: true,
|
|
153
|
+
validate: "string",
|
|
154
|
+
shape: { element: "img", attributes: src => ({ src }) },
|
|
155
|
+
selectable: true,
|
|
156
|
+
parseRules: [{
|
|
157
|
+
selector: "img[src]",
|
|
158
|
+
readElement: elt => elt.src
|
|
159
|
+
}]
|
|
160
|
+
});
|
|
161
|
+
const Figure = /*@__PURE__*/(() => Leaf.Type.define("Figure", {
|
|
162
|
+
validate: "string",
|
|
163
|
+
shape: { structure: src => Elt.mk("figure", [Elt.mk("img", { src })]) },
|
|
164
|
+
selectable: true,
|
|
165
|
+
group: G.Content,
|
|
166
|
+
parseRules: [{
|
|
167
|
+
selector: "figure:has(img[src])",
|
|
168
|
+
marksFrom: "img[src]",
|
|
169
|
+
readElement: elt => elt.querySelector("img[src]").src,
|
|
170
|
+
precedence: 2
|
|
171
|
+
}]
|
|
172
|
+
}))();
|
|
173
|
+
const CaptionedFigure = /*@__PURE__*/(() => Plot.Type.define("CaptionedFigure", {
|
|
174
|
+
inlineContent: true,
|
|
175
|
+
validate: "string",
|
|
176
|
+
shape: { structure: src => Elt.mk("figure", [Elt.mk("img", { src }), Elt.mk("figcaption", [0])]), atom: false },
|
|
177
|
+
group: G.Content,
|
|
178
|
+
parseRules: [{
|
|
179
|
+
selector: "figure:has(img[src]):has(figcaption)",
|
|
180
|
+
marksFrom: "img[src]",
|
|
181
|
+
readElement: elt => elt.querySelector("img[src]").src,
|
|
182
|
+
contentElement: "figcaption",
|
|
183
|
+
precedence: 4
|
|
184
|
+
}]
|
|
185
|
+
}))();
|
|
186
|
+
const ImageAlt = /*@__PURE__*/Mark.Type.define("ImageAlt", {
|
|
187
|
+
target: [Image, Figure, CaptionedFigure],
|
|
188
|
+
validate: "string",
|
|
189
|
+
shape: { attribute: "alt", value: 0, preferTarget: "img" }
|
|
190
|
+
});
|
|
191
|
+
const ImageSize = /*@__PURE__*/Mark.Type.define("ImageSize", {
|
|
192
|
+
target: [Image, Figure, CaptionedFigure],
|
|
193
|
+
validate: "number",
|
|
194
|
+
shape: { attribute: "style", value: size => `width: ${size}px`, preferTarget: "img" }
|
|
195
|
+
});
|
|
196
|
+
const Alignment = /*@__PURE__*/(() => Mark.Type.define("Alignment", {
|
|
197
|
+
target: [G.Textblock, Figure],
|
|
198
|
+
keepOnSplit: true,
|
|
199
|
+
keepOnTypeChange: true,
|
|
200
|
+
shape: { attribute: "style", value: align => `text-align: ${align}` },
|
|
201
|
+
parseRules: [
|
|
202
|
+
{ attribute: "style/text-align", readAttribute: value => /^(end|center)$/.test(value) ? value : parse.Reject }
|
|
203
|
+
]
|
|
204
|
+
}))();
|
|
205
|
+
const Direction = /*@__PURE__*/(() => Mark.Type.define("Direction", {
|
|
206
|
+
target: G.Textblock,
|
|
207
|
+
keepOnSplit: true,
|
|
208
|
+
keepOnTypeChange: true,
|
|
209
|
+
validate: val => {
|
|
210
|
+
if (val != "ltr" && val != "rtl" && val != "auto")
|
|
211
|
+
throw new ValidationError(`Invalid direction value: ${val}`);
|
|
212
|
+
},
|
|
213
|
+
shape: { attribute: "dir", value: 0 }
|
|
214
|
+
}))();
|
|
215
|
+
const Emphasis = /*@__PURE__*/Mark.define("Emphasis", {
|
|
216
|
+
rank: 50,
|
|
217
|
+
shape: { element: "em" },
|
|
218
|
+
parseRules: [
|
|
219
|
+
{ attribute: "style/font-style", value: "italic" },
|
|
220
|
+
{ attribute: "style/font-style", value: "normal", clearMark: p => p.name == "Emphasis" }
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
const Strong = /*@__PURE__*/Mark.define("Strong", {
|
|
224
|
+
rank: 60,
|
|
225
|
+
shape: { element: "strong" },
|
|
226
|
+
parseRules: [
|
|
227
|
+
{ attribute: "style/font-weight",
|
|
228
|
+
readAttribute: value => /^(bold(er)?|[5-9]\d{2,})$/.test(value) ? null : parse.Reject },
|
|
229
|
+
{ attribute: "style/font-weight",
|
|
230
|
+
readAttribute: value => /^(normal|lighter|[1-4]\d{2})$/.test(value) ? null : parse.Reject,
|
|
231
|
+
clearMark: p => p.name == "Strong" },
|
|
232
|
+
]
|
|
233
|
+
});
|
|
234
|
+
const Underline = /*@__PURE__*/Mark.define("Underline", {
|
|
235
|
+
rank: 40,
|
|
236
|
+
shape: { element: "u" },
|
|
237
|
+
parseRules: [
|
|
238
|
+
{ attribute: "style/text-decoration", value: "underline" }
|
|
239
|
+
]
|
|
240
|
+
});
|
|
241
|
+
const Strikethrough = /*@__PURE__*/Mark.define("Strikethrough", {
|
|
242
|
+
rank: 42,
|
|
243
|
+
shape: { element: "s" },
|
|
244
|
+
parseRules: [
|
|
245
|
+
{ attribute: "style/text-decoration", value: "line-through" }
|
|
246
|
+
]
|
|
247
|
+
});
|
|
248
|
+
const Superscript = /*@__PURE__*/Mark.define("Superscript", {
|
|
249
|
+
rank: 45,
|
|
250
|
+
shape: { element: "sup" }
|
|
251
|
+
});
|
|
252
|
+
const Subscript = /*@__PURE__*/Mark.define("Subscript", {
|
|
253
|
+
rank: 47,
|
|
254
|
+
shape: { element: "sub" }
|
|
255
|
+
});
|
|
256
|
+
const Link = /*@__PURE__*/Mark.Type.define("Link", {
|
|
257
|
+
rank: 20,
|
|
258
|
+
validate: "string",
|
|
259
|
+
inclusive: false,
|
|
260
|
+
shape: {
|
|
261
|
+
element: "a",
|
|
262
|
+
preferTarget: "a[href]",
|
|
263
|
+
attributes: href => ({ href }),
|
|
264
|
+
readElement: dom => dom.href
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
const Code = /*@__PURE__*/Mark.define("Code", {
|
|
268
|
+
rank: 80,
|
|
269
|
+
shape: { element: "code" }
|
|
270
|
+
});
|
|
271
|
+
const Color = /*@__PURE__*/Mark.Type.define("Color", {
|
|
272
|
+
rank: 30,
|
|
273
|
+
shape: { attribute: "style/color", value: 0 },
|
|
274
|
+
spanning: true,
|
|
275
|
+
});
|
|
276
|
+
const BackgroundColor = /*@__PURE__*/Mark.Type.define("BackgroundColor", {
|
|
277
|
+
rank: 35,
|
|
278
|
+
shape: { attribute: "style/background-color", value: 0 },
|
|
279
|
+
spanning: true,
|
|
280
|
+
});
|
|
281
|
+
const Doc = /*@__PURE__*/(() => Plot.defineDoc({
|
|
282
|
+
blockContent: G.Content
|
|
283
|
+
}))();
|
|
284
|
+
const InlineDoc = /*@__PURE__*/Plot.defineDoc({
|
|
285
|
+
inlineContent: true
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
export { Alignment, BackgroundColor, BlockCell, BlockHeaderCell, Blockquote, BulletList, CaptionedFigure, Cell, Code, CodeBlock, CodeBlockLanguage, ColSpan, Color, Direction, Doc, Emphasis, Figure, HeaderCell, Heading, HorizontalRule, Image, ImageAlt, ImageSize, InlineDoc, InlineListItem, LineBreak, Link, ListItem, OrderedList, Paragraph, RowSpan, Strikethrough, Strong, Subscript, Superscript, Table, TableRow, Underline };
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nerd-bible/wordgard",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "Semantic rich text editor system",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./doc": "./dist/doc.js",
|
|
10
|
+
"./types": "./dist/types.js",
|
|
11
|
+
"./schema": "./dist/schema.js",
|
|
12
|
+
"./table": "./dist/table.js",
|
|
13
|
+
"./state": "./dist/state.js",
|
|
14
|
+
"./editor": "./dist/editor.js",
|
|
15
|
+
"./command": "./dist/command.js",
|
|
16
|
+
"./history": "./dist/history.js",
|
|
17
|
+
"./collab": "./dist/collab.js",
|
|
18
|
+
"./phrases": "./dist/phrases.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"/dist"
|
|
22
|
+
],
|
|
23
|
+
"author": "Marijn Haverbeke <marijn@haverbeke.berlin>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@marijn/find-cluster-break": "^1.0.2",
|
|
27
|
+
"crelt": "^1.0.6",
|
|
28
|
+
"style-mod": "^4.1.3"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@nerd-bible/config": "^0.2.2",
|
|
32
|
+
"@swc/wasm-typescript": "^1.15.3",
|
|
33
|
+
"@types/mocha": "^10.0.10",
|
|
34
|
+
"@types/node": "^24.10.2",
|
|
35
|
+
"acorn": "^8.16.0",
|
|
36
|
+
"acorn-walk": "^8.3.5",
|
|
37
|
+
"esmoduleserve": "^0.3.1",
|
|
38
|
+
"ist": "^1.1.7",
|
|
39
|
+
"mocha": "^11.7.6",
|
|
40
|
+
"rollup": "^4.60.1",
|
|
41
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
42
|
+
"send": "^1.2.1",
|
|
43
|
+
"serve-static": "^1.15.0",
|
|
44
|
+
"typescript": "^6.0.3"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=22"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"url": "https://github.com/nerd-bible/wordgard"
|
|
51
|
+
}
|
|
52
|
+
}
|