@astl/editor 0.0.0 → 0.1.1
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/CHANGELOG.md +107 -0
- package/LICENSE +202 -0
- package/README.md +43 -0
- package/dist/authoring.d.ts +284 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +566 -0
- package/dist/authoring.js.map +1 -0
- package/dist/define.d.ts +8 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +35 -0
- package/dist/define.js.map +1 -0
- package/dist/edit.d.ts +45 -0
- package/dist/edit.d.ts.map +1 -0
- package/dist/edit.js +150 -0
- package/dist/edit.js.map +1 -0
- package/dist/elements/base.d.ts +31 -0
- package/dist/elements/base.d.ts.map +1 -0
- package/dist/elements/base.js +75 -0
- package/dist/elements/base.js.map +1 -0
- package/dist/elements/color-control.d.ts +25 -0
- package/dist/elements/color-control.d.ts.map +1 -0
- package/dist/elements/color-control.js +139 -0
- package/dist/elements/color-control.js.map +1 -0
- package/dist/elements/help-form.d.ts +31 -0
- package/dist/elements/help-form.d.ts.map +1 -0
- package/dist/elements/help-form.js +371 -0
- package/dist/elements/help-form.js.map +1 -0
- package/dist/elements/insert-menu.d.ts +79 -0
- package/dist/elements/insert-menu.d.ts.map +1 -0
- package/dist/elements/insert-menu.js +362 -0
- package/dist/elements/insert-menu.js.map +1 -0
- package/dist/elements/inspector.d.ts +24 -0
- package/dist/elements/inspector.d.ts.map +1 -0
- package/dist/elements/inspector.js +846 -0
- package/dist/elements/inspector.js.map +1 -0
- package/dist/elements/issue-list.d.ts +18 -0
- package/dist/elements/issue-list.d.ts.map +1 -0
- package/dist/elements/issue-list.js +85 -0
- package/dist/elements/issue-list.js.map +1 -0
- package/dist/elements/issues.d.ts +24 -0
- package/dist/elements/issues.d.ts.map +1 -0
- package/dist/elements/issues.js +81 -0
- package/dist/elements/issues.js.map +1 -0
- package/dist/elements/picture-dialog.d.ts +40 -0
- package/dist/elements/picture-dialog.d.ts.map +1 -0
- package/dist/elements/picture-dialog.js +433 -0
- package/dist/elements/picture-dialog.js.map +1 -0
- package/dist/elements/picture-field.d.ts +33 -0
- package/dist/elements/picture-field.d.ts.map +1 -0
- package/dist/elements/picture-field.js +692 -0
- package/dist/elements/picture-field.js.map +1 -0
- package/dist/elements/preview.d.ts +34 -0
- package/dist/elements/preview.d.ts.map +1 -0
- package/dist/elements/preview.js +165 -0
- package/dist/elements/preview.js.map +1 -0
- package/dist/elements/style-form.d.ts +30 -0
- package/dist/elements/style-form.d.ts.map +1 -0
- package/dist/elements/style-form.js +640 -0
- package/dist/elements/style-form.js.map +1 -0
- package/dist/elements/style-load.d.ts +26 -0
- package/dist/elements/style-load.d.ts.map +1 -0
- package/dist/elements/style-load.js +50 -0
- package/dist/elements/style-load.js.map +1 -0
- package/dist/elements/style-popups.d.ts +39 -0
- package/dist/elements/style-popups.d.ts.map +1 -0
- package/dist/elements/style-popups.js +173 -0
- package/dist/elements/style-popups.js.map +1 -0
- package/dist/elements/style-rules.d.ts +21 -0
- package/dist/elements/style-rules.d.ts.map +1 -0
- package/dist/elements/style-rules.js +274 -0
- package/dist/elements/style-rules.js.map +1 -0
- package/dist/elements/styles.d.ts +9 -0
- package/dist/elements/styles.d.ts.map +1 -0
- package/dist/elements/styles.js +161 -0
- package/dist/elements/styles.js.map +1 -0
- package/dist/elements/toolbar.d.ts +65 -0
- package/dist/elements/toolbar.d.ts.map +1 -0
- package/dist/elements/toolbar.js +1270 -0
- package/dist/elements/toolbar.js.map +1 -0
- package/dist/help.d.ts +33 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +111 -0
- package/dist/help.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +251 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +428 -0
- package/dist/inspect.js.map +1 -0
- package/dist/messages/en.json +252 -0
- package/dist/messages/help/en.json +18 -0
- package/dist/messages/help/pl.json +18 -0
- package/dist/messages/pl.json +252 -0
- package/dist/messages/style/en.json +67 -0
- package/dist/messages/style/pl.json +67 -0
- package/dist/messages.d.ts +5 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +9 -0
- package/dist/messages.js.map +1 -0
- package/dist/pages.d.ts +28 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +147 -0
- package/dist/pages.js.map +1 -0
- package/dist/scan.d.ts +82 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +329 -0
- package/dist/scan.js.map +1 -0
- package/dist/style-messages.d.ts +7 -0
- package/dist/style-messages.d.ts.map +1 -0
- package/dist/style-messages.js +12 -0
- package/dist/style-messages.js.map +1 -0
- package/dist/style-model.d.ts +50 -0
- package/dist/style-model.d.ts.map +1 -0
- package/dist/style-model.js +76 -0
- package/dist/style-model.js.map +1 -0
- package/dist/style-placing.d.ts +38 -0
- package/dist/style-placing.d.ts.map +1 -0
- package/dist/style-placing.js +98 -0
- package/dist/style-placing.js.map +1 -0
- package/dist/textarea.d.ts +17 -0
- package/dist/textarea.d.ts.map +1 -0
- package/dist/textarea.js +175 -0
- package/dist/textarea.js.map +1 -0
- package/package.json +54 -4
- package/src/authoring.ts +896 -0
- package/src/define.ts +34 -0
- package/src/edit.ts +195 -0
- package/src/elements/base.ts +93 -0
- package/src/elements/color-control.ts +159 -0
- package/src/elements/help-form.ts +404 -0
- package/src/elements/insert-menu.ts +481 -0
- package/src/elements/inspector.ts +941 -0
- package/src/elements/issue-list.ts +103 -0
- package/src/elements/issues.ts +89 -0
- package/src/elements/picture-dialog.ts +461 -0
- package/src/elements/picture-field.ts +770 -0
- package/src/elements/preview.ts +186 -0
- package/src/elements/style-form.ts +751 -0
- package/src/elements/style-load.ts +64 -0
- package/src/elements/style-popups.ts +257 -0
- package/src/elements/style-rules.ts +294 -0
- package/src/elements/styles.ts +162 -0
- package/src/elements/toolbar.ts +1386 -0
- package/src/help.ts +156 -0
- package/src/index.ts +81 -0
- package/src/inspect.ts +774 -0
- package/src/messages/en.json +252 -0
- package/src/messages/help/en.json +18 -0
- package/src/messages/help/pl.json +18 -0
- package/src/messages/pl.json +252 -0
- package/src/messages/style/en.json +67 -0
- package/src/messages/style/pl.json +67 -0
- package/src/messages.ts +11 -0
- package/src/pages.ts +158 -0
- package/src/scan.ts +382 -0
- package/src/style-messages.ts +13 -0
- package/src/style-model.ts +125 -0
- package/src/style-placing.ts +117 -0
- package/src/textarea.ts +182 -0
package/dist/scan.js
ADDED
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small, tolerant HTML tokenizer for text-based editing. It only locates tags (with exact source offsets), so edits
|
|
3
|
+
* can splice the source and leave everything else byte-identical. Reading values the way a browser would (entities,
|
|
4
|
+
* tree construction) is the engine's `parseHtml`.
|
|
5
|
+
*/
|
|
6
|
+
import { COLUMN_TAG, COLUMNS_TAG, HELP_TAGS, PAGE_TAG, STYLE_TAG } from '@astl/core';
|
|
7
|
+
import { parseHtml } from '@astl/engine';
|
|
8
|
+
/** Elements whose content the HTML parser reads as raw text: tags inside them are not tags. */
|
|
9
|
+
const RAW_TEXT = new Set([
|
|
10
|
+
'script',
|
|
11
|
+
'style',
|
|
12
|
+
'textarea',
|
|
13
|
+
'title',
|
|
14
|
+
'xmp',
|
|
15
|
+
'iframe',
|
|
16
|
+
'noembed',
|
|
17
|
+
'noframes',
|
|
18
|
+
'noscript',
|
|
19
|
+
]);
|
|
20
|
+
const VOID = new Set([
|
|
21
|
+
'area',
|
|
22
|
+
'base',
|
|
23
|
+
'br',
|
|
24
|
+
'col',
|
|
25
|
+
'embed',
|
|
26
|
+
'hr',
|
|
27
|
+
'img',
|
|
28
|
+
'input',
|
|
29
|
+
'link',
|
|
30
|
+
'meta',
|
|
31
|
+
'source',
|
|
32
|
+
'track',
|
|
33
|
+
'wbr',
|
|
34
|
+
]);
|
|
35
|
+
const DOC_TAG = 'astl-doc';
|
|
36
|
+
function isSpace(code) {
|
|
37
|
+
return code === 32 || code === 9 || code === 10 || code === 12 || code === 13;
|
|
38
|
+
}
|
|
39
|
+
function isAsciiLetter(code) {
|
|
40
|
+
return (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
|
41
|
+
}
|
|
42
|
+
/** Offset after a comment that starts at `at` (`<!--`). */
|
|
43
|
+
function commentEnd(source, at) {
|
|
44
|
+
if (source.startsWith('<!-->', at))
|
|
45
|
+
return at + 5;
|
|
46
|
+
if (source.startsWith('<!--->', at))
|
|
47
|
+
return at + 6;
|
|
48
|
+
const ends = [source.indexOf('-->', at + 4), source.indexOf('--!>', at + 4)].filter((i) => i >= 0);
|
|
49
|
+
if (ends.length === 0)
|
|
50
|
+
return source.length;
|
|
51
|
+
const end = Math.min(...ends);
|
|
52
|
+
return end + (source.startsWith('-->', end) ? 3 : 4);
|
|
53
|
+
}
|
|
54
|
+
/** Offset after the next `>` (bogus comments, doctypes), or the end. */
|
|
55
|
+
function afterNextGt(source, from) {
|
|
56
|
+
const gt = source.indexOf('>', from);
|
|
57
|
+
return gt < 0 ? source.length : gt + 1;
|
|
58
|
+
}
|
|
59
|
+
/** Offset of the end tag that closes a raw text element, or the end of the source. */
|
|
60
|
+
function rawTextEnd(source, from, name) {
|
|
61
|
+
const re = new RegExp(`</${name}(?=[\\t\\n\\f\\r />])`, 'gi');
|
|
62
|
+
re.lastIndex = from;
|
|
63
|
+
return re.exec(source)?.index ?? source.length;
|
|
64
|
+
}
|
|
65
|
+
function readTag(source, start, type) {
|
|
66
|
+
const n = source.length;
|
|
67
|
+
let i = start + (type === 'end' ? 2 : 1);
|
|
68
|
+
const nameStart = i;
|
|
69
|
+
while (i < n) {
|
|
70
|
+
const c = source.charCodeAt(i);
|
|
71
|
+
if (isSpace(c) || c === 47 /* / */ || c === 62 /* > */)
|
|
72
|
+
break;
|
|
73
|
+
i++;
|
|
74
|
+
}
|
|
75
|
+
const name = source.slice(nameStart, i).toLowerCase();
|
|
76
|
+
const attributes = [];
|
|
77
|
+
const done = (end, selfClosing) => ({
|
|
78
|
+
type,
|
|
79
|
+
name,
|
|
80
|
+
start,
|
|
81
|
+
end,
|
|
82
|
+
attributes,
|
|
83
|
+
selfClosing,
|
|
84
|
+
});
|
|
85
|
+
while (i < n) {
|
|
86
|
+
const c = source.charCodeAt(i);
|
|
87
|
+
if (isSpace(c)) {
|
|
88
|
+
i++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (c === 62)
|
|
92
|
+
return done(i + 1, false);
|
|
93
|
+
if (c === 47) {
|
|
94
|
+
if (source.charCodeAt(i + 1) === 62)
|
|
95
|
+
return done(i + 2, true);
|
|
96
|
+
i++;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
// Attribute name: up to space, `/`, `>` or `=` (a leading `=` belongs to the name, as in the HTML tokenizer).
|
|
100
|
+
const attrStart = i;
|
|
101
|
+
i++;
|
|
102
|
+
while (i < n) {
|
|
103
|
+
const d = source.charCodeAt(i);
|
|
104
|
+
if (isSpace(d) || d === 47 || d === 62 || d === 61 /* = */)
|
|
105
|
+
break;
|
|
106
|
+
i++;
|
|
107
|
+
}
|
|
108
|
+
const attrName = source.slice(attrStart, i).toLowerCase();
|
|
109
|
+
let j = i;
|
|
110
|
+
while (j < n && isSpace(source.charCodeAt(j)))
|
|
111
|
+
j++;
|
|
112
|
+
if (source.charCodeAt(j) !== 61) {
|
|
113
|
+
attributes.push({ name: attrName, raw: null, start: attrStart, end: i });
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
j++;
|
|
117
|
+
while (j < n && isSpace(source.charCodeAt(j)))
|
|
118
|
+
j++;
|
|
119
|
+
const quote = source[j];
|
|
120
|
+
if (quote === '"' || quote === "'") {
|
|
121
|
+
const close = source.indexOf(quote, j + 1);
|
|
122
|
+
const end = close < 0 ? n : close + 1;
|
|
123
|
+
attributes.push({
|
|
124
|
+
name: attrName,
|
|
125
|
+
raw: source.slice(j + 1, close < 0 ? n : close),
|
|
126
|
+
start: attrStart,
|
|
127
|
+
end,
|
|
128
|
+
});
|
|
129
|
+
i = end;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
let k = j;
|
|
133
|
+
while (k < n && !isSpace(source.charCodeAt(k)) && source.charCodeAt(k) !== 62)
|
|
134
|
+
k++;
|
|
135
|
+
attributes.push({ name: attrName, raw: source.slice(j, k), start: attrStart, end: k });
|
|
136
|
+
i = k;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return done(n, false);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Start and end tags in source order. Comments, doctypes and bogus comments are skipped, and so is the content of raw
|
|
143
|
+
* text elements (`script`, `style`, `textarea`, ...). A `<` that does not start a tag is text.
|
|
144
|
+
*/
|
|
145
|
+
export function tokenize(source) {
|
|
146
|
+
const out = [];
|
|
147
|
+
const n = source.length;
|
|
148
|
+
let i = 0;
|
|
149
|
+
while (i < n) {
|
|
150
|
+
const lt = source.indexOf('<', i);
|
|
151
|
+
if (lt < 0)
|
|
152
|
+
break;
|
|
153
|
+
i = lt;
|
|
154
|
+
const next = source.charCodeAt(i + 1);
|
|
155
|
+
if (source.startsWith('<!--', i)) {
|
|
156
|
+
i = commentEnd(source, i);
|
|
157
|
+
}
|
|
158
|
+
else if (next === 33 /* ! */ || next === 63 /* ? */) {
|
|
159
|
+
i = afterNextGt(source, i + 2);
|
|
160
|
+
}
|
|
161
|
+
else if (next === 47 /* / */) {
|
|
162
|
+
const c = source.charCodeAt(i + 2);
|
|
163
|
+
if (isAsciiLetter(c)) {
|
|
164
|
+
const tag = readTag(source, i, 'end');
|
|
165
|
+
out.push(tag);
|
|
166
|
+
i = tag.end;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
i = c === 62 ? i + 3 : afterNextGt(source, i + 2);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else if (isAsciiLetter(next)) {
|
|
173
|
+
const tag = readTag(source, i, 'start');
|
|
174
|
+
out.push(tag);
|
|
175
|
+
i = tag.end;
|
|
176
|
+
if (RAW_TEXT.has(tag.name))
|
|
177
|
+
i = rawTextEnd(source, i, tag.name);
|
|
178
|
+
else if (tag.name === 'plaintext')
|
|
179
|
+
i = n;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
i++;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
187
|
+
function isCustom(name) {
|
|
188
|
+
return name.includes('-');
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* The element tree of `source` with offsets. Tolerant: an end tag closes the nearest open element of its name (and
|
|
192
|
+
* everything opened inside it); stray end tags are ignored; elements still open at the end close there. Custom
|
|
193
|
+
* elements written `<x-y ... />` count as closed (the author's intent; HTML would leave them open).
|
|
194
|
+
*/
|
|
195
|
+
export function elementTree(source) {
|
|
196
|
+
const roots = [];
|
|
197
|
+
const stack = [];
|
|
198
|
+
const add = (range) => (stack[stack.length - 1]?.children ?? roots).push(range);
|
|
199
|
+
const close = (open, end, endTag) => add({
|
|
200
|
+
name: open.name,
|
|
201
|
+
start: open.start,
|
|
202
|
+
end,
|
|
203
|
+
startTag: open.startTag,
|
|
204
|
+
endTag,
|
|
205
|
+
children: open.children,
|
|
206
|
+
});
|
|
207
|
+
for (const tag of tokenize(source)) {
|
|
208
|
+
if (tag.type === 'start') {
|
|
209
|
+
if (VOID.has(tag.name) || (tag.selfClosing && isCustom(tag.name))) {
|
|
210
|
+
add({ name: tag.name, start: tag.start, end: tag.end, startTag: tag, endTag: null, children: [] });
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
stack.push({ name: tag.name, start: tag.start, startTag: tag, children: [] });
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
let index = stack.length - 1;
|
|
218
|
+
while (index >= 0 && stack[index]?.name !== tag.name)
|
|
219
|
+
index--;
|
|
220
|
+
if (index < 0)
|
|
221
|
+
continue;
|
|
222
|
+
while (stack.length - 1 > index)
|
|
223
|
+
close(stack.pop(), tag.start, null);
|
|
224
|
+
close(stack.pop(), tag.end, tag);
|
|
225
|
+
}
|
|
226
|
+
while (stack.length > 0)
|
|
227
|
+
close(stack.pop(), source.length, null);
|
|
228
|
+
return roots;
|
|
229
|
+
}
|
|
230
|
+
/** Decodes entities in an attribute value, exactly as the HTML parser does. */
|
|
231
|
+
export function decodeAttribute(raw) {
|
|
232
|
+
if (!raw.includes('&'))
|
|
233
|
+
return raw;
|
|
234
|
+
const [node] = parseHtml(`<b title="${raw.replaceAll('"', '"')}"></b>`);
|
|
235
|
+
return node?.type === 'element' ? (node.attrs.title ?? raw) : raw;
|
|
236
|
+
}
|
|
237
|
+
/** Decoded value of the first attribute called `name`; '' for a bare attribute, null when absent. */
|
|
238
|
+
export function attributeValue(tag, name) {
|
|
239
|
+
const attribute = tag.attributes.find((a) => a.name === name);
|
|
240
|
+
if (attribute === undefined)
|
|
241
|
+
return null;
|
|
242
|
+
return attribute.raw === null ? '' : decodeAttribute(attribute.raw);
|
|
243
|
+
}
|
|
244
|
+
/** Pages and components with their ranges (internal form of `scanElements`). */
|
|
245
|
+
export function scanRanges(source) {
|
|
246
|
+
const out = [];
|
|
247
|
+
const walk = (ranges) => {
|
|
248
|
+
for (const range of ranges) {
|
|
249
|
+
const { name } = range;
|
|
250
|
+
// Neither a named style nor a layout is a component; what a layout holds is on its page, and so is what follows
|
|
251
|
+
// a self-closed named style, which HTML reads as its content.
|
|
252
|
+
// Nor is help for students on a page: what it holds (a component, wrongly) is on the page too.
|
|
253
|
+
if (name === STYLE_TAG || name === COLUMNS_TAG || name === COLUMN_TAG || HELP_TAGS.has(name)) {
|
|
254
|
+
walk(range.children);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if (name === PAGE_TAG || (isCustom(name) && name !== DOC_TAG)) {
|
|
258
|
+
const id = attributeValue(range.startTag, 'id');
|
|
259
|
+
out.push({ tag: name, id, start: range.start, end: range.end, range });
|
|
260
|
+
// Components do not nest: custom elements inside one are its children (options, alternatives).
|
|
261
|
+
if (name !== PAGE_TAG)
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
walk(range.children);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
walk(elementTree(source));
|
|
268
|
+
return out;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Pages (`astl-page`) and components in document order, with offsets into `source`, for text-based adapters. An
|
|
272
|
+
* component is any custom element outside another component (so a misspelt tag is found too), but for the tags of the
|
|
273
|
+
* format: a layout's are looked through, named styles are skipped; custom elements inside a component are its children.
|
|
274
|
+
* Tolerant of messy input: comments, quoted `>` in attributes, any case, unclosed or self-closed elements.
|
|
275
|
+
*/
|
|
276
|
+
export function scanElements(source) {
|
|
277
|
+
return scanRanges(source).map(({ tag, id, start, end }) => ({ tag, id, start, end }));
|
|
278
|
+
}
|
|
279
|
+
/** Every `id` attribute value in the source (pages, components and local child ids). */
|
|
280
|
+
export function usedIds(source) {
|
|
281
|
+
const ids = new Set();
|
|
282
|
+
for (const tag of tokenize(source)) {
|
|
283
|
+
if (tag.type !== 'start')
|
|
284
|
+
continue;
|
|
285
|
+
const id = attributeValue(tag, 'id');
|
|
286
|
+
if (id !== null)
|
|
287
|
+
ids.add(id);
|
|
288
|
+
}
|
|
289
|
+
return ids;
|
|
290
|
+
}
|
|
291
|
+
const NBSP = String.fromCodePoint(0xa0);
|
|
292
|
+
const TEXT_SPECIALS = new RegExp(`[&<>${NBSP}]`, 'g');
|
|
293
|
+
const ATTRIBUTE_SPECIALS = new RegExp(`[&"<>${NBSP}]`, 'g');
|
|
294
|
+
const HTML_SPECIALS = new RegExp(`[&<>"'${NBSP}]`, 'g');
|
|
295
|
+
const ENTITIES = {
|
|
296
|
+
'&': '&',
|
|
297
|
+
'<': '<',
|
|
298
|
+
'>': '>',
|
|
299
|
+
'"': '"',
|
|
300
|
+
"'": ''',
|
|
301
|
+
[NBSP]: ' ',
|
|
302
|
+
};
|
|
303
|
+
const entity = (ch) => ENTITIES[ch] ?? ch;
|
|
304
|
+
export function escapeText(value) {
|
|
305
|
+
return value.replace(TEXT_SPECIALS, entity);
|
|
306
|
+
}
|
|
307
|
+
export function escapeAttribute(value) {
|
|
308
|
+
return value.replace(ATTRIBUTE_SPECIALS, entity);
|
|
309
|
+
}
|
|
310
|
+
/** Safe in text and in quoted attribute values. */
|
|
311
|
+
export function escapeHtml(value) {
|
|
312
|
+
return value.replace(HTML_SPECIALS, entity);
|
|
313
|
+
}
|
|
314
|
+
/** Applies non-overlapping edits. */
|
|
315
|
+
export function applyEdits(source, edits) {
|
|
316
|
+
let out = source;
|
|
317
|
+
for (const edit of [...edits].sort((a, b) => b.start - a.start)) {
|
|
318
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
319
|
+
}
|
|
320
|
+
return out;
|
|
321
|
+
}
|
|
322
|
+
/** Start of the whitespace run that ends at `at` (or `at` itself). */
|
|
323
|
+
export function spaceBefore(source, at) {
|
|
324
|
+
let i = at;
|
|
325
|
+
while (i > 0 && isSpace(source.charCodeAt(i - 1)))
|
|
326
|
+
i--;
|
|
327
|
+
return i;
|
|
328
|
+
}
|
|
329
|
+
//# sourceMappingURL=scan.js.map
|
package/dist/scan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACrF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA6CzC,+FAA+F;AAC/F,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAC;IAC5C,QAAQ;IACR,OAAO;IACP,UAAU;IACV,OAAO;IACP,KAAK;IACL,QAAQ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,CAAC,CAAC;QAAE,CAAC,EAAE,CAAC;IACvD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MessageCatalog } from '@astl/core';
|
|
2
|
+
/**
|
|
3
|
+
* What only `<astl-style-form>` and `<astl-style-rules>` say. They bring it with them, outside the editor's first load,
|
|
4
|
+
* and add it to the authoring they are given.
|
|
5
|
+
*/
|
|
6
|
+
export declare const styleMessages: readonly MessageCatalog[];
|
|
7
|
+
//# sourceMappingURL=style-messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-messages.d.ts","sourceRoot":"","sources":["../src/style-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjD;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,cAAc,EAGlD,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import en from './messages/style/en.json' with { type: 'json' };
|
|
2
|
+
import pl from './messages/style/pl.json' with { type: 'json' };
|
|
3
|
+
import { EDITOR_NAMESPACE } from './messages.js';
|
|
4
|
+
/**
|
|
5
|
+
* What only `<astl-style-form>` and `<astl-style-rules>` say. They bring it with them, outside the editor's first load,
|
|
6
|
+
* and add it to the authoring they are given.
|
|
7
|
+
*/
|
|
8
|
+
export const styleMessages = [
|
|
9
|
+
{ namespace: EDITOR_NAMESPACE, locale: 'en', messages: en },
|
|
10
|
+
{ namespace: EDITOR_NAMESPACE, locale: 'pl', messages: pl },
|
|
11
|
+
];
|
|
12
|
+
//# sourceMappingURL=style-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-messages.js","sourceRoot":"","sources":["../src/style-messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,0BAA0B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EAAE,MAAM,0BAA0B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAA8B;IACtD,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3D,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;CAC5D,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the first load of the kit reads: the declarations of a style as a map, the host's fonts, the ready styles and
|
|
3
|
+
* the layouts. A layout's source goes through the format's rules like any other.
|
|
4
|
+
*/
|
|
5
|
+
import type { EditorLayoutShape } from '@astl/core';
|
|
6
|
+
/** The declarations of a `style` value as a map, read as they are written (they come from the allow-list). */
|
|
7
|
+
export declare const styleMapOf: (style: string) => ReadonlyMap<string, string>;
|
|
8
|
+
/** A font a host offers (`defineEditor({ fonts })`): its name in the menus, and its CSS stack. */
|
|
9
|
+
export interface EditorFont {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly stack: string;
|
|
12
|
+
}
|
|
13
|
+
/** The default list: stacks every system has, nothing to download or license. */
|
|
14
|
+
export declare const DEFAULT_FONTS: readonly EditorFont[];
|
|
15
|
+
/**
|
|
16
|
+
* A ready style a host offers (`defineEditor({ styles })`), as a word processor has its built-in ones. Picked, it is
|
|
17
|
+
* written into the document as a named style (`<astl-style>`), which the exercise then owns like any other.
|
|
18
|
+
*/
|
|
19
|
+
export interface EditorStylePreset {
|
|
20
|
+
/** The name it is applied by (`class`): what `isStyleName` takes. */
|
|
21
|
+
readonly name: string;
|
|
22
|
+
/** Its declarations, every one of which the style allow-list must keep. */
|
|
23
|
+
readonly style: string;
|
|
24
|
+
/** Its name in the menus and in the rule. Default: the kit's message `style.preset.<name>`, else the name. */
|
|
25
|
+
readonly label?: string;
|
|
26
|
+
/**
|
|
27
|
+
* A style of words: it goes on the selected text, and with only a cursor on what the cursor is in. Without it, a
|
|
28
|
+
* style of boxes: on what the cursor is in (a block, a component), words selected or not.
|
|
29
|
+
*/
|
|
30
|
+
readonly text?: true;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The default ready styles: boxes for a note, a tip, a warning, a definition, an example and a quote, then two for
|
|
34
|
+
* words. Their text reads at 4.5:1 on what is behind it, in the light theme and as the player paints them in the dark
|
|
35
|
+
* one (`styled.browser.test.ts`). A style of words holds no padding and no margin: on a phone the player gives
|
|
36
|
+
* whatever has a padding its own (`styled.ts`), which would pad a word inside its sentence.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_STYLES: readonly EditorStylePreset[];
|
|
39
|
+
/** The theme's colours an author can pick, by number: `var(--astl-palette-<n>)`. */
|
|
40
|
+
export declare const PALETTE_SIZE = 8;
|
|
41
|
+
/** The layouts of the insert menu's "Layout" group. */
|
|
42
|
+
export type LayoutName = EditorLayoutShape | 'picture-text';
|
|
43
|
+
export declare const LAYOUTS: readonly LayoutName[];
|
|
44
|
+
/** The shapes a layout can be changed to (`EditorStyles.editLayout`), in the menu's order. */
|
|
45
|
+
export declare const LAYOUT_SHAPES: readonly EditorLayoutShape[];
|
|
46
|
+
/** Each shape's columns by their `flex-grow`: null for an equal share. */
|
|
47
|
+
export declare const LAYOUT_COLUMNS: Readonly<Record<EditorLayoutShape, readonly (number | null)[]>>;
|
|
48
|
+
/** The source of a layout; `picture-text` takes the source of its picture. */
|
|
49
|
+
export declare function layoutHtml(name: LayoutName, picture?: string): string;
|
|
50
|
+
//# sourceMappingURL=style-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-model.d.ts","sourceRoot":"","sources":["../src/style-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAE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come from the allow-list). */
|
|
2
|
+
export const styleMapOf = (style) => new Map(style.split(';').flatMap((part) => {
|
|
3
|
+
const at = part.indexOf(':');
|
|
4
|
+
return at < 0
|
|
5
|
+
? []
|
|
6
|
+
: [
|
|
7
|
+
[
|
|
8
|
+
part.slice(0, at).trim().toLowerCase(),
|
|
9
|
+
part
|
|
10
|
+
.slice(at + 1)
|
|
11
|
+
.trim()
|
|
12
|
+
.toLowerCase(),
|
|
13
|
+
],
|
|
14
|
+
];
|
|
15
|
+
}));
|
|
16
|
+
/** The default list: stacks every system has, nothing to download or license. */
|
|
17
|
+
export const DEFAULT_FONTS = [
|
|
18
|
+
{ name: 'Arial', stack: 'Arial, Helvetica, sans-serif' },
|
|
19
|
+
{ name: 'Verdana', stack: 'Verdana, Geneva, sans-serif' },
|
|
20
|
+
{ name: 'Georgia', stack: 'Georgia, serif' },
|
|
21
|
+
{ name: 'Times New Roman', stack: '"Times New Roman", Times, serif' },
|
|
22
|
+
{ name: 'Courier New', stack: '"Courier New", Courier, monospace' },
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* The default ready styles: boxes for a note, a tip, a warning, a definition, an example and a quote, then two for
|
|
26
|
+
* words. Their text reads at 4.5:1 on what is behind it, in the light theme and as the player paints them in the dark
|
|
27
|
+
* one (`styled.browser.test.ts`). A style of words holds no padding and no margin: on a phone the player gives
|
|
28
|
+
* whatever has a padding its own (`styled.ts`), which would pad a word inside its sentence.
|
|
29
|
+
*/
|
|
30
|
+
export const DEFAULT_STYLES = [
|
|
31
|
+
{
|
|
32
|
+
name: 'note',
|
|
33
|
+
style: 'background-color: #fff4d6; border-inline-start: 4px solid #b7791f; padding: 12px 16px; border-radius: 6px',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'tip',
|
|
37
|
+
style: 'background-color: #e7f6ec; border-inline-start: 4px solid #2f855a; padding: 12px 16px; border-radius: 6px',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'important',
|
|
41
|
+
style: 'background-color: #fdecec; border-inline-start: 4px solid #c53030; padding: 12px 16px; border-radius: 6px',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'definition',
|
|
45
|
+
style: 'background-color: #eef1fe; border: 1px solid #5a67d8; padding: 12px 16px; border-radius: 6px',
|
|
46
|
+
},
|
|
47
|
+
{ name: 'example', style: 'border: 2px dashed #718096; padding: 12px 16px; border-radius: 6px' },
|
|
48
|
+
{
|
|
49
|
+
name: 'quote',
|
|
50
|
+
style: 'border-inline-start: 3px solid #a0aec0; padding-inline-start: 16px; font-style: italic; color: #4a5568',
|
|
51
|
+
},
|
|
52
|
+
{ name: 'highlight', style: 'background-color: #fff3a3', text: true },
|
|
53
|
+
{ name: 'small-print', style: 'font-size: 14px; color: #4a5568', text: true },
|
|
54
|
+
];
|
|
55
|
+
/** The theme's colours an author can pick, by number: `var(--astl-palette-<n>)`. */
|
|
56
|
+
export const PALETTE_SIZE = 8;
|
|
57
|
+
export const LAYOUTS = ['two', 'three', 'wide-narrow', 'narrow-wide', 'picture-text'];
|
|
58
|
+
/** The shapes a layout can be changed to (`EditorStyles.editLayout`), in the menu's order. */
|
|
59
|
+
export const LAYOUT_SHAPES = ['two', 'three', 'wide-narrow', 'narrow-wide'];
|
|
60
|
+
/** Each shape's columns by their `flex-grow`: null for an equal share. */
|
|
61
|
+
export const LAYOUT_COLUMNS = {
|
|
62
|
+
two: [null, null],
|
|
63
|
+
three: [null, null, null],
|
|
64
|
+
'wide-narrow': [2, null],
|
|
65
|
+
'narrow-wide': [null, 2],
|
|
66
|
+
};
|
|
67
|
+
const column = (content = '<p></p>', grow = null) => `<astl-column${grow === null ? '' : ` style="flex-grow: ${grow}"`}>${content}</astl-column>`;
|
|
68
|
+
/** The source of a layout; `picture-text` takes the source of its picture. */
|
|
69
|
+
export function layoutHtml(name, picture = '') {
|
|
70
|
+
const columns = name === 'picture-text'
|
|
71
|
+
? column(picture.startsWith('<figure') ? picture : `<p>${picture}</p>`) + column()
|
|
72
|
+
: LAYOUT_COLUMNS[name].map((grow) => column('<p></p>', grow)).join('');
|
|
73
|
+
const shape = name === 'picture-text' ? ' style="align-items: start"' : '';
|
|
74
|
+
return `<astl-columns${shape}>${columns}</astl-columns>`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=style-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-model.js","sourceRoot":"","sources":["../src/style-model.ts"],"names":[],"mappings":"AAMA,8GAA8G;AAC9G,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAa,EAA+B,EAAE,CACvE,IAAI,GAAG,CACL,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAsB,EAAE;IACpD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,EAAE,GAAG,CAAC;QACX,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACE;gBACE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;gBACtC,IAAI;qBACD,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;qBACb,IAAI,EAAE;qBACN,WAAW,EAAE;aACjB;SACF,CAAC;AACR,CAAC,CAAC,CACH,CAAC;AAQJ,iFAAiF;AACjF,MAAM,CAAC,MAAM,aAAa,GAA0B;IAClD,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,8BAA8B,EAAE;IACxD,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,6BAA6B,EAAE;IACzD,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,gBAAgB,EAAE;IAC5C,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,iCAAiC,EAAE;IACrE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,mCAAmC,EAAE;CACpE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AkB,IAAI,EAAE,EAAE,CACjE,eAAe,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,sBAAsB,IAAI,GAAG,IAAI,OAAO,gBAAgB,CAAC;AAE/F,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAC,IAAgB,EAAE,OAAO,GAAG,EAAE;IACvD,MAAM,OAAO,GACX,IAAI,KAAK,cAAc;QACrB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,GAAG,MAAM,EAAE;QAClF,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3E,MAAM,KAAK,GAAG,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3E,OAAO,gBAAgB,KAAK,IAAI,OAAO,iBAAiB,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a placement of a picture, a figure or a component is written, and a new style's name: what the style form and a surface read, outside the
|
|
3
|
+
* kit's first load. Everything a position writes has its logical form in the allow-list, so a page in any direction
|
|
4
|
+
* reads the same; the player's narrow rule keeps `auto` margins and lets the others go.
|
|
5
|
+
*/
|
|
6
|
+
import type { EditorStyleChanges } from '@astl/core';
|
|
7
|
+
/**
|
|
8
|
+
* Where a picture, a figure or a component sits: in the line, floating at either side with text beside it, centred,
|
|
9
|
+
* or filling.
|
|
10
|
+
*/
|
|
11
|
+
export type Placement = 'inline' | 'start' | 'end' | 'center' | 'full';
|
|
12
|
+
export declare const PLACEMENTS: readonly Placement[];
|
|
13
|
+
/** @deprecated Use `Placement`: components are placed the same way. */
|
|
14
|
+
export type PicturePosition = Placement;
|
|
15
|
+
/** @deprecated Use `PLACEMENTS`. */
|
|
16
|
+
export declare const PICTURE_POSITIONS: readonly Placement[];
|
|
17
|
+
/** The position a `style` value says, also written by hand, with physical sides or `margin: 0 auto`. */
|
|
18
|
+
export declare function positionOf(style: string): Placement;
|
|
19
|
+
/**
|
|
20
|
+
* The changes that put an element whose style is `style` at `position`; leaving "full width" lets go of its width. A
|
|
21
|
+
* figure fills the line unless it has a width, so "centred" would not show on one without it (`figure`).
|
|
22
|
+
*/
|
|
23
|
+
export declare function positionChanges(position: Placement, style: string, figure?: boolean): EditorStyleChanges;
|
|
24
|
+
/** The changes that make an element whose style is `style` this wide: a handle and a field write the same. */
|
|
25
|
+
export declare function widthChanges(style: string, percent: number): EditorStyleChanges;
|
|
26
|
+
/**
|
|
27
|
+
* A `style` value in two: what places the element (its position and width) and the rest. A surface that frames an
|
|
28
|
+
* element draws the first on the frame and the rest inside it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function splitPlacement(style: string): {
|
|
31
|
+
readonly placed: string;
|
|
32
|
+
readonly rest: string;
|
|
33
|
+
};
|
|
34
|
+
/** The width a `style` value gives in percent, or null: none, or another unit. */
|
|
35
|
+
export declare function widthPercent(style: string): number | null;
|
|
36
|
+
/** A name for a new style from its label: lowercase letters, digits and dashes, the format's grammar, not taken. */
|
|
37
|
+
export declare function styleNameFrom(label: string, taken: ReadonlySet<string>): string;
|
|
38
|
+
//# sourceMappingURL=style-placing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-placing.d.ts","sourceRoot":"","sources":["../src/style-placing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAIrD;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvE,eAAO,MAAM,UAAU,EAAE,SAAS,SAAS,EAAiD,CAAC;AAE7F,uEAAuE;AACvE,MAAM,MAAM,eAAe,GAAG,SAAS,CAAC;AAExC,oCAAoC;AACpC,eAAO,MAAM,iBAAiB,EAAE,SAAS,SAAS,EAAe,CAAC;AAuBlE,wGAAwG;AACxG,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAYnD;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,UAAQ,GAAG,kBAAkB,CAOtG;AAED,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAM/E;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAMhG;AAED,kFAAkF;AAClF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGzD;AAED,oHAAoH;AACpH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAc/E"}
|