@nerd-bible/wordgard 0.6.2-beta10 → 0.6.2-beta12
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.d.ts +1 -1
- package/dist/doc.js +5 -6
- package/dist/editor.d.ts +1 -1
- package/dist/editor.js +25 -20
- package/dist/schema.js +2 -2
- package/dist/set.js +11 -2
- package/package.json +1 -1
package/dist/doc.d.ts
CHANGED
|
@@ -2049,7 +2049,7 @@ declare class ChangeSet {
|
|
|
2049
2049
|
*/
|
|
2050
2050
|
pad(before: number, after: number): ChangeSet;
|
|
2051
2051
|
/**
|
|
2052
|
-
Clip the set to only a sub-region. This can fail
|
|
2052
|
+
Clip the set to only a sub-region. This can fail if there are
|
|
2053
2053
|
replacements across the region's sides, in which case the
|
|
2054
2054
|
method returns null
|
|
2055
2055
|
*/
|
package/dist/doc.js
CHANGED
|
@@ -2364,13 +2364,12 @@ class ChangeSet {
|
|
|
2364
2364
|
for (let i = 0, pos = 0; i < this.sections.length && pos <= to;) {
|
|
2365
2365
|
let value = this.data[i >> 1], len = this.sections[i++], ins = this.sections[i++];
|
|
2366
2366
|
let end = pos + len;
|
|
2367
|
-
if (
|
|
2368
|
-
|
|
2369
|
-
addSection(sections, data, end - pos, ins, value);
|
|
2370
|
-
else if (end > from && pos < from)
|
|
2371
|
-
return null;
|
|
2367
|
+
if (pos >= from && end <= to) {
|
|
2368
|
+
addSection(sections, data, len, ins, value);
|
|
2372
2369
|
}
|
|
2373
|
-
else if (
|
|
2370
|
+
else if (end > from && pos < to) {
|
|
2371
|
+
if (ins >= 0)
|
|
2372
|
+
return null;
|
|
2374
2373
|
addSection(sections, data, Math.min(end, to) - Math.max(pos, from), ins, value);
|
|
2375
2374
|
}
|
|
2376
2375
|
pos = end;
|
package/dist/editor.d.ts
CHANGED
|
@@ -731,7 +731,7 @@ 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:
|
|
734
|
+
static pasteHandler: GardState.Facet<(wg: Wordgard, event: ClipboardEvent, slice: wordgard_doc.Slice, html: string, text: string) => boolean, readonly ((wg: Wordgard, event: ClipboardEvent, slice: wordgard_doc.Slice, html: string, text: string) => boolean)[]>;
|
|
735
735
|
/**
|
|
736
736
|
Perform a paste with the given content. This will run {@link
|
|
737
737
|
Wordgard.pasteHandler paste handlers} and, if none handles the
|
package/dist/editor.js
CHANGED
|
@@ -952,17 +952,6 @@ function getSelection(root) {
|
|
|
952
952
|
}
|
|
953
953
|
return target.getSelection();
|
|
954
954
|
}
|
|
955
|
-
function getSelectionRange(root) {
|
|
956
|
-
let sel = getSelection(root);
|
|
957
|
-
if (!sel)
|
|
958
|
-
return null;
|
|
959
|
-
if (browser.safari && root.nodeType == 11) {
|
|
960
|
-
let range = sel.getComposedRanges(root)[0];
|
|
961
|
-
if (range)
|
|
962
|
-
return range;
|
|
963
|
-
}
|
|
964
|
-
return new StaticRange(sel.getRangeAt(0));
|
|
965
|
-
}
|
|
966
955
|
function hasSelection(dom, selection) {
|
|
967
956
|
if (!selection.focusNode)
|
|
968
957
|
return false;
|
|
@@ -2999,6 +2988,7 @@ const baseStyles = /*@__PURE__*/buildTheme("." + styleID, {
|
|
|
2999
2988
|
".wg-buffer": {
|
|
3000
2989
|
verticalAlign: "bottom",
|
|
3001
2990
|
height: "1em",
|
|
2991
|
+
display: "inline"
|
|
3002
2992
|
},
|
|
3003
2993
|
".wg-blockBuffer": {
|
|
3004
2994
|
position: "absolute"
|
|
@@ -3904,6 +3894,8 @@ class InputState {
|
|
|
3904
3894
|
this.lastKeyCode = event.keyCode;
|
|
3905
3895
|
this.lastKeyTime = Date.now();
|
|
3906
3896
|
this.shiftKey = event.keyCode == 16 || event.shiftKey;
|
|
3897
|
+
if (this.composing && event.isComposing === false)
|
|
3898
|
+
compositionEnd(this.wg);
|
|
3907
3899
|
return false;
|
|
3908
3900
|
}
|
|
3909
3901
|
ignoreDuringComposition(event) {
|
|
@@ -3968,6 +3960,8 @@ class InputState {
|
|
|
3968
3960
|
return this.domMapping.mapPos(this.getDOMPos(node, offset), assoc);
|
|
3969
3961
|
}
|
|
3970
3962
|
beforeInput(event, data) {
|
|
3963
|
+
if (this.composing && event.isComposing === false)
|
|
3964
|
+
compositionEnd(this.wg);
|
|
3971
3965
|
let type = event.inputType, range;
|
|
3972
3966
|
let { wg } = this, sel = wg.state.selection;
|
|
3973
3967
|
if (data.domRange) {
|
|
@@ -3997,14 +3991,8 @@ class InputState {
|
|
|
3997
3991
|
Command.dispatch(wg, insertText, { from, to, insert, userEvent: "input.type" });
|
|
3998
3992
|
}
|
|
3999
3993
|
else if (type == "insertFromPaste") {
|
|
4000
|
-
let isSel = this.unflushedSelection;
|
|
4001
|
-
if (!isSel) {
|
|
4002
|
-
let r = data.domRange.range, domSel = getSelectionRange(wg.root);
|
|
4003
|
-
isSel = !!domSel && isEquivalentPosition(r.startContainer, r.startOffset, domSel.startContainer, domSel.startOffset) &&
|
|
4004
|
-
isEquivalentPosition(r.endContainer, r.endOffset, domSel.endContainer, domSel.endOffset);
|
|
4005
|
-
}
|
|
4006
3994
|
let transfer = event.dataTransfer;
|
|
4007
|
-
doPaste(wg, getHTML(transfer), getText(transfer),
|
|
3995
|
+
doPaste(wg, getHTML(transfer), getText(transfer), this.unflushedSelection ? wg.state.selection : range, null);
|
|
4008
3996
|
}
|
|
4009
3997
|
else if ((type == "insertReplacementText" || type == "insertFromYank")) {
|
|
4010
3998
|
let transfer = event.dataTransfer;
|
|
@@ -4109,6 +4097,8 @@ class InputState {
|
|
|
4109
4097
|
}
|
|
4110
4098
|
clearComposition() {
|
|
4111
4099
|
let comp = this.composing;
|
|
4100
|
+
if (!comp)
|
|
4101
|
+
return false;
|
|
4112
4102
|
this.composing = null;
|
|
4113
4103
|
this.compositionPendingKey = true;
|
|
4114
4104
|
this.compositionEndedAt = Date.now();
|
|
@@ -4195,8 +4185,15 @@ function computeHandlers(state) {
|
|
|
4195
4185
|
function doPaste(wg, html, text, targetRange, event) {
|
|
4196
4186
|
let { from, to } = targetRange || wg.state.selection.replacementRange;
|
|
4197
4187
|
let slice = readClipboard(wg.state, html, text, wg.state.doc.resolve(from), wg.inputState.shiftKey);
|
|
4198
|
-
if (!targetRange
|
|
4199
|
-
|
|
4188
|
+
if (!targetRange) {
|
|
4189
|
+
if (!event) {
|
|
4190
|
+
event = new ClipboardEvent("paste", { clipboardData: new DataTransfer });
|
|
4191
|
+
event.clipboardData.setData("text/html", html);
|
|
4192
|
+
event.clipboardData.setData("text/plain", text);
|
|
4193
|
+
}
|
|
4194
|
+
if (wg.state.facet(pasteHandler).some(h => h(wg, event, slice || Slice.empty, text, html)))
|
|
4195
|
+
return;
|
|
4196
|
+
}
|
|
4200
4197
|
if (slice) {
|
|
4201
4198
|
wg.dispatch({
|
|
4202
4199
|
changes: { correct: { from, to, insert: slice, fit: true }, local: true },
|
|
@@ -4547,6 +4544,13 @@ const baseHandlers = {
|
|
|
4547
4544
|
},
|
|
4548
4545
|
copy,
|
|
4549
4546
|
cut: copy,
|
|
4547
|
+
paste(wg, event) {
|
|
4548
|
+
let data = event.clipboardData;
|
|
4549
|
+
if (!data)
|
|
4550
|
+
return false;
|
|
4551
|
+
doPaste(wg, getHTML(data), getText(data), null, event);
|
|
4552
|
+
return true;
|
|
4553
|
+
},
|
|
4550
4554
|
drop(wg, event) {
|
|
4551
4555
|
let data = event.dataTransfer;
|
|
4552
4556
|
if (!data || wg.state.readOnly)
|
|
@@ -7417,6 +7421,7 @@ const theme = /*@__PURE__*/Wordgard.styles({
|
|
|
7417
7421
|
fill: "currentColor",
|
|
7418
7422
|
width: "var(--wg-menu-item-size)",
|
|
7419
7423
|
height: "var(--wg-menu-item-size)",
|
|
7424
|
+
display: "inline-block"
|
|
7420
7425
|
},
|
|
7421
7426
|
"wg-menu-spacer": {
|
|
7422
7427
|
display: "block",
|
package/dist/schema.js
CHANGED
|
@@ -809,7 +809,7 @@ function figure(conf = {}) {
|
|
|
809
809
|
function imageResizing() {
|
|
810
810
|
return [GardState.schemaElement.of(ImageSize), imageResizing.keyBindings, imageResizing.dragHandle];
|
|
811
811
|
}
|
|
812
|
-
const
|
|
812
|
+
const resizeStyle = /*@__PURE__*/Wordgard.styles({
|
|
813
813
|
".wg-resize-hover": {
|
|
814
814
|
display: "inline-block",
|
|
815
815
|
lineHeight: "0.1",
|
|
@@ -939,7 +939,7 @@ const resizeHandlers = /*@__PURE__*/(() => [
|
|
|
939
939
|
GardState.prec.high(resizeHandlers),
|
|
940
940
|
resizeState,
|
|
941
941
|
Decoration.Point.source.of(s => s.field(resizeState).deco),
|
|
942
|
-
|
|
942
|
+
resizeStyle
|
|
943
943
|
];
|
|
944
944
|
;return imageResizing})(imageResizing);
|
|
945
945
|
;image = /*@__PURE__*/(function (image) {
|
package/dist/set.js
CHANGED
|
@@ -137,6 +137,7 @@ let SetBuilder$1 = class SetBuilder {
|
|
|
137
137
|
spilled = null;
|
|
138
138
|
lastTo = -1;
|
|
139
139
|
lastFrom = -1;
|
|
140
|
+
closed = false;
|
|
140
141
|
get next() {
|
|
141
142
|
return this.spilled || (this.spilled = new SetBuilder());
|
|
142
143
|
}
|
|
@@ -147,6 +148,7 @@ let SetBuilder$1 = class SetBuilder {
|
|
|
147
148
|
else {
|
|
148
149
|
this.chunks.push(chunk);
|
|
149
150
|
this.lastTo = chunk.end;
|
|
151
|
+
this.closed = true;
|
|
150
152
|
}
|
|
151
153
|
}
|
|
152
154
|
add(source, pre) {
|
|
@@ -172,13 +174,14 @@ let SetBuilder$1 = class SetBuilder {
|
|
|
172
174
|
}
|
|
173
175
|
addInner(value, from, to) {
|
|
174
176
|
let chunk;
|
|
175
|
-
if (this.chunks.length) {
|
|
177
|
+
if (this.chunks.length && !this.closed) {
|
|
176
178
|
chunk = this.chunks[this.chunks.length - 1];
|
|
177
179
|
if (chunk.value.length >= 512)
|
|
178
180
|
chunk = undefined;
|
|
179
181
|
}
|
|
180
182
|
if (!chunk) {
|
|
181
183
|
this.chunks.push(chunk = new Chunk$1(from, [], [], []));
|
|
184
|
+
this.closed = false;
|
|
182
185
|
}
|
|
183
186
|
chunk.from.push(from - chunk.start);
|
|
184
187
|
chunk.to.push(to - chunk.start);
|
|
@@ -470,10 +473,12 @@ class SetBuilder {
|
|
|
470
473
|
chunks = [];
|
|
471
474
|
lastPos = -1;
|
|
472
475
|
lastSide = -1;
|
|
476
|
+
closed = false;
|
|
473
477
|
addChunk(chunk) {
|
|
474
478
|
this.chunks.push(chunk);
|
|
475
479
|
this.lastPos = chunk.end;
|
|
476
480
|
this.lastSide = chunk.endSide;
|
|
481
|
+
this.closed = true;
|
|
477
482
|
}
|
|
478
483
|
add(source, pre) {
|
|
479
484
|
if (typeof source != "function") {
|
|
@@ -491,13 +496,15 @@ class SetBuilder {
|
|
|
491
496
|
}
|
|
492
497
|
addPoint(value, pos) {
|
|
493
498
|
let chunk;
|
|
494
|
-
|
|
499
|
+
let wasClosed = this.closed;
|
|
500
|
+
if (this.chunks.length && !wasClosed) {
|
|
495
501
|
chunk = this.chunks[this.chunks.length - 1];
|
|
496
502
|
if (chunk.value.length >= 512)
|
|
497
503
|
chunk = undefined;
|
|
498
504
|
}
|
|
499
505
|
if (!chunk) {
|
|
500
506
|
this.chunks.push(chunk = new Chunk(pos, [], []));
|
|
507
|
+
this.closed = false;
|
|
501
508
|
}
|
|
502
509
|
chunk.pos.push(pos - chunk.start);
|
|
503
510
|
chunk.value.push(value);
|
|
@@ -512,6 +519,8 @@ class SetBuilder {
|
|
|
512
519
|
if (!chunkI)
|
|
513
520
|
break;
|
|
514
521
|
nextChunk = this.chunks[--chunkI];
|
|
522
|
+
if (wasClosed)
|
|
523
|
+
nextChunk = this.chunks[chunkI] = new Chunk(nextChunk.start, nextChunk.pos.slice(), nextChunk.value.slice());
|
|
515
524
|
nextI = nextChunk.value.length - 1;
|
|
516
525
|
}
|
|
517
526
|
if ((pos - nextChunk.pos[nextI] || value.side - nextChunk.value[nextI].side) >= 0)
|