@teipublisher/oddity-language-server 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +48 -2
- package/dist/edit.js +313 -0
- package/dist/edit.js.map +7 -0
- package/dist/index.js +803 -0
- package/dist/index.js.map +7 -0
- package/dist/node.cjs +44962 -0
- package/dist/node.cjs.map +7 -0
- package/package.json +74 -4
- package/schema/README.md +41 -0
- package/schema/docbook/docbook.rng +18457 -0
- package/schema/jats/BITS-embedded-index2.ent.rng +340 -0
- package/schema/jats/BITS-question-answer2.ent.rng +795 -0
- package/schema/jats/JATS-XHTMLtablesetup1-3.ent.rng +614 -0
- package/schema/jats/JATS-ali-namespace1-3.ent.rng +284 -0
- package/schema/jats/JATS-archivearticle1-3-mathml3.rng +1277 -0
- package/schema/jats/JATS-archivecustom-classes1-3.ent.rng +427 -0
- package/schema/jats/JATS-archivecustom-mixes1-3.ent.rng +630 -0
- package/schema/jats/JATS-archivecustom-models1-3.ent.rng +2205 -0
- package/schema/jats/JATS-articlemeta1-3.ent.rng +3138 -0
- package/schema/jats/JATS-backmatter1-3.ent.rng +601 -0
- package/schema/jats/JATS-chars1-3.ent.rng +715 -0
- package/schema/jats/JATS-common-atts1-3.ent.rng +367 -0
- package/schema/jats/JATS-common1-3.ent.rng +6007 -0
- package/schema/jats/JATS-default-classes1-3.ent.rng +1953 -0
- package/schema/jats/JATS-default-mixes1-3.ent.rng +583 -0
- package/schema/jats/JATS-display1-3.ent.rng +1669 -0
- package/schema/jats/JATS-format1-3.ent.rng +1256 -0
- package/schema/jats/JATS-funding1-3.ent.rng +1389 -0
- package/schema/jats/JATS-journalmeta1-3.ent.rng +691 -0
- package/schema/jats/JATS-link1-3.ent.rng +664 -0
- package/schema/jats/JATS-list1-3.ent.rng +747 -0
- package/schema/jats/JATS-math1-3.ent.rng +620 -0
- package/schema/jats/JATS-mathml3-mathmlsetup1-3.ent.rng +459 -0
- package/schema/jats/JATS-nlmcitation1-3.ent.rng +522 -0
- package/schema/jats/JATS-para1-3.ent.rng +780 -0
- package/schema/jats/JATS-phrase1-3.ent.rng +725 -0
- package/schema/jats/JATS-references1-3.ent.rng +1713 -0
- package/schema/jats/JATS-related-object1-3.ent.rng +453 -0
- package/schema/jats/JATS-section1-3.ent.rng +482 -0
- package/schema/jats/mathml3-qname1.mod.rng +61 -0
- package/schema/jats/mathml3.rng +4094 -0
- package/schema/jats/xhtml-inlstyle-1.mod.rng +37 -0
- package/schema/jats/xhtml-table-1.mod.rng +426 -0
- package/schema/odd/teipublisher_odds.rng +12769 -0
- package/schema/tei/tei_all.rng +23212 -0
- package/src/core/association.ts +155 -0
- package/src/core/complete.ts +147 -0
- package/src/core/elements.ts +86 -0
- package/src/core/outline.ts +156 -0
- package/src/core/schema.ts +55 -0
- package/src/core/tags.ts +104 -0
- package/src/core/toml.ts +64 -0
- package/src/core/validate.ts +128 -0
- package/src/core/wellformed.ts +16 -0
- package/src/edit.ts +11 -0
- package/src/index.ts +16 -0
- package/src/node.ts +39 -0
- package/src/server/server.ts +248 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 e-editiones
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# oddity-language-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
RELAX NG validation and schema-aware completion for TEI documents and ODDs, as a
|
|
4
|
+
language server. Used by the ODDity VS Code extension.
|
|
5
|
+
|
|
6
|
+
Completion only suggests elements and attributes that the schema allows at the
|
|
7
|
+
cursor position, and it respects their required order. For example, right after
|
|
8
|
+
`<TEI>` it suggests only `<teiHeader>`. Each suggestion shows the description
|
|
9
|
+
that the ODD provides for that element or attribute.
|
|
10
|
+
|
|
11
|
+
## Schema lookup
|
|
12
|
+
|
|
13
|
+
The language server tries to find the schema associated with a document by checking the following locations in order:
|
|
14
|
+
|
|
15
|
+
1. a local `.rng` named by the document's `<?xml-model?>`
|
|
16
|
+
2. for documents other than ODDs, `[editor] schema` in the nearest `opm.toml`
|
|
17
|
+
3. defaults by vocabulary: `schema/odd/teipublisher_odds.rng` for `.odd` files,
|
|
18
|
+
and for documents recognised as TEI, DocBook or JATS `tei_all`, DocBook 5.2 or
|
|
19
|
+
JATS 1.3 Archiving with MathML 3 (see `schema/README.md` for sources and licences)
|
|
20
|
+
|
|
21
|
+
An `<?xml-model?>` or `[editor] schema` naming one of these by its published URL
|
|
22
|
+
(e.g. the TEI's `tei_all.rng`) uses the bundled copy; other remote schemas are ignored.
|
|
23
|
+
|
|
24
|
+
If no schema can be determined, the language server still supports
|
|
25
|
+
well-formedness checks, an outline and tag renaming.
|
|
26
|
+
|
|
27
|
+
## Layout
|
|
28
|
+
|
|
29
|
+
- `src/core/`: editor-independent code (validation, completion, schema
|
|
30
|
+
association, outline, tag matching), exported from `src/index.ts`.
|
|
31
|
+
`validate.ts`, `complete.ts` and `toml.ts` come from opm studio.
|
|
32
|
+
- `src/server/server.ts`: the language server, independent of its transport.
|
|
33
|
+
- `src/node.ts`: Node entry (`--node-ipc` or `--stdio`), built to `dist/node.cjs`.
|
|
34
|
+
`ODDITY_LS_SCHEMAS` points it at a `schema/` folder for the defaults; clients
|
|
35
|
+
can pass `initializationOptions.defaultSchemas` instead.
|
|
36
|
+
|
|
37
|
+
Custom protocol: request `oddity/schemaFor { uri }` returns the schema in use;
|
|
38
|
+
notification `oddity/schemaChanged { uri, schema }` is sent when it changes.
|
|
39
|
+
|
|
40
|
+
## Development
|
|
41
|
+
|
|
42
|
+
npm install
|
|
43
|
+
npm test # node --test, runs the TypeScript directly
|
|
44
|
+
npm run check # tsc
|
|
45
|
+
npm run build # dist/
|
|
46
|
+
npm run schemas # regenerate schema/ (opm compiles teipublisher_odds.odd from jinks)
|
|
47
|
+
|
|
48
|
+
`npm run schemas` looks for jinks in `$JINKS_DIR`, `../../apps/tei-publisher/jinks`
|
|
49
|
+
or `../jinks`, and falls back to GitHub.
|
package/dist/edit.js
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// src/core/tags.ts
|
|
2
|
+
var SKIP = [["<!--", "-->"], ["<![CDATA[", "]]>"], ["<?", "?>"], ["<!", ">"]];
|
|
3
|
+
function scanTags(text) {
|
|
4
|
+
const tags = [];
|
|
5
|
+
let i = 0;
|
|
6
|
+
while ((i = text.indexOf("<", i)) >= 0) {
|
|
7
|
+
const skip = SKIP.find(([open]) => text.startsWith(open, i));
|
|
8
|
+
if (skip) {
|
|
9
|
+
const end = text.indexOf(skip[1], i + skip[0].length);
|
|
10
|
+
if (end < 0) break;
|
|
11
|
+
i = end + skip[1].length;
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
const closing = text[i + 1] === "/";
|
|
15
|
+
const nameFrom = i + (closing ? 2 : 1);
|
|
16
|
+
const name = text.slice(nameFrom).match(/^[^\s<>/="']*/)[0];
|
|
17
|
+
let j = nameFrom + name.length, quote = "";
|
|
18
|
+
for (; j < text.length; j++) {
|
|
19
|
+
const c = text[j];
|
|
20
|
+
if (quote) {
|
|
21
|
+
if (c === quote) quote = "";
|
|
22
|
+
} else if (c === '"' || c === "'") quote = c;
|
|
23
|
+
else if (c === ">" || c === "<") break;
|
|
24
|
+
}
|
|
25
|
+
const finished = text[j] === ">";
|
|
26
|
+
const to = finished ? j + 1 : j;
|
|
27
|
+
const kind = closing ? "close" : finished && text[j - 1] === "/" ? "empty" : "open";
|
|
28
|
+
tags.push({ kind, name, from: i, nameFrom, nameTo: nameFrom + name.length, to });
|
|
29
|
+
i = finished ? to : Math.max(j, i + 1);
|
|
30
|
+
}
|
|
31
|
+
return tags;
|
|
32
|
+
}
|
|
33
|
+
function pairs(tags) {
|
|
34
|
+
const stack = [];
|
|
35
|
+
const pair = /* @__PURE__ */ new Map();
|
|
36
|
+
tags.forEach((t, i) => {
|
|
37
|
+
if (t.kind === "open") stack.push(i);
|
|
38
|
+
else if (t.kind === "close") {
|
|
39
|
+
const k = stack.map((s) => tags[s].name).lastIndexOf(t.name);
|
|
40
|
+
if (k < 0) return;
|
|
41
|
+
pair.set(stack[k], i);
|
|
42
|
+
pair.set(i, stack[k]);
|
|
43
|
+
stack.length = k;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
return pair;
|
|
47
|
+
}
|
|
48
|
+
function matchingTags(text, offset) {
|
|
49
|
+
const tags = scanTags(text);
|
|
50
|
+
const at = tags.findIndex((t) => t.kind !== "empty" && t.nameFrom <= offset && offset <= t.nameTo);
|
|
51
|
+
if (at < 0) return null;
|
|
52
|
+
const other = pairs(tags).get(at);
|
|
53
|
+
if (other === void 0) return null;
|
|
54
|
+
return [at, other].sort((a, b) => a - b).map((i) => ({ from: tags[i].nameFrom, to: tags[i].nameTo }));
|
|
55
|
+
}
|
|
56
|
+
function openElementAt(text, offset) {
|
|
57
|
+
const tags = scanTags(text.slice(0, offset));
|
|
58
|
+
const pair = pairs(tags);
|
|
59
|
+
for (let i = tags.length - 1; i >= 0; i--) {
|
|
60
|
+
if (tags[i].kind === "open" && !pair.has(i) && tags[i].to <= offset && text[tags[i].to - 1] === ">") return tags[i].name;
|
|
61
|
+
}
|
|
62
|
+
return void 0;
|
|
63
|
+
}
|
|
64
|
+
function closeTagAt(text, offset) {
|
|
65
|
+
const before = text.slice(0, offset);
|
|
66
|
+
if (before.endsWith("</")) {
|
|
67
|
+
const name = openElementAt(text, offset - 2);
|
|
68
|
+
if (!name) return void 0;
|
|
69
|
+
return text.slice(offset).startsWith(">") ? name : `${name}>`;
|
|
70
|
+
}
|
|
71
|
+
if (!before.endsWith(">") || before.endsWith("/>")) return void 0;
|
|
72
|
+
const tags = scanTags(before);
|
|
73
|
+
const last = tags[tags.length - 1];
|
|
74
|
+
if (!last || last.kind !== "open" || last.to !== offset || !last.name) return void 0;
|
|
75
|
+
const end = `</${last.name}>`;
|
|
76
|
+
if (text.slice(offset).startsWith(end)) return void 0;
|
|
77
|
+
return end;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/core/toml.ts
|
|
81
|
+
import { parse } from "smol-toml";
|
|
82
|
+
var q = (s) => JSON.stringify(s);
|
|
83
|
+
var sectionEnd = (lines, head) => {
|
|
84
|
+
for (let i = head + 1; i < lines.length; i++) if (/^\s*\[/.test(lines[i])) return i;
|
|
85
|
+
return lines.length;
|
|
86
|
+
};
|
|
87
|
+
function setToml(text, section, key, value) {
|
|
88
|
+
const line = `${key} = ${q(value)}`, lines = text ? text.split("\n") : [];
|
|
89
|
+
const head = lines.findIndex((l) => l.trim() === `[${section}]`);
|
|
90
|
+
if (head < 0) return (text && !text.endsWith("\n") ? text + "\n" : text) + (text ? "\n" : "") + `[${section}]
|
|
91
|
+
${line}
|
|
92
|
+
`;
|
|
93
|
+
const end = sectionEnd(lines, head), re = new RegExp(`^\\s*${key}\\s*=`);
|
|
94
|
+
for (let i = head + 1; i < end; i++) if (re.test(lines[i])) {
|
|
95
|
+
lines[i] = line;
|
|
96
|
+
return lines.join("\n");
|
|
97
|
+
}
|
|
98
|
+
lines.splice(head + 1, 0, line);
|
|
99
|
+
return lines.join("\n");
|
|
100
|
+
}
|
|
101
|
+
function unsetToml(text, section, key) {
|
|
102
|
+
const lines = text.split("\n"), head = lines.findIndex((l) => l.trim() === `[${section}]`);
|
|
103
|
+
if (head < 0) return text;
|
|
104
|
+
const end = sectionEnd(lines, head), re = new RegExp(`^\\s*${key}\\s*=`);
|
|
105
|
+
for (let i = head + 1; i < end; i++) if (re.test(lines[i])) {
|
|
106
|
+
lines.splice(i, 1);
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
return lines.join("\n");
|
|
110
|
+
}
|
|
111
|
+
function readToml(text) {
|
|
112
|
+
let doc;
|
|
113
|
+
try {
|
|
114
|
+
doc = parse(text);
|
|
115
|
+
} catch {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
const cfg = {};
|
|
119
|
+
const walk = (table, path) => {
|
|
120
|
+
for (const [key, v] of Object.entries(table)) {
|
|
121
|
+
if (typeof v === "string" || Array.isArray(v) && v.length && v.every((x) => typeof x === "string")) {
|
|
122
|
+
(cfg[path.join(".")] ||= {})[key] = v;
|
|
123
|
+
} else if (Array.isArray(v) && !v.length) {
|
|
124
|
+
(cfg[path.join(".")] ||= {})[key] = [];
|
|
125
|
+
} else if (v && typeof v === "object" && !Array.isArray(v) && !(v instanceof Date)) {
|
|
126
|
+
walk(v, [...path, key]);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
walk(doc, []);
|
|
131
|
+
return cfg;
|
|
132
|
+
}
|
|
133
|
+
var tomlString = (cfg, section, key) => {
|
|
134
|
+
const v = cfg[section]?.[key];
|
|
135
|
+
return typeof v === "string" ? v : "";
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/core/association.ts
|
|
139
|
+
var RNG_NS = "http://relaxng.org/ns/structure/1.0";
|
|
140
|
+
var isOdd = (url) => /\.odd$/i.test(new URL(url).pathname);
|
|
141
|
+
var DEFAULT_SCHEMA_FILES = {
|
|
142
|
+
odd: "odd/teipublisher_odds.rng",
|
|
143
|
+
tei: "tei/tei_all.rng",
|
|
144
|
+
docbook: "docbook/docbook.rng",
|
|
145
|
+
jats: "jats/JATS-archivearticle1-3-mathml3.rng"
|
|
146
|
+
};
|
|
147
|
+
var PUBLIC_SCHEMA_URLS = {
|
|
148
|
+
tei: "https://tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng",
|
|
149
|
+
docbook: "https://cdn.docbook.org/schema/5.2/rng/docbook.rng",
|
|
150
|
+
jats: "https://jats.nlm.nih.gov/archiving/1.3/rng/JATS-archivearticle1-3-mathml3.rng"
|
|
151
|
+
};
|
|
152
|
+
function publicSchema(url) {
|
|
153
|
+
if (/^https?:\/\/(www\.)?tei-c\.org\/.*\/tei_all\.rng$/i.test(url)) return "tei";
|
|
154
|
+
if (/^https?:\/\/([\w-]+\.)?docbook\.org\/.*\/docbook\.rng$/i.test(url)) return "docbook";
|
|
155
|
+
if (/^https?:\/\/jats\.nlm\.nih\.gov\/.*\.rng$/i.test(url)) return "jats";
|
|
156
|
+
return void 0;
|
|
157
|
+
}
|
|
158
|
+
function vocabulary(text) {
|
|
159
|
+
const head = text.slice(0, 5e3);
|
|
160
|
+
if (head.includes("http://www.tei-c.org/ns/1.0") || /<(TEI|teiCorpus)[\s>]/.test(head)) return "tei";
|
|
161
|
+
if (head.includes("http://docbook.org/ns/docbook")) return "docbook";
|
|
162
|
+
if (/<!DOCTYPE\s+article\s+PUBLIC\s+"-\/\/NLM\/\/DTD/.test(head)) return "jats";
|
|
163
|
+
const article = head.match(/<article(?=[\s>])[^>]*>/)?.[0];
|
|
164
|
+
if (article && !/\sxmlns\s*=/.test(article) && (/\s(dtd-version|article-type)\s*=/.test(article) || /<front[\s>]/.test(head))) return "jats";
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
function xmlModels(text) {
|
|
168
|
+
const out = [];
|
|
169
|
+
for (const m of text.slice(0, 5e3).matchAll(/<\?xml-model\s([^?]*)\?>/g)) {
|
|
170
|
+
const pseudo = (name) => m[1].match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']*)["']`))?.[1];
|
|
171
|
+
out.push({ from: m.index, to: m.index + m[0].length, href: pseudo("href"), schematypens: pseudo("schematypens"), raw: m[0] });
|
|
172
|
+
}
|
|
173
|
+
return out;
|
|
174
|
+
}
|
|
175
|
+
var isRngModel = (pi) => pi.schematypens === RNG_NS || !pi.schematypens && !!pi.href && /\.rng$/i.test(pi.href) && !/schematron/i.test(pi.raw);
|
|
176
|
+
function projectRoot(url, files, stops = []) {
|
|
177
|
+
let dir = new URL("./", url);
|
|
178
|
+
for (; ; ) {
|
|
179
|
+
if (files.exists(new URL("opm.toml", dir).href)) return dir.href;
|
|
180
|
+
const parent = new URL("../", dir);
|
|
181
|
+
if (parent.href === dir.href || stops.some((s) => sameDir(s, dir.href))) return void 0;
|
|
182
|
+
dir = parent;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
var sameDir = (a, b) => a.replace(/\/?$/, "/") === b.replace(/\/?$/, "/");
|
|
186
|
+
function schemaFor(url, text, files, defaults, stops = []) {
|
|
187
|
+
for (const pi of xmlModels(text)) {
|
|
188
|
+
if (!isRngModel(pi) || !pi.href) continue;
|
|
189
|
+
if (/^(https?|ftp):/i.test(pi.href)) {
|
|
190
|
+
const bundled = defaults[publicSchema(pi.href) ?? ""];
|
|
191
|
+
if (bundled) return { url: bundled, via: "xml-model" };
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
const target = new URL(pi.href, url).href;
|
|
195
|
+
if (files.exists(target)) return { url: target, via: "xml-model" };
|
|
196
|
+
}
|
|
197
|
+
const odd = isOdd(url);
|
|
198
|
+
if (!odd) {
|
|
199
|
+
const root = projectRoot(url, files, stops);
|
|
200
|
+
const toml = root && files.read(new URL("opm.toml", root).href);
|
|
201
|
+
const configured = toml ? tomlString(readToml(toml), "editor", "schema") : "";
|
|
202
|
+
if (configured && /\.rng$/i.test(configured)) {
|
|
203
|
+
const bundled = defaults[publicSchema(configured) ?? ""];
|
|
204
|
+
if (bundled) return { url: bundled, via: "project" };
|
|
205
|
+
const target = new URL(configured, root).href;
|
|
206
|
+
if (files.exists(target)) return { url: target, via: "project" };
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const fallback = defaults[odd ? "odd" : vocabulary(text)];
|
|
210
|
+
return fallback ? { url: fallback, via: "default" } : null;
|
|
211
|
+
}
|
|
212
|
+
function relativeHref(from, to) {
|
|
213
|
+
const a = new URL(from), b = new URL(to);
|
|
214
|
+
if (a.protocol !== b.protocol || a.host !== b.host) return to;
|
|
215
|
+
const dir = a.pathname.split("/").slice(0, -1), target = b.pathname.split("/");
|
|
216
|
+
let i = 0;
|
|
217
|
+
while (i < dir.length && i < target.length - 1 && dir[i] === target[i]) i++;
|
|
218
|
+
return [...Array(dir.length - i).fill(".."), ...target.slice(i)].join("/");
|
|
219
|
+
}
|
|
220
|
+
function xmlModelEdits(text, href) {
|
|
221
|
+
const nl = text.includes("\r\n") ? "\r\n" : "\n";
|
|
222
|
+
const models = xmlModels(text).filter(isRngModel);
|
|
223
|
+
const pi = href && `<?xml-model href="${href.replace(/&/g, "&").replace(/"/g, """)}" type="application/xml" schematypens="${RNG_NS}"?>`;
|
|
224
|
+
const removal = (m) => {
|
|
225
|
+
const after = text.slice(m.to).match(/^\r?\n/)?.[0].length ?? 0;
|
|
226
|
+
return { from: m.from, to: m.to + after, insert: "" };
|
|
227
|
+
};
|
|
228
|
+
if (!pi) return models.map(removal);
|
|
229
|
+
if (models.length) return [{ from: models[0].from, to: models[0].to, insert: pi }, ...models.slice(1).map(removal)];
|
|
230
|
+
const decl = text.match(/^?<\?xml\s[^?]*\?>/);
|
|
231
|
+
if (decl) return [{ from: decl[0].length, to: decl[0].length, insert: nl + pi }];
|
|
232
|
+
const bom = text.startsWith("\uFEFF") ? 1 : 0;
|
|
233
|
+
return [{ from: bom, to: bom, insert: pi + nl }];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/core/elements.ts
|
|
237
|
+
function elements(text) {
|
|
238
|
+
const tags = scanTags(text), pair = pairs(tags), out = [];
|
|
239
|
+
tags.forEach((t, i) => {
|
|
240
|
+
if (t.kind === "empty") out.push({ name: t.name, from: t.from, to: t.to, open: t });
|
|
241
|
+
else if (t.kind === "open" && pair.has(i)) {
|
|
242
|
+
const close = tags[pair.get(i)];
|
|
243
|
+
out.push({ name: t.name, from: t.from, to: close.to, open: t, close });
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return out;
|
|
247
|
+
}
|
|
248
|
+
function elementsAround(text, from, to = from) {
|
|
249
|
+
return elements(text).filter((e) => e.from <= from && e.to >= to).sort((a, b) => a.to - a.from - (b.to - b.from));
|
|
250
|
+
}
|
|
251
|
+
function elementAround(text, from, to, outer) {
|
|
252
|
+
return elementsAround(text, from, to).find((e) => !outer || from === to || e.from < from || e.to > to);
|
|
253
|
+
}
|
|
254
|
+
function selectElement(text, from, to) {
|
|
255
|
+
const e = elementAround(text, from, to, true);
|
|
256
|
+
return e ? { changes: [], selection: { anchor: e.from, head: e.to } } : null;
|
|
257
|
+
}
|
|
258
|
+
function removeElementTags(text, from, to) {
|
|
259
|
+
const e = elementAround(text, from, to, false);
|
|
260
|
+
if (!e) return null;
|
|
261
|
+
const { open, close } = e;
|
|
262
|
+
if (!close) return { changes: [{ from: open.from, to: open.to, insert: "" }], selection: { anchor: open.from, head: open.from } };
|
|
263
|
+
const length = open.to - open.from;
|
|
264
|
+
return {
|
|
265
|
+
changes: [{ from: open.from, to: open.to, insert: "" }, { from: close.from, to: close.to, insert: "" }],
|
|
266
|
+
selection: { anchor: open.from, head: close.from - length }
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function splitElement(text, pos) {
|
|
270
|
+
const e = elementsAround(text, pos).find((x) => x.close && pos >= x.open.to && pos <= x.close.from);
|
|
271
|
+
if (!e) return null;
|
|
272
|
+
const start = text.slice(e.open.from, e.open.to).replace(/\s(xml:)?id\s*=\s*("[^"]*"|'[^']*')/g, "");
|
|
273
|
+
const insert = `</${e.name}>${start}`;
|
|
274
|
+
return { changes: [{ from: pos, to: pos, insert }], selection: { anchor: pos + insert.length, head: pos + insert.length } };
|
|
275
|
+
}
|
|
276
|
+
function surroundWithElement(from, to, tag) {
|
|
277
|
+
const start = `<${tag.trim()}>`, end = `</${tag.trim().split(/\s/)[0]}>`;
|
|
278
|
+
return {
|
|
279
|
+
changes: [{ from, to: from, insert: start }, { from: to, to, insert: end }],
|
|
280
|
+
selection: { anchor: from + start.length, head: to + start.length }
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
DEFAULT_SCHEMA_FILES,
|
|
285
|
+
PUBLIC_SCHEMA_URLS,
|
|
286
|
+
RNG_NS,
|
|
287
|
+
closeTagAt,
|
|
288
|
+
elementAround,
|
|
289
|
+
elements,
|
|
290
|
+
elementsAround,
|
|
291
|
+
isOdd,
|
|
292
|
+
isRngModel,
|
|
293
|
+
matchingTags,
|
|
294
|
+
openElementAt,
|
|
295
|
+
pairs,
|
|
296
|
+
projectRoot,
|
|
297
|
+
publicSchema,
|
|
298
|
+
readToml,
|
|
299
|
+
relativeHref,
|
|
300
|
+
removeElementTags,
|
|
301
|
+
scanTags,
|
|
302
|
+
schemaFor,
|
|
303
|
+
selectElement,
|
|
304
|
+
setToml,
|
|
305
|
+
splitElement,
|
|
306
|
+
surroundWithElement,
|
|
307
|
+
tomlString,
|
|
308
|
+
unsetToml,
|
|
309
|
+
vocabulary,
|
|
310
|
+
xmlModelEdits,
|
|
311
|
+
xmlModels
|
|
312
|
+
};
|
|
313
|
+
//# sourceMappingURL=edit.js.map
|
package/dist/edit.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/core/tags.ts", "../src/core/toml.ts", "../src/core/association.ts", "../src/core/elements.ts"],
|
|
4
|
+
"sourcesContent": ["// \u2500\u2500 start and end tags: matching pairs and closing tags \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// A light scanner rather than a parser: it has to work on half-typed documents.\n\nexport interface Tag {\n kind: 'open' | 'close' | 'empty';\n name: string;\n /** Offset of the '<'. */\n from: number;\n nameFrom: number;\n nameTo: number;\n /** Offset just after the '>', or the end of the text for an unfinished tag. */\n to: number;\n}\n\nconst SKIP: [string, string][] = [['<!--', '-->'], ['<![CDATA[', ']]>'], ['<?', '?>'], ['<!', '>']];\n\n/** Every tag in text, skipping comments, CDATA, processing instructions and declarations. */\nexport function scanTags(text: string): Tag[] {\n const tags: Tag[] = [];\n let i = 0;\n while ((i = text.indexOf('<', i)) >= 0) {\n const skip = SKIP.find(([open]) => text.startsWith(open, i));\n if (skip) {\n const end = text.indexOf(skip[1], i + skip[0].length);\n if (end < 0) break;\n i = end + skip[1].length;\n continue;\n }\n const closing = text[i + 1] === '/';\n const nameFrom = i + (closing ? 2 : 1);\n const name = text.slice(nameFrom).match(/^[^\\s<>/=\"']*/)![0];\n // the end of the tag: the first '>' outside a quoted value\n let j = nameFrom + name.length, quote = '';\n for (; j < text.length; j++) {\n const c = text[j];\n if (quote) { if (c === quote) quote = ''; } else if (c === '\"' || c === \"'\") quote = c; else if (c === '>' || c === '<') break;\n }\n const finished = text[j] === '>';\n const to = finished ? j + 1 : j;\n const kind = closing ? 'close' : finished && text[j - 1] === '/' ? 'empty' : 'open';\n tags.push({ kind, name, from: i, nameFrom, nameTo: nameFrom + name.length, to });\n i = finished ? to : Math.max(j, i + 1);\n }\n return tags;\n}\n\n/** Pairs of open and close tags, by index into tags, matched like a parser would. */\nexport function pairs(tags: Tag[]): Map<number, number> {\n const stack: number[] = [];\n const pair = new Map<number, number>();\n tags.forEach((t, i) => {\n if (t.kind === 'open') stack.push(i);\n else if (t.kind === 'close') {\n // close the nearest open tag of the same name; anything above it was left open\n const k = stack.map(s => tags[s].name).lastIndexOf(t.name);\n if (k < 0) return;\n pair.set(stack[k], i);\n pair.set(i, stack[k]);\n stack.length = k;\n }\n });\n return pair;\n}\n\n/** The name ranges of the tag whose name holds offset and its partner, for renaming both at once. */\nexport function matchingTags(text: string, offset: number): { from: number; to: number }[] | null {\n const tags = scanTags(text);\n const at = tags.findIndex(t => t.kind !== 'empty' && t.nameFrom <= offset && offset <= t.nameTo);\n if (at < 0) return null;\n const other = pairs(tags).get(at);\n if (other === undefined) return null;\n return [at, other].sort((a, b) => a - b).map(i => ({ from: tags[i].nameFrom, to: tags[i].nameTo }));\n}\n\n/** The innermost element still open at offset. */\nexport function openElementAt(text: string, offset: number): string | undefined {\n const tags = scanTags(text.slice(0, offset));\n const pair = pairs(tags);\n for (let i = tags.length - 1; i >= 0; i--) {\n if (tags[i].kind === 'open' && !pair.has(i) && tags[i].to <= offset && text[tags[i].to - 1] === '>') return tags[i].name;\n }\n return undefined;\n}\n\n/**\n * What to insert at offset, just after the user typed a character, to close a tag:\n * after the '>' of a start tag its end tag, after '</' the name of the open element.\n */\nexport function closeTagAt(text: string, offset: number): string | undefined {\n const before = text.slice(0, offset);\n if (before.endsWith('</')) {\n const name = openElementAt(text, offset - 2);\n if (!name) return undefined;\n return text.slice(offset).startsWith('>') ? name : `${name}>`;\n }\n if (!before.endsWith('>') || before.endsWith('/>')) return undefined;\n const tags = scanTags(before);\n const last = tags[tags.length - 1];\n if (!last || last.kind !== 'open' || last.to !== offset || !last.name) return undefined;\n const end = `</${last.name}>`;\n // already closed right after the cursor, e.g. when a '>' is retyped\n if (text.slice(offset).startsWith(end)) return undefined;\n return end;\n}\n", "// \u2500\u2500 opm.toml: write the keys the page controls, read the few it needs \u2500\u2500\u2500\u2500\u2500\n// Reading parses the whole file with smol-toml (TOML 1.0). Writing does not\n// serialize: the edits leave every other line of the file, comments included, as it is.\nimport { parse } from 'smol-toml';\n\nexport type TomlValue = string | string[];\nexport type TomlConfig = Record<string, Record<string, TomlValue>>;\n\nconst q = (s: string) => JSON.stringify(s);\nconst sectionEnd = (lines: string[], head: number) => {\n for (let i = head + 1; i < lines.length; i++) if (/^\\s*\\[/.test(lines[i])) return i;\n return lines.length;\n};\n\n/** Set section.key = value in place, keeping everything else in the file as it is. */\nexport function setToml(text: string, section: string, key: string, value: string): string {\n const line = `${key} = ${q(value)}`, lines = text ? text.split('\\n') : [];\n const head = lines.findIndex(l => l.trim() === `[${section}]`);\n if (head < 0) return (text && !text.endsWith('\\n') ? text + '\\n' : text) + (text ? '\\n' : '') + `[${section}]\\n${line}\\n`;\n const end = sectionEnd(lines, head), re = new RegExp(`^\\\\s*${key}\\\\s*=`);\n for (let i = head + 1; i < end; i++) if (re.test(lines[i])) { lines[i] = line; return lines.join('\\n'); }\n lines.splice(head + 1, 0, line);\n return lines.join('\\n');\n}\n\n/** Drop section.key, leaving the rest of the file as it is. */\nexport function unsetToml(text: string, section: string, key: string): string {\n const lines = text.split('\\n'), head = lines.findIndex(l => l.trim() === `[${section}]`);\n if (head < 0) return text;\n const end = sectionEnd(lines, head), re = new RegExp(`^\\\\s*${key}\\\\s*=`);\n for (let i = head + 1; i < end; i++) if (re.test(lines[i])) { lines.splice(i, 1); break; }\n return lines.join('\\n');\n}\n\n/**\n * The string and string-array values of a TOML file, by table: `[transform.web] template = \u2026`,\n * `[transform] web.template = \u2026` and `transform.web.template = \u2026` all end up under\n * cfg['transform.web'].template. Other values and arrays of tables are left out.\n * A file that is not valid TOML gives no values, as opm would not run with it either.\n */\nexport function readToml(text: string): TomlConfig {\n let doc: Record<string, unknown>;\n try { doc = parse(text); } catch { return {}; }\n const cfg: TomlConfig = {};\n const walk = (table: Record<string, unknown>, path: string[]) => {\n for (const [key, v] of Object.entries(table)) {\n if (typeof v === 'string' || (Array.isArray(v) && v.length && v.every(x => typeof x === 'string'))) {\n (cfg[path.join('.')] ||= {})[key] = v as TomlValue;\n } else if (Array.isArray(v) && !v.length) {\n (cfg[path.join('.')] ||= {})[key] = [];\n } else if (v && typeof v === 'object' && !Array.isArray(v) && !(v instanceof Date)) {\n walk(v as Record<string, unknown>, [...path, key]);\n }\n }\n };\n walk(doc, []);\n return cfg;\n}\n\n/** A string value from the config, or '' when it is missing or not a string. */\nexport const tomlString = (cfg: TomlConfig, section: string, key: string): string => {\n const v = cfg[section]?.[key];\n return typeof v === 'string' ? v : '';\n};\n", "// \u2500\u2500 which RELAX NG schema an XML file gets \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// The same order as opm studio (src/ui/xmlSchema.ts there):\n// 1. a local RNG named by the document's <?xml-model?>\n// 2. for documents other than ODDs, [editor] schema in the nearest opm.toml\n// 3. a default by vocabulary: TEI Publisher's ODD schema for ODDs, tei_all for TEI,\n// DocBook 5.2 and JATS 1.3 Archiving\n// Everything is a URL, so relative paths resolve the same way on every platform.\nimport { readToml, tomlString } from './toml.ts';\n\nexport const RNG_NS = 'http://relaxng.org/ns/structure/1.0';\n\n/** What association needs to know about files: synchronous, as the files are small or only checked. */\nexport interface Files {\n exists(url: string): boolean;\n read(url: string): string | undefined;\n}\n\n/** Default schema URL by vocabulary ('odd', 'tei', \u2026). */\nexport type Defaults = Record<string, string | undefined>;\n\nexport interface SchemaChoice {\n /** URL of the main RNG. */\n url: string;\n /** Where the choice came from. */\n via: 'xml-model' | 'project' | 'default';\n}\n\nexport const isOdd = (url: string) => /\\.odd$/i.test(new URL(url).pathname);\n\n/** The main file of each default schema, relative to the schema folder shipped with the package. */\nexport const DEFAULT_SCHEMA_FILES: Record<string, string> = {\n odd: 'odd/teipublisher_odds.rng',\n tei: 'tei/tei_all.rng',\n docbook: 'docbook/docbook.rng',\n jats: 'jats/JATS-archivearticle1-3-mathml3.rng',\n};\n\n/** Where each default schema is published; documents often name these in their <?xml-model?>. */\nexport const PUBLIC_SCHEMA_URLS: Record<string, string> = {\n tei: 'https://tei-c.org/release/xml/tei/custom/schema/relaxng/tei_all.rng',\n docbook: 'https://cdn.docbook.org/schema/5.2/rng/docbook.rng',\n jats: 'https://jats.nlm.nih.gov/archiving/1.3/rng/JATS-archivearticle1-3-mathml3.rng',\n};\n\n/**\n * The default schema a published schema URL stands for, so that the bundled copy is used\n * instead of fetching it. Any JATS tag set maps to Archiving, the loosest of them.\n */\nexport function publicSchema(url: string): string | undefined {\n if (/^https?:\\/\\/(www\\.)?tei-c\\.org\\/.*\\/tei_all\\.rng$/i.test(url)) return 'tei';\n if (/^https?:\\/\\/([\\w-]+\\.)?docbook\\.org\\/.*\\/docbook\\.rng$/i.test(url)) return 'docbook';\n if (/^https?:\\/\\/jats\\.nlm\\.nih\\.gov\\/.*\\.rng$/i.test(url)) return 'jats';\n return undefined;\n}\n\n/** The vocabulary of a document by namespace, root element or doctype; '' for none we know. */\nexport function vocabulary(text: string): string {\n const head = text.slice(0, 5000);\n if (head.includes('http://www.tei-c.org/ns/1.0') || /<(TEI|teiCorpus)[\\s>]/.test(head)) return 'tei';\n if (head.includes('http://docbook.org/ns/docbook')) return 'docbook';\n // JATS has no namespace: its doctype, or an <article> without one (DocBook's has its own)\n // that says it is JATS by @dtd-version, @article-type or its <front>\n if (/<!DOCTYPE\\s+article\\s+PUBLIC\\s+\"-\\/\\/NLM\\/\\/DTD/.test(head)) return 'jats';\n const article = head.match(/<article(?=[\\s>])[^>]*>/)?.[0];\n if (article && !/\\sxmlns\\s*=/.test(article) && (/\\s(dtd-version|article-type)\\s*=/.test(article) || /<front[\\s>]/.test(head))) return 'jats';\n return '';\n}\n\n/** The <?xml-model?> processing instructions in the head of a document, with their pseudo-attributes. */\nexport function xmlModels(text: string): { from: number; to: number; href?: string; schematypens?: string; raw: string }[] {\n const out = [];\n for (const m of text.slice(0, 5000).matchAll(/<\\?xml-model\\s([^?]*)\\?>/g)) {\n const pseudo = (name: string) => m[1].match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*[\"']([^\"']*)[\"']`))?.[1];\n out.push({ from: m.index!, to: m.index! + m[0].length, href: pseudo('href'), schematypens: pseudo('schematypens'), raw: m[0] });\n }\n return out;\n}\n\n/** True for an xml-model PI that points at a RELAX NG schema (not Schematron). */\nexport const isRngModel = (pi: { href?: string; schematypens?: string; raw: string }) =>\n pi.schematypens === RNG_NS || (!pi.schematypens && !!pi.href && /\\.rng$/i.test(pi.href) && !/schematron/i.test(pi.raw));\n\n/** URL of the folder (ending in '/') holding the nearest opm.toml above url, stopping at any of stops. */\nexport function projectRoot(url: string, files: Files, stops: string[] = []): string | undefined {\n let dir = new URL('./', url);\n for (;;) {\n if (files.exists(new URL('opm.toml', dir).href)) return dir.href;\n const parent = new URL('../', dir);\n if (parent.href === dir.href || stops.some(s => sameDir(s, dir.href))) return undefined;\n dir = parent;\n }\n}\n\nconst sameDir = (a: string, b: string) => a.replace(/\\/?$/, '/') === b.replace(/\\/?$/, '/');\n\n/** The schema of the document at url with text, or null when it has none. */\nexport function schemaFor(url: string, text: string, files: Files, defaults: Defaults, stops: string[] = []): SchemaChoice | null {\n for (const pi of xmlModels(text)) {\n if (!isRngModel(pi) || !pi.href) continue;\n // a published default schema is used from the bundled copy; other remote ones are left alone\n if (/^(https?|ftp):/i.test(pi.href)) {\n const bundled = defaults[publicSchema(pi.href) ?? ''];\n if (bundled) return { url: bundled, via: 'xml-model' };\n continue;\n }\n const target = new URL(pi.href, url).href;\n if (files.exists(target)) return { url: target, via: 'xml-model' };\n }\n const odd = isOdd(url);\n if (!odd) {\n const root = projectRoot(url, files, stops);\n const toml = root && files.read(new URL('opm.toml', root).href);\n const configured = toml ? tomlString(readToml(toml), 'editor', 'schema') : '';\n if (configured && /\\.rng$/i.test(configured)) {\n const bundled = defaults[publicSchema(configured) ?? ''];\n if (bundled) return { url: bundled, via: 'project' };\n const target = new URL(configured, root).href;\n if (files.exists(target)) return { url: target, via: 'project' };\n }\n }\n const fallback = defaults[odd ? 'odd' : vocabulary(text)];\n return fallback ? { url: fallback, via: 'default' } : null;\n}\n\n/** A relative href from the document at `from` to `to`, or `to` itself when they share no root. */\nexport function relativeHref(from: string, to: string): string {\n const a = new URL(from), b = new URL(to);\n if (a.protocol !== b.protocol || a.host !== b.host) return to;\n const dir = a.pathname.split('/').slice(0, -1), target = b.pathname.split('/');\n let i = 0;\n while (i < dir.length && i < target.length - 1 && dir[i] === target[i]) i++;\n return [...Array(dir.length - i).fill('..'), ...target.slice(i)].join('/');\n}\n\nexport interface TextEdit { from: number; to: number; insert: string }\n\n/**\n * The edit that makes text associate with the RNG at href: it replaces the first RELAX NG\n * xml-model PI, or adds one after the XML declaration. With href null it removes them all.\n */\nexport function xmlModelEdits(text: string, href: string | null): TextEdit[] {\n const nl = text.includes('\\r\\n') ? '\\r\\n' : '\\n';\n const models = xmlModels(text).filter(isRngModel);\n const pi = href && `<?xml-model href=\"${href.replace(/&/g, '&').replace(/\"/g, '"')}\" type=\"application/xml\" schematypens=\"${RNG_NS}\"?>`;\n const removal = (m: { from: number; to: number }): TextEdit => {\n const after = text.slice(m.to).match(/^\\r?\\n/)?.[0].length ?? 0;\n return { from: m.from, to: m.to + after, insert: '' };\n };\n if (!pi) return models.map(removal);\n if (models.length) return [{ from: models[0].from, to: models[0].to, insert: pi }, ...models.slice(1).map(removal)];\n const decl = text.match(/^\uFEFF?<\\?xml\\s[^?]*\\?>/);\n if (decl) return [{ from: decl[0].length, to: decl[0].length, insert: nl + pi }];\n const bom = text.startsWith('\uFEFF') ? 1 : 0;\n return [{ from: bom, to: bom, insert: pi + nl }];\n}\n", "// \u2500\u2500 element editing: select, remove tags, split, surround \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// The commands of opm studio's src/ui/xmlCommands.ts, on plain text: each takes\n// the text and one selection and returns the changes plus the selection after them.\nimport { pairs, scanTags, type Tag } from './tags.ts';\nimport type { TextEdit } from './association.ts';\n\nexport interface Element {\n name: string;\n from: number;\n to: number;\n open: Tag;\n /** Missing for a self-closing element. */\n close?: Tag;\n}\n\nexport interface Selection { anchor: number; head: number }\n\n/** The result of a command for one selection: changes and the selection after them (counting only these changes). */\nexport interface ElementEdit { changes: TextEdit[]; selection: Selection }\n\n/** Every complete element in text, in document order of their start tags. */\nexport function elements(text: string): Element[] {\n const tags = scanTags(text), pair = pairs(tags), out: Element[] = [];\n tags.forEach((t, i) => {\n if (t.kind === 'empty') out.push({ name: t.name, from: t.from, to: t.to, open: t });\n else if (t.kind === 'open' && pair.has(i)) {\n const close = tags[pair.get(i)!];\n out.push({ name: t.name, from: t.from, to: close.to, open: t, close });\n }\n });\n return out;\n}\n\n/** The elements holding from..to, innermost first. */\nexport function elementsAround(text: string, from: number, to = from): Element[] {\n return elements(text).filter(e => e.from <= from && e.to >= to).sort((a, b) => (a.to - a.from) - (b.to - b.from));\n}\n\n/**\n * The element around a range. With `outer`, one that is larger than the range,\n * so that selecting the element again moves on to its parent.\n */\nexport function elementAround(text: string, from: number, to: number, outer: boolean): Element | undefined {\n return elementsAround(text, from, to).find(e => !outer || from === to || e.from < from || e.to > to);\n}\n\n/** Select the element around the selection; again for its parent. */\nexport function selectElement(text: string, from: number, to: number): ElementEdit | null {\n const e = elementAround(text, from, to, true);\n return e ? { changes: [], selection: { anchor: e.from, head: e.to } } : null;\n}\n\n/** Remove the tags of the element around the selection, keeping its content selected. */\nexport function removeElementTags(text: string, from: number, to: number): ElementEdit | null {\n const e = elementAround(text, from, to, false);\n if (!e) return null;\n const { open, close } = e;\n if (!close) return { changes: [{ from: open.from, to: open.to, insert: '' }], selection: { anchor: open.from, head: open.from } };\n const length = open.to - open.from;\n return {\n changes: [{ from: open.from, to: open.to, insert: '' }, { from: close.from, to: close.to, insert: '' }],\n selection: { anchor: open.from, head: close.from - length },\n };\n}\n\n/**\n * Split the element around the cursor in two at the cursor: its end tag, then its\n * start tag again, with the same attributes but for an id, which has to stay unique.\n */\nexport function splitElement(text: string, pos: number): ElementEdit | null {\n // the innermost element whose content holds the cursor, not one whose tag does\n const e = elementsAround(text, pos).find(x => x.close && pos >= x.open.to && pos <= x.close.from);\n if (!e) return null;\n const start = text.slice(e.open.from, e.open.to).replace(/\\s(xml:)?id\\s*=\\s*(\"[^\"]*\"|'[^']*')/g, '');\n const insert = `</${e.name}>${start}`;\n return { changes: [{ from: pos, to: pos, insert }], selection: { anchor: pos + insert.length, head: pos + insert.length } };\n}\n\n/** Wrap from..to in an element; `tag` is its name, optionally followed by attributes. The text stays selected. */\nexport function surroundWithElement(from: number, to: number, tag: string): ElementEdit {\n const start = `<${tag.trim()}>`, end = `</${tag.trim().split(/\\s/)[0]}>`;\n return {\n changes: [{ from, to: from, insert: start }, { from: to, to, insert: end }],\n selection: { anchor: from + start.length, head: to + start.length },\n };\n}\n"],
|
|
5
|
+
"mappings": ";AAcA,IAAM,OAA2B,CAAC,CAAC,QAAQ,KAAK,GAAG,CAAC,aAAa,KAAK,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;AAG3F,SAAS,SAAS,MAAqB;AAC5C,QAAM,OAAc,CAAC;AACrB,MAAI,IAAI;AACR,UAAQ,IAAI,KAAK,QAAQ,KAAK,CAAC,MAAM,GAAG;AACtC,UAAM,OAAO,KAAK,KAAK,CAAC,CAAC,IAAI,MAAM,KAAK,WAAW,MAAM,CAAC,CAAC;AAC3D,QAAI,MAAM;AACR,YAAM,MAAM,KAAK,QAAQ,KAAK,CAAC,GAAG,IAAI,KAAK,C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