quietmark 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +276 -2
- package/dist/index.d.ts +76 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/inline.d.ts +2 -0
- package/dist/inline.js +16 -0
- package/dist/inline.js.map +1 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/wasm/inline.d.ts +1 -0
- package/dist/wasm/inline.js +2 -0
- package/dist/wasm/quietmark.d.ts +139 -0
- package/dist/wasm/quietmark.js +807 -0
- package/dist/wasm/quietmark_bg.wasm +0 -0
- package/dist/wasm/quietmark_bg.wasm.d.ts +30 -0
- package/package.json +51 -3
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/** A run of the text, from `from` up to but not including `to`. */
|
|
2
|
+
export interface Range {
|
|
3
|
+
from: number;
|
|
4
|
+
to: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* An inline style. `tag` is what a paired HTML tag such as `<kbd>` holds,
|
|
8
|
+
* with the tag's name in the span's `tag`.
|
|
9
|
+
*/
|
|
10
|
+
export type SpanStyle = "strong" | "emphasis" | "strike" | "code" | "link" | "done" | "comment" | "tag";
|
|
11
|
+
export interface Span {
|
|
12
|
+
range: Range;
|
|
13
|
+
style: SpanStyle;
|
|
14
|
+
/** The tag's name, for a `tag` span. */
|
|
15
|
+
tag?: string;
|
|
16
|
+
}
|
|
17
|
+
/** A line of a fence or a formula block. */
|
|
18
|
+
export interface CodeLine {
|
|
19
|
+
first: boolean;
|
|
20
|
+
last: boolean;
|
|
21
|
+
/** One of the block's own fence lines, not its code. */
|
|
22
|
+
fence: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A line's block style. A line can be in a quote and a fence at once. */
|
|
25
|
+
export interface LineLook {
|
|
26
|
+
line: number;
|
|
27
|
+
/** A heading's level as written, 1 through 6. */
|
|
28
|
+
heading?: number;
|
|
29
|
+
/** How many quotes deep the line is. */
|
|
30
|
+
quote: number;
|
|
31
|
+
code?: CodeLine;
|
|
32
|
+
/** A thematic break on a line of its own. */
|
|
33
|
+
rule: boolean;
|
|
34
|
+
/** A ticked task's line. */
|
|
35
|
+
taskDone: boolean;
|
|
36
|
+
/** A callout's kind in lower case, such as `note` for `> [!NOTE]`. */
|
|
37
|
+
callout?: string;
|
|
38
|
+
table: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface DrawnBlockBase {
|
|
41
|
+
/** What it draws from, such as the formula without its `$$` lines. */
|
|
42
|
+
source: string;
|
|
43
|
+
/** Its first line. */
|
|
44
|
+
first: number;
|
|
45
|
+
/** Its last line. */
|
|
46
|
+
last: number;
|
|
47
|
+
/** Where the caret goes to edit it. */
|
|
48
|
+
caret: number;
|
|
49
|
+
}
|
|
50
|
+
/** A block on lines of its own, drawn whole while the selection is off it. */
|
|
51
|
+
export type DrawnBlock = DrawnBlockBase & ({
|
|
52
|
+
kind: "math";
|
|
53
|
+
} | {
|
|
54
|
+
kind: "image";
|
|
55
|
+
url: string;
|
|
56
|
+
alt: string;
|
|
57
|
+
} | {
|
|
58
|
+
kind: "callout";
|
|
59
|
+
callout: string;
|
|
60
|
+
} | {
|
|
61
|
+
kind: "html";
|
|
62
|
+
} | {
|
|
63
|
+
kind: "fence";
|
|
64
|
+
info: string;
|
|
65
|
+
} | {
|
|
66
|
+
kind: "directive";
|
|
67
|
+
name: string;
|
|
68
|
+
attributes: string;
|
|
69
|
+
});
|
|
70
|
+
/** What draws in a hidden marker's place. */
|
|
71
|
+
export type Glyph = {
|
|
72
|
+
kind: "bullet";
|
|
73
|
+
} | {
|
|
74
|
+
kind: "taskBox";
|
|
75
|
+
checked: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
kind: "rule";
|
|
78
|
+
} | {
|
|
79
|
+
kind: "cellBorder";
|
|
80
|
+
} | {
|
|
81
|
+
kind: "lineBreak";
|
|
82
|
+
} | {
|
|
83
|
+
kind: "footnote";
|
|
84
|
+
id: string;
|
|
85
|
+
number: number;
|
|
86
|
+
} | {
|
|
87
|
+
kind: "formula";
|
|
88
|
+
source: string;
|
|
89
|
+
} | {
|
|
90
|
+
kind: "block";
|
|
91
|
+
block: DrawnBlock;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Syntax that hides while the selection is off `reveal`, and may draw
|
|
95
|
+
* something in its place. With no `reveal` it always shows, as an ordered
|
|
96
|
+
* list's number does.
|
|
97
|
+
*/
|
|
98
|
+
export interface Marker {
|
|
99
|
+
range: Range;
|
|
100
|
+
reveal?: Range;
|
|
101
|
+
glyph?: Glyph;
|
|
102
|
+
/** A line that folds away while the marker hides. */
|
|
103
|
+
fold?: number;
|
|
104
|
+
}
|
|
105
|
+
/** A fence's lines, from the first through the last. */
|
|
106
|
+
export interface Fence {
|
|
107
|
+
first: number;
|
|
108
|
+
last: number;
|
|
109
|
+
}
|
|
110
|
+
/** The code of a top-level fence that names its language. */
|
|
111
|
+
export interface FenceCode {
|
|
112
|
+
lang: string;
|
|
113
|
+
range: Range;
|
|
114
|
+
}
|
|
115
|
+
export type Align = "none" | "left" | "center" | "right";
|
|
116
|
+
export interface Row {
|
|
117
|
+
range: Range;
|
|
118
|
+
/** Each cell's text without the spaces around it. */
|
|
119
|
+
cells: Range[];
|
|
120
|
+
}
|
|
121
|
+
/** A table, which a view lays out as a grid around its cells' text. */
|
|
122
|
+
export interface Table {
|
|
123
|
+
range: Range;
|
|
124
|
+
align: Align[];
|
|
125
|
+
delimiter: Range;
|
|
126
|
+
/** The header row first. */
|
|
127
|
+
rows: Row[];
|
|
128
|
+
}
|
|
129
|
+
/** A link: `url` for an inline target, `ref` for a reference link's id. */
|
|
130
|
+
export interface Link {
|
|
131
|
+
range: Range;
|
|
132
|
+
url?: string;
|
|
133
|
+
ref?: string;
|
|
134
|
+
}
|
|
135
|
+
export interface LinkDefinition {
|
|
136
|
+
/** The normalized label a reference matches on. */
|
|
137
|
+
id: string;
|
|
138
|
+
/** The label as written. */
|
|
139
|
+
label: string;
|
|
140
|
+
url: string;
|
|
141
|
+
}
|
|
142
|
+
export interface NoteDefinition {
|
|
143
|
+
id: string;
|
|
144
|
+
label: string;
|
|
145
|
+
}
|
|
146
|
+
export interface Definitions {
|
|
147
|
+
links: LinkDefinition[];
|
|
148
|
+
notes: NoteDefinition[];
|
|
149
|
+
}
|
|
150
|
+
/** How a text looks. Only which markers show depends on the selection. */
|
|
151
|
+
export interface Look {
|
|
152
|
+
spans: Span[];
|
|
153
|
+
lines: LineLook[];
|
|
154
|
+
markers: Marker[];
|
|
155
|
+
fences: Fence[];
|
|
156
|
+
code: FenceCode[];
|
|
157
|
+
tables: Table[];
|
|
158
|
+
links: Link[];
|
|
159
|
+
defines: Definitions;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* One block's look. `range` is where the block is in the whole text, and
|
|
163
|
+
* the look counts from the block's start: offsets from `range.from`, lines
|
|
164
|
+
* from `line`.
|
|
165
|
+
*/
|
|
166
|
+
export interface BlockLook {
|
|
167
|
+
range: Range;
|
|
168
|
+
line: number;
|
|
169
|
+
look: Look;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Which blocks a change drew differently, by index. The blocks from `at`
|
|
173
|
+
* up to `at + removed` before the change are gone, the ones from `at` up to
|
|
174
|
+
* `at + added` after it stand in their place, and the ones in `reread` kept
|
|
175
|
+
* their text but read differently.
|
|
176
|
+
*/
|
|
177
|
+
export interface Changed {
|
|
178
|
+
at: number;
|
|
179
|
+
removed: number;
|
|
180
|
+
added: number;
|
|
181
|
+
reread: number[];
|
|
182
|
+
}
|
|
183
|
+
/** One replacement, by its range in the text before the edit. */
|
|
184
|
+
export interface Change {
|
|
185
|
+
range: Range;
|
|
186
|
+
insert: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* What a key does: changes that don't overlap, in text order, and where the
|
|
190
|
+
* selection goes in the text after them.
|
|
191
|
+
*/
|
|
192
|
+
export interface Edit {
|
|
193
|
+
changes: Change[];
|
|
194
|
+
selection: Range;
|
|
195
|
+
}
|
|
196
|
+
/** A key that means something in Markdown. */
|
|
197
|
+
export type Key = "Enter" | "Tab" | "ShiftTab" | "Backspace";
|
|
198
|
+
/** A block the app draws itself: `{ fence: "mermaid" }` or `{ directive: "note" }`. */
|
|
199
|
+
export type BlockRule = {
|
|
200
|
+
fence: string;
|
|
201
|
+
} | {
|
|
202
|
+
directive: string;
|
|
203
|
+
};
|
|
204
|
+
/** What the look draws. */
|
|
205
|
+
export interface Options {
|
|
206
|
+
/** Fence lines, a heading's underline and a table's delimiter row fold. */
|
|
207
|
+
foldLines: boolean;
|
|
208
|
+
/** A list's `-`, `*` or `+` draws as a bullet. */
|
|
209
|
+
bullets: boolean;
|
|
210
|
+
/** A task's `[ ]` or `[x]` draws as a box. */
|
|
211
|
+
tasks: boolean;
|
|
212
|
+
/** `$x$` and `$$` blocks draw as formulas. */
|
|
213
|
+
math: boolean;
|
|
214
|
+
/** A picture on a line of its own draws. */
|
|
215
|
+
images: boolean;
|
|
216
|
+
/** Raw HTML that a rendered reply would draw draws. */
|
|
217
|
+
html: boolean;
|
|
218
|
+
/** Blocks the app draws itself. */
|
|
219
|
+
blocks: BlockRule[];
|
|
220
|
+
}
|
|
221
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,gCAAgC","sourcesContent":["// SPDX-License-Identifier: MIT\n// Copyright (c) 2026 Max Boksem\n\n// The shapes the core hands a page. Every offset counts UTF-16 code units,\n// as a JavaScript string does, and every line counts from 0.\n\n/** A run of the text, from `from` up to but not including `to`. */\nexport interface Range {\n from: number;\n to: number;\n}\n\n/**\n * An inline style. `tag` is what a paired HTML tag such as `<kbd>` holds,\n * with the tag's name in the span's `tag`.\n */\nexport type SpanStyle =\n | \"strong\"\n | \"emphasis\"\n | \"strike\"\n | \"code\"\n | \"link\"\n | \"done\"\n | \"comment\"\n | \"tag\";\n\nexport interface Span {\n range: Range;\n style: SpanStyle;\n /** The tag's name, for a `tag` span. */\n tag?: string;\n}\n\n/** A line of a fence or a formula block. */\nexport interface CodeLine {\n first: boolean;\n last: boolean;\n /** One of the block's own fence lines, not its code. */\n fence: boolean;\n}\n\n/** A line's block style. A line can be in a quote and a fence at once. */\nexport interface LineLook {\n line: number;\n /** A heading's level as written, 1 through 6. */\n heading?: number;\n /** How many quotes deep the line is. */\n quote: number;\n code?: CodeLine;\n /** A thematic break on a line of its own. */\n rule: boolean;\n /** A ticked task's line. */\n taskDone: boolean;\n /** A callout's kind in lower case, such as `note` for `> [!NOTE]`. */\n callout?: string;\n table: boolean;\n}\n\ninterface DrawnBlockBase {\n /** What it draws from, such as the formula without its `$$` lines. */\n source: string;\n /** Its first line. */\n first: number;\n /** Its last line. */\n last: number;\n /** Where the caret goes to edit it. */\n caret: number;\n}\n\n/** A block on lines of its own, drawn whole while the selection is off it. */\nexport type DrawnBlock = DrawnBlockBase &\n (\n | { kind: \"math\" }\n | { kind: \"image\"; url: string; alt: string }\n | { kind: \"callout\"; callout: string }\n | { kind: \"html\" }\n | { kind: \"fence\"; info: string }\n | { kind: \"directive\"; name: string; attributes: string }\n );\n\n/** What draws in a hidden marker's place. */\nexport type Glyph =\n | { kind: \"bullet\" }\n | { kind: \"taskBox\"; checked: boolean }\n | { kind: \"rule\" }\n | { kind: \"cellBorder\" }\n | { kind: \"lineBreak\" }\n | { kind: \"footnote\"; id: string; number: number }\n | { kind: \"formula\"; source: string }\n | { kind: \"block\"; block: DrawnBlock };\n\n/**\n * Syntax that hides while the selection is off `reveal`, and may draw\n * something in its place. With no `reveal` it always shows, as an ordered\n * list's number does.\n */\nexport interface Marker {\n range: Range;\n reveal?: Range;\n glyph?: Glyph;\n /** A line that folds away while the marker hides. */\n fold?: number;\n}\n\n/** A fence's lines, from the first through the last. */\nexport interface Fence {\n first: number;\n last: number;\n}\n\n/** The code of a top-level fence that names its language. */\nexport interface FenceCode {\n lang: string;\n range: Range;\n}\n\nexport type Align = \"none\" | \"left\" | \"center\" | \"right\";\n\nexport interface Row {\n range: Range;\n /** Each cell's text without the spaces around it. */\n cells: Range[];\n}\n\n/** A table, which a view lays out as a grid around its cells' text. */\nexport interface Table {\n range: Range;\n align: Align[];\n delimiter: Range;\n /** The header row first. */\n rows: Row[];\n}\n\n/** A link: `url` for an inline target, `ref` for a reference link's id. */\nexport interface Link {\n range: Range;\n url?: string;\n ref?: string;\n}\n\nexport interface LinkDefinition {\n /** The normalized label a reference matches on. */\n id: string;\n /** The label as written. */\n label: string;\n url: string;\n}\n\nexport interface NoteDefinition {\n id: string;\n label: string;\n}\n\nexport interface Definitions {\n links: LinkDefinition[];\n notes: NoteDefinition[];\n}\n\n/** How a text looks. Only which markers show depends on the selection. */\nexport interface Look {\n spans: Span[];\n lines: LineLook[];\n markers: Marker[];\n fences: Fence[];\n code: FenceCode[];\n tables: Table[];\n links: Link[];\n defines: Definitions;\n}\n\n/**\n * One block's look. `range` is where the block is in the whole text, and\n * the look counts from the block's start: offsets from `range.from`, lines\n * from `line`.\n */\nexport interface BlockLook {\n range: Range;\n line: number;\n look: Look;\n}\n\n/**\n * Which blocks a change drew differently, by index. The blocks from `at`\n * up to `at + removed` before the change are gone, the ones from `at` up to\n * `at + added` after it stand in their place, and the ones in `reread` kept\n * their text but read differently.\n */\nexport interface Changed {\n at: number;\n removed: number;\n added: number;\n reread: number[];\n}\n\n/** One replacement, by its range in the text before the edit. */\nexport interface Change {\n range: Range;\n insert: string;\n}\n\n/**\n * What a key does: changes that don't overlap, in text order, and where the\n * selection goes in the text after them.\n */\nexport interface Edit {\n changes: Change[];\n selection: Range;\n}\n\n/** A key that means something in Markdown. */\nexport type Key = \"Enter\" | \"Tab\" | \"ShiftTab\" | \"Backspace\";\n\n/** A block the app draws itself: `{ fence: \"mermaid\" }` or `{ directive: \"note\" }`. */\nexport type BlockRule = { fence: string } | { directive: string };\n\n/** What the look draws. */\nexport interface Options {\n /** Fence lines, a heading's underline and a table's delimiter row fold. */\n foldLines: boolean;\n /** A list's `-`, `*` or `+` draws as a bullet. */\n bullets: boolean;\n /** A task's `[ ]` or `[x]` draws as a box. */\n tasks: boolean;\n /** `$x$` and `$$` blocks draw as formulas. */\n math: boolean;\n /** A picture on a line of its own draws. */\n images: boolean;\n /** Raw HTML that a rendered reply would draw draws. */\n html: boolean;\n /** Blocks the app draws itself. */\n blocks: BlockRule[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const wasmBase64: string;
|