@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/modules/uiNode.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { ParentBlot } from 'parchment';
|
|
2
|
-
import Module from '../core/module.js';
|
|
3
|
-
import Quill from '../core/quill.js';
|
|
4
|
-
const isMac = /Mac/i.test(navigator.platform);
|
|
5
|
-
|
|
6
|
-
// Export for testing
|
|
7
|
-
export const TTL_FOR_VALID_SELECTION_CHANGE = 100;
|
|
8
|
-
|
|
9
|
-
// A loose check to determine if the shortcut can move the caret before a UI node:
|
|
10
|
-
// <ANY_PARENT>[CARET]<div class="ql-ui"></div>[CONTENT]</ANY_PARENT>
|
|
11
|
-
const canMoveCaretBeforeUINode = event => {
|
|
12
|
-
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight' ||
|
|
13
|
-
// RTL scripts or moving from the end of the previous line
|
|
14
|
-
event.key === 'ArrowUp' || event.key === 'ArrowDown' || event.key === 'Home') {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
if (isMac && event.key === 'a' && event.ctrlKey === true) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
};
|
|
22
|
-
class UINode extends Module {
|
|
23
|
-
isListening = false;
|
|
24
|
-
selectionChangeDeadline = 0;
|
|
25
|
-
constructor(quill, options) {
|
|
26
|
-
super(quill, options);
|
|
27
|
-
this.handleArrowKeys();
|
|
28
|
-
this.handleNavigationShortcuts();
|
|
29
|
-
}
|
|
30
|
-
handleArrowKeys() {
|
|
31
|
-
this.quill.keyboard.addBinding({
|
|
32
|
-
key: ['ArrowLeft', 'ArrowRight'],
|
|
33
|
-
offset: 0,
|
|
34
|
-
shiftKey: null,
|
|
35
|
-
handler(range, _ref) {
|
|
36
|
-
let {
|
|
37
|
-
line,
|
|
38
|
-
event
|
|
39
|
-
} = _ref;
|
|
40
|
-
if (!(line instanceof ParentBlot) || !line.uiNode) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
const isRTL = getComputedStyle(line.domNode)['direction'] === 'rtl';
|
|
44
|
-
if (isRTL && event.key !== 'ArrowRight' || !isRTL && event.key !== 'ArrowLeft') {
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
this.quill.setSelection(range.index - 1, range.length + (event.shiftKey ? 1 : 0), Quill.sources.USER);
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
handleNavigationShortcuts() {
|
|
53
|
-
this.quill.root.addEventListener('keydown', event => {
|
|
54
|
-
if (!event.defaultPrevented && canMoveCaretBeforeUINode(event)) {
|
|
55
|
-
this.ensureListeningToSelectionChange();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* We only listen to the `selectionchange` event when
|
|
62
|
-
* there is an intention of moving the caret to the beginning using shortcuts.
|
|
63
|
-
* This is primarily implemented to prevent infinite loops, as we are changing
|
|
64
|
-
* the selection within the handler of a `selectionchange` event.
|
|
65
|
-
*/
|
|
66
|
-
ensureListeningToSelectionChange() {
|
|
67
|
-
this.selectionChangeDeadline = Date.now() + TTL_FOR_VALID_SELECTION_CHANGE;
|
|
68
|
-
if (this.isListening) return;
|
|
69
|
-
this.isListening = true;
|
|
70
|
-
const listener = () => {
|
|
71
|
-
this.isListening = false;
|
|
72
|
-
if (Date.now() <= this.selectionChangeDeadline) {
|
|
73
|
-
this.handleSelectionChange();
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
document.addEventListener('selectionchange', listener, {
|
|
77
|
-
once: true
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
handleSelectionChange() {
|
|
81
|
-
const selection = document.getSelection();
|
|
82
|
-
if (!selection) return;
|
|
83
|
-
const range = selection.getRangeAt(0);
|
|
84
|
-
if (range.collapsed !== true || range.startOffset !== 0) return;
|
|
85
|
-
const line = this.quill.scroll.find(range.startContainer);
|
|
86
|
-
if (!(line instanceof ParentBlot) || !line.uiNode) return;
|
|
87
|
-
const newRange = document.createRange();
|
|
88
|
-
newRange.setStartAfter(line.uiNode);
|
|
89
|
-
newRange.setEndAfter(line.uiNode);
|
|
90
|
-
selection.removeAllRanges();
|
|
91
|
-
selection.addRange(newRange);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
export default UINode;
|
|
95
|
-
//# sourceMappingURL=uiNode.js.map
|
package/modules/uiNode.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uiNode.js","names":["ParentBlot","Module","Quill","isMac","test","navigator","platform","TTL_FOR_VALID_SELECTION_CHANGE","canMoveCaretBeforeUINode","event","key","ctrlKey","UINode","isListening","selectionChangeDeadline","constructor","quill","options","handleArrowKeys","handleNavigationShortcuts","keyboard","addBinding","offset","shiftKey","handler","range","_ref","line","uiNode","isRTL","getComputedStyle","domNode","setSelection","index","length","sources","USER","root","addEventListener","defaultPrevented","ensureListeningToSelectionChange","Date","now","listener","handleSelectionChange","document","once","selection","getSelection","getRangeAt","collapsed","startOffset","scroll","find","startContainer","newRange","createRange","setStartAfter","setEndAfter","removeAllRanges","addRange"],"sources":["../../src/modules/uiNode.ts"],"sourcesContent":["import { ParentBlot } from 'parchment';\nimport Module from '../core/module.js';\nimport Quill from '../core/quill.js';\n\nconst isMac = /Mac/i.test(navigator.platform);\n\n// Export for testing\nexport const TTL_FOR_VALID_SELECTION_CHANGE = 100;\n\n// A loose check to determine if the shortcut can move the caret before a UI node:\n// <ANY_PARENT>[CARET]<div class=\"ql-ui\"></div>[CONTENT]</ANY_PARENT>\nconst canMoveCaretBeforeUINode = (event: KeyboardEvent) => {\n if (\n event.key === 'ArrowLeft' ||\n event.key === 'ArrowRight' || // RTL scripts or moving from the end of the previous line\n event.key === 'ArrowUp' ||\n event.key === 'ArrowDown' ||\n event.key === 'Home'\n ) {\n return true;\n }\n\n if (isMac && event.key === 'a' && event.ctrlKey === true) {\n return true;\n }\n\n return false;\n};\n\nclass UINode extends Module {\n isListening = false;\n selectionChangeDeadline = 0;\n\n constructor(quill: Quill, options: Record<string, never>) {\n super(quill, options);\n\n this.handleArrowKeys();\n this.handleNavigationShortcuts();\n }\n\n private handleArrowKeys() {\n this.quill.keyboard.addBinding({\n key: ['ArrowLeft', 'ArrowRight'],\n offset: 0,\n shiftKey: null,\n handler(range, { line, event }) {\n if (!(line instanceof ParentBlot) || !line.uiNode) {\n return true;\n }\n\n const isRTL = getComputedStyle(line.domNode)['direction'] === 'rtl';\n if (\n (isRTL && event.key !== 'ArrowRight') ||\n (!isRTL && event.key !== 'ArrowLeft')\n ) {\n return true;\n }\n\n this.quill.setSelection(\n range.index - 1,\n range.length + (event.shiftKey ? 1 : 0),\n Quill.sources.USER,\n );\n return false;\n },\n });\n }\n\n private handleNavigationShortcuts() {\n this.quill.root.addEventListener('keydown', (event) => {\n if (!event.defaultPrevented && canMoveCaretBeforeUINode(event)) {\n this.ensureListeningToSelectionChange();\n }\n });\n }\n\n /**\n * We only listen to the `selectionchange` event when\n * there is an intention of moving the caret to the beginning using shortcuts.\n * This is primarily implemented to prevent infinite loops, as we are changing\n * the selection within the handler of a `selectionchange` event.\n */\n private ensureListeningToSelectionChange() {\n this.selectionChangeDeadline = Date.now() + TTL_FOR_VALID_SELECTION_CHANGE;\n\n if (this.isListening) return;\n this.isListening = true;\n\n const listener = () => {\n this.isListening = false;\n\n if (Date.now() <= this.selectionChangeDeadline) {\n this.handleSelectionChange();\n }\n };\n\n document.addEventListener('selectionchange', listener, {\n once: true,\n });\n }\n\n private handleSelectionChange() {\n const selection = document.getSelection();\n if (!selection) return;\n const range = selection.getRangeAt(0);\n if (range.collapsed !== true || range.startOffset !== 0) return;\n\n const line = this.quill.scroll.find(range.startContainer);\n if (!(line instanceof ParentBlot) || !line.uiNode) return;\n\n const newRange = document.createRange();\n newRange.setStartAfter(line.uiNode);\n newRange.setEndAfter(line.uiNode);\n selection.removeAllRanges();\n selection.addRange(newRange);\n }\n}\n\nexport default UINode;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,WAAW;AACtC,OAAOC,MAAM,MAAM,mBAAmB;AACtC,OAAOC,KAAK,MAAM,kBAAkB;AAEpC,MAAMC,KAAK,GAAG,MAAM,CAACC,IAAI,CAACC,SAAS,CAACC,QAAQ,CAAC;;AAE7C;AACA,OAAO,MAAMC,8BAA8B,GAAG,GAAG;;AAEjD;AACA;AACA,MAAMC,wBAAwB,GAAIC,KAAoB,IAAK;EACzD,IACEA,KAAK,CAACC,GAAG,KAAK,WAAW,IACzBD,KAAK,CAACC,GAAG,KAAK,YAAY;EAAI;EAC9BD,KAAK,CAACC,GAAG,KAAK,SAAS,IACvBD,KAAK,CAACC,GAAG,KAAK,WAAW,IACzBD,KAAK,CAACC,GAAG,KAAK,MAAM,EACpB;IACA,OAAO,IAAI;EACb;EAEA,IAAIP,KAAK,IAAIM,KAAK,CAACC,GAAG,KAAK,GAAG,IAAID,KAAK,CAACE,OAAO,KAAK,IAAI,EAAE;IACxD,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd,CAAC;AAED,MAAMC,MAAM,SAASX,MAAM,CAAC;EAC1BY,WAAW,GAAG,KAAK;EACnBC,uBAAuB,GAAG,CAAC;EAE3BC,WAAWA,CAACC,KAAY,EAAEC,OAA8B,EAAE;IACxD,KAAK,CAACD,KAAK,EAAEC,OAAO,CAAC;IAErB,IAAI,CAACC,eAAe,CAAC,CAAC;IACtB,IAAI,CAACC,yBAAyB,CAAC,CAAC;EAClC;EAEQD,eAAeA,CAAA,EAAG;IACxB,IAAI,CAACF,KAAK,CAACI,QAAQ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|
-
import type Quill from '../core/quill.js';
|
|
2
|
-
import Module from '../core/module.js';
|
|
3
|
-
import type { Range } from '../core/selection.js';
|
|
4
|
-
interface UploaderOptions {
|
|
5
|
-
mimetypes: string[];
|
|
6
|
-
handler: (this: {
|
|
7
|
-
quill: Quill;
|
|
8
|
-
}, range: Range, files: File[]) => void;
|
|
9
|
-
}
|
|
10
|
-
declare class Uploader extends Module<UploaderOptions> {
|
|
11
|
-
static DEFAULTS: UploaderOptions;
|
|
12
|
-
constructor(quill: Quill, options: Partial<UploaderOptions>);
|
|
13
|
-
upload(range: Range, files: FileList | File[]): void;
|
|
14
|
-
}
|
|
15
|
-
export default Uploader;
|
package/modules/uploader.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import Delta from 'quill-delta';
|
|
2
|
-
import Emitter from '../core/emitter.js';
|
|
3
|
-
import Module from '../core/module.js';
|
|
4
|
-
class Uploader extends Module {
|
|
5
|
-
constructor(quill, options) {
|
|
6
|
-
super(quill, options);
|
|
7
|
-
quill.root.addEventListener('drop', e => {
|
|
8
|
-
e.preventDefault();
|
|
9
|
-
let native = null;
|
|
10
|
-
if (document.caretRangeFromPoint) {
|
|
11
|
-
native = document.caretRangeFromPoint(e.clientX, e.clientY);
|
|
12
|
-
// @ts-expect-error
|
|
13
|
-
} else if (document.caretPositionFromPoint) {
|
|
14
|
-
// @ts-expect-error
|
|
15
|
-
const position = document.caretPositionFromPoint(e.clientX, e.clientY);
|
|
16
|
-
native = document.createRange();
|
|
17
|
-
native.setStart(position.offsetNode, position.offset);
|
|
18
|
-
native.setEnd(position.offsetNode, position.offset);
|
|
19
|
-
}
|
|
20
|
-
const normalized = native && quill.selection.normalizeNative(native);
|
|
21
|
-
if (normalized) {
|
|
22
|
-
const range = quill.selection.normalizedToRange(normalized);
|
|
23
|
-
if (e.dataTransfer?.files) {
|
|
24
|
-
this.upload(range, e.dataTransfer.files);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
upload(range, files) {
|
|
30
|
-
const uploads = [];
|
|
31
|
-
Array.from(files).forEach(file => {
|
|
32
|
-
if (file && this.options.mimetypes?.includes(file.type)) {
|
|
33
|
-
uploads.push(file);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
if (uploads.length > 0) {
|
|
37
|
-
// @ts-expect-error Fix me later
|
|
38
|
-
this.options.handler.call(this, range, uploads);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
Uploader.DEFAULTS = {
|
|
43
|
-
mimetypes: ['image/png', 'image/jpeg'],
|
|
44
|
-
handler(range, files) {
|
|
45
|
-
if (!this.quill.scroll.query('image')) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const promises = files.map(file => {
|
|
49
|
-
return new Promise(resolve => {
|
|
50
|
-
const reader = new FileReader();
|
|
51
|
-
reader.onload = () => {
|
|
52
|
-
resolve(reader.result);
|
|
53
|
-
};
|
|
54
|
-
reader.readAsDataURL(file);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
Promise.all(promises).then(images => {
|
|
58
|
-
const update = images.reduce((delta, image) => {
|
|
59
|
-
return delta.insert({
|
|
60
|
-
image
|
|
61
|
-
});
|
|
62
|
-
}, new Delta().retain(range.index).delete(range.length));
|
|
63
|
-
this.quill.updateContents(update, Emitter.sources.USER);
|
|
64
|
-
this.quill.setSelection(range.index + images.length, Emitter.sources.SILENT);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
export default Uploader;
|
|
69
|
-
//# sourceMappingURL=uploader.js.map
|
package/modules/uploader.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uploader.js","names":["Delta","Emitter","Module","Uploader","constructor","quill","options","root","addEventListener","e","preventDefault","native","document","caretRangeFromPoint","clientX","clientY","caretPositionFromPoint","position","createRange","setStart","offsetNode","offset","setEnd","normalized","selection","normalizeNative","range","normalizedToRange","dataTransfer","files","upload","uploads","Array","from","forEach","file","mimetypes","includes","type","push","length","handler","call","DEFAULTS","scroll","query","promises","map","Promise","resolve","reader","FileReader","onload","result","readAsDataURL","all","then","images","update","reduce","delta","image","insert","retain","index","delete","updateContents","sources","USER","setSelection","SILENT"],"sources":["../../src/modules/uploader.ts"],"sourcesContent":["import Delta from 'quill-delta';\nimport type Quill from '../core/quill.js';\nimport Emitter from '../core/emitter.js';\nimport Module from '../core/module.js';\nimport type { Range } from '../core/selection.js';\n\ninterface UploaderOptions {\n mimetypes: string[];\n handler: (this: { quill: Quill }, range: Range, files: File[]) => void;\n}\n\nclass Uploader extends Module<UploaderOptions> {\n static DEFAULTS: UploaderOptions;\n\n constructor(quill: Quill, options: Partial<UploaderOptions>) {\n super(quill, options);\n quill.root.addEventListener('drop', (e) => {\n e.preventDefault();\n let native: ReturnType<typeof document.createRange> | null = null;\n if (document.caretRangeFromPoint) {\n native = document.caretRangeFromPoint(e.clientX, e.clientY);\n // @ts-expect-error\n } else if (document.caretPositionFromPoint) {\n // @ts-expect-error\n const position = document.caretPositionFromPoint(e.clientX, e.clientY);\n native = document.createRange();\n native.setStart(position.offsetNode, position.offset);\n native.setEnd(position.offsetNode, position.offset);\n }\n\n const normalized = native && quill.selection.normalizeNative(native);\n if (normalized) {\n const range = quill.selection.normalizedToRange(normalized);\n if (e.dataTransfer?.files) {\n this.upload(range, e.dataTransfer.files);\n }\n }\n });\n }\n\n upload(range: Range, files: FileList | File[]) {\n const uploads: File[] = [];\n Array.from(files).forEach((file) => {\n if (file && this.options.mimetypes?.includes(file.type)) {\n uploads.push(file);\n }\n });\n if (uploads.length > 0) {\n // @ts-expect-error Fix me later\n this.options.handler.call(this, range, uploads);\n }\n }\n}\n\nUploader.DEFAULTS = {\n mimetypes: ['image/png', 'image/jpeg'],\n handler(range: Range, files: File[]) {\n if (!this.quill.scroll.query('image')) {\n return;\n }\n const promises = files.map<Promise<string>>((file) => {\n return new Promise((resolve) => {\n const reader = new FileReader();\n reader.onload = () => {\n resolve(reader.result as string);\n };\n reader.readAsDataURL(file);\n });\n });\n Promise.all(promises).then((images) => {\n const update = images.reduce((delta: Delta, image) => {\n return delta.insert({ image });\n }, new Delta().retain(range.index).delete(range.length)) as Delta;\n this.quill.updateContents(update, Emitter.sources.USER);\n this.quill.setSelection(\n range.index + images.length,\n Emitter.sources.SILENT,\n );\n });\n },\n};\n\nexport default Uploader;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,aAAa;AAE/B,OAAOC,OAAO,MAAM,oBAAoB;AACxC,OAAOC,MAAM,MAAM,mBAAmB;AAQtC,MAAMC,QAAQ,SAASD,MAAM,CAAkB;EAG7CE,WAAWA,CAACC,KAAY,EAAEC,OAAiC,EAAE;IAC3D,KAAK,CAACD,KAAK,EAAEC,OAAO,CAAC;IACrBD,KAAK,CAACE,IAAI,CAACC,gBAAgB,CAAC,MAAM,EAAGC,CAAC,IAAK;MACzCA,CAAC,CAACC,cAAc,CAAC,CAAC;MAClB,IAAIC,MAAsD,GAAG,IAAI;MACjE,IAAIC,QAAQ,CAACC,mBAAmB,EAAE;QAChCF,MAAM,GAAGC,QAAQ,CAACC,mBAAmB,CAACJ,CAAC,CAACK,OAAO,EAAEL,CAAC,CAACM,OAAO,CAAC;QAC3D;MACF,CAAC,MAAM,IAAIH,QAAQ,CAACI,sBAAsB,EAAE;QAC1C;QACA,MAAMC,QAAQ,GAAGL,QAAQ,CAACI,sBAAsB,CAACP,CAAC,CAACK,OAAO,EAAEL,CAAC,CAACM,OAAO,CAAC;QACtEJ,MAAM,GAAGC,QAAQ,CAACM,WAAW,CAAC,CAAC;QAC/BP,MAAM,CAACQ,QAAQ,CAACF,QAAQ,CAACG,UAAU,EAAEH,QAAQ,CAACI,MAAM,CAAC;QACrDV,MAAM,CAACW,MAAM,CAACL,QAAQ,CAACG,UAAU,EAAEH,QAAQ,CAACI,MAAM,CAAC;MACrD;MAEA,MAAME,UAAU,GAAGZ,MAAM,IAAIN,KA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AACE,MAAM,GAAG,MAAM;UACpBH,OAAO,CAACC,MAAM,CAACG,MAAgB,CAAC;QAClC,CAAC;QACDH,MAAM,CAACI,aAAa,CAACnB,IAAI,CAAC;MAC5B,CAAC,CAAC;IACJ,CAAC,CAAC;IACFa,OAAO,CAACO,GAAG,CAACT,QAAQ,CAAC,CAACU,IAAI,CAAEC,MAAM,IAAK;MACrC,MAAMC,MAAM,GAAGD,MAAM,CAACE,MAAM,CAAC,CAACC,KAAY,EAAEC,KAAK,KAAK;QACpD,OAAOD,KAAK,CAACE,MAAM,CAAC;UAAED;QAAM,CAAC,CAAC;MAChC,CAAC,EAAE,IAAI7D,KAAK,CAAC,CAAC,CAAC+D,MAAM,CAACrC,KAAK,CAACsC,KAAK,CAAC,CAACC,MAAM,CAACvC,KAAK,CAACc,MAAM,CAAC,CAAU;MACjE,IAAI,CAACnC,KAAK,CAAC6D,cAAc,CAACR,MAAM,EAAEzD,OAAO,CAACkE,OAAO,CAACC,IAAI,CAAC;MACvD,IAAI,CAAC/D,KAAK,CAACgE,YAAY,CACrB3C,KAAK,CAACsC,KAAK,GAAGP,MAAM,CAACjB,MAAM,EAC3BvC,OAAO,CAACkE,OAAO,CAACG,MAClB,CAAC;IACH,CAAC,CAAC;EACJ;AACF,CAAC;AAED,eAAenE,QAAQ","ignoreList":[]}
|
package/quill.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import Quill from './core.js';
|
|
2
|
-
import type { Bounds, DebugLevel, EmitterSource, ExpandedQuillOptions, QuillOptions } from './core.js';
|
|
3
|
-
export { AttributeMap, Delta, Module, Op, OpIterator, Parchment, Range, } from './core.js';
|
|
4
|
-
export type { Bounds, DebugLevel, EmitterSource, ExpandedQuillOptions, QuillOptions, };
|
|
5
|
-
export default Quill;
|
package/quill.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import Quill from './core.js';
|
|
2
|
-
import { AlignClass, AlignStyle } from './formats/align.js';
|
|
3
|
-
import { DirectionAttribute, DirectionClass, DirectionStyle } from './formats/direction.js';
|
|
4
|
-
import Indent from './formats/indent.js';
|
|
5
|
-
import Blockquote from './formats/blockquote.js';
|
|
6
|
-
import Header from './formats/header.js';
|
|
7
|
-
import List from './formats/list.js';
|
|
8
|
-
import { BackgroundClass, BackgroundStyle } from './formats/background.js';
|
|
9
|
-
import { ColorClass, ColorStyle } from './formats/color.js';
|
|
10
|
-
import { FontClass, FontStyle } from './formats/font.js';
|
|
11
|
-
import { SizeClass, SizeStyle } from './formats/size.js';
|
|
12
|
-
import Bold from './formats/bold.js';
|
|
13
|
-
import Italic from './formats/italic.js';
|
|
14
|
-
import Link from './formats/link.js';
|
|
15
|
-
import Script from './formats/script.js';
|
|
16
|
-
import Strike from './formats/strike.js';
|
|
17
|
-
import Underline from './formats/underline.js';
|
|
18
|
-
import Formula from './formats/formula.js';
|
|
19
|
-
import Image from './formats/image.js';
|
|
20
|
-
import Video from './formats/video.js';
|
|
21
|
-
import CodeBlock, { Code as InlineCode } from './formats/code.js';
|
|
22
|
-
import Syntax from './modules/syntax.js';
|
|
23
|
-
import Table from './modules/table.js';
|
|
24
|
-
import Toolbar from './modules/toolbar.js';
|
|
25
|
-
import Icons from './ui/icons.js';
|
|
26
|
-
import Picker from './ui/picker.js';
|
|
27
|
-
import ColorPicker from './ui/color-picker.js';
|
|
28
|
-
import IconPicker from './ui/icon-picker.js';
|
|
29
|
-
import Tooltip from './ui/tooltip.js';
|
|
30
|
-
import BubbleTheme from './themes/bubble.js';
|
|
31
|
-
import SnowTheme from './themes/snow.js';
|
|
32
|
-
Quill.register({
|
|
33
|
-
'attributors/attribute/direction': DirectionAttribute,
|
|
34
|
-
'attributors/class/align': AlignClass,
|
|
35
|
-
'attributors/class/background': BackgroundClass,
|
|
36
|
-
'attributors/class/color': ColorClass,
|
|
37
|
-
'attributors/class/direction': DirectionClass,
|
|
38
|
-
'attributors/class/font': FontClass,
|
|
39
|
-
'attributors/class/size': SizeClass,
|
|
40
|
-
'attributors/style/align': AlignStyle,
|
|
41
|
-
'attributors/style/background': BackgroundStyle,
|
|
42
|
-
'attributors/style/color': ColorStyle,
|
|
43
|
-
'attributors/style/direction': DirectionStyle,
|
|
44
|
-
'attributors/style/font': FontStyle,
|
|
45
|
-
'attributors/style/size': SizeStyle
|
|
46
|
-
}, true);
|
|
47
|
-
Quill.register({
|
|
48
|
-
'formats/align': AlignClass,
|
|
49
|
-
'formats/direction': DirectionClass,
|
|
50
|
-
'formats/indent': Indent,
|
|
51
|
-
'formats/background': BackgroundStyle,
|
|
52
|
-
'formats/color': ColorStyle,
|
|
53
|
-
'formats/font': FontClass,
|
|
54
|
-
'formats/size': SizeClass,
|
|
55
|
-
'formats/blockquote': Blockquote,
|
|
56
|
-
'formats/code-block': CodeBlock,
|
|
57
|
-
'formats/header': Header,
|
|
58
|
-
'formats/list': List,
|
|
59
|
-
'formats/bold': Bold,
|
|
60
|
-
'formats/code': InlineCode,
|
|
61
|
-
'formats/italic': Italic,
|
|
62
|
-
'formats/link': Link,
|
|
63
|
-
'formats/script': Script,
|
|
64
|
-
'formats/strike': Strike,
|
|
65
|
-
'formats/underline': Underline,
|
|
66
|
-
'formats/formula': Formula,
|
|
67
|
-
'formats/image': Image,
|
|
68
|
-
'formats/video': Video,
|
|
69
|
-
'modules/syntax': Syntax,
|
|
70
|
-
'modules/table': Table,
|
|
71
|
-
'modules/toolbar': Toolbar,
|
|
72
|
-
'themes/bubble': BubbleTheme,
|
|
73
|
-
'themes/snow': SnowTheme,
|
|
74
|
-
'ui/icons': Icons,
|
|
75
|
-
'ui/picker': Picker,
|
|
76
|
-
'ui/icon-picker': IconPicker,
|
|
77
|
-
'ui/color-picker': ColorPicker,
|
|
78
|
-
'ui/tooltip': Tooltip
|
|
79
|
-
}, true);
|
|
80
|
-
export { AttributeMap, Delta, Module, Op, OpIterator, Parchment, Range } from './core.js';
|
|
81
|
-
export default Quill;
|
|
82
|
-
//# sourceMappingURL=quill.js.map
|
package/quill.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"quill.js","names":["Quill","AlignClass","AlignStyle","DirectionAttribute","DirectionClass","DirectionStyle","Indent","Blockquote","Header","List","BackgroundClass","BackgroundStyle","ColorClass","ColorStyle","FontClass","FontStyle","SizeClass","SizeStyle","Bold","Italic","Link","Script","Strike","Underline","Formula","Image","Video","CodeBlock","Code","InlineCode","Syntax","Table","Toolbar","Icons","Picker","ColorPicker","IconPicker","Tooltip","BubbleTheme","SnowTheme","register","AttributeMap","Delta","Module","Op","OpIterator","Parchment","Range"],"sources":["../src/quill.ts"],"sourcesContent":["import Quill from './core.js';\nimport type {\n Bounds,\n DebugLevel,\n EmitterSource,\n ExpandedQuillOptions,\n QuillOptions,\n} from './core.js';\n\nimport { AlignClass, AlignStyle } from './formats/align.js';\nimport {\n DirectionAttribute,\n DirectionClass,\n DirectionStyle,\n} from './formats/direction.js';\nimport Indent from './formats/indent.js';\n\nimport Blockquote from './formats/blockquote.js';\nimport Header from './formats/header.js';\nimport List from './formats/list.js';\n\nimport { BackgroundClass, BackgroundStyle } from './formats/background.js';\nimport { ColorClass, ColorStyle } from './formats/color.js';\nimport { FontClass, FontStyle } from './formats/font.js';\nimport { SizeClass, SizeStyle } from './formats/size.js';\n\nimport Bold from './formats/bold.js';\nimport Italic from './formats/italic.js';\nimport Link from './formats/link.js';\nimport Script from './formats/script.js';\nimport Strike from './formats/strike.js';\nimport Underline from './formats/underline.js';\n\nimport Formula from './formats/formula.js';\nimport Image from './formats/image.js';\nimport Video from './formats/video.js';\n\nimport CodeBlock, { Code as InlineCode } from './formats/code.js';\n\nimport Syntax from './modules/syntax.js';\nimport Table from './modules/table.js';\nimport Toolbar from './modules/toolbar.js';\n\nimport Icons from './ui/icons.js';\nimport Picker from './ui/picker.js';\nimport ColorPicker from './ui/color-picker.js';\nimport IconPicker from './ui/icon-picker.js';\nimport Tooltip from './ui/tooltip.js';\n\nimport BubbleTheme from './themes/bubble.js';\nimport SnowTheme from './themes/snow.js';\n\nQuill.register(\n {\n 'attributors/attribute/direction': DirectionAttribute,\n\n 'attributors/class/align': AlignClass,\n 'attributors/class/background': BackgroundClass,\n 'attributors/class/color': ColorClass,\n 'attributors/class/direction': DirectionClass,\n 'attributors/class/font': FontClass,\n 'attributors/class/size': SizeClass,\n\n 'attributors/style/align': AlignStyle,\n 'attributors/style/background': BackgroundStyle,\n 'attributors/style/color': ColorStyle,\n 'attributors/style/direction': DirectionStyle,\n 'attributors/style/font': FontStyle,\n 'attributors/style/size': SizeStyle,\n },\n true,\n);\n\nQuill.register(\n {\n 'formats/align': AlignClass,\n 'formats/direction': DirectionClass,\n 'formats/indent': Indent,\n\n 'formats/background': BackgroundStyle,\n 'formats/color': ColorStyle,\n 'formats/font': FontClass,\n 'formats/size': SizeClass,\n\n 'formats/blockquote': Blockquote,\n 'formats/code-block': CodeBlock,\n 'formats/header': Header,\n 'formats/list': List,\n\n 'formats/bold': Bold,\n 'formats/code': InlineCode,\n 'formats/italic': Italic,\n 'formats/link': Link,\n 'formats/script': Script,\n 'formats/strike': Strike,\n 'formats/underline': Underline,\n\n 'formats/formula': Formula,\n 'formats/image': Image,\n 'formats/video': Video,\n\n 'modules/syntax': Syntax,\n 'modules/table': Table,\n 'modules/toolbar': Toolbar,\n\n 'themes/bubble': BubbleTheme,\n 'themes/snow': SnowTheme,\n\n 'ui/icons': Icons,\n 'ui/picker': Picker,\n 'ui/icon-picker': IconPicker,\n 'ui/color-picker': ColorPicker,\n 'ui/tooltip': Tooltip,\n },\n true,\n);\n\nexport {\n AttributeMap,\n Delta,\n Module,\n Op,\n OpIterator,\n Parchment,\n Range,\n} from './core.js';\nexport type {\n Bounds,\n DebugLevel,\n EmitterSource,\n ExpandedQuillOptions,\n QuillOptions,\n};\n\nexport default Quill;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,WAAW;AAS7B,SAASC,UAAU,EAAEC,UAAU,QAAQ,oBAAoB;AAC3D,SACEC,kBAAkB,EAClBC,cAA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ACA,WAAW;AASlB,eAAe/C,KAAK","ignoreList":[]}
|
package/themes/base.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type Quill from '../core/quill.js';
|
|
2
|
-
import Theme from '../core/theme.js';
|
|
3
|
-
import type { ThemeOptions } from '../core/theme.js';
|
|
4
|
-
import Picker from '../ui/picker.js';
|
|
5
|
-
import Tooltip from '../ui/tooltip.js';
|
|
6
|
-
import type { Range } from '../core/selection.js';
|
|
7
|
-
import type Clipboard from '../modules/clipboard.js';
|
|
8
|
-
import type History from '../modules/history.js';
|
|
9
|
-
import type Keyboard from '../modules/keyboard.js';
|
|
10
|
-
import type Uploader from '../modules/uploader.js';
|
|
11
|
-
import type Selection from '../core/selection.js';
|
|
12
|
-
declare class BaseTheme extends Theme {
|
|
13
|
-
pickers: Picker[];
|
|
14
|
-
tooltip?: Tooltip;
|
|
15
|
-
constructor(quill: Quill, options: ThemeOptions);
|
|
16
|
-
addModule(name: 'clipboard'): Clipboard;
|
|
17
|
-
addModule(name: 'keyboard'): Keyboard;
|
|
18
|
-
addModule(name: 'uploader'): Uploader;
|
|
19
|
-
addModule(name: 'history'): History;
|
|
20
|
-
addModule(name: 'selection'): Selection;
|
|
21
|
-
addModule(name: string): unknown;
|
|
22
|
-
buildButtons(buttons: NodeListOf<HTMLElement>, icons: Record<string, Record<string, string> | string>): void;
|
|
23
|
-
buildPickers(selects: NodeListOf<HTMLSelectElement>, icons: Record<string, string | Record<string, string>>): void;
|
|
24
|
-
}
|
|
25
|
-
declare class BaseTooltip extends Tooltip {
|
|
26
|
-
textbox: HTMLInputElement | null;
|
|
27
|
-
linkRange?: Range;
|
|
28
|
-
constructor(quill: Quill, boundsContainer?: HTMLElement);
|
|
29
|
-
listen(): void;
|
|
30
|
-
cancel(): void;
|
|
31
|
-
edit(mode?: string, preview?: string | null): void;
|
|
32
|
-
restoreFocus(): void;
|
|
33
|
-
save(): void;
|
|
34
|
-
}
|
|
35
|
-
export { BaseTooltip, BaseTheme as default };
|
package/themes/base.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { merge } from 'lodash-es';
|
|
2
|
-
import Emitter from '../core/emitter.js';
|
|
3
|
-
import Theme from '../core/theme.js';
|
|
4
|
-
import ColorPicker from '../ui/color-picker.js';
|
|
5
|
-
import IconPicker from '../ui/icon-picker.js';
|
|
6
|
-
import Picker from '../ui/picker.js';
|
|
7
|
-
import Tooltip from '../ui/tooltip.js';
|
|
8
|
-
const ALIGNS = [false, 'center', 'right', 'justify'];
|
|
9
|
-
const COLORS = ['#000000', '#e60000', '#ff9900', '#ffff00', '#008a00', '#0066cc', '#9933ff', '#ffffff', '#facccc', '#ffebcc', '#ffffcc', '#cce8cc', '#cce0f5', '#ebd6ff', '#bbbbbb', '#f06666', '#ffc266', '#ffff66', '#66b966', '#66a3e0', '#c285ff', '#888888', '#a10000', '#b26b00', '#b2b200', '#006100', '#0047b2', '#6b24b2', '#444444', '#5c0000', '#663d00', '#666600', '#003700', '#002966', '#3d1466'];
|
|
10
|
-
const FONTS = [false, 'serif', 'monospace'];
|
|
11
|
-
const HEADERS = ['1', '2', '3', false];
|
|
12
|
-
const SIZES = ['small', false, 'large', 'huge'];
|
|
13
|
-
class BaseTheme extends Theme {
|
|
14
|
-
constructor(quill, options) {
|
|
15
|
-
super(quill, options);
|
|
16
|
-
const listener = e => {
|
|
17
|
-
if (!document.body.contains(quill.root)) {
|
|
18
|
-
document.body.removeEventListener('click', listener);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (this.tooltip != null &&
|
|
22
|
-
// @ts-expect-error
|
|
23
|
-
!this.tooltip.root.contains(e.target) &&
|
|
24
|
-
// @ts-expect-error
|
|
25
|
-
document.activeElement !== this.tooltip.textbox && !this.quill.hasFocus()) {
|
|
26
|
-
this.tooltip.hide();
|
|
27
|
-
}
|
|
28
|
-
if (this.pickers != null) {
|
|
29
|
-
this.pickers.forEach(picker => {
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
if (!picker.container.contains(e.target)) {
|
|
32
|
-
picker.close();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
quill.emitter.listenDOM('click', document.body, listener);
|
|
38
|
-
}
|
|
39
|
-
addModule(name) {
|
|
40
|
-
const module = super.addModule(name);
|
|
41
|
-
if (name === 'toolbar') {
|
|
42
|
-
// @ts-expect-error
|
|
43
|
-
this.extendToolbar(module);
|
|
44
|
-
}
|
|
45
|
-
return module;
|
|
46
|
-
}
|
|
47
|
-
buildButtons(buttons, icons) {
|
|
48
|
-
Array.from(buttons).forEach(button => {
|
|
49
|
-
const className = button.getAttribute('class') || '';
|
|
50
|
-
className.split(/\s+/).forEach(name => {
|
|
51
|
-
if (!name.startsWith('ql-')) return;
|
|
52
|
-
name = name.slice('ql-'.length);
|
|
53
|
-
if (icons[name] == null) return;
|
|
54
|
-
if (name === 'direction') {
|
|
55
|
-
// @ts-expect-error
|
|
56
|
-
button.innerHTML = icons[name][''] + icons[name].rtl;
|
|
57
|
-
} else if (typeof icons[name] === 'string') {
|
|
58
|
-
// @ts-expect-error
|
|
59
|
-
button.innerHTML = icons[name];
|
|
60
|
-
} else {
|
|
61
|
-
// @ts-expect-error
|
|
62
|
-
const value = button.value || '';
|
|
63
|
-
// @ts-expect-error
|
|
64
|
-
if (value != null && icons[name][value]) {
|
|
65
|
-
// @ts-expect-error
|
|
66
|
-
button.innerHTML = icons[name][value];
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
buildPickers(selects, icons) {
|
|
73
|
-
this.pickers = Array.from(selects).map(select => {
|
|
74
|
-
if (select.classList.contains('ql-align')) {
|
|
75
|
-
if (select.querySelector('option') == null) {
|
|
76
|
-
fillSelect(select, ALIGNS);
|
|
77
|
-
}
|
|
78
|
-
if (typeof icons.align === 'object') {
|
|
79
|
-
return new IconPicker(select, icons.align);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (select.classList.contains('ql-background') || select.classList.contains('ql-color')) {
|
|
83
|
-
const format = select.classList.contains('ql-background') ? 'background' : 'color';
|
|
84
|
-
if (select.querySelector('option') == null) {
|
|
85
|
-
fillSelect(select, COLORS, format === 'background' ? '#ffffff' : '#000000');
|
|
86
|
-
}
|
|
87
|
-
return new ColorPicker(select, icons[format]);
|
|
88
|
-
}
|
|
89
|
-
if (select.querySelector('option') == null) {
|
|
90
|
-
if (select.classList.contains('ql-font')) {
|
|
91
|
-
fillSelect(select, FONTS);
|
|
92
|
-
} else if (select.classList.contains('ql-header')) {
|
|
93
|
-
fillSelect(select, HEADERS);
|
|
94
|
-
} else if (select.classList.contains('ql-size')) {
|
|
95
|
-
fillSelect(select, SIZES);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return new Picker(select);
|
|
99
|
-
});
|
|
100
|
-
const update = () => {
|
|
101
|
-
this.pickers.forEach(picker => {
|
|
102
|
-
picker.update();
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
this.quill.on(Emitter.events.EDITOR_CHANGE, update);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
BaseTheme.DEFAULTS = merge({}, Theme.DEFAULTS, {
|
|
109
|
-
modules: {
|
|
110
|
-
toolbar: {
|
|
111
|
-
handlers: {
|
|
112
|
-
formula() {
|
|
113
|
-
this.quill.theme.tooltip.edit('formula');
|
|
114
|
-
},
|
|
115
|
-
image() {
|
|
116
|
-
let fileInput = this.container.querySelector('input.ql-image[type=file]');
|
|
117
|
-
if (fileInput == null) {
|
|
118
|
-
fileInput = document.createElement('input');
|
|
119
|
-
fileInput.setAttribute('type', 'file');
|
|
120
|
-
fileInput.setAttribute('accept', this.quill.uploader.options.mimetypes.join(', '));
|
|
121
|
-
fileInput.classList.add('ql-image');
|
|
122
|
-
fileInput.addEventListener('change', () => {
|
|
123
|
-
const range = this.quill.getSelection(true);
|
|
124
|
-
this.quill.uploader.upload(range, fileInput.files);
|
|
125
|
-
fileInput.value = '';
|
|
126
|
-
});
|
|
127
|
-
this.container.appendChild(fileInput);
|
|
128
|
-
}
|
|
129
|
-
fileInput.click();
|
|
130
|
-
},
|
|
131
|
-
video() {
|
|
132
|
-
this.quill.theme.tooltip.edit('video');
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
class BaseTooltip extends Tooltip {
|
|
139
|
-
constructor(quill, boundsContainer) {
|
|
140
|
-
super(quill, boundsContainer);
|
|
141
|
-
this.textbox = this.root.querySelector('input[type="text"]');
|
|
142
|
-
this.listen();
|
|
143
|
-
}
|
|
144
|
-
listen() {
|
|
145
|
-
// @ts-expect-error Fix me later
|
|
146
|
-
this.textbox.addEventListener('keydown', event => {
|
|
147
|
-
if (event.key === 'Enter') {
|
|
148
|
-
this.save();
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
} else if (event.key === 'Escape') {
|
|
151
|
-
this.cancel();
|
|
152
|
-
event.preventDefault();
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
cancel() {
|
|
157
|
-
this.hide();
|
|
158
|
-
this.restoreFocus();
|
|
159
|
-
}
|
|
160
|
-
edit() {
|
|
161
|
-
let mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'link';
|
|
162
|
-
let preview = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
163
|
-
this.root.classList.remove('ql-hidden');
|
|
164
|
-
this.root.classList.add('ql-editing');
|
|
165
|
-
if (this.textbox == null) return;
|
|
166
|
-
if (preview != null) {
|
|
167
|
-
this.textbox.value = preview;
|
|
168
|
-
} else if (mode !== this.root.getAttribute('data-mode')) {
|
|
169
|
-
this.textbox.value = '';
|
|
170
|
-
}
|
|
171
|
-
const bounds = this.quill.getBounds(this.quill.selection.savedRange);
|
|
172
|
-
if (bounds != null) {
|
|
173
|
-
this.position(bounds);
|
|
174
|
-
}
|
|
175
|
-
this.textbox.select();
|
|
176
|
-
this.textbox.setAttribute('placeholder', this.textbox.getAttribute(`data-${mode}`) || '');
|
|
177
|
-
this.root.setAttribute('data-mode', mode);
|
|
178
|
-
}
|
|
179
|
-
restoreFocus() {
|
|
180
|
-
this.quill.focus({
|
|
181
|
-
preventScroll: true
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
save() {
|
|
185
|
-
// @ts-expect-error Fix me later
|
|
186
|
-
let {
|
|
187
|
-
value
|
|
188
|
-
} = this.textbox;
|
|
189
|
-
switch (this.root.getAttribute('data-mode')) {
|
|
190
|
-
case 'link':
|
|
191
|
-
{
|
|
192
|
-
const {
|
|
193
|
-
scrollTop
|
|
194
|
-
} = this.quill.root;
|
|
195
|
-
if (this.linkRange) {
|
|
196
|
-
this.quill.formatText(this.linkRange, 'link', value, Emitter.sources.USER);
|
|
197
|
-
delete this.linkRange;
|
|
198
|
-
} else {
|
|
199
|
-
this.restoreFocus();
|
|
200
|
-
this.quill.format('link', value, Emitter.sources.USER);
|
|
201
|
-
}
|
|
202
|
-
this.quill.root.scrollTop = scrollTop;
|
|
203
|
-
break;
|
|
204
|
-
}
|
|
205
|
-
case 'video':
|
|
206
|
-
{
|
|
207
|
-
value = extractVideoUrl(value);
|
|
208
|
-
}
|
|
209
|
-
// eslint-disable-next-line no-fallthrough
|
|
210
|
-
case 'formula':
|
|
211
|
-
{
|
|
212
|
-
if (!value) break;
|
|
213
|
-
const range = this.quill.getSelection(true);
|
|
214
|
-
if (range != null) {
|
|
215
|
-
const index = range.index + range.length;
|
|
216
|
-
this.quill.insertEmbed(index,
|
|
217
|
-
// @ts-expect-error Fix me later
|
|
218
|
-
this.root.getAttribute('data-mode'), value, Emitter.sources.USER);
|
|
219
|
-
if (this.root.getAttribute('data-mode') === 'formula') {
|
|
220
|
-
this.quill.insertText(index + 1, ' ', Emitter.sources.USER);
|
|
221
|
-
}
|
|
222
|
-
this.quill.setSelection(index + 2, Emitter.sources.USER);
|
|
223
|
-
}
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
default:
|
|
227
|
-
}
|
|
228
|
-
// @ts-expect-error Fix me later
|
|
229
|
-
this.textbox.value = '';
|
|
230
|
-
this.hide();
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
function extractVideoUrl(url) {
|
|
234
|
-
let match = url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/) || url.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);
|
|
235
|
-
if (match) {
|
|
236
|
-
return `${match[1] || 'https'}://www.youtube.com/embed/${match[2]}?showinfo=0`;
|
|
237
|
-
}
|
|
238
|
-
// eslint-disable-next-line no-cond-assign
|
|
239
|
-
if (match = url.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/)) {
|
|
240
|
-
return `${match[1] || 'https'}://player.vimeo.com/video/${match[2]}/`;
|
|
241
|
-
}
|
|
242
|
-
return url;
|
|
243
|
-
}
|
|
244
|
-
function fillSelect(select, values) {
|
|
245
|
-
let defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
246
|
-
values.forEach(value => {
|
|
247
|
-
const option = document.createElement('option');
|
|
248
|
-
if (value === defaultValue) {
|
|
249
|
-
option.setAttribute('selected', 'selected');
|
|
250
|
-
} else {
|
|
251
|
-
option.setAttribute('value', String(value));
|
|
252
|
-
}
|
|
253
|
-
select.appendChild(option);
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
export { BaseTooltip, BaseTheme as default };
|
|
257
|
-
//# sourceMappingURL=base.js.map
|