@nerd-bible/wordgard 0.5.3-beta6 → 0.6.2-beta1
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/dist/command.js +11 -10
- package/dist/doc.d.ts +45 -48
- package/dist/doc.js +131 -128
- package/dist/editor.d.ts +190 -104
- package/dist/editor.js +2001 -1616
- package/dist/highlight-code.d.ts +249 -0
- package/dist/highlight-code.js +264 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/phrases.d.ts +3 -2
- package/dist/phrases.js +20 -1
- package/dist/schema.d.ts +37 -1
- package/dist/schema.js +154 -127
- package/dist/set.js +5 -4
- package/dist/state.d.ts +68 -22
- package/dist/state.js +137 -107
- package/dist/table.d.ts +3 -2
- package/dist/table.js +32 -14
- package/package.json +3 -2
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Plot } from 'wordgard/doc';
|
|
2
|
+
import { GardState } from 'wordgard/state';
|
|
3
|
+
import { StreamParser } from '@codemirror/streamparser';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Object type used to associate a parser with a language name and
|
|
7
|
+
optional set of aliases.
|
|
8
|
+
*/
|
|
9
|
+
declare class Language {
|
|
10
|
+
/**
|
|
11
|
+
The name of this language.
|
|
12
|
+
*/
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/**
|
|
15
|
+
Alternative names for the mode (lowercased, includes `this.name`).
|
|
16
|
+
*/
|
|
17
|
+
readonly alias: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
The parser that highlights this language.
|
|
20
|
+
*/
|
|
21
|
+
readonly parser: StreamParser<unknown>;
|
|
22
|
+
private constructor();
|
|
23
|
+
/**
|
|
24
|
+
Create a language object.
|
|
25
|
+
*/
|
|
26
|
+
static of(spec: {
|
|
27
|
+
/**
|
|
28
|
+
The language's name.
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
An optional array of alternative names.
|
|
33
|
+
*/
|
|
34
|
+
alias?: readonly string[];
|
|
35
|
+
/**
|
|
36
|
+
The parser to use for this language.
|
|
37
|
+
*/
|
|
38
|
+
parser: StreamParser<unknown>;
|
|
39
|
+
}): Language;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
@hidden
|
|
43
|
+
*/
|
|
44
|
+
declare const C: Language;
|
|
45
|
+
/**
|
|
46
|
+
@hidden
|
|
47
|
+
*/
|
|
48
|
+
declare const Cpp: Language;
|
|
49
|
+
/**
|
|
50
|
+
@hidden
|
|
51
|
+
*/
|
|
52
|
+
declare const Csharp: Language;
|
|
53
|
+
/**
|
|
54
|
+
@hidden
|
|
55
|
+
*/
|
|
56
|
+
declare const Dart: Language;
|
|
57
|
+
/**
|
|
58
|
+
@hidden
|
|
59
|
+
*/
|
|
60
|
+
declare const Java: Language;
|
|
61
|
+
/**
|
|
62
|
+
@hidden
|
|
63
|
+
*/
|
|
64
|
+
declare const Kotlin: Language;
|
|
65
|
+
/**
|
|
66
|
+
@hidden
|
|
67
|
+
*/
|
|
68
|
+
declare const ObjectiveC: Language;
|
|
69
|
+
/**
|
|
70
|
+
@hidden
|
|
71
|
+
*/
|
|
72
|
+
declare const Scala: Language;
|
|
73
|
+
/**
|
|
74
|
+
@hidden
|
|
75
|
+
*/
|
|
76
|
+
declare const CSS: Language;
|
|
77
|
+
/**
|
|
78
|
+
@hidden
|
|
79
|
+
*/
|
|
80
|
+
declare const Less: Language;
|
|
81
|
+
/**
|
|
82
|
+
@hidden
|
|
83
|
+
*/
|
|
84
|
+
declare const Go: Language;
|
|
85
|
+
/**
|
|
86
|
+
@hidden
|
|
87
|
+
*/
|
|
88
|
+
declare const HTML: Language;
|
|
89
|
+
/**
|
|
90
|
+
@hidden
|
|
91
|
+
*/
|
|
92
|
+
declare const XML: Language;
|
|
93
|
+
/**
|
|
94
|
+
@hidden
|
|
95
|
+
*/
|
|
96
|
+
declare const JavaScript: Language;
|
|
97
|
+
/**
|
|
98
|
+
@hidden
|
|
99
|
+
*/
|
|
100
|
+
declare const TypeScript: Language;
|
|
101
|
+
/**
|
|
102
|
+
@hidden
|
|
103
|
+
*/
|
|
104
|
+
declare const JSON: Language;
|
|
105
|
+
/**
|
|
106
|
+
@hidden
|
|
107
|
+
*/
|
|
108
|
+
declare const Jinja2: Language;
|
|
109
|
+
/**
|
|
110
|
+
@hidden
|
|
111
|
+
*/
|
|
112
|
+
declare const SQL: Language;
|
|
113
|
+
/**
|
|
114
|
+
@hidden
|
|
115
|
+
*/
|
|
116
|
+
declare const MSSQL: Language;
|
|
117
|
+
/**
|
|
118
|
+
@hidden
|
|
119
|
+
*/
|
|
120
|
+
declare const MySQL: Language;
|
|
121
|
+
/**
|
|
122
|
+
@hidden
|
|
123
|
+
*/
|
|
124
|
+
declare const PostgreSQL: Language;
|
|
125
|
+
/**
|
|
126
|
+
@hidden
|
|
127
|
+
*/
|
|
128
|
+
declare const SQLite: Language;
|
|
129
|
+
/**
|
|
130
|
+
@hidden
|
|
131
|
+
*/
|
|
132
|
+
declare const Python: Language;
|
|
133
|
+
/**
|
|
134
|
+
@hidden
|
|
135
|
+
*/
|
|
136
|
+
declare const Rust: Language;
|
|
137
|
+
/**
|
|
138
|
+
@hidden
|
|
139
|
+
*/
|
|
140
|
+
declare const Sass: Language;
|
|
141
|
+
/**
|
|
142
|
+
@hidden
|
|
143
|
+
*/
|
|
144
|
+
declare const WebAssembly: Language;
|
|
145
|
+
/**
|
|
146
|
+
@hidden
|
|
147
|
+
*/
|
|
148
|
+
declare const YAML: Language;
|
|
149
|
+
/**
|
|
150
|
+
@hidden
|
|
151
|
+
*/
|
|
152
|
+
declare const Cobol: Language;
|
|
153
|
+
/**
|
|
154
|
+
@hidden
|
|
155
|
+
*/
|
|
156
|
+
declare const Clojure: Language;
|
|
157
|
+
/**
|
|
158
|
+
@hidden
|
|
159
|
+
*/
|
|
160
|
+
declare const CommonLisp: Language;
|
|
161
|
+
/**
|
|
162
|
+
@hidden
|
|
163
|
+
*/
|
|
164
|
+
declare const Elm: Language;
|
|
165
|
+
/**
|
|
166
|
+
@hidden
|
|
167
|
+
*/
|
|
168
|
+
declare const Erlang: Language;
|
|
169
|
+
/**
|
|
170
|
+
@hidden
|
|
171
|
+
*/
|
|
172
|
+
declare const Haskell: Language;
|
|
173
|
+
/**
|
|
174
|
+
@hidden
|
|
175
|
+
*/
|
|
176
|
+
declare const Julia: Language;
|
|
177
|
+
/**
|
|
178
|
+
@hidden
|
|
179
|
+
*/
|
|
180
|
+
declare const Lua: Language;
|
|
181
|
+
/**
|
|
182
|
+
@hidden
|
|
183
|
+
*/
|
|
184
|
+
declare const OCaml: Language;
|
|
185
|
+
/**
|
|
186
|
+
@hidden
|
|
187
|
+
*/
|
|
188
|
+
declare const FSharp: Language;
|
|
189
|
+
/**
|
|
190
|
+
@hidden
|
|
191
|
+
*/
|
|
192
|
+
declare const SML: Language;
|
|
193
|
+
/**
|
|
194
|
+
@hidden
|
|
195
|
+
*/
|
|
196
|
+
declare const Perl: Language;
|
|
197
|
+
/**
|
|
198
|
+
@hidden
|
|
199
|
+
*/
|
|
200
|
+
declare const R: Language;
|
|
201
|
+
/**
|
|
202
|
+
@hidden
|
|
203
|
+
*/
|
|
204
|
+
declare const Ruby: Language;
|
|
205
|
+
/**
|
|
206
|
+
@hidden
|
|
207
|
+
*/
|
|
208
|
+
declare const Scheme: Language;
|
|
209
|
+
/**
|
|
210
|
+
@hidden
|
|
211
|
+
*/
|
|
212
|
+
declare const Shell: Language;
|
|
213
|
+
/**
|
|
214
|
+
@hidden
|
|
215
|
+
*/
|
|
216
|
+
declare const Swift: Language;
|
|
217
|
+
/**
|
|
218
|
+
@hidden
|
|
219
|
+
*/
|
|
220
|
+
declare const LaTeX: Language;
|
|
221
|
+
/**
|
|
222
|
+
An array of common languages. Contains `C`, `CSS`, `Cpp`, `HTML`,
|
|
223
|
+
`Java`, `JavaScript`, `JSON`, `Python`, `Ruby`, `Rust`,
|
|
224
|
+
`TypeScript`, and `XML`.
|
|
225
|
+
*/
|
|
226
|
+
declare const baseLanguages: readonly Language[];
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
Returns an extension that highlights {@link CodeBlock code
|
|
230
|
+
blocks}. Will add {@link codeBlockLanguage.options options} for
|
|
231
|
+
the block language menu for the provided languages.
|
|
232
|
+
*/
|
|
233
|
+
declare function highlightCode(options?: {
|
|
234
|
+
/**
|
|
235
|
+
A set of languages to use for highlighting. A given language
|
|
236
|
+
will be used if the block's {@link CodeBlockLanguage} mark
|
|
237
|
+
matches its name or one of it aliases.
|
|
238
|
+
*/
|
|
239
|
+
languages?: readonly Language[];
|
|
240
|
+
/**
|
|
241
|
+
An optional function to override the way a language is
|
|
242
|
+
determined for a block. Can be used to provide a default
|
|
243
|
+
highlighting language, language detection, or more advanced
|
|
244
|
+
language name matching.
|
|
245
|
+
*/
|
|
246
|
+
getLanguage?: (block: Plot) => Language | null;
|
|
247
|
+
}): GardState.Extension;
|
|
248
|
+
|
|
249
|
+
export { C, CSS, Clojure, Cobol, CommonLisp, Cpp, Csharp, Dart, Elm, Erlang, FSharp, Go, HTML, Haskell, JSON, Java, JavaScript, Jinja2, Julia, Kotlin, LaTeX, Language, Less, Lua, MSSQL, MySQL, OCaml, ObjectiveC, Perl, PostgreSQL, Python, R, Ruby, Rust, SML, SQL, SQLite, Sass, Scala, Scheme, Shell, Swift, TypeScript, WebAssembly, XML, YAML, baseLanguages, highlightCode };
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { Leaf } from 'wordgard/doc';
|
|
2
|
+
import { CodeBlock, CodeBlockLanguage, LineBreak } from 'wordgard/types';
|
|
3
|
+
import { Wordgard, Decoration, decoratePlots } from 'wordgard/editor';
|
|
4
|
+
import { codeBlockLanguage } from 'wordgard/schema';
|
|
5
|
+
import { StringStream } from '@codemirror/streamparser';
|
|
6
|
+
import { c, cpp, csharp, dart, java, kotlin, objectiveC, scala } from '@codemirror/legacy-modes/mode/clike';
|
|
7
|
+
import { css, less } from '@codemirror/legacy-modes/mode/css';
|
|
8
|
+
import { go } from '@codemirror/legacy-modes/mode/go';
|
|
9
|
+
import { html, xml } from '@codemirror/legacy-modes/mode/xml';
|
|
10
|
+
import { json, javascript, typescript } from '@codemirror/legacy-modes/mode/javascript';
|
|
11
|
+
import { jinja2 } from '@codemirror/legacy-modes/mode/jinja2';
|
|
12
|
+
import { msSQL, mySQL, pgSQL, standardSQL, sqlite } from '@codemirror/legacy-modes/mode/sql';
|
|
13
|
+
import { python } from '@codemirror/legacy-modes/mode/python';
|
|
14
|
+
import { rust } from '@codemirror/legacy-modes/mode/rust';
|
|
15
|
+
import { sass } from '@codemirror/legacy-modes/mode/sass';
|
|
16
|
+
import { wast } from '@codemirror/legacy-modes/mode/wast';
|
|
17
|
+
import { yaml } from '@codemirror/legacy-modes/mode/yaml';
|
|
18
|
+
import { cobol } from '@codemirror/legacy-modes/mode/cobol';
|
|
19
|
+
import { clojure } from '@codemirror/legacy-modes/mode/clojure';
|
|
20
|
+
import { commonLisp } from '@codemirror/legacy-modes/mode/commonlisp';
|
|
21
|
+
import { elm } from '@codemirror/legacy-modes/mode/elm';
|
|
22
|
+
import { erlang } from '@codemirror/legacy-modes/mode/erlang';
|
|
23
|
+
import { haskell } from '@codemirror/legacy-modes/mode/haskell';
|
|
24
|
+
import { julia } from '@codemirror/legacy-modes/mode/julia';
|
|
25
|
+
import { lua } from '@codemirror/legacy-modes/mode/lua';
|
|
26
|
+
import { fSharp, oCaml, sml } from '@codemirror/legacy-modes/mode/mllike';
|
|
27
|
+
import { perl } from '@codemirror/legacy-modes/mode/perl';
|
|
28
|
+
import { r } from '@codemirror/legacy-modes/mode/r';
|
|
29
|
+
import { ruby } from '@codemirror/legacy-modes/mode/ruby';
|
|
30
|
+
import { scheme } from '@codemirror/legacy-modes/mode/scheme';
|
|
31
|
+
import { shell } from '@codemirror/legacy-modes/mode/shell';
|
|
32
|
+
import { swift } from '@codemirror/legacy-modes/mode/swift';
|
|
33
|
+
import { stex } from '@codemirror/legacy-modes/mode/stex';
|
|
34
|
+
|
|
35
|
+
const theme = /*@__PURE__*/Wordgard.styles({
|
|
36
|
+
".wg-t-keyword": { color: "#708" },
|
|
37
|
+
".wg-t-atom, .wg-t-bool, .wg-t-label": { color: "#219" },
|
|
38
|
+
".wg-t-literal, .wg-t-number": { color: "#164" },
|
|
39
|
+
".wg-t-string": { color: "#a11" },
|
|
40
|
+
".wg-t-name, .wg-t-prop": {},
|
|
41
|
+
".wg-t-local": { color: "#30a" },
|
|
42
|
+
".wg-t-def": { color: "#00f" },
|
|
43
|
+
".wg-t-type, .wg-t-namespace, .wg-t-class": { color: "#085" },
|
|
44
|
+
".wg-t-macro, .wg-t-special": { color: "#256" },
|
|
45
|
+
".wg-t-comment": { color: "#940" },
|
|
46
|
+
".wg-t-error": { color: "#f00" }
|
|
47
|
+
});
|
|
48
|
+
const tokenMap = /*@__PURE__*/(() => new Map)();
|
|
49
|
+
function tokenClass(token) {
|
|
50
|
+
let cls = tokenMap.get(token);
|
|
51
|
+
if (cls === undefined)
|
|
52
|
+
tokenMap.set(token, cls = getTokenClass(token));
|
|
53
|
+
return cls;
|
|
54
|
+
}
|
|
55
|
+
function getTokenClass(token) {
|
|
56
|
+
if (/\.local/.test(token))
|
|
57
|
+
return "local";
|
|
58
|
+
if (token == "variable-2" || token == "variableName.special")
|
|
59
|
+
return "special";
|
|
60
|
+
if (token == "def" || token == "variableName.definition")
|
|
61
|
+
return "def";
|
|
62
|
+
if (/^keyword/.test(token))
|
|
63
|
+
return "keyword";
|
|
64
|
+
if (/^string/.test(token))
|
|
65
|
+
return "string";
|
|
66
|
+
if (/^(variable|name)/.test(token))
|
|
67
|
+
return "name";
|
|
68
|
+
if (/^(type|tag)/.test(token))
|
|
69
|
+
return "type";
|
|
70
|
+
if (/^(attribute|prop)/.test(token))
|
|
71
|
+
return "prop";
|
|
72
|
+
if (/^type/.test(token))
|
|
73
|
+
return "type";
|
|
74
|
+
if (/^(error|invalid)/.test(token))
|
|
75
|
+
return "error";
|
|
76
|
+
if (/^string/.test(token))
|
|
77
|
+
return "string";
|
|
78
|
+
if (/^number/.test(token))
|
|
79
|
+
return "number";
|
|
80
|
+
if (/^bool/.test(token))
|
|
81
|
+
return "bool";
|
|
82
|
+
if (/^atom/.test(token))
|
|
83
|
+
return "atom";
|
|
84
|
+
if (/^(literal|regexp|color)/.test(token))
|
|
85
|
+
return "literal";
|
|
86
|
+
if (/^label/.test(token))
|
|
87
|
+
return "label";
|
|
88
|
+
if (/^class/.test(token))
|
|
89
|
+
return "class";
|
|
90
|
+
if (/^namespace/.test(token))
|
|
91
|
+
return "namespace";
|
|
92
|
+
if (/^label/.test(token))
|
|
93
|
+
return "label";
|
|
94
|
+
if (/^macro/.test(token))
|
|
95
|
+
return "macro";
|
|
96
|
+
if (/comment/i.test(token))
|
|
97
|
+
return "comment";
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
const tokenDeco = /*@__PURE__*/(() => ({
|
|
101
|
+
keyword: Decoration.Range.attribute("class", "wg-t-keyword"),
|
|
102
|
+
atom: Decoration.Range.attribute("class", "wg-t-atom"),
|
|
103
|
+
bool: Decoration.Range.attribute("class", "wg-t-bool"),
|
|
104
|
+
label: Decoration.Range.attribute("class", "wg-t-label"),
|
|
105
|
+
literal: Decoration.Range.attribute("class", "wg-t-literal"),
|
|
106
|
+
number: Decoration.Range.attribute("class", "wg-t-number"),
|
|
107
|
+
string: Decoration.Range.attribute("class", "wg-t-string"),
|
|
108
|
+
name: Decoration.Range.attribute("class", "wg-t-name"),
|
|
109
|
+
prop: Decoration.Range.attribute("class", "wg-t-prop"),
|
|
110
|
+
local: Decoration.Range.attribute("class", "wg-t-local"),
|
|
111
|
+
def: Decoration.Range.attribute("class", "wg-t-def"),
|
|
112
|
+
type: Decoration.Range.attribute("class", "wg-t-type"),
|
|
113
|
+
namespace: Decoration.Range.attribute("class", "wg-t-namespace"),
|
|
114
|
+
class: Decoration.Range.attribute("class", "wg-t-class"),
|
|
115
|
+
macro: Decoration.Range.attribute("class", "wg-t-macro"),
|
|
116
|
+
special: Decoration.Range.attribute("class", "wg-t-special"),
|
|
117
|
+
comment: Decoration.Range.attribute("class", "wg-t-comment"),
|
|
118
|
+
error: Decoration.Range.attribute("class", "wg-t-error")
|
|
119
|
+
}))();
|
|
120
|
+
function blockText(plot) {
|
|
121
|
+
let text = "";
|
|
122
|
+
for (let ch of plot.content) {
|
|
123
|
+
if (ch.is(Leaf.Text))
|
|
124
|
+
text += ch.param;
|
|
125
|
+
else if (ch.type == LineBreak.type)
|
|
126
|
+
text += "\n";
|
|
127
|
+
else if (ch.isLeaf)
|
|
128
|
+
text += " ";
|
|
129
|
+
else
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
return text;
|
|
133
|
+
}
|
|
134
|
+
function readToken(token, stream, state) {
|
|
135
|
+
stream.start = stream.pos;
|
|
136
|
+
for (let i = 0; i < 10; i++) {
|
|
137
|
+
let result = token(stream, state);
|
|
138
|
+
if (stream.pos > stream.start)
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
stream.skipToEnd();
|
|
142
|
+
return "";
|
|
143
|
+
}
|
|
144
|
+
const maxHighlight = 10000;
|
|
145
|
+
function highlightBlock(text, language, add) {
|
|
146
|
+
let { parser } = language;
|
|
147
|
+
let pos = 0, state = parser.startState ? parser.startState(2) : true;
|
|
148
|
+
hl: for (let line of text.split("\n")) {
|
|
149
|
+
let stream = new StringStream(line, 4, 2);
|
|
150
|
+
if (stream.eol()) {
|
|
151
|
+
parser.blankLine?.(state, 2);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
while (!stream.eol()) {
|
|
155
|
+
let token = readToken(parser.token, stream, state);
|
|
156
|
+
if (token) {
|
|
157
|
+
let cls = tokenClass(token);
|
|
158
|
+
if (cls)
|
|
159
|
+
add(tokenDeco[cls], pos + stream.start, pos + stream.pos);
|
|
160
|
+
}
|
|
161
|
+
if (pos + stream.pos > maxHighlight)
|
|
162
|
+
break hl;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
pos += line.length + 1;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function highlightCode(options = {}) {
|
|
169
|
+
let map = new Map;
|
|
170
|
+
let langOptions = [];
|
|
171
|
+
for (let lang of options.languages || []) {
|
|
172
|
+
langOptions.push(lang.name);
|
|
173
|
+
for (let alias of lang.alias)
|
|
174
|
+
map.set(alias, lang);
|
|
175
|
+
}
|
|
176
|
+
return [
|
|
177
|
+
theme,
|
|
178
|
+
codeBlockLanguage.options.of(langOptions),
|
|
179
|
+
decoratePlots({
|
|
180
|
+
type: CodeBlock,
|
|
181
|
+
ranges: (block, add) => {
|
|
182
|
+
let lang = options.getLanguage ? options.getLanguage(block) : undefined;
|
|
183
|
+
if (!lang) {
|
|
184
|
+
let langName = block.mark(CodeBlockLanguage);
|
|
185
|
+
if (langName)
|
|
186
|
+
lang = map.get(langName);
|
|
187
|
+
}
|
|
188
|
+
if (lang) {
|
|
189
|
+
let text = blockText(block);
|
|
190
|
+
if (text)
|
|
191
|
+
highlightBlock(text, lang, add);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
];
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
class Language {
|
|
199
|
+
name;
|
|
200
|
+
alias;
|
|
201
|
+
parser;
|
|
202
|
+
constructor(
|
|
203
|
+
name,
|
|
204
|
+
alias,
|
|
205
|
+
parser) {
|
|
206
|
+
this.name = name;
|
|
207
|
+
this.alias = alias;
|
|
208
|
+
this.parser = parser;
|
|
209
|
+
}
|
|
210
|
+
static of(spec) {
|
|
211
|
+
return new Language(spec.name, (spec.alias || []).concat(spec.name).map(s => s.toLowerCase()), spec.parser);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function lang(name, parser, alias) {
|
|
215
|
+
return Language.of({ name, alias, parser });
|
|
216
|
+
}
|
|
217
|
+
const C = /*@__PURE__*/lang("C", c);
|
|
218
|
+
const Cpp = /*@__PURE__*/lang("C++", cpp, ["cpp"]);
|
|
219
|
+
const Csharp = /*@__PURE__*/lang("C#", csharp, ["csharp"]);
|
|
220
|
+
const Dart = /*@__PURE__*/lang("Dart", dart);
|
|
221
|
+
const Java = /*@__PURE__*/lang("Java", java);
|
|
222
|
+
const Kotlin = /*@__PURE__*/lang("Kotlin", kotlin);
|
|
223
|
+
const ObjectiveC = /*@__PURE__*/lang("ObjectiveC", objectiveC, ["objective-c", "objc"]);
|
|
224
|
+
const Scala = /*@__PURE__*/lang("Scala", scala);
|
|
225
|
+
const CSS = /*@__PURE__*/lang("CSS", css);
|
|
226
|
+
const Less = /*@__PURE__*/lang("Less", less);
|
|
227
|
+
const Go = /*@__PURE__*/lang("Go", go);
|
|
228
|
+
const HTML = /*@__PURE__*/lang("HTML", html, ["xhtml"]);
|
|
229
|
+
const XML = /*@__PURE__*/lang("XML", xml, ["rss", "wsdl", "xsd"]);
|
|
230
|
+
const JavaScript = /*@__PURE__*/lang("JavaScript", javascript, ["ecmascript", "js", "node"]);
|
|
231
|
+
const TypeScript = /*@__PURE__*/lang("TypeScript", typescript, ["ts"]);
|
|
232
|
+
const JSON = /*@__PURE__*/lang("JSON", json, ["json5"]);
|
|
233
|
+
const Jinja2 = /*@__PURE__*/lang("Jinja2", jinja2);
|
|
234
|
+
const SQL = /*@__PURE__*/lang("SQL", standardSQL);
|
|
235
|
+
const MSSQL = /*@__PURE__*/lang("MSSQL", msSQL);
|
|
236
|
+
const MySQL = /*@__PURE__*/lang("MySQL", mySQL);
|
|
237
|
+
const PostgreSQL = /*@__PURE__*/lang("PostgreSQL", pgSQL, ["postgres", "pgsql"]);
|
|
238
|
+
const SQLite = /*@__PURE__*/lang("SQLite", sqlite);
|
|
239
|
+
const Python = /*@__PURE__*/lang("Python", python);
|
|
240
|
+
const Rust = /*@__PURE__*/lang("Rust", rust);
|
|
241
|
+
const Sass = /*@__PURE__*/lang("Sass", sass);
|
|
242
|
+
const WebAssembly = /*@__PURE__*/lang("WebAssembly", wast, ["wast"]);
|
|
243
|
+
const YAML = /*@__PURE__*/lang("YAML", yaml, ["yml"]);
|
|
244
|
+
const Cobol = /*@__PURE__*/lang("Cobol", cobol);
|
|
245
|
+
const Clojure = /*@__PURE__*/lang("Clojure", clojure, ["clojurescript"]);
|
|
246
|
+
const CommonLisp = /*@__PURE__*/lang("CommonLisp", commonLisp, ["lisp", "cl"]);
|
|
247
|
+
const Elm = /*@__PURE__*/lang("Elm", elm);
|
|
248
|
+
const Erlang = /*@__PURE__*/lang("Erlang", erlang);
|
|
249
|
+
const Haskell = /*@__PURE__*/lang("Haskell", haskell);
|
|
250
|
+
const Julia = /*@__PURE__*/lang("Julia", julia);
|
|
251
|
+
const Lua = /*@__PURE__*/lang("Lua", lua);
|
|
252
|
+
const OCaml = /*@__PURE__*/lang("OCaml", oCaml);
|
|
253
|
+
const FSharp = /*@__PURE__*/lang("F#", fSharp, ["fsharp"]);
|
|
254
|
+
const SML = /*@__PURE__*/lang("SML", sml);
|
|
255
|
+
const Perl = /*@__PURE__*/lang("Perl", perl);
|
|
256
|
+
const R = /*@__PURE__*/lang("R", r);
|
|
257
|
+
const Ruby = /*@__PURE__*/lang("Ruby", ruby, ["jruby", "rb"]);
|
|
258
|
+
const Scheme = /*@__PURE__*/lang("Scheme", scheme);
|
|
259
|
+
const Shell = /*@__PURE__*/lang("Shell", shell, ["bash", "sh", "zsh"]);
|
|
260
|
+
const Swift = /*@__PURE__*/lang("Swift", swift);
|
|
261
|
+
const LaTeX = /*@__PURE__*/lang("LaTeX", stex, ["stex", "tex"]);
|
|
262
|
+
const baseLanguages = [C, CSS, Cpp, HTML, Java, JavaScript, JSON, Python, Ruby, Rust, TypeScript, XML];
|
|
263
|
+
|
|
264
|
+
export { C, CSS, Clojure, Cobol, CommonLisp, Cpp, Csharp, Dart, Elm, Erlang, FSharp, Go, HTML, Haskell, JSON, Java, JavaScript, Jinja2, Julia, Kotlin, LaTeX, Language, Less, Lua, MSSQL, MySQL, OCaml, ObjectiveC, Perl, PostgreSQL, Python, R, Ruby, Rust, SML, SQL, SQLite, Sass, Scala, Scheme, Shell, Swift, TypeScript, WebAssembly, XML, YAML, baseLanguages, highlightCode };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * as collab from "wordgard/collab"
|
|
|
2
2
|
export * as command from "wordgard/command"
|
|
3
3
|
export * as doc from "wordgard/doc"
|
|
4
4
|
export * as editor from "wordgard/editor"
|
|
5
|
+
export * as highlight-code from "wordgard/highlight-code"
|
|
5
6
|
export * as history from "wordgard/history"
|
|
6
7
|
export * as phrases from "wordgard/phrases"
|
|
7
8
|
export * as schema from "wordgard/schema"
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * as collab from "wordgard/collab"
|
|
|
2
2
|
export * as command from "wordgard/command"
|
|
3
3
|
export * as doc from "wordgard/doc"
|
|
4
4
|
export * as editor from "wordgard/editor"
|
|
5
|
+
export * as highlight-code from "wordgard/highlight-code"
|
|
5
6
|
export * as history from "wordgard/history"
|
|
6
7
|
export * as phrases from "wordgard/phrases"
|
|
7
8
|
export * as schema from "wordgard/schema"
|
package/dist/phrases.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare class PhraseSet<Tags extends string> {
|
|
|
11
11
|
[tag in Tags]: string;
|
|
12
12
|
};
|
|
13
13
|
private constructor();
|
|
14
|
+
private refs;
|
|
14
15
|
/**
|
|
15
16
|
Look up a translation for phrase with the given tag.
|
|
16
17
|
|
|
@@ -72,11 +73,11 @@ declare namespace PhraseSet {
|
|
|
72
73
|
/**
|
|
73
74
|
The phrase set for the core package and basic menu items.
|
|
74
75
|
*/
|
|
75
|
-
declare const phrases: PhraseSet<"dialog_close" | "overflow_more" | "block_style" | "toggle_strong" | "toggle_em" | "toggle_code" | "toggle_underline" | "toggle_strikethrough" | "toggle_super" | "toggle_sub" | "link_target" | "create_link" | "text_color" | "background_color" | "undo" | "redo" | "paragraph" | "code_block" | "heading_1" | "heading_2" | "heading_3" | "toggle_bullet_list" | "toggle_ordered_list" | "toggle_quote" | "alignment" | "align_start" | "align_end" | "align_center" | "text_dir" | "text_dir_ltr" | "text_dir_rtl" | "text_dir_auto">;
|
|
76
|
+
declare const phrases: PhraseSet<"dialog_close" | "group_block" | "group_inline" | "group_history" | "key_bindings" | "show_keys" | "overflow_more" | "block_style" | "toggle_strong" | "toggle_em" | "toggle_code" | "toggle_underline" | "toggle_strikethrough" | "toggle_super" | "toggle_sub" | "link_target" | "create_link" | "insert_break" | "text_color" | "background_color" | "undo" | "redo" | "paragraph" | "code_block" | "code_block_language" | "heading_1" | "heading_2" | "heading_3" | "heading_4" | "heading_5" | "heading_6" | "toggle_bullet_list" | "toggle_ordered_list" | "toggle_quote" | "alignment" | "align_start" | "align_end" | "align_left" | "align_right" | "align_center" | "text_dir" | "text_dir_ltr" | "text_dir_rtl" | "text_dir_auto">;
|
|
76
77
|
/**
|
|
77
78
|
Phrases used by the {@link schema.image.button image dialog}.
|
|
78
79
|
*/
|
|
79
|
-
declare const imagePhrases: PhraseSet<"inline" | "auto" | "width" | "cancel" | "figure" | "update" | "insert" | "insert_image" | "update_image" | "figure_center" | "figure_end" | "captioned" | "image_style" | "uploading" | "upload_failed" | "upload_image" | "image_source" | "alt_text" | "describe_image">;
|
|
80
|
+
declare const imagePhrases: PhraseSet<"inline" | "auto" | "width" | "cancel" | "figure" | "update" | "insert" | "group_image" | "insert_image" | "update_image" | "figure_center" | "figure_end" | "captioned" | "image_style" | "uploading" | "upload_failed" | "resize_up" | "resize_down" | "upload_image" | "image_source" | "alt_text" | "describe_image">;
|
|
80
81
|
/**
|
|
81
82
|
Phrases (mostly color names) used by the {@link schema.ColorPicker
|
|
82
83
|
color picker}.
|
package/dist/phrases.js
CHANGED
|
@@ -16,6 +16,7 @@ class PhraseSet {
|
|
|
16
16
|
constructor(phrases) {
|
|
17
17
|
this.phrases = phrases;
|
|
18
18
|
}
|
|
19
|
+
refs = new Map;
|
|
19
20
|
get(state, tag, ...insert) {
|
|
20
21
|
let override = state.facet(phraseOverride).get(this);
|
|
21
22
|
let phrase = (override && override[tag]) ?? this.phrases[tag];
|
|
@@ -29,7 +30,10 @@ class PhraseSet {
|
|
|
29
30
|
return phrase;
|
|
30
31
|
}
|
|
31
32
|
ref(tag) {
|
|
32
|
-
|
|
33
|
+
let found = this.refs.get(tag);
|
|
34
|
+
if (!found)
|
|
35
|
+
this.refs.set(tag, found = (state, ...insert) => this.get(state, tag, ...insert));
|
|
36
|
+
return found;
|
|
33
37
|
}
|
|
34
38
|
translate(phrases) {
|
|
35
39
|
return phraseOverride.of({ set: this, phrases });
|
|
@@ -47,6 +51,11 @@ class PhraseSet {
|
|
|
47
51
|
|
|
48
52
|
const phrases = /*@__PURE__*/PhraseSet.define({
|
|
49
53
|
dialog_close: "close",
|
|
54
|
+
group_block: "Block-level editing",
|
|
55
|
+
group_inline: "Inline editing",
|
|
56
|
+
group_history: "Undo history",
|
|
57
|
+
key_bindings: "Keyboard Shortcuts",
|
|
58
|
+
show_keys: "Show keyboard shortcuts",
|
|
50
59
|
overflow_more: "More",
|
|
51
60
|
block_style: "Block style",
|
|
52
61
|
toggle_strong: "Toggle strong emphasis",
|
|
@@ -58,21 +67,28 @@ const phrases = /*@__PURE__*/PhraseSet.define({
|
|
|
58
67
|
toggle_sub: "Toggle subscript",
|
|
59
68
|
link_target: "Link target",
|
|
60
69
|
create_link: "Create link",
|
|
70
|
+
insert_break: "Insert line break",
|
|
61
71
|
text_color: "Text color",
|
|
62
72
|
background_color: "Background color",
|
|
63
73
|
undo: "Undo",
|
|
64
74
|
redo: "Redo",
|
|
65
75
|
paragraph: "Paragraph",
|
|
66
76
|
code_block: "Code block",
|
|
77
|
+
code_block_language: "Select code block language",
|
|
67
78
|
heading_1: "Heading 1",
|
|
68
79
|
heading_2: "Heading 2",
|
|
69
80
|
heading_3: "Heading 3",
|
|
81
|
+
heading_4: "Heading 4",
|
|
82
|
+
heading_5: "Heading 5",
|
|
83
|
+
heading_6: "Heading 6",
|
|
70
84
|
toggle_bullet_list: "Toggle bullet list",
|
|
71
85
|
toggle_ordered_list: "Toggle ordered list",
|
|
72
86
|
toggle_quote: "Toggle blockquote",
|
|
73
87
|
alignment: "Alignment",
|
|
74
88
|
align_start: "Align text to block start",
|
|
75
89
|
align_end: "Align text to block end",
|
|
90
|
+
align_left: "Align text to the left",
|
|
91
|
+
align_right: "Align text to the right",
|
|
76
92
|
align_center: "Center text",
|
|
77
93
|
text_dir: "Text direction",
|
|
78
94
|
text_dir_ltr: "Left-to-right text",
|
|
@@ -80,6 +96,7 @@ const phrases = /*@__PURE__*/PhraseSet.define({
|
|
|
80
96
|
text_dir_auto: "Automatic text direction",
|
|
81
97
|
});
|
|
82
98
|
const imagePhrases = /*@__PURE__*/PhraseSet.define({
|
|
99
|
+
group_image: "Image manipulation",
|
|
83
100
|
insert_image: "Insert image",
|
|
84
101
|
update_image: "Update image",
|
|
85
102
|
update: "Update",
|
|
@@ -94,6 +111,8 @@ const imagePhrases = /*@__PURE__*/PhraseSet.define({
|
|
|
94
111
|
uploading: "Uploading...",
|
|
95
112
|
upload_failed: "Image upload failed",
|
|
96
113
|
width: "Width in pixels",
|
|
114
|
+
resize_up: "Make image larger",
|
|
115
|
+
resize_down: "Make image smaller",
|
|
97
116
|
upload_image: "Upload an image",
|
|
98
117
|
image_source: "Image source",
|
|
99
118
|
alt_text: "Alternative text",
|
package/dist/schema.d.ts
CHANGED
|
@@ -240,6 +240,42 @@ declare namespace codeBlock {
|
|
|
240
240
|
language, converts the block into a code block.
|
|
241
241
|
*/
|
|
242
242
|
const createOnBackticks: GardState.Extension;
|
|
243
|
+
/**
|
|
244
|
+
Simple style that gives code blocks a background and slightly
|
|
245
|
+
rounded corners.
|
|
246
|
+
*/
|
|
247
|
+
const theme: GardState.Extension;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
Add support for the code block {@link CodeBlockLanguage language
|
|
251
|
+
mark}.
|
|
252
|
+
*/
|
|
253
|
+
declare function codeBlockLanguage(options?: {
|
|
254
|
+
/**
|
|
255
|
+
When given, show a drop-down menu in the corner of code blocks
|
|
256
|
+
that allows the user to choose a language for block from the
|
|
257
|
+
given list of strings. The actual mark value will be the
|
|
258
|
+
lower-case form of the selected language name.
|
|
259
|
+
*/
|
|
260
|
+
languages?: readonly string[];
|
|
261
|
+
}): GardState.Extension;
|
|
262
|
+
declare namespace codeBlockLanguage {
|
|
263
|
+
/**
|
|
264
|
+
If the selection is in a code block, and language selection is
|
|
265
|
+
enabled, this command focuses the language field to allow
|
|
266
|
+
selection via the keyboard.
|
|
267
|
+
*/
|
|
268
|
+
const selectLanguage: Command;
|
|
269
|
+
/**
|
|
270
|
+
Key binding that binds Shift-Ctrl-l (Shift-Cmd-l on MacOS) to
|
|
271
|
+
{@link codeBlockLanguage.selectLanguage `selectLanguage`}.
|
|
272
|
+
*/
|
|
273
|
+
const selectLanguageBinding: KeyBinding;
|
|
274
|
+
/**
|
|
275
|
+
A facet that allows you to add options to the language selection
|
|
276
|
+
drop-down.
|
|
277
|
+
*/
|
|
278
|
+
const options: GardState.Facet<readonly string[], readonly string[]>;
|
|
243
279
|
}
|
|
244
280
|
|
|
245
281
|
/**
|
|
@@ -576,4 +612,4 @@ declare namespace image {
|
|
|
576
612
|
const uploader: GardState.Facet<(file: File, wg: Wordgard, progress: (percent: number) => void) => Promise<string>, readonly ((file: File, wg: Wordgard, progress: (percent: number) => void) => Promise<string>)[]>;
|
|
577
613
|
}
|
|
578
614
|
|
|
579
|
-
export { ColorPicker, alignment, backgroundColor, basicMarks, basicSchema, blockDoc, blockquote, bulletList, code, codeBlock, color, direction, emphasis, figure, fullSchema, heading, horizontalRule, image, imageResizing, inlineDoc, inlineMarks, inlineSchema, lineBreak, link, orderedList, paragraph, strikethrough, strong, subscript, superscript, underline };
|
|
615
|
+
export { ColorPicker, alignment, backgroundColor, basicMarks, basicSchema, blockDoc, blockquote, bulletList, code, codeBlock, codeBlockLanguage, color, direction, emphasis, figure, fullSchema, heading, horizontalRule, image, imageResizing, inlineDoc, inlineMarks, inlineSchema, lineBreak, link, orderedList, paragraph, strikethrough, strong, subscript, superscript, underline };
|