@plotdb/quill 1.0.0 → 1.0.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/babel.config.cjs +12 -0
- package/package.json +2 -1
- package/scripts/babel-svg-inline-import.cjs +44 -0
- package/scripts/build +20 -0
- package/src/types.d.ts +6 -0
- package/webpack.common.cjs +69 -0
- package/webpack.config.cjs +42 -0
- package/blots/block.d.ts +0 -34
- package/blots/block.js +0 -182
- package/blots/block.js.map +0 -1
- package/blots/break.d.ts +0 -8
- package/blots/break.js +0 -21
- package/blots/break.js.map +0 -1
- package/blots/container.d.ts +0 -4
- package/blots/container.js +0 -4
- package/blots/container.js.map +0 -1
- package/blots/cursor.d.ts +0 -26
- package/blots/cursor.js +0 -170
- package/blots/cursor.js.map +0 -1
- package/blots/embed.d.ts +0 -18
- package/blots/embed.js +0 -72
- package/blots/embed.js.map +0 -1
- package/blots/inline.d.ts +0 -12
- package/blots/inline.js +0 -48
- package/blots/inline.js.map +0 -1
- package/blots/scroll.d.ts +0 -49
- package/blots/scroll.js +0 -349
- package/blots/scroll.js.map +0 -1
- package/blots/text.d.ts +0 -5
- package/blots/text.js +0 -16
- package/blots/text.js.map +0 -1
- package/core/composition.d.ts +0 -12
- package/core/composition.js +0 -44
- package/core/composition.js.map +0 -1
- package/core/editor.d.ts +0 -28
- package/core/editor.js +0 -404
- package/core/editor.js.map +0 -1
- package/core/emitter.d.ts +0 -33
- package/core/emitter.js +0 -78
- package/core/emitter.js.map +0 -1
- package/core/instances.d.ts +0 -3
- package/core/instances.js +0 -2
- package/core/instances.js.map +0 -1
- package/core/logger.d.ts +0 -7
- package/core/logger.js +0 -24
- package/core/logger.js.map +0 -1
- package/core/module.d.ts +0 -8
- package/core/module.js +0 -10
- package/core/module.js.map +0 -1
- package/core/quill.d.ts +0 -218
- package/core/quill.js +0 -630
- package/core/quill.js.map +0 -1
- package/core/selection.d.ts +0 -74
- package/core/selection.js +0 -374
- package/core/selection.js.map +0 -1
- package/core/theme.d.ts +0 -32
- package/core/theme.js +0 -28
- package/core/theme.js.map +0 -1
- package/core/utils/createRegistryWithFormats.d.ts +0 -5
- package/core/utils/createRegistryWithFormats.js +0 -29
- package/core/utils/createRegistryWithFormats.js.map +0 -1
- package/core/utils/scrollRectIntoView.d.ts +0 -11
- package/core/utils/scrollRectIntoView.js +0 -110
- package/core/utils/scrollRectIntoView.js.map +0 -1
- package/core.d.ts +0 -7
- package/core.js +0 -37
- package/core.js.map +0 -1
- package/dist/quill.bubble.css +0 -10
- package/dist/quill.bubble.css.map +0 -1
- package/dist/quill.core.css +0 -10
- package/dist/quill.core.css.map +0 -1
- package/dist/quill.core.js +0 -3
- package/dist/quill.core.js.LICENSE.txt +0 -7
- package/dist/quill.core.js.map +0 -1
- package/dist/quill.js +0 -3
- package/dist/quill.js.LICENSE.txt +0 -7
- package/dist/quill.js.map +0 -1
- package/dist/quill.snow.css +0 -10
- package/dist/quill.snow.css.map +0 -1
- package/formats/align.d.ts +0 -5
- package/formats/align.js +0 -10
- package/formats/align.js.map +0 -1
- package/formats/background.d.ts +0 -5
- package/formats/background.js +0 -10
- package/formats/background.js.map +0 -1
- package/formats/blockquote.d.ts +0 -6
- package/formats/blockquote.js +0 -7
- package/formats/blockquote.js.map +0 -1
- package/formats/bold.d.ts +0 -11
- package/formats/bold.js +0 -19
- package/formats/bold.js.map +0 -1
- package/formats/code.d.ts +0 -15
- package/formats/code.js +0 -44
- package/formats/code.js.map +0 -1
- package/formats/color.d.ts +0 -7
- package/formats/color.js +0 -18
- package/formats/color.js.map +0 -1
- package/formats/direction.d.ts +0 -5
- package/formats/direction.js +0 -10
- package/formats/direction.js.map +0 -1
- package/formats/font.d.ts +0 -7
- package/formats/font.js +0 -14
- package/formats/font.js.map +0 -1
- package/formats/formula.d.ts +0 -10
- package/formats/formula.js +0 -34
- package/formats/formula.js.map +0 -1
- package/formats/header.d.ts +0 -7
- package/formats/header.js +0 -10
- package/formats/header.js.map +0 -1
- package/formats/image.d.ts +0 -13
- package/formats/image.js +0 -44
- package/formats/image.js.map +0 -1
- package/formats/indent.d.ts +0 -8
- package/formats/indent.js +0 -30
- package/formats/indent.js.map +0 -1
- package/formats/italic.d.ts +0 -6
- package/formats/italic.js +0 -7
- package/formats/italic.js.map +0 -1
- package/formats/link.d.ts +0 -13
- package/formats/link.js +0 -36
- package/formats/link.js.map +0 -1
- package/formats/list.d.ts +0 -13
- package/formats/list.js +0 -50
- package/formats/list.js.map +0 -1
- package/formats/script.d.ts +0 -8
- package/formats/script.js +0 -21
- package/formats/script.js.map +0 -1
- package/formats/size.d.ts +0 -4
- package/formats/size.js +0 -11
- package/formats/size.js.map +0 -1
- package/formats/strike.d.ts +0 -6
- package/formats/strike.js +0 -7
- package/formats/strike.js.map +0 -1
- package/formats/table.d.ts +0 -45
- package/formats/table.js +0 -176
- package/formats/table.js.map +0 -1
- package/formats/underline.d.ts +0 -6
- package/formats/underline.js +0 -7
- package/formats/underline.js.map +0 -1
- package/formats/video.d.ts +0 -14
- package/formats/video.js +0 -49
- package/formats/video.js.map +0 -1
- package/modules/clipboard.d.ts +0 -43
- package/modules/clipboard.js +0 -477
- package/modules/clipboard.js.map +0 -1
- package/modules/history.d.ts +0 -36
- package/modules/history.js +0 -178
- package/modules/history.js.map +0 -1
- package/modules/input.d.ts +0 -10
- package/modules/input.js +0 -83
- package/modules/input.js.map +0 -1
- package/modules/keyboard.d.ts +0 -58
- package/modules/keyboard.js +0 -713
- package/modules/keyboard.js.map +0 -1
- package/modules/normalizeExternalHTML/index.d.ts +0 -2
- package/modules/normalizeExternalHTML/index.js +0 -12
- package/modules/normalizeExternalHTML/index.js.map +0 -1
- package/modules/normalizeExternalHTML/normalizers/googleDocs.d.ts +0 -1
- package/modules/normalizeExternalHTML/normalizers/googleDocs.js +0 -24
- package/modules/normalizeExternalHTML/normalizers/googleDocs.js.map +0 -1
- package/modules/normalizeExternalHTML/normalizers/msWord.d.ts +0 -1
- package/modules/normalizeExternalHTML/normalizers/msWord.js +0 -87
- package/modules/normalizeExternalHTML/normalizers/msWord.js.map +0 -1
- package/modules/syntax.d.ts +0 -50
- package/modules/syntax.js +0 -332
- package/modules/syntax.js.map +0 -1
- package/modules/table.d.ts +0 -20
- package/modules/table.js +0 -125
- package/modules/table.js.map +0 -1
- package/modules/tableEmbed.d.ts +0 -27
- package/modules/tableEmbed.js +0 -209
- package/modules/tableEmbed.js.map +0 -1
- package/modules/toolbar.d.ts +0 -24
- package/modules/toolbar.js +0 -265
- package/modules/toolbar.js.map +0 -1
- package/modules/uiNode.d.ts +0 -19
- package/modules/uiNode.js +0 -95
- package/modules/uiNode.js.map +0 -1
- package/modules/uploader.d.ts +0 -15
- package/modules/uploader.js +0 -69
- package/modules/uploader.js.map +0 -1
- package/quill.d.ts +0 -5
- package/quill.js +0 -82
- package/quill.js.map +0 -1
- package/themes/base.d.ts +0 -35
- package/themes/base.js +0 -257
- package/themes/base.js.map +0 -1
- package/themes/bubble.d.ts +0 -18
- package/themes/bubble.js +0 -114
- package/themes/bubble.js.map +0 -1
- package/themes/snow.d.ts +0 -9
- package/themes/snow.js +0 -122
- package/themes/snow.js.map +0 -1
- package/types.d.js +0 -2
- package/types.d.js.map +0 -1
- package/ui/color-picker.d.ts +0 -7
- package/ui/color-picker.js +0 -30
- package/ui/color-picker.js.map +0 -1
- package/ui/icon-picker.d.ts +0 -7
- package/ui/icon-picker.js +0 -22
- package/ui/icon-picker.js.map +0 -1
- package/ui/icons.d.ts +0 -49
- package/ui/icons.js +0 -82
- package/ui/icons.js.map +0 -1
- package/ui/picker.d.ts +0 -16
- package/ui/picker.js +0 -171
- package/ui/picker.js.map +0 -1
- package/ui/tooltip.d.ts +0 -12
- package/ui/tooltip.js +0 -56
- package/ui/tooltip.js.map +0 -1
- /package/{assets → src/assets}/base.styl +0 -0
- /package/{assets → src/assets}/bubble/toolbar.styl +0 -0
- /package/{assets → src/assets}/bubble/tooltip.styl +0 -0
- /package/{assets → src/assets}/bubble.styl +0 -0
- /package/{assets → src/assets}/core.styl +0 -0
- /package/{assets → src/assets}/favicon.png +0 -0
- /package/{assets → src/assets}/icons/align-center.svg +0 -0
- /package/{assets → src/assets}/icons/align-justify.svg +0 -0
- /package/{assets → src/assets}/icons/align-left.svg +0 -0
- /package/{assets → src/assets}/icons/align-right.svg +0 -0
- /package/{assets → src/assets}/icons/attachment.svg +0 -0
- /package/{assets → src/assets}/icons/audio.svg +0 -0
- /package/{assets → src/assets}/icons/authorship.svg +0 -0
- /package/{assets → src/assets}/icons/background.svg +0 -0
- /package/{assets → src/assets}/icons/blockquote.svg +0 -0
- /package/{assets → src/assets}/icons/bold.svg +0 -0
- /package/{assets → src/assets}/icons/clean.svg +0 -0
- /package/{assets → src/assets}/icons/code.svg +0 -0
- /package/{assets → src/assets}/icons/color.svg +0 -0
- /package/{assets → src/assets}/icons/comment.svg +0 -0
- /package/{assets → src/assets}/icons/direction-ltr.svg +0 -0
- /package/{assets → src/assets}/icons/direction-rtl.svg +0 -0
- /package/{assets → src/assets}/icons/dropdown.svg +0 -0
- /package/{assets → src/assets}/icons/embed.svg +0 -0
- /package/{assets → src/assets}/icons/emoji.svg +0 -0
- /package/{assets → src/assets}/icons/float-center.svg +0 -0
- /package/{assets → src/assets}/icons/float-full.svg +0 -0
- /package/{assets → src/assets}/icons/float-left.svg +0 -0
- /package/{assets → src/assets}/icons/float-right.svg +0 -0
- /package/{assets → src/assets}/icons/font.svg +0 -0
- /package/{assets → src/assets}/icons/formula.svg +0 -0
- /package/{assets → src/assets}/icons/hashtag.svg +0 -0
- /package/{assets → src/assets}/icons/header-2.svg +0 -0
- /package/{assets → src/assets}/icons/header-3.svg +0 -0
- /package/{assets → src/assets}/icons/header-4.svg +0 -0
- /package/{assets → src/assets}/icons/header-5.svg +0 -0
- /package/{assets → src/assets}/icons/header-6.svg +0 -0
- /package/{assets → src/assets}/icons/header.svg +0 -0
- /package/{assets → src/assets}/icons/horizontal-rule.svg +0 -0
- /package/{assets → src/assets}/icons/image.svg +0 -0
- /package/{assets → src/assets}/icons/indent.svg +0 -0
- /package/{assets → src/assets}/icons/italic.svg +0 -0
- /package/{assets → src/assets}/icons/link.svg +0 -0
- /package/{assets → src/assets}/icons/list-bullet.svg +0 -0
- /package/{assets → src/assets}/icons/list-check.svg +0 -0
- /package/{assets → src/assets}/icons/list-ordered.svg +0 -0
- /package/{assets → src/assets}/icons/map.svg +0 -0
- /package/{assets → src/assets}/icons/mention.svg +0 -0
- /package/{assets → src/assets}/icons/more.svg +0 -0
- /package/{assets → src/assets}/icons/outdent.svg +0 -0
- /package/{assets → src/assets}/icons/redo.svg +0 -0
- /package/{assets → src/assets}/icons/size-decrease.svg +0 -0
- /package/{assets → src/assets}/icons/size-increase.svg +0 -0
- /package/{assets → src/assets}/icons/size.svg +0 -0
- /package/{assets → src/assets}/icons/spacing.svg +0 -0
- /package/{assets → src/assets}/icons/speech.svg +0 -0
- /package/{assets → src/assets}/icons/strike.svg +0 -0
- /package/{assets → src/assets}/icons/subscript.svg +0 -0
- /package/{assets → src/assets}/icons/superscript.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-all.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-bottom.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-left.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-none.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-outside.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-right.svg +0 -0
- /package/{assets → src/assets}/icons/table-border-top.svg +0 -0
- /package/{assets → src/assets}/icons/table-delete-cells.svg +0 -0
- /package/{assets → src/assets}/icons/table-delete-columns.svg +0 -0
- /package/{assets → src/assets}/icons/table-delete-rows.svg +0 -0
- /package/{assets → src/assets}/icons/table-insert-cells.svg +0 -0
- /package/{assets → src/assets}/icons/table-insert-columns.svg +0 -0
- /package/{assets → src/assets}/icons/table-insert-rows.svg +0 -0
- /package/{assets → src/assets}/icons/table-merge-cells.svg +0 -0
- /package/{assets → src/assets}/icons/table-unmerge-cells.svg +0 -0
- /package/{assets → src/assets}/icons/table.svg +0 -0
- /package/{assets → src/assets}/icons/underline.svg +0 -0
- /package/{assets → src/assets}/icons/undo.svg +0 -0
- /package/{assets → src/assets}/icons/video.svg +0 -0
- /package/{assets → src/assets}/snow/toolbar.styl +0 -0
- /package/{assets → src/assets}/snow/tooltip.styl +0 -0
- /package/{assets → src/assets}/snow.styl +0 -0
package/blots/cursor.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { EmbedBlot, Scope } from 'parchment';
|
|
2
|
-
import TextBlot from './text.js';
|
|
3
|
-
class Cursor extends EmbedBlot {
|
|
4
|
-
static blotName = 'cursor';
|
|
5
|
-
static className = 'ql-cursor';
|
|
6
|
-
static tagName = 'span';
|
|
7
|
-
static CONTENTS = '\uFEFF'; // Zero width no break space
|
|
8
|
-
|
|
9
|
-
static value() {
|
|
10
|
-
return undefined;
|
|
11
|
-
}
|
|
12
|
-
constructor(scroll, domNode, selection) {
|
|
13
|
-
super(scroll, domNode);
|
|
14
|
-
this.selection = selection;
|
|
15
|
-
this.textNode = document.createTextNode(Cursor.CONTENTS);
|
|
16
|
-
this.domNode.appendChild(this.textNode);
|
|
17
|
-
this.savedLength = 0;
|
|
18
|
-
}
|
|
19
|
-
detach() {
|
|
20
|
-
// super.detach() will also clear domNode.__blot
|
|
21
|
-
if (this.parent != null) this.parent.removeChild(this);
|
|
22
|
-
}
|
|
23
|
-
format(name, value) {
|
|
24
|
-
if (this.savedLength !== 0) {
|
|
25
|
-
super.format(name, value);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
// TODO: Fix this next time the file is edited.
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
30
|
-
let target = this;
|
|
31
|
-
let index = 0;
|
|
32
|
-
while (target != null && target.statics.scope !== Scope.BLOCK_BLOT) {
|
|
33
|
-
index += target.offset(target.parent);
|
|
34
|
-
target = target.parent;
|
|
35
|
-
}
|
|
36
|
-
if (target != null) {
|
|
37
|
-
this.savedLength = Cursor.CONTENTS.length;
|
|
38
|
-
// @ts-expect-error TODO: allow empty context in Parchment
|
|
39
|
-
target.optimize();
|
|
40
|
-
target.formatAt(index, Cursor.CONTENTS.length, name, value);
|
|
41
|
-
this.savedLength = 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
index(node, offset) {
|
|
45
|
-
if (node === this.textNode) return 0;
|
|
46
|
-
return super.index(node, offset);
|
|
47
|
-
}
|
|
48
|
-
length() {
|
|
49
|
-
return this.savedLength;
|
|
50
|
-
}
|
|
51
|
-
position() {
|
|
52
|
-
return [this.textNode, this.textNode.data.length];
|
|
53
|
-
}
|
|
54
|
-
remove() {
|
|
55
|
-
super.remove();
|
|
56
|
-
// @ts-expect-error Fix me later
|
|
57
|
-
this.parent = null;
|
|
58
|
-
}
|
|
59
|
-
restore() {
|
|
60
|
-
if (this.selection.composing || this.parent == null) return null;
|
|
61
|
-
const range = this.selection.getNativeRange();
|
|
62
|
-
// Browser may push down styles/nodes inside the cursor blot.
|
|
63
|
-
// https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#push-down-values
|
|
64
|
-
while (this.domNode.lastChild != null && this.domNode.lastChild !== this.textNode) {
|
|
65
|
-
// @ts-expect-error Fix me later
|
|
66
|
-
this.domNode.parentNode.insertBefore(this.domNode.lastChild, this.domNode);
|
|
67
|
-
}
|
|
68
|
-
const prevTextBlot = this.prev instanceof TextBlot ? this.prev : null;
|
|
69
|
-
const prevTextLength = prevTextBlot ? prevTextBlot.length() : 0;
|
|
70
|
-
const nextTextBlot = this.next instanceof TextBlot ? this.next : null;
|
|
71
|
-
// @ts-expect-error TODO: make TextBlot.text public
|
|
72
|
-
const nextText = nextTextBlot ? nextTextBlot.text : '';
|
|
73
|
-
const {
|
|
74
|
-
textNode
|
|
75
|
-
} = this;
|
|
76
|
-
// take text from inside this blot and reset it
|
|
77
|
-
const newText = textNode.data.split(Cursor.CONTENTS).join('');
|
|
78
|
-
textNode.data = Cursor.CONTENTS;
|
|
79
|
-
|
|
80
|
-
// proactively merge TextBlots around cursor so that optimization
|
|
81
|
-
// doesn't lose the cursor. the reason we are here in cursor.restore
|
|
82
|
-
// could be that the user clicked in prevTextBlot or nextTextBlot, or
|
|
83
|
-
// the user typed something.
|
|
84
|
-
let mergedTextBlot;
|
|
85
|
-
if (prevTextBlot) {
|
|
86
|
-
mergedTextBlot = prevTextBlot;
|
|
87
|
-
if (newText || nextTextBlot) {
|
|
88
|
-
prevTextBlot.insertAt(prevTextBlot.length(), newText + nextText);
|
|
89
|
-
if (nextTextBlot) {
|
|
90
|
-
nextTextBlot.remove();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
} else if (nextTextBlot) {
|
|
94
|
-
mergedTextBlot = nextTextBlot;
|
|
95
|
-
nextTextBlot.insertAt(0, newText);
|
|
96
|
-
} else {
|
|
97
|
-
const newTextNode = document.createTextNode(newText);
|
|
98
|
-
mergedTextBlot = this.scroll.create(newTextNode);
|
|
99
|
-
this.parent.insertBefore(mergedTextBlot, this);
|
|
100
|
-
}
|
|
101
|
-
this.remove();
|
|
102
|
-
if (range) {
|
|
103
|
-
// calculate selection to restore
|
|
104
|
-
const remapOffset = (node, offset) => {
|
|
105
|
-
if (prevTextBlot && node === prevTextBlot.domNode) {
|
|
106
|
-
return offset;
|
|
107
|
-
}
|
|
108
|
-
if (node === textNode) {
|
|
109
|
-
return prevTextLength + offset - 1;
|
|
110
|
-
}
|
|
111
|
-
if (nextTextBlot && node === nextTextBlot.domNode) {
|
|
112
|
-
return prevTextLength + newText.length + offset;
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
};
|
|
116
|
-
const start = remapOffset(range.start.node, range.start.offset);
|
|
117
|
-
const end = remapOffset(range.end.node, range.end.offset);
|
|
118
|
-
if (start !== null && end !== null) {
|
|
119
|
-
return {
|
|
120
|
-
startNode: mergedTextBlot.domNode,
|
|
121
|
-
startOffset: start,
|
|
122
|
-
endNode: mergedTextBlot.domNode,
|
|
123
|
-
endOffset: end
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
update(mutations, context) {
|
|
130
|
-
if (mutations.some(mutation => {
|
|
131
|
-
return mutation.type === 'characterData' && mutation.target === this.textNode;
|
|
132
|
-
})) {
|
|
133
|
-
const range = this.restore();
|
|
134
|
-
if (range) context.range = range;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// Avoid .ql-cursor being a descendant of `<a/>`.
|
|
139
|
-
// The reason is Safari pushes down `<a/>` on text insertion.
|
|
140
|
-
// That will cause DOM nodes not sync with the model.
|
|
141
|
-
//
|
|
142
|
-
// For example ({I} is the caret), given the markup:
|
|
143
|
-
// <a><span class="ql-cursor">\uFEFF{I}</span></a>
|
|
144
|
-
// When typing a char "x", `<a/>` will be pushed down inside the `<span>` first:
|
|
145
|
-
// <span class="ql-cursor"><a>\uFEFF{I}</a></span>
|
|
146
|
-
// And then "x" will be inserted after `<a/>`:
|
|
147
|
-
// <span class="ql-cursor"><a>\uFEFF</a>d{I}</span>
|
|
148
|
-
optimize(context) {
|
|
149
|
-
// @ts-expect-error Fix me later
|
|
150
|
-
super.optimize(context);
|
|
151
|
-
let {
|
|
152
|
-
parent
|
|
153
|
-
} = this;
|
|
154
|
-
while (parent) {
|
|
155
|
-
if (parent.domNode.tagName === 'A') {
|
|
156
|
-
this.savedLength = Cursor.CONTENTS.length;
|
|
157
|
-
// @ts-expect-error TODO: make isolate generic
|
|
158
|
-
parent.isolate(this.offset(parent), this.length()).unwrap();
|
|
159
|
-
this.savedLength = 0;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
parent = parent.parent;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
value() {
|
|
166
|
-
return '';
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
export default Cursor;
|
|
170
|
-
//# sourceMappingURL=cursor.js.map
|
package/blots/cursor.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.js","names":["EmbedBlot","Scope","TextBlot","Cursor","blotName","className","tagName","CONTENTS","value","undefined","constructor","scroll","domNode","selection","textNode","document","createTextNode","appendChild","savedLength","detach","parent","removeChild","format","name","target","index","statics","scope","BLOCK_BLOT","offset","length","optimize","formatAt","node","position","data","remove","restore","composing","range","getNativeRange","lastChild","parentNode","insertBefore","prevTextBlot","prev","prevTextLength","nextTextBlot","next","nextText","text","newText","split","join","mergedTextBlot","insertAt","newTextNode","create","remapOffset","start","end","startNode","startOffset","endNode","endOffset","update","mutations","context","some","mutation","type","isolate","unwrap"],"sources":["../../src/blots/cursor.ts"],"sourcesContent":["import { EmbedBlot, Scope } from 'parchment';\nimport type { Parent, ScrollBlot } from 'parchment';\nimport type Selection from '../core/selection.js';\nimport TextBlot from './text.js';\nimport type { EmbedContextRange } from './embed.js';\n\nclass Cursor extends EmbedBlot {\n static blotName = 'cursor';\n static className = 'ql-cursor';\n static tagName = 'span';\n static CONTENTS = '\\uFEFF'; // Zero width no break space\n\n static value() {\n return undefined;\n }\n\n selection: Selection;\n textNode: Text;\n savedLength: number;\n\n constructor(scroll: ScrollBlot, domNode: HTMLElement, selection: Selection) {\n super(scroll, domNode);\n this.selection = selection;\n this.textNode = document.createTextNode(Cursor.CONTENTS);\n this.domNode.appendChild(this.textNode);\n this.savedLength = 0;\n }\n\n detach() {\n // super.detach() will also clear domNode.__blot\n if (this.parent != null) this.parent.removeChild(this);\n }\n\n format(name: string, value: unknown) {\n if (this.savedLength !== 0) {\n super.format(name, value);\n return;\n }\n // TODO: Fix this next time the file is edited.\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n let target: Parent | this = this;\n let index = 0;\n while (target != null && target.statics.scope !== Scope.BLOCK_BLOT) {\n index += target.offset(target.parent);\n target = target.parent;\n }\n if (target != null) {\n this.savedLength = Cursor.CONTENTS.length;\n // @ts-expect-error TODO: allow empty context in Parchment\n target.optimize();\n target.formatAt(index, Cursor.CONTENTS.length, name, value);\n this.savedLength = 0;\n }\n }\n\n index(node: Node, offset: number) {\n if (node === this.textNode) return 0;\n return super.index(node, offset);\n }\n\n length() {\n return this.savedLength;\n }\n\n position(): [Text, number] {\n return [this.textNode, this.textNode.data.length];\n }\n\n remove() {\n super.remove();\n // @ts-expect-error Fix me later\n this.parent = null;\n }\n\n restore(): EmbedContextRange | null {\n if (this.selection.composing || this.parent == null) return null;\n const range = this.selection.getNativeRange();\n // Browser may push down styles/nodes inside the cursor blot.\n // https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html#push-down-values\n while (\n this.domNode.lastChild != null &&\n this.domNode.lastChild !== this.textNode\n ) {\n // @ts-expect-error Fix me later\n this.domNode.parentNode.insertBefore(\n this.domNode.lastChild,\n this.domNode,\n );\n }\n\n const prevTextBlot = this.prev instanceof TextBlot ? this.prev : null;\n const prevTextLength = prevTextBlot ? prevTextBlot.length() : 0;\n const nextTextBlot = this.next instanceof TextBlot ? this.next : null;\n // @ts-expect-error TODO: make TextBlot.text public\n const nextText = nextTextBlot ? nextTextBlot.text : '';\n const { textNode } = this;\n // take text from inside this blot and reset it\n const newText = textNode.data.split(Cursor.CONTENTS).join('');\n textNode.data = Cursor.CONTENTS;\n\n // proactively merge TextBlots around cursor so that optimization\n // doesn't lose the cursor. the reason we are here in cursor.restore\n // could be that the user clicked in prevTextBlot or nextTextBlot, or\n // the user typed something.\n let mergedTextBlot;\n if (prevTextBlot) {\n mergedTextBlot = prevTextBlot;\n if (newText || nextTextBlot) {\n prevTextBlot.insertAt(prevTextBlot.length(), newText + nextText);\n if (nextTextBlot) {\n nextTextBlot.remove();\n }\n }\n } else if (nextTextBlot) {\n mergedTextBlot = nextTextBlot;\n nextTextBlot.insertAt(0, newText);\n } else {\n const newTextNode = document.createTextNode(newText);\n mergedTextBlot = this.scroll.create(newTextNode);\n this.parent.insertBefore(mergedTextBlot, this);\n }\n\n this.remove();\n if (range) {\n // calculate selection to restore\n const remapOffset = (node: Node, offset: number) => {\n if (prevTextBlot && node === prevTextBlot.domNode) {\n return offset;\n }\n if (node === textNode) {\n return prevTextLength + offset - 1;\n }\n if (nextTextBlot && node === nextTextBlot.domNode) {\n return prevTextLength + newText.length + offset;\n }\n return null;\n };\n\n const start = remapOffset(range.start.node, range.start.offset);\n const end = remapOffset(range.end.node, range.end.offset);\n if (start !== null && end !== null) {\n return {\n startNode: mergedTextBlot.domNode,\n startOffset: start,\n endNode: mergedTextBlot.domNode,\n endOffset: end,\n };\n }\n }\n return null;\n }\n\n update(mutations: MutationRecord[], context: Record<string, unknown>) {\n if (\n mutations.some((mutation) => {\n return (\n mutation.type === 'characterData' && mutation.target === this.textNode\n );\n })\n ) {\n const range = this.restore();\n if (range) context.range = range;\n }\n }\n\n // Avoid .ql-cursor being a descendant of `<a/>`.\n // The reason is Safari pushes down `<a/>` on text insertion.\n // That will cause DOM nodes not sync with the model.\n //\n // For example ({I} is the caret), given the markup:\n // <a><span class=\"ql-cursor\">\\uFEFF{I}</span></a>\n // When typing a char \"x\", `<a/>` will be pushed down inside the `<span>` first:\n // <span class=\"ql-cursor\"><a>\\uFEFF{I}</a></span>\n // And then \"x\" will be inserted after `<a/>`:\n // <span class=\"ql-cursor\"><a>\\uFEFF</a>d{I}</span>\n optimize(context?: unknown) {\n // @ts-expect-error Fix me later\n super.optimize(context);\n\n let { parent } = this;\n while (parent) {\n if (parent.domNode.tagName === 'A') {\n this.savedLength = Cursor.CONTENTS.length;\n // @ts-expect-error TODO: make isolate generic\n parent.isolate(this.offset(parent), this.length()).unwrap();\n this.savedLength = 0;\n break;\n }\n parent = parent.parent;\n }\n }\n\n value() {\n return '';\n }\n}\n\nexport default Cursor;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAG5C,OAAOC,QAAQ,MAAM,WAAW;AAGhC,MAAMC,MAAM,SAASH,SAAS,CAAC;EAC7B,OAAOI,QAA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EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACAR,QAAQA,CAACoC,OAAiB,EAAE;IAC1B;IACA,KAAK,CAACpC,QAAQ,CAACoC,OAAO,CAAC;IAEvB,IAAI;MAAE/C;IAAO,CAAC,GAAG,IAAI;IACrB,OAAOA,MAAM,EAAE;MACb,IAAIA,MAAM,CAACR,OAAO,CAACN,OAAO,KAAK,GAAG,EAAE;QAClC,IAAI,CAACY,WAAW,GAAGf,MAAM,CAACI,QAAQ,CAACuB,MAAM;QACzC;QACAV,MAAM,CAACmD,OAAO,CAAC,IAAI,CAAC1C,MAAM,CAACT,MAAM,CAAC,EAAE,IAAI,CAACU,MAAM,CAAC,CAAC,CAAC,CAAC0C,MAAM,CAAC,CAAC;QAC3D,IAAI,CAACtD,WAAW,GAAG,CAAC;QACpB;MACF;MACAE,MAAM,GAAGA,MAAM,CAACA,MAAM;IACxB;EACF;EAEAZ,KAAKA,CAAA,EAAG;IACN,OAAO,EAAE;EACX;AACF;AAEA,eAAeL,MAAM","ignoreList":[]}
|
package/blots/embed.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ScrollBlot } from 'parchment';
|
|
2
|
-
import { EmbedBlot } from 'parchment';
|
|
3
|
-
export interface EmbedContextRange {
|
|
4
|
-
startNode: Node | Text;
|
|
5
|
-
startOffset: number;
|
|
6
|
-
endNode?: Node | Text;
|
|
7
|
-
endOffset?: number;
|
|
8
|
-
}
|
|
9
|
-
declare class Embed extends EmbedBlot {
|
|
10
|
-
contentNode: HTMLSpanElement;
|
|
11
|
-
leftGuard: Text;
|
|
12
|
-
rightGuard: Text;
|
|
13
|
-
constructor(scroll: ScrollBlot, node: Node);
|
|
14
|
-
index(node: Node, offset: number): number;
|
|
15
|
-
restore(node: Text): EmbedContextRange | null;
|
|
16
|
-
update(mutations: MutationRecord[], context: Record<string, unknown>): void;
|
|
17
|
-
}
|
|
18
|
-
export default Embed;
|
package/blots/embed.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { EmbedBlot } from 'parchment';
|
|
2
|
-
import TextBlot from './text.js';
|
|
3
|
-
const GUARD_TEXT = '\uFEFF';
|
|
4
|
-
class Embed extends EmbedBlot {
|
|
5
|
-
constructor(scroll, node) {
|
|
6
|
-
super(scroll, node);
|
|
7
|
-
this.contentNode = document.createElement('span');
|
|
8
|
-
this.contentNode.setAttribute('contenteditable', 'false');
|
|
9
|
-
Array.from(this.domNode.childNodes).forEach(childNode => {
|
|
10
|
-
this.contentNode.appendChild(childNode);
|
|
11
|
-
});
|
|
12
|
-
this.leftGuard = document.createTextNode(GUARD_TEXT);
|
|
13
|
-
this.rightGuard = document.createTextNode(GUARD_TEXT);
|
|
14
|
-
this.domNode.appendChild(this.leftGuard);
|
|
15
|
-
this.domNode.appendChild(this.contentNode);
|
|
16
|
-
this.domNode.appendChild(this.rightGuard);
|
|
17
|
-
}
|
|
18
|
-
index(node, offset) {
|
|
19
|
-
if (node === this.leftGuard) return 0;
|
|
20
|
-
if (node === this.rightGuard) return 1;
|
|
21
|
-
return super.index(node, offset);
|
|
22
|
-
}
|
|
23
|
-
restore(node) {
|
|
24
|
-
let range = null;
|
|
25
|
-
let textNode;
|
|
26
|
-
const text = node.data.split(GUARD_TEXT).join('');
|
|
27
|
-
if (node === this.leftGuard) {
|
|
28
|
-
if (this.prev instanceof TextBlot) {
|
|
29
|
-
const prevLength = this.prev.length();
|
|
30
|
-
this.prev.insertAt(prevLength, text);
|
|
31
|
-
range = {
|
|
32
|
-
startNode: this.prev.domNode,
|
|
33
|
-
startOffset: prevLength + text.length
|
|
34
|
-
};
|
|
35
|
-
} else {
|
|
36
|
-
textNode = document.createTextNode(text);
|
|
37
|
-
this.parent.insertBefore(this.scroll.create(textNode), this);
|
|
38
|
-
range = {
|
|
39
|
-
startNode: textNode,
|
|
40
|
-
startOffset: text.length
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
} else if (node === this.rightGuard) {
|
|
44
|
-
if (this.next instanceof TextBlot) {
|
|
45
|
-
this.next.insertAt(0, text);
|
|
46
|
-
range = {
|
|
47
|
-
startNode: this.next.domNode,
|
|
48
|
-
startOffset: text.length
|
|
49
|
-
};
|
|
50
|
-
} else {
|
|
51
|
-
textNode = document.createTextNode(text);
|
|
52
|
-
this.parent.insertBefore(this.scroll.create(textNode), this.next);
|
|
53
|
-
range = {
|
|
54
|
-
startNode: textNode,
|
|
55
|
-
startOffset: text.length
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
node.data = GUARD_TEXT;
|
|
60
|
-
return range;
|
|
61
|
-
}
|
|
62
|
-
update(mutations, context) {
|
|
63
|
-
mutations.forEach(mutation => {
|
|
64
|
-
if (mutation.type === 'characterData' && (mutation.target === this.leftGuard || mutation.target === this.rightGuard)) {
|
|
65
|
-
const range = this.restore(mutation.target);
|
|
66
|
-
if (range) context.range = range;
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export default Embed;
|
|
72
|
-
//# sourceMappingURL=embed.js.map
|
package/blots/embed.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"embed.js","names":["EmbedBlot","TextBlot","GUARD_TEXT","Embed","constructor","scroll","node","contentNode","document","createElement","setAttribute","Array","from","domNode","childNodes","forEach","childNode","appendChild","leftGuard","createTextNode","rightGuard","index","offset","restore","range","textNode","text","data","split","join","prev","prevLength","length","insertAt","startNode","startOffset","parent","insertBefore","create","next","update","mutations","context","mutation","type","target"],"sources":["../../src/blots/embed.ts"],"sourcesContent":["import type { ScrollBlot } from 'parchment';\nimport { EmbedBlot } from 'parchment';\nimport TextBlot from './text.js';\n\nconst GUARD_TEXT = '\\uFEFF';\n\nexport interface EmbedContextRange {\n startNode: Node | Text;\n startOffset: number;\n endNode?: Node | Text;\n endOffset?: number;\n}\n\nclass Embed extends EmbedBlot {\n contentNode: HTMLSpanElement;\n leftGuard: Text;\n rightGuard: Text;\n\n constructor(scroll: ScrollBlot, node: Node) {\n super(scroll, node);\n this.contentNode = document.createElement('span');\n this.contentNode.setAttribute('contenteditable', 'false');\n Array.from(this.domNode.childNodes).forEach((childNode) => {\n this.contentNode.appendChild(childNode);\n });\n this.leftGuard = document.createTextNode(GUARD_TEXT);\n this.rightGuard = document.createTextNode(GUARD_TEXT);\n this.domNode.appendChild(this.leftGuard);\n this.domNode.appendChild(this.contentNode);\n this.domNode.appendChild(this.rightGuard);\n }\n\n index(node: Node, offset: number) {\n if (node === this.leftGuard) return 0;\n if (node === this.rightGuard) return 1;\n return super.index(node, offset);\n }\n\n restore(node: Text): EmbedContextRange | null {\n let range: EmbedContextRange | null = null;\n let textNode: Text;\n const text = node.data.split(GUARD_TEXT).join('');\n if (node === this.leftGuard) {\n if (this.prev instanceof TextBlot) {\n const prevLength = this.prev.length();\n this.prev.insertAt(prevLength, text);\n range = {\n startNode: this.prev.domNode,\n startOffset: prevLength + text.length,\n };\n } else {\n textNode = document.createTextNode(text);\n this.parent.insertBefore(this.scroll.create(textNode), this);\n range = {\n startNode: textNode,\n startOffset: text.length,\n };\n }\n } else if (node === this.rightGuard) {\n if (this.next instanceof TextBlot) {\n this.next.insertAt(0, text);\n range = {\n startNode: this.next.domNode,\n startOffset: text.length,\n };\n } else {\n textNode = document.createTextNode(text);\n this.parent.insertBefore(this.scroll.create(textNode), this.next);\n range = {\n startNode: textNode,\n startOffset: text.length,\n };\n }\n }\n node.data = GUARD_TEXT;\n return range;\n }\n\n update(mutations: MutationRecord[], context: Record<string, unknown>) {\n mutations.forEach((mutation) => {\n if (\n mutation.type === 'characterData' &&\n (mutation.target === this.leftGuard ||\n mutation.target === this.rightGuard)\n ) {\n const range = this.restore(mutation.target as Text);\n if (range) context.range = range;\n }\n });\n }\n}\n\nexport default Embed;\n"],"mappings":"AACA,SAASA,SAAS,QAAQ,WAAW;AACrC,OAAOC,QAAQ,MAAM,WAAW;AAEhC,MAAMC,UAAU,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I,CAACM;QACpB,CAAC;MACH;IACF;IACA1B,IAAI,CAACqB,IAAI,GAAGzB,UAAU;IACtB,OAAOsB,KAAK;EACd;EAEAgB,MAAMA,CAACC,SAA2B,EAAEC,OAAgC,EAAE;IACpED,SAAS,CAAC1B,OAAO,CAAE4B,QAAQ,IAAK;MAC9B,IACEA,QAAQ,CAACC,IAAI,KAAK,eAAe,KAChCD,QAAQ,CAACE,MAAM,KAAK,IAAI,CAAC3B,SAAS,IACjCyB,QAAQ,CAACE,MAAM,KAAK,IAAI,CAACzB,UAAU,CAAC,EACtC;QACA,MAAMI,KAAK,GAAG,IAAI,CAACD,OAAO,CAACoB,QAAQ,CAACE,MAAc,CAAC;QACnD,IAAIrB,KAAK,EAAEkB,OAAO,CAAClB,KAAK,GAAGA,KAAK;MAClC;IACF,CAAC,CAAC;EACJ;AACF;AAEA,eAAerB,KAAK","ignoreList":[]}
|
package/blots/inline.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { InlineBlot } from 'parchment';
|
|
2
|
-
import type { BlotConstructor } from 'parchment';
|
|
3
|
-
declare class Inline extends InlineBlot {
|
|
4
|
-
static allowedChildren: BlotConstructor[];
|
|
5
|
-
static order: string[];
|
|
6
|
-
static compare(self: string, other: string): number;
|
|
7
|
-
formatAt(index: number, length: number, name: string, value: unknown): void;
|
|
8
|
-
optimize(context: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}): void;
|
|
11
|
-
}
|
|
12
|
-
export default Inline;
|
package/blots/inline.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { EmbedBlot, InlineBlot, Scope } from 'parchment';
|
|
2
|
-
import Break from './break.js';
|
|
3
|
-
import Text from './text.js';
|
|
4
|
-
class Inline extends InlineBlot {
|
|
5
|
-
static allowedChildren = [Inline, Break, EmbedBlot, Text];
|
|
6
|
-
// Lower index means deeper in the DOM tree, since not found (-1) is for embeds
|
|
7
|
-
static order = ['cursor', 'inline',
|
|
8
|
-
// Must be lower
|
|
9
|
-
'link',
|
|
10
|
-
// Chrome wants <a> to be lower
|
|
11
|
-
'underline', 'strike', 'italic', 'bold', 'script', 'code' // Must be higher
|
|
12
|
-
];
|
|
13
|
-
static compare(self, other) {
|
|
14
|
-
const selfIndex = Inline.order.indexOf(self);
|
|
15
|
-
const otherIndex = Inline.order.indexOf(other);
|
|
16
|
-
if (selfIndex >= 0 || otherIndex >= 0) {
|
|
17
|
-
return selfIndex - otherIndex;
|
|
18
|
-
}
|
|
19
|
-
if (self === other) {
|
|
20
|
-
return 0;
|
|
21
|
-
}
|
|
22
|
-
if (self < other) {
|
|
23
|
-
return -1;
|
|
24
|
-
}
|
|
25
|
-
return 1;
|
|
26
|
-
}
|
|
27
|
-
formatAt(index, length, name, value) {
|
|
28
|
-
if (Inline.compare(this.statics.blotName, name) < 0 && this.scroll.query(name, Scope.BLOT)) {
|
|
29
|
-
const blot = this.isolate(index, length);
|
|
30
|
-
if (value) {
|
|
31
|
-
blot.wrap(name, value);
|
|
32
|
-
}
|
|
33
|
-
} else {
|
|
34
|
-
super.formatAt(index, length, name, value);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
optimize(context) {
|
|
38
|
-
super.optimize(context);
|
|
39
|
-
if (this.parent instanceof Inline && Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0) {
|
|
40
|
-
const parent = this.parent.isolate(this.offset(), this.length());
|
|
41
|
-
// @ts-expect-error TODO: make isolate generic
|
|
42
|
-
this.moveChildren(parent);
|
|
43
|
-
parent.wrap(this);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
export default Inline;
|
|
48
|
-
//# sourceMappingURL=inline.js.map
|
package/blots/inline.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inline.js","names":["EmbedBlot","InlineBlot","Scope","Break","Text","Inline","allowedChildren","order","compare","self","other","selfIndex","indexOf","otherIndex","formatAt","index","length","name","value","statics","blotName","scroll","query","BLOT","blot","isolate","wrap","optimize","context","parent","offset","moveChildren"],"sources":["../../src/blots/inline.ts"],"sourcesContent":["import { EmbedBlot, InlineBlot, Scope } from 'parchment';\nimport type { BlotConstructor } from 'parchment';\nimport Break from './break.js';\nimport Text from './text.js';\n\nclass Inline extends InlineBlot {\n static allowedChildren: BlotConstructor[] = [Inline, Break, EmbedBlot, Text];\n // Lower index means deeper in the DOM tree, since not found (-1) is for embeds\n static order = [\n 'cursor',\n 'inline', // Must be lower\n 'link', // Chrome wants <a> to be lower\n 'underline',\n 'strike',\n 'italic',\n 'bold',\n 'script',\n 'code', // Must be higher\n ];\n\n static compare(self: string, other: string) {\n const selfIndex = Inline.order.indexOf(self);\n const otherIndex = Inline.order.indexOf(other);\n if (selfIndex >= 0 || otherIndex >= 0) {\n return selfIndex - otherIndex;\n }\n if (self === other) {\n return 0;\n }\n if (self < other) {\n return -1;\n }\n return 1;\n }\n\n formatAt(index: number, length: number, name: string, value: unknown) {\n if (\n Inline.compare(this.statics.blotName, name) < 0 &&\n this.scroll.query(name, Scope.BLOT)\n ) {\n const blot = this.isolate(index, length);\n if (value) {\n blot.wrap(name, value);\n }\n } else {\n super.formatAt(index, length, name, value);\n }\n }\n\n optimize(context: { [key: string]: any }) {\n super.optimize(context);\n if (\n this.parent instanceof Inline &&\n Inline.compare(this.statics.blotName, this.parent.statics.blotName) > 0\n ) {\n const parent = this.parent.isolate(this.offset(), this.length());\n // @ts-expect-error TODO: make isolate generic\n this.moveChildren(parent);\n parent.wrap(this);\n }\n }\n}\n\nexport default Inline;\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,UAAU,EAAEC,KAAK,QAAQ,WAAW;AAExD,OAAOC,KAAK,MAAM,YAAY;AAC9B,OAAOC,IAAI,MAAM,WAAW;AAE5B,MAAMC,MAAM,SAASJ,UAAU,CAAC;EAC9B,OAAOK,eAAe,GAAsB,CAACD,MAAM,EAAEF,KAAK,EAAEH,SAAS,EAAEI,IAAI,CAAC;EAC5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AAI,CAACC,MAAM,YAAYxB,MAAM,IAC7BA,MAAM,CAACG,OAAO,CAAC,IAAI,CAACW,OAAO,CAACC,QAAQ,EAAE,IAAI,CAACS,MAAM,CAACV,OAAO,CAACC,QAAQ,CAAC,GAAG,CAAC,EACvE;MACA,MAAMS,MAAM,GAAG,IAAI,CAACA,MAAM,CAACJ,OAAO,CAAC,IAAI,CAACK,MAAM,CAAC,CAAC,EAAE,IAAI,CAACd,MAAM,CAAC,CAAC,CAAC;MAChE;MACA,IAAI,CAACe,YAAY,CAACF,MAAM,CAAC;MACzBA,MAAM,CAACH,IAAI,CAAC,IAAI,CAAC;IACnB;EACF;AACF;AAEA,eAAerB,MAAM","ignoreList":[]}
|
package/blots/scroll.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { LeafBlot, ScrollBlot } from 'parchment';
|
|
2
|
-
import type { Blot, Registry } from 'parchment';
|
|
3
|
-
import Delta from 'quill-delta';
|
|
4
|
-
import Emitter from '../core/emitter.js';
|
|
5
|
-
import type { EmitterSource } from '../core/emitter.js';
|
|
6
|
-
import Block, { BlockEmbed } from './block.js';
|
|
7
|
-
import Container from './container.js';
|
|
8
|
-
declare class Scroll extends ScrollBlot {
|
|
9
|
-
static blotName: string;
|
|
10
|
-
static className: string;
|
|
11
|
-
static tagName: string;
|
|
12
|
-
static defaultChild: typeof Block;
|
|
13
|
-
static allowedChildren: (typeof Block | typeof BlockEmbed | typeof Container)[];
|
|
14
|
-
emitter: Emitter;
|
|
15
|
-
batch: false | MutationRecord[];
|
|
16
|
-
constructor(registry: Registry, domNode: HTMLDivElement, { emitter }: {
|
|
17
|
-
emitter: Emitter;
|
|
18
|
-
});
|
|
19
|
-
batchStart(): void;
|
|
20
|
-
batchEnd(): void;
|
|
21
|
-
emitMount(blot: Blot): void;
|
|
22
|
-
emitUnmount(blot: Blot): void;
|
|
23
|
-
emitEmbedUpdate(blot: Blot, change: unknown): void;
|
|
24
|
-
deleteAt(index: number, length: number): void;
|
|
25
|
-
enable(enabled?: boolean): void;
|
|
26
|
-
formatAt(index: number, length: number, format: string, value: unknown): void;
|
|
27
|
-
insertAt(index: number, value: string, def?: unknown): void;
|
|
28
|
-
insertBefore(blot: Blot, ref?: Blot | null): void;
|
|
29
|
-
insertContents(index: number, delta: Delta): void;
|
|
30
|
-
isEnabled(): boolean;
|
|
31
|
-
leaf(index: number): [LeafBlot | null, number];
|
|
32
|
-
line(index: number): [Block | BlockEmbed | null, number];
|
|
33
|
-
lines(index?: number, length?: number): (Block | BlockEmbed)[];
|
|
34
|
-
optimize(context?: {
|
|
35
|
-
[key: string]: any;
|
|
36
|
-
}): void;
|
|
37
|
-
optimize(mutations?: MutationRecord[], context?: {
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
}): void;
|
|
40
|
-
path(index: number): [Blot, number][];
|
|
41
|
-
remove(): void;
|
|
42
|
-
update(source?: EmitterSource): void;
|
|
43
|
-
update(mutations?: MutationRecord[]): void;
|
|
44
|
-
updateEmbedAt(index: number, key: string, change: unknown): void;
|
|
45
|
-
protected handleDragStart(event: DragEvent): void;
|
|
46
|
-
private deltaToRenderBlocks;
|
|
47
|
-
private createBlock;
|
|
48
|
-
}
|
|
49
|
-
export default Scroll;
|