@nerd-bible/wordgard 0.6.2-beta8 → 0.6.2-beta9
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/collab.js +3 -0
- package/dist/command.js +6 -2
- package/dist/doc.d.ts +13 -2
- package/dist/doc.js +38 -18
- package/dist/editor.d.ts +13 -2
- package/dist/editor.js +167 -84
- package/dist/history.js +7 -2
- package/dist/phrases.js +1 -0
- package/dist/schema.js +11 -8
- package/dist/set.js +11 -7
- package/dist/state.d.ts +49 -4
- package/dist/state.js +90 -31
- package/dist/table.js +1 -0
- package/package.json +1 -1
package/dist/collab.js
CHANGED
|
@@ -37,6 +37,7 @@ class CollabState {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
const collabConfig = /*@__PURE__*/GardState.Facet.define({
|
|
40
|
+
name: "collabConfig",
|
|
40
41
|
combine(configs) {
|
|
41
42
|
let combined = GardState.Facet.combineConfig(configs, {
|
|
42
43
|
startVersion: 0,
|
|
@@ -52,12 +53,14 @@ const collabConfig = /*@__PURE__*/GardState.Facet.define({
|
|
|
52
53
|
}
|
|
53
54
|
});
|
|
54
55
|
const collabReceive = /*@__PURE__*/Transaction.Effect.define({
|
|
56
|
+
name: "collabReceive",
|
|
55
57
|
map(state, changes) {
|
|
56
58
|
return changes.empty ? state
|
|
57
59
|
: new CollabState(state.version, state.syncedDoc, state.nextUpdate, addUpdate(state.openUpdate, changes));
|
|
58
60
|
}
|
|
59
61
|
});
|
|
60
62
|
const collabField = /*@__PURE__*/GardState.Field.define({
|
|
63
|
+
name: "collab",
|
|
61
64
|
create(state) {
|
|
62
65
|
return new CollabState(state.facet(collabConfig).startVersion, state.doc, null, null);
|
|
63
66
|
},
|
package/dist/command.js
CHANGED
|
@@ -5,6 +5,7 @@ import { findClusterBreak } from '@marijn/find-cluster-break';
|
|
|
5
5
|
import { Alignment, Direction, Emphasis, Strong, Underline } from 'wordgard/types';
|
|
6
6
|
|
|
7
7
|
const commandHandler = /*@__PURE__*/GardState.Facet.define({
|
|
8
|
+
name: "commandHandler",
|
|
8
9
|
combine(handlers) {
|
|
9
10
|
let map = new Map();
|
|
10
11
|
for (let [cmd, handler] of handlers) {
|
|
@@ -834,8 +835,9 @@ const deleteToLineEnd = (wg, dir) => {
|
|
|
834
835
|
userEvent: "delete." + dir
|
|
835
836
|
};
|
|
836
837
|
};
|
|
837
|
-
const addToKillBuffer = /*@__PURE__*/Transaction.Effect.define();
|
|
838
|
+
const addToKillBuffer = /*@__PURE__*/Transaction.Effect.define({ name: "addToKillBuffer" });
|
|
838
839
|
const killBuffer = /*@__PURE__*/GardState.Field.define({
|
|
840
|
+
name: "killBuffer",
|
|
839
841
|
create() { return { content: [], active: false }; },
|
|
840
842
|
update(value, tr) {
|
|
841
843
|
let add = tr.effects.find(e => e.is(addToKillBuffer));
|
|
@@ -1318,9 +1320,10 @@ const Menu = /*@__PURE__*/(function (Menu) {
|
|
|
1318
1320
|
let src = Menu.Item.source.of(this);
|
|
1319
1321
|
this.extension = this.parent ? [src, this.parent] : src;
|
|
1320
1322
|
}
|
|
1323
|
+
toString() { return "Menu.Item"; }
|
|
1321
1324
|
}
|
|
1322
1325
|
Item.Base = Base;
|
|
1323
|
-
Item.source = GardState.Facet.define();
|
|
1326
|
+
Item.source = GardState.Facet.define({ name: "menuItem" });
|
|
1324
1327
|
})(Item = Menu.Item || (Menu.Item = {}));
|
|
1325
1328
|
class Button extends Item.Base {
|
|
1326
1329
|
spec;
|
|
@@ -1395,6 +1398,7 @@ const Menu = /*@__PURE__*/(function (Menu) {
|
|
|
1395
1398
|
template(...content) {
|
|
1396
1399
|
return Template.new(this, content.length ? content : ["..."]);
|
|
1397
1400
|
}
|
|
1401
|
+
toString() { return "Menu.Group"; }
|
|
1398
1402
|
}
|
|
1399
1403
|
Menu.Group = Group;
|
|
1400
1404
|
(function (Group) {
|
package/dist/doc.d.ts
CHANGED
|
@@ -1310,12 +1310,19 @@ declare namespace Node {
|
|
|
1310
1310
|
implies membership of its parent groups.
|
|
1311
1311
|
*/
|
|
1312
1312
|
readonly parent: Group | undefined;
|
|
1313
|
+
/**
|
|
1314
|
+
This group's debug name.
|
|
1315
|
+
*/
|
|
1316
|
+
readonly name: string | null;
|
|
1313
1317
|
private tag;
|
|
1314
1318
|
private constructor();
|
|
1315
1319
|
/**
|
|
1316
1320
|
Define a custom node group.
|
|
1317
1321
|
*/
|
|
1318
|
-
static define(
|
|
1322
|
+
static define(spec?: {
|
|
1323
|
+
parent?: Group;
|
|
1324
|
+
name?: string;
|
|
1325
|
+
}): Group;
|
|
1319
1326
|
/**
|
|
1320
1327
|
A group that contains every node type.
|
|
1321
1328
|
*/
|
|
@@ -1374,11 +1381,15 @@ declare namespace Node {
|
|
|
1374
1381
|
whether a given node has the role attached.
|
|
1375
1382
|
*/
|
|
1376
1383
|
class Role {
|
|
1384
|
+
/**
|
|
1385
|
+
This role's name.
|
|
1386
|
+
*/
|
|
1387
|
+
readonly name: string | null;
|
|
1377
1388
|
private constructor();
|
|
1378
1389
|
/**
|
|
1379
1390
|
Define a new role.
|
|
1380
1391
|
*/
|
|
1381
|
-
static define(): Role;
|
|
1392
|
+
static define(name?: string): Role;
|
|
1382
1393
|
/**
|
|
1383
1394
|
This role indicates that a plot contains code, and makes some
|
|
1384
1395
|
commands behave differently inside such a plot.
|
package/dist/doc.js
CHANGED
|
@@ -867,8 +867,8 @@ class Pos {
|
|
|
867
867
|
let d = this.depth;
|
|
868
868
|
if (depth > d)
|
|
869
869
|
throw new RangeError("Asking for parent deeper than position depth");
|
|
870
|
-
for (let
|
|
871
|
-
if (d == depth)
|
|
870
|
+
for (let p = this.parent;; p = p.parent)
|
|
871
|
+
if (d-- == depth)
|
|
872
872
|
return p;
|
|
873
873
|
}
|
|
874
874
|
isAtStart(parent) {
|
|
@@ -1093,6 +1093,7 @@ class BaseType {
|
|
|
1093
1093
|
get isBlock() { return (this.flags & 1) == 0; }
|
|
1094
1094
|
get isAtom() { return (this.flags & 4) > 0; }
|
|
1095
1095
|
get isSelectable() { return (this.flags & 32) > 0; }
|
|
1096
|
+
toString() { return this.name; }
|
|
1096
1097
|
}
|
|
1097
1098
|
class BaseTag {
|
|
1098
1099
|
param;
|
|
@@ -1131,29 +1132,48 @@ const Node = /*@__PURE__*/(function (Node) {
|
|
|
1131
1132
|
})(Node.Type || (Node.Type = {}));
|
|
1132
1133
|
class Group {
|
|
1133
1134
|
parent;
|
|
1135
|
+
name;
|
|
1134
1136
|
constructor(
|
|
1135
|
-
parent
|
|
1137
|
+
parent,
|
|
1138
|
+
name) {
|
|
1136
1139
|
this.parent = parent;
|
|
1140
|
+
this.name = name;
|
|
1137
1141
|
}
|
|
1138
|
-
static define(
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
static
|
|
1142
|
-
static
|
|
1143
|
-
static
|
|
1144
|
-
static
|
|
1145
|
-
static
|
|
1146
|
-
static
|
|
1147
|
-
static
|
|
1142
|
+
static define(spec = {}) {
|
|
1143
|
+
return new Group(spec.parent, spec.name || null);
|
|
1144
|
+
}
|
|
1145
|
+
static All = Group.define({ name: "All" });
|
|
1146
|
+
static Inline = Group.define({ name: "Inline" });
|
|
1147
|
+
static Block = Group.define({ name: "Block" });
|
|
1148
|
+
static Leaf = Group.define({ name: "Leaf" });
|
|
1149
|
+
static Plot = Group.define({ name: "Plot" });
|
|
1150
|
+
static Textblock = Group.define({ name: "Textblock" });
|
|
1151
|
+
static Content = Group.define({ name: "Content" });
|
|
1152
|
+
static TableCell = Group.define({ name: "TableCell" });
|
|
1153
|
+
static ListItem = Group.define({ name: "ListItem" });
|
|
1148
1154
|
static builtin = [Group.All, Group.Inline, Group.Block, Group.Leaf, Group.Plot, Group.Textblock];
|
|
1155
|
+
toString() { return "Node.Group" + (this.name ? ":" + this.name : ""); }
|
|
1149
1156
|
}
|
|
1150
1157
|
Node.Group = Group;
|
|
1158
|
+
function queryToString(q) {
|
|
1159
|
+
if ("and" in q)
|
|
1160
|
+
return `and(${q.and.map(queryToString)})`;
|
|
1161
|
+
if (Array.isArray(q))
|
|
1162
|
+
return `or(q.map(queryToString))`;
|
|
1163
|
+
return String(q);
|
|
1164
|
+
}
|
|
1165
|
+
Node.queryToString = queryToString;
|
|
1151
1166
|
class Role {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1167
|
+
name;
|
|
1168
|
+
constructor(
|
|
1169
|
+
name) {
|
|
1170
|
+
this.name = name;
|
|
1171
|
+
}
|
|
1172
|
+
static define(name) { return new Role(name || null); }
|
|
1173
|
+
static Code = Role.define("Code");
|
|
1174
|
+
static List = Role.define("List");
|
|
1175
|
+
static LineBreak = Role.define("LineBreak");
|
|
1176
|
+
toString() { return "Node.Role" + (this.name ? ":" + this.name : ""); }
|
|
1157
1177
|
}
|
|
1158
1178
|
Node.Role = Role;
|
|
1159
1179
|
;return Node})({});
|
package/dist/editor.d.ts
CHANGED
|
@@ -731,7 +731,13 @@ declare class Wordgard {
|
|
|
731
731
|
Facet that allows you to register handlers to override paste
|
|
732
732
|
behavior.
|
|
733
733
|
*/
|
|
734
|
-
static pasteHandler: GardState.Facet<(wg: Wordgard, event: InputEvent, slice: wordgard_doc.Slice) => boolean, readonly ((wg: Wordgard, event: InputEvent, slice: wordgard_doc.Slice) => boolean)[]>;
|
|
734
|
+
static pasteHandler: GardState.Facet<(wg: Wordgard, event: InputEvent | null, slice: wordgard_doc.Slice, html: string, text: string) => boolean, readonly ((wg: Wordgard, event: InputEvent | null, slice: wordgard_doc.Slice, html: string, text: string) => boolean)[]>;
|
|
735
|
+
/**
|
|
736
|
+
Perform a paste with the given content. This will run {@link
|
|
737
|
+
Wordgard.pasteHandler paste handlers} and, if none handles the
|
|
738
|
+
paste, fall back to the default handling.
|
|
739
|
+
*/
|
|
740
|
+
paste(html: string, text?: string): void;
|
|
735
741
|
/**
|
|
736
742
|
Facet for custom drop handlers. When the drop is done inside the
|
|
737
743
|
editor and should move an existing range, the `move` parameter
|
|
@@ -857,7 +863,7 @@ declare class Wordgard {
|
|
|
857
863
|
the editor's {@link Wordgard.dom wrapper element} (to which the
|
|
858
864
|
scope class will be added) need to be explicitly differentiated
|
|
859
865
|
by adding an `&` to the selector for that element—for example
|
|
860
|
-
|
|
866
|
+
`&.wg-focused`.
|
|
861
867
|
*/
|
|
862
868
|
static theme(spec: Record<string, StyleSpec>): GardState.Extension;
|
|
863
869
|
/**
|
|
@@ -926,6 +932,11 @@ declare class Wordgard {
|
|
|
926
932
|
part of the editor (for example a gutter).
|
|
927
933
|
*/
|
|
928
934
|
static coveredMargins: GardState.Facet<(wg: Wordgard) => Partial<DOMRect> | null, readonly ((wg: Wordgard) => Partial<DOMRect> | null)[]>;
|
|
935
|
+
/**
|
|
936
|
+
Given a DOM element that may be a Wordgard editor, retrieve its
|
|
937
|
+
editor instance.
|
|
938
|
+
*/
|
|
939
|
+
static findFromDOM(elt: Element): Wordgard | null;
|
|
929
940
|
}
|
|
930
941
|
declare namespace Wordgard {
|
|
931
942
|
/**
|