@nerd-bible/wordgard 0.6.2-beta7 → 0.6.2-beta8
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/doc.js +2 -0
- package/dist/editor.d.ts +3 -2
- package/dist/editor.js +21 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/table.d.ts +111 -1
- package/dist/table.js +31 -22
- package/package.json +1 -1
package/dist/doc.js
CHANGED
|
@@ -1392,6 +1392,8 @@ class Plot {
|
|
|
1392
1392
|
constructor(type, param, marks) {
|
|
1393
1393
|
super(param, marks);
|
|
1394
1394
|
this.type = type;
|
|
1395
|
+
if (this.type.isDoc && marks.length)
|
|
1396
|
+
throw new Error("Document nodes cannot have marks");
|
|
1395
1397
|
}
|
|
1396
1398
|
static new(type, param, marks) {
|
|
1397
1399
|
return new Tag(type, param, marks);
|
package/dist/editor.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { PointSet, Set, RangeSet } from 'wordgard/set';
|
|
|
8
8
|
|
|
9
9
|
type MakeSelectionStyle = (wg: Wordgard, event: MouseEvent) => Wordgard.MouseSelectionStyle | null;
|
|
10
10
|
|
|
11
|
+
import Mark_ = Mark;
|
|
11
12
|
/**
|
|
12
13
|
A widget describes a piece of DOM content that can be used to
|
|
13
14
|
render a node, a part of a node, or an extra element added via a
|
|
@@ -193,8 +194,8 @@ declare namespace Decoration {
|
|
|
193
194
|
/**
|
|
194
195
|
Override the shape used for a given mark inside the editor.
|
|
195
196
|
*/
|
|
196
|
-
function shape<V>(type:
|
|
197
|
-
function shape(mark:
|
|
197
|
+
function shape<V>(type: Mark_.Type<V>, shape: Shape.Element<V> | Shape.Attribute<V> | Shape.Attributes<V>): GardState.Extension;
|
|
198
|
+
function shape(mark: Mark_<null>, shape: Shape.Element<null> | Shape.Attribute<null> | Shape.Attributes<null>): GardState.Extension;
|
|
198
199
|
}
|
|
199
200
|
/**
|
|
200
201
|
A point decoration is a decoration that targets a given position
|
package/dist/editor.js
CHANGED
|
@@ -132,6 +132,7 @@ function joinRanges(ranges) {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
var Mark_ = Mark;
|
|
135
136
|
class Widget {
|
|
136
137
|
value;
|
|
137
138
|
constructor(type,
|
|
@@ -286,15 +287,15 @@ const Decoration = /*@__PURE__*/(function (Decoration) {
|
|
|
286
287
|
}
|
|
287
288
|
Tag.attribute = attribute;
|
|
288
289
|
})(Decoration.Tag || (Decoration.Tag = {}));
|
|
289
|
-
(function (Mark
|
|
290
|
+
(function (Mark) {
|
|
290
291
|
function shape(type, shape) {
|
|
291
|
-
if (type instanceof
|
|
292
|
+
if (type instanceof Mark_)
|
|
292
293
|
type = type.type;
|
|
293
294
|
if (type.spanning && !("element" in shape))
|
|
294
295
|
throw new Error("Spanning marks must have an element shape");
|
|
295
|
-
return markShape.of({ type, modified:
|
|
296
|
+
return markShape.of({ type, modified: Mark_.Type.define(type.name, { ...type.spec, shape }) });
|
|
296
297
|
}
|
|
297
|
-
Mark
|
|
298
|
+
Mark.shape = shape;
|
|
298
299
|
})(Decoration.Mark || (Decoration.Mark = {}));
|
|
299
300
|
class Point {
|
|
300
301
|
constructor() { }
|
|
@@ -763,15 +764,17 @@ class DecoIterator {
|
|
|
763
764
|
shape = applyDeco(shape, deco, node.tag);
|
|
764
765
|
let wrappers = this.nodeWrappers(node.tag, iter.active, !shape.hasContent);
|
|
765
766
|
let atom = !shape.hasContent;
|
|
766
|
-
if (atom)
|
|
767
|
+
if (atom) {
|
|
767
768
|
walker.node(node, shape, wrappers, pos + node.length > to ? to - pos : undefined);
|
|
768
|
-
|
|
769
|
+
}
|
|
770
|
+
else {
|
|
769
771
|
walker.enter(node, shape, wrappers);
|
|
770
|
-
|
|
772
|
+
this.widgets(node.tag, 2, walker);
|
|
773
|
+
}
|
|
771
774
|
return !atom;
|
|
772
775
|
},
|
|
773
776
|
leavePlot: tag => {
|
|
774
|
-
if (started)
|
|
777
|
+
if (started && !atomParent)
|
|
775
778
|
this.widgets(tag, 3, walker);
|
|
776
779
|
else
|
|
777
780
|
started = true;
|
|
@@ -779,7 +782,7 @@ class DecoIterator {
|
|
|
779
782
|
this.widgets(tag, 1, walker);
|
|
780
783
|
}
|
|
781
784
|
};
|
|
782
|
-
if (inclusiveStart) {
|
|
785
|
+
if (inclusiveStart && !atomParent) {
|
|
783
786
|
let before = pos.nodeBefore;
|
|
784
787
|
if (before)
|
|
785
788
|
this.widgets(before.tag, 1, walker);
|
|
@@ -791,9 +794,10 @@ class DecoIterator {
|
|
|
791
794
|
let end = Math.min(to, atomParent.after), done = atomParent.after <= to;
|
|
792
795
|
walker.nodePart(atomParent.node, end - pos.pos, done);
|
|
793
796
|
pos = pos.advance(end - pos.pos);
|
|
794
|
-
if (done)
|
|
797
|
+
if (done) {
|
|
795
798
|
this.widgets(atomParent.node.tag, 1, walker);
|
|
796
|
-
|
|
799
|
+
atomParent = undefined;
|
|
800
|
+
}
|
|
797
801
|
while (iter.point && iter.from < end)
|
|
798
802
|
iter.next();
|
|
799
803
|
}
|
|
@@ -2082,6 +2086,9 @@ class ContentUpdate {
|
|
|
2082
2086
|
this.partialNode = null;
|
|
2083
2087
|
this.new.addChild(this.buildNodeShape(tag, length + (to - from), shape, reuse));
|
|
2084
2088
|
}
|
|
2089
|
+
else {
|
|
2090
|
+
this.partialNode.length += to - from;
|
|
2091
|
+
}
|
|
2085
2092
|
}
|
|
2086
2093
|
}
|
|
2087
2094
|
else if (this.new.lastChild instanceof TextTile && !this.new.lastChild.isComposition) {
|
|
@@ -2295,6 +2302,9 @@ class ContentUpdate {
|
|
|
2295
2302
|
for (let i = 0; i < wrappers; i++)
|
|
2296
2303
|
this.up();
|
|
2297
2304
|
}
|
|
2305
|
+
else {
|
|
2306
|
+
this.partialNode.length += length;
|
|
2307
|
+
}
|
|
2298
2308
|
},
|
|
2299
2309
|
widget: (widget, side) => {
|
|
2300
2310
|
let sideFlag = side < 0 ? 32 : side > 0 ? 64 : 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +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
|
|
5
|
+
export * as highlightCode from "wordgard/highlight-code"
|
|
6
6
|
export * as history from "wordgard/history"
|
|
7
7
|
export * as phrases from "wordgard/phrases"
|
|
8
8
|
export * as schema from "wordgard/schema"
|
package/dist/index.js
CHANGED
|
@@ -2,7 +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
|
|
5
|
+
export * as highlightCode from "wordgard/highlight-code"
|
|
6
6
|
export * as history from "wordgard/history"
|
|
7
7
|
export * as phrases from "wordgard/phrases"
|
|
8
8
|
export * as schema from "wordgard/schema"
|
package/dist/table.d.ts
CHANGED
|
@@ -175,6 +175,116 @@ declare class CellSelection extends GardSelection {
|
|
|
175
175
|
static extension: GardState.Extension;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
/**
|
|
179
|
+
A table map describes the structore of a given table.
|
|
180
|
+
*/
|
|
181
|
+
declare class TableMap {
|
|
182
|
+
/**
|
|
183
|
+
The start position of the table's content.
|
|
184
|
+
*/
|
|
185
|
+
readonly start: number;
|
|
186
|
+
/**
|
|
187
|
+
Get a table map for the given table node. Will reuse known
|
|
188
|
+
structure of unchanged tables across document changes.
|
|
189
|
+
*/
|
|
190
|
+
static get(table: Plot, start: number): TableMap;
|
|
191
|
+
private constructor();
|
|
192
|
+
/**
|
|
193
|
+
The number of columns in this table.
|
|
194
|
+
*/
|
|
195
|
+
get width(): number;
|
|
196
|
+
/**
|
|
197
|
+
The number of rows in the table.
|
|
198
|
+
*/
|
|
199
|
+
get height(): number;
|
|
200
|
+
/**
|
|
201
|
+
The table plot.
|
|
202
|
+
*/
|
|
203
|
+
get table(): Plot;
|
|
204
|
+
/**
|
|
205
|
+
The document position before the table.
|
|
206
|
+
*/
|
|
207
|
+
get tablePos(): number;
|
|
208
|
+
/**
|
|
209
|
+
Find the dimensions of the cell at the given position.
|
|
210
|
+
*/
|
|
211
|
+
cellRect(pos: number): TableMap.Rect;
|
|
212
|
+
/**
|
|
213
|
+
Find the end position of the given cell.
|
|
214
|
+
*/
|
|
215
|
+
cellEnd(pos: number): number;
|
|
216
|
+
/**
|
|
217
|
+
Get the rectangle spanning the two given cells.
|
|
218
|
+
*/
|
|
219
|
+
rectBetween(a: number, b: number): TableMap.Rect;
|
|
220
|
+
/**
|
|
221
|
+
Return the position of all cells that have their top start
|
|
222
|
+
corner in the given rectangle.
|
|
223
|
+
*/
|
|
224
|
+
cellsInRect(rect: TableMap.Rect): number[];
|
|
225
|
+
/**
|
|
226
|
+
Return the position of the cell that occupies the position at the
|
|
227
|
+
given row and column (which must be in bounds for the table).
|
|
228
|
+
*/
|
|
229
|
+
cellAt(col: number, row: number): number | null;
|
|
230
|
+
/**
|
|
231
|
+
Get the position at the start of the given row (which may be
|
|
232
|
+
`width` to query the position after the last row).
|
|
233
|
+
*/
|
|
234
|
+
rowPos(row: number): number;
|
|
235
|
+
/**
|
|
236
|
+
Get the position where a cell would have to be inserted to
|
|
237
|
+
appear at the given column and row.
|
|
238
|
+
*/
|
|
239
|
+
cellInsertionPos(col: number, row: number): number;
|
|
240
|
+
/**
|
|
241
|
+
Get the node for the cell at the given position.
|
|
242
|
+
*/
|
|
243
|
+
getCell(pos: number): Plot;
|
|
244
|
+
}
|
|
245
|
+
declare namespace TableMap {
|
|
246
|
+
/**
|
|
247
|
+
Data type used for a rectangular area in a table.
|
|
248
|
+
*/
|
|
249
|
+
class Rect {
|
|
250
|
+
/**
|
|
251
|
+
Starting column of the rectangle.
|
|
252
|
+
*/
|
|
253
|
+
readonly startCol: number;
|
|
254
|
+
/**
|
|
255
|
+
Starting row.
|
|
256
|
+
*/
|
|
257
|
+
readonly startRow: number;
|
|
258
|
+
/**
|
|
259
|
+
The end column. Non-inclusive. Always higher than
|
|
260
|
+
`startCol`.
|
|
261
|
+
*/
|
|
262
|
+
readonly endCol: number;
|
|
263
|
+
/**
|
|
264
|
+
The end row. Non-inclusive. Always higher than `startRow`.
|
|
265
|
+
*/
|
|
266
|
+
readonly endRow: number;
|
|
267
|
+
constructor(
|
|
268
|
+
/**
|
|
269
|
+
Starting column of the rectangle.
|
|
270
|
+
*/
|
|
271
|
+
startCol: number,
|
|
272
|
+
/**
|
|
273
|
+
Starting row.
|
|
274
|
+
*/
|
|
275
|
+
startRow: number,
|
|
276
|
+
/**
|
|
277
|
+
The end column. Non-inclusive. Always higher than
|
|
278
|
+
`startCol`.
|
|
279
|
+
*/
|
|
280
|
+
endCol: number,
|
|
281
|
+
/**
|
|
282
|
+
The end row. Non-inclusive. Always higher than `startRow`.
|
|
283
|
+
*/
|
|
284
|
+
endRow: number);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
178
288
|
declare const toggleHeaderCell: Command.Pure;
|
|
179
289
|
/**
|
|
180
290
|
Add a column at the given side of the selection. The selection may
|
|
@@ -213,4 +323,4 @@ declare const splitCell: Command.Pure;
|
|
|
213
323
|
*/
|
|
214
324
|
declare function handleTablePaste(state: GardState, slice: Slice, drop?: number): false | Transaction.Spec;
|
|
215
325
|
|
|
216
|
-
export { CellSelection, addColumn, addRow, deleteColumn, deleteRow, handleTablePaste, mergeCells, splitCell, tableMenu, tables, toggleHeaderCell };
|
|
326
|
+
export { CellSelection, TableMap, addColumn, addRow, deleteColumn, deleteRow, handleTablePaste, mergeCells, splitCell, tableMenu, tables, toggleHeaderCell };
|
package/dist/table.js
CHANGED
|
@@ -5,18 +5,6 @@ import { Node, Slice, ValidationError, Token, ChangeSet } from 'wordgard/doc';
|
|
|
5
5
|
import { Command, moveByUnit, moveByWord, moveByLine, moveToLineSide, Menu } from 'wordgard/command';
|
|
6
6
|
import { tablePhrases } from 'wordgard/phrases';
|
|
7
7
|
|
|
8
|
-
class Rect {
|
|
9
|
-
startCol;
|
|
10
|
-
startRow;
|
|
11
|
-
endCol;
|
|
12
|
-
endRow;
|
|
13
|
-
constructor(startCol, startRow, endCol, endRow) {
|
|
14
|
-
this.startCol = startCol;
|
|
15
|
-
this.startRow = startRow;
|
|
16
|
-
this.endCol = endCol;
|
|
17
|
-
this.endRow = endRow;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
8
|
class MapData {
|
|
21
9
|
table;
|
|
22
10
|
width;
|
|
@@ -37,7 +25,15 @@ let cache = /*@__PURE__*/(() => new WeakMap())();
|
|
|
37
25
|
class TableMap {
|
|
38
26
|
start;
|
|
39
27
|
data;
|
|
40
|
-
|
|
28
|
+
static get(table, start) {
|
|
29
|
+
let data = cache.get(table);
|
|
30
|
+
if (!data)
|
|
31
|
+
cache.set(table, data = computeMap(table));
|
|
32
|
+
return new TableMap(start, data);
|
|
33
|
+
}
|
|
34
|
+
constructor(
|
|
35
|
+
start,
|
|
36
|
+
data) {
|
|
41
37
|
this.start = start;
|
|
42
38
|
this.data = data;
|
|
43
39
|
}
|
|
@@ -55,7 +51,7 @@ class TableMap {
|
|
|
55
51
|
endCol++;
|
|
56
52
|
for (let j = 1; endRow < height && map[i + (width * j)] == localPos; j++)
|
|
57
53
|
endRow++;
|
|
58
|
-
return new Rect(startCol, startRow, endCol, endRow);
|
|
54
|
+
return new TableMap.Rect(startCol, startRow, endCol, endRow);
|
|
59
55
|
}
|
|
60
56
|
throw new RangeError(`No cell with offset ${pos} found`);
|
|
61
57
|
}
|
|
@@ -87,7 +83,7 @@ class TableMap {
|
|
|
87
83
|
rectBetween(a, b) {
|
|
88
84
|
let { startCol: startColA, endCol: endColA, startRow: startRowA, endRow: endRowA } = this.cellRect(a);
|
|
89
85
|
let { startCol: startColB, endCol: endColB, startRow: startRowB, endRow: endRowB } = this.cellRect(b);
|
|
90
|
-
return new Rect(Math.min(startColA, startColB), Math.min(startRowA, startRowB), Math.max(endColA, endColB), Math.max(endRowA, endRowB));
|
|
86
|
+
return new TableMap.Rect(Math.min(startColA, startColB), Math.min(startRowA, startRowB), Math.max(endColA, endColB), Math.max(endRowA, endRowB));
|
|
91
87
|
}
|
|
92
88
|
cellsInRect(rect) {
|
|
93
89
|
let result = [], { map, width } = this.data;
|
|
@@ -148,13 +144,26 @@ class TableMap {
|
|
|
148
144
|
}
|
|
149
145
|
return false;
|
|
150
146
|
}
|
|
151
|
-
static get(table, start) {
|
|
152
|
-
let data = cache.get(table);
|
|
153
|
-
if (!data)
|
|
154
|
-
cache.set(table, data = computeMap(table));
|
|
155
|
-
return new TableMap(start, data);
|
|
156
|
-
}
|
|
157
147
|
}
|
|
148
|
+
;TableMap = /*@__PURE__*/(function (TableMap) {
|
|
149
|
+
class Rect {
|
|
150
|
+
startCol;
|
|
151
|
+
startRow;
|
|
152
|
+
endCol;
|
|
153
|
+
endRow;
|
|
154
|
+
constructor(
|
|
155
|
+
startCol,
|
|
156
|
+
startRow,
|
|
157
|
+
endCol,
|
|
158
|
+
endRow) {
|
|
159
|
+
this.startCol = startCol;
|
|
160
|
+
this.startRow = startRow;
|
|
161
|
+
this.endCol = endCol;
|
|
162
|
+
this.endRow = endRow;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
TableMap.Rect = Rect;
|
|
166
|
+
;return TableMap})(TableMap);
|
|
158
167
|
function sameCell(a, b) {
|
|
159
168
|
return a != 0 && a == b;
|
|
160
169
|
}
|
|
@@ -1318,4 +1327,4 @@ function tables(config = {}) {
|
|
|
1318
1327
|
tables.dropHandler = tableDropHandler;
|
|
1319
1328
|
;return tables})(tables);
|
|
1320
1329
|
|
|
1321
|
-
export { CellSelection, addColumn, addRow, deleteColumn, deleteRow, handleTablePaste, mergeCells, splitCell, tableMenu, tables, toggleHeaderCell };
|
|
1330
|
+
export { CellSelection, TableMap, addColumn, addRow, deleteColumn, deleteRow, handleTablePaste, mergeCells, splitCell, tableMenu, tables, toggleHeaderCell };
|