Comparing version 0.0.0-experimental-b9ebd32ba-20240125 to 0.0.0-experimental-d6d773267-20240311
@@ -1,18 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.BlockEmbed = void 0; | ||
exports.blockDelta = blockDelta; | ||
exports.bubbleFormats = bubbleFormats; | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _break = _interopRequireDefault(require("./break")); | ||
var _inline = _interopRequireDefault(require("./inline")); | ||
var _text = _interopRequireDefault(require("./text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { AttributorStore, BlockBlot, EmbedBlot, LeafBlot, Scope } from 'parchment'; | ||
import Delta from 'quill-delta'; | ||
import Break from './break.js'; | ||
import Inline from './inline.js'; | ||
import TextBlot from './text.js'; | ||
const NEWLINE_LENGTH = 1; | ||
class Block extends _parchment.BlockBlot { | ||
class Block extends BlockBlot { | ||
cache = {}; | ||
@@ -31,3 +21,3 @@ delta() { | ||
if (length <= 0) return; | ||
if (this.scroll.query(name, _parchment.Scope.BLOCK)) { | ||
if (this.scroll.query(name, Scope.BLOCK)) { | ||
if (index + length === this.length()) { | ||
@@ -73,3 +63,3 @@ this.format(name, value); | ||
super.insertBefore(blot, ref); | ||
if (head instanceof _break.default) { | ||
if (head instanceof Break) { | ||
head.remove(); | ||
@@ -118,14 +108,13 @@ } | ||
} | ||
exports.default = Block; | ||
Block.blotName = 'block'; | ||
Block.tagName = 'P'; | ||
Block.defaultChild = _break.default; | ||
Block.allowedChildren = [_break.default, _inline.default, _parchment.EmbedBlot, _text.default]; | ||
class BlockEmbed extends _parchment.EmbedBlot { | ||
Block.defaultChild = Break; | ||
Block.allowedChildren = [Break, Inline, EmbedBlot, TextBlot]; | ||
class BlockEmbed extends EmbedBlot { | ||
attach() { | ||
super.attach(); | ||
this.attributes = new _parchment.AttributorStore(this.domNode); | ||
this.attributes = new AttributorStore(this.domNode); | ||
} | ||
delta() { | ||
return new _quillDelta.default().insert(this.value(), { | ||
return new Delta().insert(this.value(), { | ||
...this.formats(), | ||
@@ -136,3 +125,3 @@ ...this.attributes.values() | ||
format(name, value) { | ||
const attribute = this.scroll.query(name, _parchment.Scope.BLOCK_ATTRIBUTE); | ||
const attribute = this.scroll.query(name, Scope.BLOCK_ATTRIBUTE); | ||
if (attribute != null) { | ||
@@ -169,4 +158,3 @@ // @ts-expect-error TODO: Scroll#query() should return Attributor when scope is attribute | ||
} | ||
exports.BlockEmbed = BlockEmbed; | ||
BlockEmbed.scope = _parchment.Scope.BLOCK_BLOT; | ||
BlockEmbed.scope = Scope.BLOCK_BLOT; | ||
// It is important for cursor behavior BlockEmbeds use tags that are block level elements | ||
@@ -176,3 +164,3 @@ | ||
let filter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; | ||
return blot.descendants(_parchment.LeafBlot).reduce((delta, leaf) => { | ||
return blot.descendants(LeafBlot).reduce((delta, leaf) => { | ||
if (leaf.length() === 0) { | ||
@@ -182,3 +170,3 @@ return delta; | ||
return delta.insert(leaf.value(), bubbleFormats(leaf, {}, filter)); | ||
}, new _quillDelta.default()).insert('\n', bubbleFormats(blot)); | ||
}, new Delta()).insert('\n', bubbleFormats(blot)); | ||
} | ||
@@ -204,2 +192,3 @@ function bubbleFormats(blot) { | ||
} | ||
export { blockDelta, bubbleFormats, BlockEmbed, Block as default }; | ||
//# sourceMappingURL=block.js.map |
@@ -1,9 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
class Break extends _parchment.EmbedBlot { | ||
import { EmbedBlot } from 'parchment'; | ||
class Break extends EmbedBlot { | ||
static value() { | ||
@@ -26,3 +20,3 @@ return undefined; | ||
Break.tagName = 'BR'; | ||
var _default = exports.default = Break; | ||
export default Break; | ||
//# sourceMappingURL=break.js.map |
@@ -1,10 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
class Container extends _parchment.ContainerBlot {} | ||
var _default = exports.default = Container; | ||
import { ContainerBlot } from 'parchment'; | ||
class Container extends ContainerBlot {} | ||
export default Container; | ||
//# sourceMappingURL=container.js.map |
import { EmbedBlot } from 'parchment'; | ||
import type { ScrollBlot } from 'parchment'; | ||
import type Selection from '../core/selection'; | ||
import type { EmbedContextRange } from './embed'; | ||
import type Selection from '../core/selection.js'; | ||
import type { EmbedContextRange } from './embed.js'; | ||
declare class Cursor extends EmbedBlot { | ||
@@ -6,0 +6,0 @@ static blotName: string; |
@@ -1,11 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
var _text = _interopRequireDefault(require("./text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Cursor extends _parchment.EmbedBlot { | ||
import { EmbedBlot, Scope } from 'parchment'; | ||
import TextBlot from './text.js'; | ||
class Cursor extends EmbedBlot { | ||
static blotName = 'cursor'; | ||
@@ -39,3 +32,3 @@ static className = 'ql-cursor'; | ||
let index = 0; | ||
while (target != null && target.statics.scope !== _parchment.Scope.BLOCK_BLOT) { | ||
while (target != null && target.statics.scope !== Scope.BLOCK_BLOT) { | ||
index += target.offset(target.parent); | ||
@@ -76,5 +69,5 @@ target = target.parent; | ||
} | ||
const prevTextBlot = this.prev instanceof _text.default ? this.prev : null; | ||
const prevTextBlot = this.prev instanceof TextBlot ? this.prev : null; | ||
const prevTextLength = prevTextBlot ? prevTextBlot.length() : 0; | ||
const nextTextBlot = this.next instanceof _text.default ? this.next : null; | ||
const nextTextBlot = this.next instanceof TextBlot ? this.next : null; | ||
// @ts-expect-error TODO: make TextBlot.text public | ||
@@ -178,3 +171,3 @@ const nextText = nextTextBlot ? nextTextBlot.text : ''; | ||
} | ||
var _default = exports.default = Cursor; | ||
export default Cursor; | ||
//# sourceMappingURL=cursor.js.map |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
var _text = _interopRequireDefault(require("./text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { EmbedBlot } from 'parchment'; | ||
import TextBlot from './text.js'; | ||
const GUARD_TEXT = '\uFEFF'; | ||
class Embed extends _parchment.EmbedBlot { | ||
class Embed extends EmbedBlot { | ||
constructor(scroll, node) { | ||
@@ -35,3 +28,3 @@ super(scroll, node); | ||
if (node === this.leftGuard) { | ||
if (this.prev instanceof _text.default) { | ||
if (this.prev instanceof TextBlot) { | ||
const prevLength = this.prev.length(); | ||
@@ -52,3 +45,3 @@ this.prev.insertAt(prevLength, text); | ||
} else if (node === this.rightGuard) { | ||
if (this.next instanceof _text.default) { | ||
if (this.next instanceof TextBlot) { | ||
this.next.insertAt(0, text); | ||
@@ -81,3 +74,3 @@ range = { | ||
} | ||
var _default = exports.default = Embed; | ||
export default Embed; | ||
//# sourceMappingURL=embed.js.map |
@@ -1,13 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
var _break = _interopRequireDefault(require("./break")); | ||
var _text = _interopRequireDefault(require("./text")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Inline extends _parchment.InlineBlot { | ||
static allowedChildren = [Inline, _break.default, _parchment.EmbedBlot, _text.default]; | ||
import { EmbedBlot, InlineBlot, Scope } from 'parchment'; | ||
import Break from './break.js'; | ||
import Text from './text.js'; | ||
class Inline extends InlineBlot { | ||
static allowedChildren = [Inline, Break, EmbedBlot, Text]; | ||
// Lower index means deeper in the DOM tree, since not found (-1) is for embeds | ||
@@ -36,3 +29,3 @@ static order = ['cursor', 'inline', | ||
formatAt(index, length, name, value) { | ||
if (Inline.compare(this.statics.blotName, name) < 0 && this.scroll.query(name, _parchment.Scope.BLOT)) { | ||
if (Inline.compare(this.statics.blotName, name) < 0 && this.scroll.query(name, Scope.BLOT)) { | ||
const blot = this.isolate(index, length); | ||
@@ -56,3 +49,3 @@ if (value) { | ||
} | ||
var _default = exports.default = Inline; | ||
export default Inline; | ||
//# sourceMappingURL=inline.js.map |
import { LeafBlot, ScrollBlot } from 'parchment'; | ||
import type { Blot, Registry } from 'parchment'; | ||
import Delta from 'quill-delta'; | ||
import Emitter from '../core/emitter'; | ||
import type { EmitterSource } from '../core/emitter'; | ||
import Block, { BlockEmbed } from './block'; | ||
import Container from './container'; | ||
import Emitter from '../core/emitter.js'; | ||
import type { EmitterSource } from '../core/emitter.js'; | ||
import Block, { BlockEmbed } from './block.js'; | ||
import Container from './container.js'; | ||
declare class Scroll extends ScrollBlot { | ||
@@ -9,0 +9,0 @@ static blotName: string; |
@@ -1,18 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
var _quillDelta = _interopRequireWildcard(require("quill-delta")); | ||
var _emitter = _interopRequireDefault(require("../core/emitter")); | ||
var _block = _interopRequireWildcard(require("./block")); | ||
var _break = _interopRequireDefault(require("./break")); | ||
var _container = _interopRequireDefault(require("./container")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
import { ContainerBlot, LeafBlot, Scope, ScrollBlot } from 'parchment'; | ||
import Delta, { AttributeMap, Op } from 'quill-delta'; | ||
import Emitter from '../core/emitter.js'; | ||
import Block, { BlockEmbed, bubbleFormats } from './block.js'; | ||
import Break from './break.js'; | ||
import Container from './container.js'; | ||
function isLine(blot) { | ||
return blot instanceof _block.default || blot instanceof _block.BlockEmbed; | ||
return blot instanceof Block || blot instanceof BlockEmbed; | ||
} | ||
@@ -22,8 +13,8 @@ function isUpdatable(blot) { | ||
} | ||
class Scroll extends _parchment.ScrollBlot { | ||
class Scroll extends ScrollBlot { | ||
static blotName = 'scroll'; | ||
static className = 'ql-editor'; | ||
static tagName = 'DIV'; | ||
static defaultChild = _block.default; | ||
static allowedChildren = [_block.default, _block.BlockEmbed, _container.default]; | ||
static defaultChild = Block; | ||
static allowedChildren = [Block, BlockEmbed, Container]; | ||
constructor(registry, domNode, _ref) { | ||
@@ -52,9 +43,9 @@ let { | ||
emitMount(blot) { | ||
this.emitter.emit(_emitter.default.events.SCROLL_BLOT_MOUNT, blot); | ||
this.emitter.emit(Emitter.events.SCROLL_BLOT_MOUNT, blot); | ||
} | ||
emitUnmount(blot) { | ||
this.emitter.emit(_emitter.default.events.SCROLL_BLOT_UNMOUNT, blot); | ||
this.emitter.emit(Emitter.events.SCROLL_BLOT_UNMOUNT, blot); | ||
} | ||
emitEmbedUpdate(blot, change) { | ||
this.emitter.emit(_emitter.default.events.SCROLL_EMBED_UPDATE, blot, change); | ||
this.emitter.emit(Emitter.events.SCROLL_EMBED_UPDATE, blot, change); | ||
} | ||
@@ -66,7 +57,7 @@ deleteAt(index, length) { | ||
if (last != null && first !== last && offset > 0) { | ||
if (first instanceof _block.BlockEmbed || last instanceof _block.BlockEmbed) { | ||
if (first instanceof BlockEmbed || last instanceof BlockEmbed) { | ||
this.optimize(); | ||
return; | ||
} | ||
const ref = last.children.head instanceof _break.default ? null : last.children.head; | ||
const ref = last.children.head instanceof Break ? null : last.children.head; | ||
// @ts-expect-error | ||
@@ -89,3 +80,3 @@ first.moveChildren(last, ref); | ||
if (index >= this.length()) { | ||
if (def == null || this.scroll.query(value, _parchment.Scope.BLOCK) == null) { | ||
if (def == null || this.scroll.query(value, Scope.BLOCK) == null) { | ||
const blot = this.scroll.create(this.statics.defaultChild.blotName); | ||
@@ -108,3 +99,3 @@ this.appendChild(blot); | ||
insertBefore(blot, ref) { | ||
if (blot.statics.scope === _parchment.Scope.INLINE_BLOT) { | ||
if (blot.statics.scope === Scope.INLINE_BLOT) { | ||
const wrapper = this.scroll.create(this.statics.defaultChild.blotName); | ||
@@ -118,3 +109,3 @@ wrapper.appendChild(blot); | ||
insertContents(index, delta) { | ||
const renderBlocks = this.deltaToRenderBlocks(delta.concat(new _quillDelta.default().insert('\n'))); | ||
const renderBlocks = this.deltaToRenderBlocks(delta.concat(new Delta().insert('\n'))); | ||
const last = renderBlocks.pop(); | ||
@@ -125,4 +116,4 @@ if (last == null) return; | ||
if (first) { | ||
const shouldInsertNewlineChar = first.type === 'block' && (first.delta.length() === 0 || !this.descendant(_block.BlockEmbed, index)[0] && index < this.length()); | ||
const delta = first.type === 'block' ? first.delta : new _quillDelta.default().insert({ | ||
const shouldInsertNewlineChar = first.type === 'block' && (first.delta.length() === 0 || !this.descendant(BlockEmbed, index)[0] && index < this.length()); | ||
const delta = first.type === 'block' ? first.delta : new Delta().insert({ | ||
[first.key]: first.value | ||
@@ -136,4 +127,4 @@ }); | ||
} | ||
const formats = (0, _block.bubbleFormats)(this.line(index)[0]); | ||
const attributes = _quillDelta.AttributeMap.diff(formats, first.attributes) || {}; | ||
const formats = bubbleFormats(this.line(index)[0]); | ||
const attributes = AttributeMap.diff(formats, first.attributes) || {}; | ||
Object.keys(attributes).forEach(name => { | ||
@@ -179,3 +170,3 @@ this.formatAt(lineEndIndex - 1, 1, name, attributes[name]); | ||
const [blot, offset] = last; | ||
return blot instanceof _parchment.LeafBlot ? [blot, offset] : [null, -1]; | ||
return blot instanceof LeafBlot ? [blot, offset] : [null, -1]; | ||
} | ||
@@ -198,3 +189,3 @@ line(index) { | ||
lines.push(child); | ||
} else if (child instanceof _parchment.ContainerBlot) { | ||
} else if (child instanceof ContainerBlot) { | ||
lines = lines.concat(getLines(child, childIndex, lengthLeft)); | ||
@@ -214,3 +205,3 @@ } | ||
if (mutations.length > 0) { | ||
this.emitter.emit(_emitter.default.events.SCROLL_OPTIMIZE, mutations, context); | ||
this.emitter.emit(Emitter.events.SCROLL_OPTIMIZE, mutations, context); | ||
} | ||
@@ -232,3 +223,3 @@ } | ||
} | ||
let source = _emitter.default.sources.USER; | ||
let source = Emitter.sources.USER; | ||
if (typeof mutations === 'string') { | ||
@@ -248,7 +239,7 @@ source = mutations; | ||
if (mutations.length > 0) { | ||
this.emitter.emit(_emitter.default.events.SCROLL_BEFORE_UPDATE, source, mutations); | ||
this.emitter.emit(Emitter.events.SCROLL_BEFORE_UPDATE, source, mutations); | ||
} | ||
super.update(mutations.concat([])); // pass copy | ||
if (mutations.length > 0) { | ||
this.emitter.emit(_emitter.default.events.SCROLL_UPDATE, source, mutations); | ||
this.emitter.emit(Emitter.events.SCROLL_UPDATE, source, mutations); | ||
} | ||
@@ -259,3 +250,3 @@ } | ||
// We can update `ParentBlot` in parchment to support inline embeds. | ||
const [blot] = this.descendant(b => b instanceof _block.BlockEmbed, index); | ||
const [blot] = this.descendant(b => b instanceof BlockEmbed, index); | ||
if (blot && blot.statics.blotName === key && isUpdatable(blot)) { | ||
@@ -270,3 +261,3 @@ blot.updateContent(change); | ||
const renderBlocks = []; | ||
let currentBlockDelta = new _quillDelta.default(); | ||
let currentBlockDelta = new Delta(); | ||
delta.forEach(op => { | ||
@@ -284,3 +275,3 @@ const insert = op?.insert; | ||
}); | ||
currentBlockDelta = new _quillDelta.default(); | ||
currentBlockDelta = new Delta(); | ||
}); | ||
@@ -294,3 +285,3 @@ const last = splitted[splitted.length - 1]; | ||
if (!key) return; | ||
if (this.query(key, _parchment.Scope.INLINE)) { | ||
if (this.query(key, Scope.INLINE)) { | ||
currentBlockDelta.push(op); | ||
@@ -305,3 +296,3 @@ } else { | ||
} | ||
currentBlockDelta = new _quillDelta.default(); | ||
currentBlockDelta = new Delta(); | ||
renderBlocks.push({ | ||
@@ -330,3 +321,3 @@ type: 'blockEmbed', | ||
let [key, value] = _ref3; | ||
const isBlockBlot = this.query(key, _parchment.Scope.BLOCK & _parchment.Scope.BLOT) != null; | ||
const isBlockBlot = this.query(key, Scope.BLOCK & Scope.BLOT) != null; | ||
if (isBlockBlot) { | ||
@@ -350,3 +341,3 @@ blotName = key; | ||
inlineContents.reduce((index, op) => { | ||
const length = _quillDelta.Op.length(op); | ||
const length = Op.length(op); | ||
let attributes = op.attributes || {}; | ||
@@ -357,5 +348,5 @@ if (op.insert != null) { | ||
parent.insertAt(index, text); | ||
const [leaf] = parent.descendant(_parchment.LeafBlot, index); | ||
const formats = (0, _block.bubbleFormats)(leaf); | ||
attributes = _quillDelta.AttributeMap.diff(formats, attributes) || {}; | ||
const [leaf] = parent.descendant(LeafBlot, index); | ||
const formats = bubbleFormats(leaf); | ||
attributes = AttributeMap.diff(formats, attributes) || {}; | ||
} else if (typeof op.insert === 'object') { | ||
@@ -365,7 +356,7 @@ const key = Object.keys(op.insert)[0]; // There should only be one key | ||
parent.insertAt(index, key, op.insert[key]); | ||
const isInlineEmbed = parent.scroll.query(key, _parchment.Scope.INLINE) != null; | ||
const isInlineEmbed = parent.scroll.query(key, Scope.INLINE) != null; | ||
if (isInlineEmbed) { | ||
const [leaf] = parent.descendant(_parchment.LeafBlot, index); | ||
const formats = (0, _block.bubbleFormats)(leaf); | ||
attributes = _quillDelta.AttributeMap.diff(formats, attributes) || {}; | ||
const [leaf] = parent.descendant(LeafBlot, index); | ||
const formats = bubbleFormats(leaf); | ||
attributes = AttributeMap.diff(formats, attributes) || {}; | ||
} | ||
@@ -380,3 +371,3 @@ } | ||
} | ||
var _default = exports.default = Scroll; | ||
export default Scroll; | ||
//# sourceMappingURL=scroll.js.map |
@@ -1,11 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.escapeText = escapeText; | ||
var _parchment = require("parchment"); | ||
class Text extends _parchment.TextBlot {} | ||
exports.default = Text; | ||
import { TextBlot } from 'parchment'; | ||
class Text extends TextBlot {} | ||
function escapeText(text) { | ||
@@ -24,2 +16,3 @@ return text.replace(/[&<>"']/g, s => { | ||
} | ||
export { Text as default, escapeText }; | ||
//# sourceMappingURL=text.js.map |
@@ -1,4 +0,4 @@ | ||
import Quill from './core/quill'; | ||
import Quill from './core/quill.js'; | ||
import Delta, { Op, OpIterator, AttributeMap } from 'quill-delta'; | ||
export { Delta, Op, OpIterator, AttributeMap }; | ||
export default Quill; |
100
core.js
@@ -1,68 +0,36 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
import Quill from './core/quill.js'; | ||
import Block, { BlockEmbed } from './blots/block.js'; | ||
import Break from './blots/break.js'; | ||
import Container from './blots/container.js'; | ||
import Cursor from './blots/cursor.js'; | ||
import Embed from './blots/embed.js'; | ||
import Inline from './blots/inline.js'; | ||
import Scroll from './blots/scroll.js'; | ||
import TextBlot from './blots/text.js'; | ||
import Clipboard from './modules/clipboard.js'; | ||
import History from './modules/history.js'; | ||
import Keyboard from './modules/keyboard.js'; | ||
import Uploader from './modules/uploader.js'; | ||
import Delta, { Op, OpIterator, AttributeMap } from 'quill-delta'; | ||
import Input from './modules/input.js'; | ||
import UINode from './modules/uiNode.js'; | ||
export { Delta, Op, OpIterator, AttributeMap }; | ||
Quill.register({ | ||
'blots/block': Block, | ||
'blots/block/embed': BlockEmbed, | ||
'blots/break': Break, | ||
'blots/container': Container, | ||
'blots/cursor': Cursor, | ||
'blots/embed': Embed, | ||
'blots/inline': Inline, | ||
'blots/scroll': Scroll, | ||
'blots/text': TextBlot, | ||
'modules/clipboard': Clipboard, | ||
'modules/history': History, | ||
'modules/keyboard': Keyboard, | ||
'modules/uploader': Uploader, | ||
'modules/input': Input, | ||
'modules/uiNode': UINode | ||
}); | ||
Object.defineProperty(exports, "AttributeMap", { | ||
enumerable: true, | ||
get: function () { | ||
return _quillDelta.AttributeMap; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Delta", { | ||
enumerable: true, | ||
get: function () { | ||
return _quillDelta.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Op", { | ||
enumerable: true, | ||
get: function () { | ||
return _quillDelta.Op; | ||
} | ||
}); | ||
Object.defineProperty(exports, "OpIterator", { | ||
enumerable: true, | ||
get: function () { | ||
return _quillDelta.OpIterator; | ||
} | ||
}); | ||
exports.default = void 0; | ||
var _quill = _interopRequireDefault(require("./core/quill")); | ||
var _block = _interopRequireWildcard(require("./blots/block")); | ||
var _break = _interopRequireDefault(require("./blots/break")); | ||
var _container = _interopRequireDefault(require("./blots/container")); | ||
var _cursor = _interopRequireDefault(require("./blots/cursor")); | ||
var _embed = _interopRequireDefault(require("./blots/embed")); | ||
var _inline = _interopRequireDefault(require("./blots/inline")); | ||
var _scroll = _interopRequireDefault(require("./blots/scroll")); | ||
var _text = _interopRequireDefault(require("./blots/text")); | ||
var _clipboard = _interopRequireDefault(require("./modules/clipboard")); | ||
var _history = _interopRequireDefault(require("./modules/history")); | ||
var _keyboard = _interopRequireDefault(require("./modules/keyboard")); | ||
var _uploader = _interopRequireDefault(require("./modules/uploader")); | ||
var _quillDelta = _interopRequireWildcard(require("quill-delta")); | ||
var _input = _interopRequireDefault(require("./modules/input")); | ||
var _uiNode = _interopRequireDefault(require("./modules/uiNode")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
_quill.default.register({ | ||
'blots/block': _block.default, | ||
'blots/block/embed': _block.BlockEmbed, | ||
'blots/break': _break.default, | ||
'blots/container': _container.default, | ||
'blots/cursor': _cursor.default, | ||
'blots/embed': _embed.default, | ||
'blots/inline': _inline.default, | ||
'blots/scroll': _scroll.default, | ||
'blots/text': _text.default, | ||
'modules/clipboard': _clipboard.default, | ||
'modules/history': _history.default, | ||
'modules/keyboard': _keyboard.default, | ||
'modules/uploader': _uploader.default, | ||
'modules/input': _input.default, | ||
'modules/uiNode': _uiNode.default | ||
}); | ||
var _default = exports.default = _quill.default; | ||
export default Quill; | ||
//# sourceMappingURL=core.js.map |
@@ -1,3 +0,3 @@ | ||
import type Scroll from '../blots/scroll'; | ||
import Emitter from './emitter'; | ||
import type Scroll from '../blots/scroll.js'; | ||
import Emitter from './emitter.js'; | ||
declare class Composition { | ||
@@ -4,0 +4,0 @@ private scroll; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _embed = _interopRequireDefault(require("../blots/embed")); | ||
var _emitter = _interopRequireDefault(require("./emitter")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import Embed from '../blots/embed.js'; | ||
import Emitter from './emitter.js'; | ||
class Composition { | ||
@@ -36,6 +29,6 @@ isComposing = false; | ||
const blot = event.target instanceof Node ? this.scroll.find(event.target, true) : null; | ||
if (blot && !(blot instanceof _embed.default)) { | ||
this.emitter.emit(_emitter.default.events.COMPOSITION_BEFORE_START, event); | ||
if (blot && !(blot instanceof Embed)) { | ||
this.emitter.emit(Emitter.events.COMPOSITION_BEFORE_START, event); | ||
this.scroll.batchStart(); | ||
this.emitter.emit(_emitter.default.events.COMPOSITION_START, event); | ||
this.emitter.emit(Emitter.events.COMPOSITION_START, event); | ||
this.isComposing = true; | ||
@@ -45,9 +38,9 @@ } | ||
handleCompositionEnd(event) { | ||
this.emitter.emit(_emitter.default.events.COMPOSITION_BEFORE_END, event); | ||
this.emitter.emit(Emitter.events.COMPOSITION_BEFORE_END, event); | ||
this.scroll.batchEnd(); | ||
this.emitter.emit(_emitter.default.events.COMPOSITION_END, event); | ||
this.emitter.emit(Emitter.events.COMPOSITION_END, event); | ||
this.isComposing = false; | ||
} | ||
} | ||
var _default = exports.default = Composition; | ||
export default Composition; | ||
//# sourceMappingURL=composition.js.map |
import Delta from 'quill-delta'; | ||
import type Scroll from '../blots/scroll'; | ||
import { Range } from './selection'; | ||
import type Scroll from '../blots/scroll.js'; | ||
import { Range } from './selection.js'; | ||
type SelectionInfo = { | ||
@@ -5,0 +5,0 @@ newRange: Range; |
@@ -1,18 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _lodashEs = require("lodash-es"); | ||
var _parchment = require("parchment"); | ||
var _quillDelta = _interopRequireWildcard(require("quill-delta")); | ||
var _block = _interopRequireWildcard(require("../blots/block")); | ||
var _break = _interopRequireDefault(require("../blots/break")); | ||
var _cursor = _interopRequireDefault(require("../blots/cursor")); | ||
var _text = _interopRequireWildcard(require("../blots/text")); | ||
var _selection = require("./selection"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
import { cloneDeep, isEqual, merge } from 'lodash-es'; | ||
import { LeafBlot, EmbedBlot, Scope, ParentBlot } from 'parchment'; | ||
import Delta, { AttributeMap, Op } from 'quill-delta'; | ||
import Block, { BlockEmbed, bubbleFormats } from '../blots/block.js'; | ||
import Break from '../blots/break.js'; | ||
import CursorBlot from '../blots/cursor.js'; | ||
import TextBlot, { escapeText } from '../blots/text.js'; | ||
import { Range } from './selection.js'; | ||
const ASCII = /^[ -~]*$/; | ||
@@ -29,6 +20,6 @@ class Editor { | ||
const normalizedDelta = normalizeDelta(delta); | ||
const deleteDelta = new _quillDelta.default(); | ||
const deleteDelta = new Delta(); | ||
const normalizedOps = splitOpLines(normalizedDelta.ops.slice()); | ||
normalizedOps.reduce((index, op) => { | ||
const length = _quillDelta.Op.length(op); | ||
const length = Op.length(op); | ||
let attributes = op.attributes || {}; | ||
@@ -41,24 +32,24 @@ let isImplicitNewlinePrepended = false; | ||
const text = op.insert; | ||
isImplicitNewlineAppended = !text.endsWith('\n') && (scrollLength <= index || !!this.scroll.descendant(_block.BlockEmbed, index)[0]); | ||
isImplicitNewlineAppended = !text.endsWith('\n') && (scrollLength <= index || !!this.scroll.descendant(BlockEmbed, index)[0]); | ||
this.scroll.insertAt(index, text); | ||
const [line, offset] = this.scroll.line(index); | ||
let formats = (0, _lodashEs.merge)({}, (0, _block.bubbleFormats)(line)); | ||
if (line instanceof _block.default) { | ||
const [leaf] = line.descendant(_parchment.LeafBlot, offset); | ||
let formats = merge({}, bubbleFormats(line)); | ||
if (line instanceof Block) { | ||
const [leaf] = line.descendant(LeafBlot, offset); | ||
if (leaf) { | ||
formats = (0, _lodashEs.merge)(formats, (0, _block.bubbleFormats)(leaf)); | ||
formats = merge(formats, bubbleFormats(leaf)); | ||
} | ||
} | ||
attributes = _quillDelta.AttributeMap.diff(formats, attributes) || {}; | ||
attributes = AttributeMap.diff(formats, attributes) || {}; | ||
} else if (typeof op.insert === 'object') { | ||
const key = Object.keys(op.insert)[0]; // There should only be one key | ||
if (key == null) return index; | ||
const isInlineEmbed = this.scroll.query(key, _parchment.Scope.INLINE) != null; | ||
const isInlineEmbed = this.scroll.query(key, Scope.INLINE) != null; | ||
if (isInlineEmbed) { | ||
if (scrollLength <= index || !!this.scroll.descendant(_block.BlockEmbed, index)[0]) { | ||
if (scrollLength <= index || !!this.scroll.descendant(BlockEmbed, index)[0]) { | ||
isImplicitNewlineAppended = true; | ||
} | ||
} else if (index > 0) { | ||
const [leaf, offset] = this.scroll.descendant(_parchment.LeafBlot, index - 1); | ||
if (leaf instanceof _text.default) { | ||
const [leaf, offset] = this.scroll.descendant(LeafBlot, index - 1); | ||
if (leaf instanceof TextBlot) { | ||
const text = leaf.value(); | ||
@@ -68,3 +59,3 @@ if (text[offset] !== '\n') { | ||
} | ||
} else if (leaf instanceof _parchment.EmbedBlot && leaf.statics.scope === _parchment.Scope.INLINE_BLOT) { | ||
} else if (leaf instanceof EmbedBlot && leaf.statics.scope === Scope.INLINE_BLOT) { | ||
isImplicitNewlinePrepended = true; | ||
@@ -75,6 +66,6 @@ } | ||
if (isInlineEmbed) { | ||
const [leaf] = this.scroll.descendant(_parchment.LeafBlot, index); | ||
const [leaf] = this.scroll.descendant(LeafBlot, index); | ||
if (leaf) { | ||
const formats = (0, _lodashEs.merge)({}, (0, _block.bubbleFormats)(leaf)); | ||
attributes = _quillDelta.AttributeMap.diff(formats, attributes) || {}; | ||
const formats = merge({}, bubbleFormats(leaf)); | ||
attributes = AttributeMap.diff(formats, attributes) || {}; | ||
} | ||
@@ -107,3 +98,3 @@ } | ||
} | ||
return index + _quillDelta.Op.length(op); | ||
return index + Op.length(op); | ||
}, 0); | ||
@@ -116,3 +107,3 @@ this.scroll.batchEnd(); | ||
this.scroll.deleteAt(index, length); | ||
return this.update(new _quillDelta.default().retain(index).delete(length)); | ||
return this.update(new Delta().retain(index).delete(length)); | ||
} | ||
@@ -128,3 +119,3 @@ formatLine(index, length) { | ||
this.scroll.optimize(); | ||
const delta = new _quillDelta.default().retain(index).retain(length, (0, _lodashEs.cloneDeep)(formats)); | ||
const delta = new Delta().retain(index).retain(length, cloneDeep(formats)); | ||
return this.update(delta); | ||
@@ -137,3 +128,3 @@ } | ||
}); | ||
const delta = new _quillDelta.default().retain(index).retain(length, (0, _lodashEs.cloneDeep)(formats)); | ||
const delta = new Delta().retain(index).retain(length, cloneDeep(formats)); | ||
return this.update(delta); | ||
@@ -147,3 +138,3 @@ } | ||
return delta.concat(line.delta()); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
@@ -157,5 +148,5 @@ getFormat(index) { | ||
const [blot] = path; | ||
if (blot instanceof _block.default) { | ||
if (blot instanceof Block) { | ||
lines.push(blot); | ||
} else if (blot instanceof _parchment.LeafBlot) { | ||
} else if (blot instanceof LeafBlot) { | ||
leaves.push(blot); | ||
@@ -166,3 +157,3 @@ } | ||
lines = this.scroll.lines(index, length); | ||
leaves = this.scroll.descendants(_parchment.LeafBlot, index, length); | ||
leaves = this.scroll.descendants(LeafBlot, index, length); | ||
} | ||
@@ -172,7 +163,7 @@ const [lineFormats, leafFormats] = [lines, leaves].map(blots => { | ||
if (blot == null) return {}; | ||
let formats = (0, _block.bubbleFormats)(blot); | ||
let formats = bubbleFormats(blot); | ||
while (Object.keys(formats).length > 0) { | ||
const blot = blots.shift(); | ||
if (blot == null) return formats; | ||
formats = combineFormats((0, _block.bubbleFormats)(blot), formats); | ||
formats = combineFormats(bubbleFormats(blot), formats); | ||
} | ||
@@ -190,5 +181,5 @@ return formats; | ||
const lineLength = line.length(); | ||
if (line.length() >= lineOffset + length) { | ||
const excludeOuterTag = !(lineOffset === 0 && length === lineLength); | ||
return convertHTML(line, lineOffset, length, excludeOuterTag); | ||
const isWithinLine = line.length() >= lineOffset + length; | ||
if (isWithinLine && !(lineOffset === 0 && length === lineLength)) { | ||
return convertHTML(line, lineOffset, length, true); | ||
} | ||
@@ -204,3 +195,3 @@ return convertHTML(this.scroll, index, length, true); | ||
const normalizedDelta = normalizeDelta(contents); | ||
const change = new _quillDelta.default().retain(index).concat(normalizedDelta); | ||
const change = new Delta().retain(index).concat(normalizedDelta); | ||
this.scroll.insertContents(index, normalizedDelta); | ||
@@ -211,3 +202,3 @@ return this.update(change); | ||
this.scroll.insertAt(index, embed, value); | ||
return this.update(new _quillDelta.default().retain(index).insert({ | ||
return this.update(new Delta().retain(index).insert({ | ||
[embed]: value | ||
@@ -223,3 +214,3 @@ })); | ||
}); | ||
return this.update(new _quillDelta.default().retain(index).insert(text, (0, _lodashEs.cloneDeep)(formats))); | ||
return this.update(new Delta().retain(index).insert(text, cloneDeep(formats))); | ||
} | ||
@@ -230,6 +221,6 @@ isBlank() { | ||
const blot = this.scroll.children.head; | ||
if (blot?.statics.blotName !== _block.default.blotName) return false; | ||
if (blot?.statics.blotName !== Block.blotName) return false; | ||
const block = blot; | ||
if (block.children.length > 1) return false; | ||
return block.children.head instanceof _break.default; | ||
return block.children.head instanceof Break; | ||
} | ||
@@ -240,3 +231,3 @@ removeFormat(index, length) { | ||
let suffixLength = 0; | ||
let suffix = new _quillDelta.default(); | ||
let suffix = new Delta(); | ||
if (line != null) { | ||
@@ -247,4 +238,4 @@ suffixLength = line.length() - offset; | ||
const contents = this.getContents(index, length + suffixLength); | ||
const diff = contents.diff(new _quillDelta.default().insert(text).concat(suffix)); | ||
const delta = new _quillDelta.default().retain(index).concat(diff); | ||
const diff = contents.diff(new Delta().insert(text).concat(suffix)); | ||
const delta = new Delta().retain(index).concat(diff); | ||
return this.applyDelta(delta); | ||
@@ -261,9 +252,9 @@ } | ||
const textBlot = this.scroll.find(mutations[0].target); | ||
const formats = (0, _block.bubbleFormats)(textBlot); | ||
const formats = bubbleFormats(textBlot); | ||
const index = textBlot.offset(this.scroll); | ||
// @ts-expect-error Fix me later | ||
const oldValue = mutations[0].oldValue.replace(_cursor.default.CONTENTS, ''); | ||
const oldText = new _quillDelta.default().insert(oldValue); | ||
const oldValue = mutations[0].oldValue.replace(CursorBlot.CONTENTS, ''); | ||
const oldText = new Delta().insert(oldValue); | ||
// @ts-expect-error | ||
const newText = new _quillDelta.default().insert(textBlot.value()); | ||
const newText = new Delta().insert(textBlot.value()); | ||
const relativeSelectionInfo = selectionInfo && { | ||
@@ -273,3 +264,3 @@ oldRange: shiftRange(selectionInfo.oldRange, -index), | ||
}; | ||
const diffDelta = new _quillDelta.default().retain(index).concat(oldText.diff(newText, relativeSelectionInfo)); | ||
const diffDelta = new Delta().retain(index).concat(oldText.diff(newText, relativeSelectionInfo)); | ||
change = diffDelta.reduce((delta, op) => { | ||
@@ -280,7 +271,7 @@ if (op.insert) { | ||
return delta.push(op); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
this.delta = oldDelta.compose(change); | ||
} else { | ||
this.delta = this.getDelta(); | ||
if (!change || !(0, _lodashEs.isEqual)(oldDelta.compose(change), this.delta)) { | ||
if (!change || !isEqual(oldDelta.compose(change), this.delta)) { | ||
change = oldDelta.diff(this.delta, selectionInfo); | ||
@@ -323,10 +314,10 @@ } | ||
function convertHTML(blot, index, length) { | ||
let excludeOuterTag = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
let isRoot = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; | ||
if ('html' in blot && typeof blot.html === 'function') { | ||
return blot.html(index, length); | ||
} | ||
if (blot instanceof _text.default) { | ||
return (0, _text.escapeText)(blot.value().slice(index, index + length)); | ||
if (blot instanceof TextBlot) { | ||
return escapeText(blot.value().slice(index, index + length)); | ||
} | ||
if (blot instanceof _parchment.ParentBlot) { | ||
if (blot instanceof ParentBlot) { | ||
// TODO fix API | ||
@@ -351,3 +342,3 @@ if (blot.statics.blotName === 'list-container') { | ||
}); | ||
if (excludeOuterTag || blot.statics.blotName === 'list') { | ||
if (isRoot || blot.statics.blotName === 'list') { | ||
return parts.join(''); | ||
@@ -405,3 +396,3 @@ } | ||
return normalizedDelta.push(op); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
@@ -413,3 +404,3 @@ function shiftRange(_ref, amount) { | ||
} = _ref; | ||
return new _selection.Range(index + amount, length); | ||
return new Range(index + amount, length); | ||
} | ||
@@ -437,3 +428,3 @@ function splitOpLines(ops) { | ||
} | ||
var _default = exports.default = Editor; | ||
export default Editor; | ||
//# sourceMappingURL=editor.js.map |
@@ -1,2 +0,2 @@ | ||
import EventEmitter from 'eventemitter3'; | ||
import { EventEmitter } from 'eventemitter3'; | ||
declare class Emitter extends EventEmitter<string> { | ||
@@ -3,0 +3,0 @@ static events: { |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _eventemitter = _interopRequireDefault(require("eventemitter3")); | ||
var _instances = _interopRequireDefault(require("./instances")); | ||
var _logger = _interopRequireDefault(require("./logger")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const debug = (0, _logger.default)('quill:events'); | ||
import { EventEmitter } from 'eventemitter3'; | ||
import instances from './instances.js'; | ||
import logger from './logger.js'; | ||
const debug = logger('quill:events'); | ||
const EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click']; | ||
@@ -19,3 +12,3 @@ EVENTS.forEach(eventName => { | ||
Array.from(document.querySelectorAll('.ql-container')).forEach(node => { | ||
const quill = _instances.default.get(node); | ||
const quill = instances.get(node); | ||
if (quill && quill.emitter) { | ||
@@ -27,3 +20,3 @@ quill.emitter.handleDOM(...args); | ||
}); | ||
class Emitter extends _eventemitter.default { | ||
class Emitter extends EventEmitter { | ||
static events = { | ||
@@ -86,3 +79,3 @@ EDITOR_CHANGE: 'editor-change', | ||
} | ||
var _default = exports.default = Emitter; | ||
export default Emitter; | ||
//# sourceMappingURL=emitter.js.map |
@@ -1,3 +0,3 @@ | ||
import type Quill from '../core'; | ||
import type Quill from '../core.js'; | ||
declare const _default: WeakMap<Node, Quill>; | ||
export default _default; |
@@ -1,8 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _default = exports.default = new WeakMap(); | ||
export default new WeakMap(); | ||
//# sourceMappingURL=instances.js.map |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const levels = ['error', 'warn', 'log', 'info']; | ||
@@ -30,3 +24,3 @@ let level = 'warn'; | ||
debug.level = namespace.level; | ||
var _default = exports.default = namespace; | ||
export default namespace; | ||
//# sourceMappingURL=logger.js.map |
@@ -1,2 +0,2 @@ | ||
import type Quill from './quill'; | ||
import type Quill from './quill.js'; | ||
declare abstract class Module<T extends {} = {}> { | ||
@@ -3,0 +3,0 @@ protected quill: Quill; |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
class Module { | ||
@@ -15,3 +9,3 @@ static DEFAULTS = {}; | ||
} | ||
var _default = exports.default = Module; | ||
export default Module; | ||
//# sourceMappingURL=module.js.map |
import * as Parchment from 'parchment'; | ||
import type { Op } from 'quill-delta'; | ||
import Delta from 'quill-delta'; | ||
import type { BlockEmbed } from '../blots/block'; | ||
import type Block from '../blots/block'; | ||
import type Scroll from '../blots/scroll'; | ||
import type Clipboard from '../modules/clipboard'; | ||
import type History from '../modules/history'; | ||
import type Keyboard from '../modules/keyboard'; | ||
import type Uploader from '../modules/uploader'; | ||
import Editor from './editor'; | ||
import Emitter from './emitter'; | ||
import type { EmitterSource } from './emitter'; | ||
import type { DebugLevel } from './logger'; | ||
import Module from './module'; | ||
import Selection, { Range } from './selection'; | ||
import type { Bounds } from './selection'; | ||
import Composition from './composition'; | ||
import Theme from './theme'; | ||
import type { ThemeConstructor } from './theme'; | ||
import type { Rect } from './utils/scrollRectIntoView'; | ||
import type { BlockEmbed } from '../blots/block.js'; | ||
import type Block from '../blots/block.js'; | ||
import type Scroll from '../blots/scroll.js'; | ||
import type Clipboard from '../modules/clipboard.js'; | ||
import type History from '../modules/history.js'; | ||
import type Keyboard from '../modules/keyboard.js'; | ||
import type Uploader from '../modules/uploader.js'; | ||
import Editor from './editor.js'; | ||
import Emitter from './emitter.js'; | ||
import type { EmitterSource } from './emitter.js'; | ||
import type { DebugLevel } from './logger.js'; | ||
import Module from './module.js'; | ||
import Selection, { Range } from './selection.js'; | ||
import type { Bounds } from './selection.js'; | ||
import Composition from './composition.js'; | ||
import Theme from './theme.js'; | ||
import type { ThemeConstructor } from './theme.js'; | ||
import type { Rect } from './utils/scrollRectIntoView.js'; | ||
declare const globalRegistry: Parchment.Registry; | ||
@@ -23,0 +23,0 @@ interface Options { |
@@ -1,27 +0,15 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.expandConfig = expandConfig; | ||
exports.globalRegistry = void 0; | ||
exports.overload = overload; | ||
var _lodashEs = require("lodash-es"); | ||
var Parchment = _interopRequireWildcard(require("parchment")); | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _editor = _interopRequireDefault(require("./editor")); | ||
var _emitter = _interopRequireDefault(require("./emitter")); | ||
var _instances = _interopRequireDefault(require("./instances")); | ||
var _logger = _interopRequireDefault(require("./logger")); | ||
var _module = _interopRequireDefault(require("./module")); | ||
var _selection = _interopRequireWildcard(require("./selection")); | ||
var _composition = _interopRequireDefault(require("./composition")); | ||
var _theme = _interopRequireDefault(require("./theme")); | ||
var _scrollRectIntoView = _interopRequireDefault(require("./utils/scrollRectIntoView")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
const debug = (0, _logger.default)('quill'); | ||
const globalRegistry = exports.globalRegistry = new Parchment.Registry(); | ||
import { cloneDeep, merge } from 'lodash-es'; | ||
import * as Parchment from 'parchment'; | ||
import Delta from 'quill-delta'; | ||
import Editor from './editor.js'; | ||
import Emitter from './emitter.js'; | ||
import instances from './instances.js'; | ||
import logger from './logger.js'; | ||
import Module from './module.js'; | ||
import Selection, { Range } from './selection.js'; | ||
import Composition from './composition.js'; | ||
import Theme from './theme.js'; | ||
import scrollRectIntoView from './utils/scrollRectIntoView.js'; | ||
const debug = logger('quill'); | ||
const globalRegistry = new Parchment.Registry(); | ||
Parchment.ParentBlot.uiClass = 'ql-ui'; | ||
@@ -37,10 +25,10 @@ class Quill { | ||
}; | ||
static events = _emitter.default.events; | ||
static sources = _emitter.default.sources; | ||
static version = typeof "0.0.0-experimental-b9ebd32ba-20240125" === 'undefined' ? 'dev' : "0.0.0-experimental-b9ebd32ba-20240125"; | ||
static events = Emitter.events; | ||
static sources = Emitter.sources; | ||
static version = typeof "0.0.0-experimental-d6d773267-20240311" === 'undefined' ? 'dev' : "0.0.0-experimental-d6d773267-20240311"; | ||
static imports = { | ||
delta: _quillDelta.default, | ||
delta: Delta, | ||
parchment: Parchment, | ||
'core/module': _module.default, | ||
'core/theme': _theme.default | ||
'core/module': Module, | ||
'core/theme': Theme | ||
}; | ||
@@ -51,7 +39,7 @@ static debug(limit) { | ||
} | ||
_logger.default.level(limit); | ||
logger.level(limit); | ||
} | ||
static find(node) { | ||
let bubble = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
return _instances.default.get(node) || globalRegistry.find(node, bubble); | ||
return instances.get(node) || globalRegistry.find(node, bubble); | ||
} | ||
@@ -109,6 +97,6 @@ static import(name) { | ||
this.container.innerHTML = ''; | ||
_instances.default.set(this.container, this); | ||
instances.set(this.container, this); | ||
this.root = this.addContainer('ql-editor'); | ||
this.root.classList.add('ql-blank'); | ||
this.emitter = new _emitter.default(); | ||
this.emitter = new Emitter(); | ||
const scrollBlotName = Parchment.ScrollBlot.blotName; | ||
@@ -122,5 +110,5 @@ const ScrollBlot = this.options.registry.query(scrollBlotName); | ||
}); | ||
this.editor = new _editor.default(this.scroll); | ||
this.selection = new _selection.default(this.scroll, this.emitter); | ||
this.composition = new _composition.default(this.scroll, this.emitter); | ||
this.editor = new Editor(this.scroll); | ||
this.selection = new Selection(this.scroll, this.emitter); | ||
this.composition = new Composition(this.scroll, this.emitter); | ||
this.theme = new this.options.theme(this, this.options); // eslint-disable-line new-cap | ||
@@ -134,8 +122,8 @@ this.keyboard = this.theme.addModule('keyboard'); | ||
this.theme.init(); | ||
this.emitter.on(_emitter.default.events.EDITOR_CHANGE, type => { | ||
if (type === _emitter.default.events.TEXT_CHANGE) { | ||
this.emitter.on(Emitter.events.EDITOR_CHANGE, type => { | ||
if (type === Emitter.events.TEXT_CHANGE) { | ||
this.root.classList.toggle('ql-blank', this.editor.isBlank()); | ||
} | ||
}); | ||
this.emitter.on(_emitter.default.events.SCROLL_UPDATE, (source, mutations) => { | ||
this.emitter.on(Emitter.events.SCROLL_UPDATE, (source, mutations) => { | ||
const oldRange = this.selection.lastRange; | ||
@@ -149,3 +137,3 @@ const [newRange] = this.selection.getRange(); | ||
}); | ||
this.emitter.on(_emitter.default.events.SCROLL_EMBED_UPDATE, (blot, delta) => { | ||
this.emitter.on(Emitter.events.SCROLL_EMBED_UPDATE, (blot, delta) => { | ||
const oldRange = this.selection.lastRange; | ||
@@ -158,3 +146,3 @@ const [newRange] = this.selection.getRange(); | ||
modify.call(this, () => { | ||
const change = new _quillDelta.default().retain(blot.offset(this)).retain({ | ||
const change = new Delta().retain(blot.offset(this)).retain({ | ||
[blot.statics.blotName]: delta | ||
@@ -224,6 +212,6 @@ }); | ||
format(name, value) { | ||
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter.default.sources.API; | ||
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Emitter.sources.API; | ||
return modify.call(this, () => { | ||
const range = this.getSelection(true); | ||
let change = new _quillDelta.default(); | ||
let change = new Delta(); | ||
if (range == null) return change; | ||
@@ -242,3 +230,3 @@ if (this.scroll.query(name, Parchment.Scope.BLOCK)) { | ||
} | ||
this.setSelection(range, _emitter.default.sources.SILENT); | ||
this.setSelection(range, Emitter.sources.SILENT); | ||
return change; | ||
@@ -334,3 +322,3 @@ }, source); | ||
if (typeof index === 'number') { | ||
length = this.getLength() - index; | ||
length = length ?? this.getLength() - index; | ||
} | ||
@@ -345,3 +333,3 @@ // @ts-expect-error | ||
if (typeof index === 'number') { | ||
length = this.getLength() - index; | ||
length = length ?? this.getLength() - index; | ||
} | ||
@@ -392,3 +380,3 @@ // @ts-expect-error | ||
scrollRectIntoView(rect) { | ||
(0, _scrollRectIntoView.default)(this.root, rect); | ||
scrollRectIntoView(this.root, rect); | ||
} | ||
@@ -416,5 +404,5 @@ | ||
setContents(delta) { | ||
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter.default.sources.API; | ||
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Emitter.sources.API; | ||
return modify.call(this, () => { | ||
delta = new _quillDelta.default(delta); | ||
delta = new Delta(delta); | ||
const length = this.getLength(); | ||
@@ -436,4 +424,4 @@ // Quill will set empty editor to \n | ||
[index, length,, source] = overload(index, length, source); | ||
this.selection.setRange(new _selection.Range(Math.max(0, index), length), source); | ||
if (source !== _emitter.default.sources.SILENT) { | ||
this.selection.setRange(new Range(Math.max(0, index), length), source); | ||
if (source !== Emitter.sources.SILENT) { | ||
this.scrollSelectionIntoView(); | ||
@@ -444,8 +432,8 @@ } | ||
setText(text) { | ||
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter.default.sources.API; | ||
const delta = new _quillDelta.default().insert(text); | ||
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Emitter.sources.API; | ||
const delta = new Delta().insert(text); | ||
return this.setContents(delta, source); | ||
} | ||
update() { | ||
let source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter.default.sources.USER; | ||
let source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Emitter.sources.USER; | ||
const change = this.scroll.update(source); // Will update selection before selection.update() does if text changes | ||
@@ -457,5 +445,5 @@ this.selection.update(source); | ||
updateContents(delta) { | ||
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _emitter.default.sources.API; | ||
let source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Emitter.sources.API; | ||
return modify.call(this, () => { | ||
delta = new _quillDelta.default(delta); | ||
delta = new Delta(delta); | ||
return this.editor.applyDelta(delta); | ||
@@ -465,6 +453,5 @@ }, source, true); | ||
} | ||
exports.default = Quill; | ||
function expandConfig(container, userConfig) { | ||
// @ts-expect-error -- TODO fix this later | ||
let expandedConfig = (0, _lodashEs.merge)({ | ||
let expandedConfig = merge({ | ||
container, | ||
@@ -481,3 +468,3 @@ modules: { | ||
if (!expandedConfig.theme || expandedConfig.theme === Quill.DEFAULTS.theme) { | ||
expandedConfig.theme = _theme.default; | ||
expandedConfig.theme = Theme; | ||
} else { | ||
@@ -490,3 +477,3 @@ expandedConfig.theme = Quill.import(`themes/${expandedConfig.theme}`); | ||
// @ts-expect-error -- TODO fix this later | ||
const themeConfig = (0, _lodashEs.cloneDeep)(expandedConfig.theme.DEFAULTS); | ||
const themeConfig = cloneDeep(expandedConfig.theme.DEFAULTS); | ||
[themeConfig, expandedConfig].forEach(config => { | ||
@@ -517,3 +504,3 @@ config.modules = config.modules || {}; | ||
} | ||
expandedConfig = (0, _lodashEs.merge)({}, Quill.DEFAULTS, { | ||
expandedConfig = merge({}, Quill.DEFAULTS, { | ||
modules: moduleConfig | ||
@@ -540,4 +527,4 @@ }, themeConfig, expandedConfig); | ||
function modify(modifier, source, index, shift) { | ||
if (!this.isEnabled() && source === _emitter.default.sources.USER && !this.allowReadOnlyEdits) { | ||
return new _quillDelta.default(); | ||
if (!this.isEnabled() && source === Emitter.sources.USER && !this.allowReadOnlyEdits) { | ||
return new Delta(); | ||
} | ||
@@ -558,8 +545,8 @@ let range = index == null ? null : this.getSelection(); | ||
} | ||
this.setSelection(range, _emitter.default.sources.SILENT); | ||
this.setSelection(range, Emitter.sources.SILENT); | ||
} | ||
if (change.length() > 0) { | ||
const args = [_emitter.default.events.TEXT_CHANGE, change, oldDelta, source]; | ||
this.emitter.emit(_emitter.default.events.EDITOR_CHANGE, ...args); | ||
if (source !== _emitter.default.sources.SILENT) { | ||
const args = [Emitter.events.TEXT_CHANGE, change, oldDelta, source]; | ||
this.emitter.emit(Emitter.events.EDITOR_CHANGE, ...args); | ||
if (source !== Emitter.sources.SILENT) { | ||
this.emitter.emit(...args); | ||
@@ -612,3 +599,3 @@ } | ||
// Handle optional source | ||
source = source || _emitter.default.sources.API; | ||
source = source || Emitter.sources.API; | ||
// @ts-expect-error | ||
@@ -626,7 +613,7 @@ return [index, length, formats, source]; | ||
// @ts-expect-error -- TODO: add a better type guard around `index` | ||
index.transformPosition(pos, source !== _emitter.default.sources.USER)); | ||
index.transformPosition(pos, source !== Emitter.sources.USER)); | ||
} else { | ||
[start, end] = [range.index, range.index + range.length].map(pos => { | ||
// @ts-expect-error -- TODO: add a better type guard around `index` | ||
if (pos < index || pos === index && source === _emitter.default.sources.USER) return pos; | ||
if (pos < index || pos === index && source === Emitter.sources.USER) return pos; | ||
if (length >= 0) { | ||
@@ -639,4 +626,5 @@ return pos + length; | ||
} | ||
return new _selection.Range(start, end - start); | ||
return new Range(start, end - start); | ||
} | ||
export { globalRegistry, expandConfig, overload, Quill as default }; | ||
//# sourceMappingURL=quill.js.map |
@@ -1,5 +0,5 @@ | ||
import Emitter from './emitter'; | ||
import type { EmitterSource } from './emitter'; | ||
import type Cursor from '../blots/cursor'; | ||
import type Scroll from '../blots/scroll'; | ||
import Emitter from './emitter.js'; | ||
import type { EmitterSource } from './emitter.js'; | ||
import type Cursor from '../blots/cursor.js'; | ||
import type Scroll from '../blots/scroll.js'; | ||
type NativeRange = AbstractRange; | ||
@@ -6,0 +6,0 @@ interface NormalizedRange { |
@@ -1,13 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.Range = void 0; | ||
var _parchment = require("parchment"); | ||
var _lodashEs = require("lodash-es"); | ||
var _emitter = _interopRequireDefault(require("./emitter")); | ||
var _logger = _interopRequireDefault(require("./logger")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const debug = (0, _logger.default)('quill:selection'); | ||
import { LeafBlot, Scope } from 'parchment'; | ||
import { cloneDeep, isEqual } from 'lodash-es'; | ||
import Emitter from './emitter.js'; | ||
import logger from './logger.js'; | ||
const debug = logger('quill:selection'); | ||
class Range { | ||
@@ -20,3 +13,2 @@ constructor(index) { | ||
} | ||
exports.Range = Range; | ||
class Selection { | ||
@@ -39,6 +31,6 @@ constructor(scroll, emitter) { | ||
if (!this.mouseDown && !this.composing) { | ||
setTimeout(this.update.bind(this, _emitter.default.sources.USER), 1); | ||
setTimeout(this.update.bind(this, Emitter.sources.USER), 1); | ||
} | ||
}); | ||
this.emitter.on(_emitter.default.events.SCROLL_BEFORE_UPDATE, () => { | ||
this.emitter.on(Emitter.events.SCROLL_BEFORE_UPDATE, () => { | ||
if (!this.hasFocus()) return; | ||
@@ -48,3 +40,3 @@ const native = this.getNativeRange(); | ||
if (native.start.node === this.cursor.textNode) return; // cursor.restore() will handle | ||
this.emitter.once(_emitter.default.events.SCROLL_UPDATE, (source, mutations) => { | ||
this.emitter.once(Emitter.events.SCROLL_UPDATE, (source, mutations) => { | ||
try { | ||
@@ -55,3 +47,3 @@ if (this.root.contains(native.start.node) && this.root.contains(native.end.node)) { | ||
const triggeredByTyping = mutations.some(mutation => mutation.type === 'characterData' || mutation.type === 'childList' || mutation.type === 'attributes' && mutation.target === this.root); | ||
this.update(triggeredByTyping ? _emitter.default.sources.SILENT : source); | ||
this.update(triggeredByTyping ? Emitter.sources.SILENT : source); | ||
} catch (ignored) { | ||
@@ -62,3 +54,3 @@ // ignore | ||
}); | ||
this.emitter.on(_emitter.default.events.SCROLL_OPTIMIZE, (mutations, context) => { | ||
this.emitter.on(Emitter.events.SCROLL_OPTIMIZE, (mutations, context) => { | ||
if (context.range) { | ||
@@ -72,12 +64,12 @@ const { | ||
this.setNativeRange(startNode, startOffset, endNode, endOffset); | ||
this.update(_emitter.default.sources.SILENT); | ||
this.update(Emitter.sources.SILENT); | ||
} | ||
}); | ||
this.update(_emitter.default.sources.SILENT); | ||
this.update(Emitter.sources.SILENT); | ||
} | ||
handleComposition() { | ||
this.emitter.on(_emitter.default.events.COMPOSITION_BEFORE_START, () => { | ||
this.emitter.on(Emitter.events.COMPOSITION_BEFORE_START, () => { | ||
this.composing = true; | ||
}); | ||
this.emitter.on(_emitter.default.events.COMPOSITION_END, () => { | ||
this.emitter.on(Emitter.events.COMPOSITION_END, () => { | ||
this.composing = false; | ||
@@ -99,3 +91,3 @@ if (this.cursor.parent) { | ||
this.mouseDown = false; | ||
this.update(_emitter.default.sources.USER); | ||
this.update(Emitter.sources.USER); | ||
}); | ||
@@ -113,3 +105,3 @@ } | ||
const nativeRange = this.getNativeRange(); | ||
if (nativeRange == null || !nativeRange.native.collapsed || this.scroll.query(format, _parchment.Scope.BLOCK)) return; | ||
if (nativeRange == null || !nativeRange.native.collapsed || this.scroll.query(format, Scope.BLOCK)) return; | ||
if (nativeRange.start.node !== this.cursor.textNode) { | ||
@@ -119,3 +111,3 @@ const blot = this.scroll.find(nativeRange.start.node, false); | ||
// TODO Give blot ability to not split | ||
if (blot instanceof _parchment.LeafBlot) { | ||
if (blot instanceof LeafBlot) { | ||
const after = blot.split(nativeRange.start.offset); | ||
@@ -144,2 +136,13 @@ // @ts-expect-error Fix me later | ||
if (leaf == null) return null; | ||
if (length > 0 && offset === leaf.length()) { | ||
const [next] = this.scroll.leaf(index + 1); | ||
if (next) { | ||
const [line] = this.scroll.line(index); | ||
const [nextLine] = this.scroll.line(index + 1); | ||
if (line === nextLine) { | ||
leaf = next; | ||
offset = 0; | ||
} | ||
} | ||
} | ||
[node, offset] = leaf.position(offset, true); | ||
@@ -226,3 +229,3 @@ const range = document.createRange(); | ||
} | ||
if (blot instanceof _parchment.LeafBlot) { | ||
if (blot instanceof LeafBlot) { | ||
return index + blot.index(node, offset); | ||
@@ -336,3 +339,3 @@ } | ||
let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; | ||
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _emitter.default.sources.API; | ||
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Emitter.sources.API; | ||
if (typeof force === 'string') { | ||
@@ -352,3 +355,3 @@ source = force; | ||
update() { | ||
let source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _emitter.default.sources.USER; | ||
let source = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Emitter.sources.USER; | ||
const oldRange = this.lastRange; | ||
@@ -361,3 +364,3 @@ const [lastRange, nativeRange] = this.getRange(); | ||
} | ||
if (!(0, _lodashEs.isEqual)(oldRange, this.lastRange)) { | ||
if (!isEqual(oldRange, this.lastRange)) { | ||
if (!this.composing && nativeRange != null && nativeRange.native.collapsed && nativeRange.start.node !== this.cursor.textNode) { | ||
@@ -369,5 +372,5 @@ const range = this.cursor.restore(); | ||
} | ||
const args = [_emitter.default.events.SELECTION_CHANGE, (0, _lodashEs.cloneDeep)(this.lastRange), (0, _lodashEs.cloneDeep)(oldRange), source]; | ||
this.emitter.emit(_emitter.default.events.EDITOR_CHANGE, ...args); | ||
if (source !== _emitter.default.sources.SILENT) { | ||
const args = [Emitter.events.SELECTION_CHANGE, cloneDeep(this.lastRange), cloneDeep(oldRange), source]; | ||
this.emitter.emit(Emitter.events.EDITOR_CHANGE, ...args); | ||
if (source !== Emitter.sources.SILENT) { | ||
this.emitter.emit(...args); | ||
@@ -378,3 +381,2 @@ } | ||
} | ||
exports.default = Selection; | ||
function contains(parent, descendant) { | ||
@@ -389,2 +391,3 @@ try { | ||
} | ||
export { Range, Selection as default }; | ||
//# sourceMappingURL=selection.js.map |
@@ -1,7 +0,7 @@ | ||
import type Quill from '../core'; | ||
import type Clipboard from '../modules/clipboard'; | ||
import type History from '../modules/history'; | ||
import type Keyboard from '../modules/keyboard'; | ||
import type { ToolbarProps } from '../modules/toolbar'; | ||
import type Uploader from '../modules/uploader'; | ||
import type Quill from '../core.js'; | ||
import type Clipboard from '../modules/clipboard.js'; | ||
import type History from '../modules/history.js'; | ||
import type Keyboard from '../modules/keyboard.js'; | ||
import type { ToolbarProps } from '../modules/toolbar.js'; | ||
import type Uploader from '../modules/uploader.js'; | ||
export interface ThemeOptions { | ||
@@ -8,0 +8,0 @@ modules: Record<string, unknown> & { |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
class Theme { | ||
@@ -33,3 +27,3 @@ static DEFAULTS = { | ||
} | ||
var _default = exports.default = Theme; | ||
export default Theme; | ||
//# sourceMappingURL=theme.js.map |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const getParentElement = element => element.parentElement || element.getRootNode().host || null; | ||
@@ -80,3 +74,3 @@ const getElementRect = element => { | ||
}; | ||
var _default = exports.default = scrollRectIntoView; | ||
export default scrollRectIntoView; | ||
//# sourceMappingURL=scrollRectIntoView.js.map |
/*! | ||
* Quill Editor v0.0.0-experimental-b9ebd32ba-20240125 | ||
* Quill Editor v0.0.0-experimental-d6d773267-20240311 | ||
* https://quilljs.com | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2017-2024, Slab |
/*! | ||
* Quill Editor v0.0.0-experimental-b9ebd32ba-20240125 | ||
* Quill Editor v0.0.0-experimental-d6d773267-20240311 | ||
* https://quilljs.com | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2017-2024, Slab |
/*! | ||
* Quill Editor v0.0.0-experimental-b9ebd32ba-20240125 | ||
* Quill Editor v0.0.0-experimental-d6d773267-20240311 | ||
* https://quilljs.com | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2017-2024, Slab |
/*! | ||
* Quill Editor v0.0.0-experimental-b9ebd32ba-20240125 | ||
* Quill Editor v0.0.0-experimental-d6d773267-20240311 | ||
* https://quilljs.com | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2017-2024, Slab |
/*! | ||
* Quill Editor v0.0.0-experimental-b9ebd32ba-20240125 | ||
* Quill Editor v0.0.0-experimental-d6d773267-20240311 | ||
* https://quilljs.com | ||
@@ -4,0 +4,0 @@ * Copyright (c) 2017-2024, Slab |
@@ -1,15 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.AlignStyle = exports.AlignClass = exports.AlignAttribute = void 0; | ||
var _parchment = require("parchment"); | ||
import { Attributor, ClassAttributor, Scope, StyleAttributor } from 'parchment'; | ||
const config = { | ||
scope: _parchment.Scope.BLOCK, | ||
scope: Scope.BLOCK, | ||
whitelist: ['right', 'center', 'justify'] | ||
}; | ||
const AlignAttribute = exports.AlignAttribute = new _parchment.Attributor('align', 'align', config); | ||
const AlignClass = exports.AlignClass = new _parchment.ClassAttributor('align', 'ql-align', config); | ||
const AlignStyle = exports.AlignStyle = new _parchment.StyleAttributor('align', 'text-align', config); | ||
const AlignAttribute = new Attributor('align', 'align', config); | ||
const AlignClass = new ClassAttributor('align', 'ql-align', config); | ||
const AlignStyle = new StyleAttributor('align', 'text-align', config); | ||
export { AlignAttribute, AlignClass, AlignStyle }; | ||
//# sourceMappingURL=align.js.map |
import { ClassAttributor } from 'parchment'; | ||
import { ColorAttributor } from './color'; | ||
import { ColorAttributor } from './color.js'; | ||
declare const BackgroundClass: ClassAttributor; | ||
declare const BackgroundStyle: ColorAttributor; | ||
export { BackgroundClass, BackgroundStyle }; |
@@ -1,15 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
import { ClassAttributor, Scope } from 'parchment'; | ||
import { ColorAttributor } from './color.js'; | ||
const BackgroundClass = new ClassAttributor('background', 'ql-bg', { | ||
scope: Scope.INLINE | ||
}); | ||
exports.BackgroundStyle = exports.BackgroundClass = void 0; | ||
var _parchment = require("parchment"); | ||
var _color = require("./color"); | ||
const BackgroundClass = exports.BackgroundClass = new _parchment.ClassAttributor('background', 'ql-bg', { | ||
scope: _parchment.Scope.INLINE | ||
const BackgroundStyle = new ColorAttributor('background', 'background-color', { | ||
scope: Scope.INLINE | ||
}); | ||
const BackgroundStyle = exports.BackgroundStyle = new _color.ColorAttributor('background', 'background-color', { | ||
scope: _parchment.Scope.INLINE | ||
}); | ||
export { BackgroundClass, BackgroundStyle }; | ||
//# sourceMappingURL=background.js.map |
@@ -1,2 +0,2 @@ | ||
import Block from '../blots/block'; | ||
import Block from '../blots/block.js'; | ||
declare class Blockquote extends Block { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,14 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _block = _interopRequireDefault(require("../blots/block")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Blockquote extends _block.default { | ||
import Block from '../blots/block.js'; | ||
class Blockquote extends Block { | ||
static blotName = 'blockquote'; | ||
static tagName = 'blockquote'; | ||
} | ||
var _default = exports.default = Blockquote; | ||
export default Blockquote; | ||
//# sourceMappingURL=blockquote.js.map |
@@ -1,2 +0,2 @@ | ||
import Inline from '../blots/inline'; | ||
import Inline from '../blots/inline.js'; | ||
declare class Bold extends Inline { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _inline = _interopRequireDefault(require("../blots/inline")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Bold extends _inline.default { | ||
import Inline from '../blots/inline.js'; | ||
class Bold extends Inline { | ||
static blotName = 'bold'; | ||
@@ -25,3 +18,3 @@ static tagName = ['STRONG', 'B']; | ||
} | ||
var _default = exports.default = Bold; | ||
export default Bold; | ||
//# sourceMappingURL=bold.js.map |
@@ -1,4 +0,4 @@ | ||
import Block from '../blots/block'; | ||
import Inline from '../blots/inline'; | ||
import Container from '../blots/container'; | ||
import Block from '../blots/block.js'; | ||
import Inline from '../blots/inline.js'; | ||
import Container from '../blots/container.js'; | ||
declare class CodeBlockContainer extends Container { | ||
@@ -5,0 +5,0 @@ static create(value: string): Element; |
@@ -1,18 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.CodeBlockContainer = exports.Code = void 0; | ||
var _block = _interopRequireDefault(require("../blots/block")); | ||
var _break = _interopRequireDefault(require("../blots/break")); | ||
var _cursor = _interopRequireDefault(require("../blots/cursor")); | ||
var _inline = _interopRequireDefault(require("../blots/inline")); | ||
var _text = _interopRequireWildcard(require("../blots/text")); | ||
var _container = _interopRequireDefault(require("../blots/container")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class CodeBlockContainer extends _container.default { | ||
import Block from '../blots/block.js'; | ||
import Break from '../blots/break.js'; | ||
import Cursor from '../blots/cursor.js'; | ||
import Inline from '../blots/inline.js'; | ||
import TextBlot, { escapeText } from '../blots/text.js'; | ||
import Container from '../blots/container.js'; | ||
import Quill from '../core/quill.js'; | ||
class CodeBlockContainer extends Container { | ||
static create(value) { | ||
@@ -31,15 +22,12 @@ const domNode = super.create(value); | ||
// https://html.spec.whatwg.org/multipage/syntax.html#element-restrictions | ||
return `<pre>\n${(0, _text.escapeText)(this.code(index, length))}\n</pre>`; | ||
return `<pre>\n${escapeText(this.code(index, length))}\n</pre>`; | ||
} | ||
} | ||
exports.CodeBlockContainer = CodeBlockContainer; | ||
class CodeBlock extends _block.default { | ||
class CodeBlock extends Block { | ||
static TAB = ' '; | ||
static register() { | ||
_quill.default.register(CodeBlockContainer); | ||
Quill.register(CodeBlockContainer); | ||
} | ||
} | ||
exports.default = CodeBlock; | ||
class Code extends _inline.default {} | ||
exports.Code = Code; | ||
class Code extends Inline {} | ||
Code.blotName = 'code'; | ||
@@ -54,4 +42,5 @@ Code.tagName = 'CODE'; | ||
CodeBlockContainer.allowedChildren = [CodeBlock]; | ||
CodeBlock.allowedChildren = [_text.default, _break.default, _cursor.default]; | ||
CodeBlock.allowedChildren = [TextBlot, Break, Cursor]; | ||
CodeBlock.requiredContainer = CodeBlockContainer; | ||
export { Code, CodeBlockContainer, CodeBlock as default }; | ||
//# sourceMappingURL=code.js.map |
@@ -1,9 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ColorStyle = exports.ColorClass = exports.ColorAttributor = void 0; | ||
var _parchment = require("parchment"); | ||
class ColorAttributor extends _parchment.StyleAttributor { | ||
import { ClassAttributor, Scope, StyleAttributor } from 'parchment'; | ||
class ColorAttributor extends StyleAttributor { | ||
value(domNode) { | ||
@@ -17,9 +11,9 @@ let value = super.value(domNode); | ||
} | ||
exports.ColorAttributor = ColorAttributor; | ||
const ColorClass = exports.ColorClass = new _parchment.ClassAttributor('color', 'ql-color', { | ||
scope: _parchment.Scope.INLINE | ||
const ColorClass = new ClassAttributor('color', 'ql-color', { | ||
scope: Scope.INLINE | ||
}); | ||
const ColorStyle = exports.ColorStyle = new ColorAttributor('color', 'color', { | ||
scope: _parchment.Scope.INLINE | ||
const ColorStyle = new ColorAttributor('color', 'color', { | ||
scope: Scope.INLINE | ||
}); | ||
export { ColorAttributor, ColorClass, ColorStyle }; | ||
//# sourceMappingURL=color.js.map |
@@ -1,15 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.DirectionStyle = exports.DirectionClass = exports.DirectionAttribute = void 0; | ||
var _parchment = require("parchment"); | ||
import { Attributor, ClassAttributor, Scope, StyleAttributor } from 'parchment'; | ||
const config = { | ||
scope: _parchment.Scope.BLOCK, | ||
scope: Scope.BLOCK, | ||
whitelist: ['rtl'] | ||
}; | ||
const DirectionAttribute = exports.DirectionAttribute = new _parchment.Attributor('direction', 'dir', config); | ||
const DirectionClass = exports.DirectionClass = new _parchment.ClassAttributor('direction', 'ql-direction', config); | ||
const DirectionStyle = exports.DirectionStyle = new _parchment.StyleAttributor('direction', 'direction', config); | ||
const DirectionAttribute = new Attributor('direction', 'dir', config); | ||
const DirectionClass = new ClassAttributor('direction', 'ql-direction', config); | ||
const DirectionStyle = new StyleAttributor('direction', 'direction', config); | ||
export { DirectionAttribute, DirectionClass, DirectionStyle }; | ||
//# sourceMappingURL=direction.js.map |
@@ -1,14 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.FontStyle = exports.FontClass = void 0; | ||
var _parchment = require("parchment"); | ||
import { ClassAttributor, Scope, StyleAttributor } from 'parchment'; | ||
const config = { | ||
scope: _parchment.Scope.INLINE, | ||
scope: Scope.INLINE, | ||
whitelist: ['serif', 'monospace'] | ||
}; | ||
const FontClass = exports.FontClass = new _parchment.ClassAttributor('font', 'ql-font', config); | ||
class FontStyleAttributor extends _parchment.StyleAttributor { | ||
const FontClass = new ClassAttributor('font', 'ql-font', config); | ||
class FontStyleAttributor extends StyleAttributor { | ||
value(node) { | ||
@@ -18,3 +12,4 @@ return super.value(node).replace(/["']/g, ''); | ||
} | ||
const FontStyle = exports.FontStyle = new FontStyleAttributor('font', 'font-family', config); | ||
const FontStyle = new FontStyleAttributor('font', 'font-family', config); | ||
export { FontStyle, FontClass }; | ||
//# sourceMappingURL=font.js.map |
@@ -1,2 +0,2 @@ | ||
import Embed from '../blots/embed'; | ||
import Embed from '../blots/embed.js'; | ||
declare class Formula extends Embed { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _embed = _interopRequireDefault(require("../blots/embed")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Formula extends _embed.default { | ||
import Embed from '../blots/embed.js'; | ||
class Formula extends Embed { | ||
static blotName = 'formula'; | ||
@@ -39,3 +32,3 @@ static className = 'ql-formula'; | ||
} | ||
var _default = exports.default = Formula; | ||
export default Formula; | ||
//# sourceMappingURL=formula.js.map |
@@ -1,2 +0,2 @@ | ||
import Block from '../blots/block'; | ||
import Block from '../blots/block.js'; | ||
declare class Header extends Block { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _block = _interopRequireDefault(require("../blots/block")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Header extends _block.default { | ||
import Block from '../blots/block.js'; | ||
class Header extends Block { | ||
static blotName = 'header'; | ||
@@ -16,3 +9,3 @@ static tagName = ['H1', 'H2', 'H3', 'H4', 'H5', 'H6']; | ||
} | ||
var _default = exports.default = Header; | ||
export default Header; | ||
//# sourceMappingURL=header.js.map |
@@ -8,3 +8,2 @@ import { EmbedBlot } from 'parchment'; | ||
static match(url: string): boolean; | ||
static register(): void; | ||
static sanitize(url: string): string; | ||
@@ -11,0 +10,0 @@ static value(domNode: Element): string | null; |
@@ -1,11 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
var _link = require("./link"); | ||
import { EmbedBlot } from 'parchment'; | ||
import { sanitize } from './link.js'; | ||
const ATTRIBUTES = ['alt', 'height', 'width']; | ||
class Image extends _parchment.EmbedBlot { | ||
class Image extends EmbedBlot { | ||
static blotName = 'image'; | ||
@@ -31,13 +25,4 @@ static tagName = 'IMG'; | ||
} | ||
static register() { | ||
if (/Firefox/i.test(navigator.userAgent)) { | ||
setTimeout(() => { | ||
// Disable image resizing in Firefox | ||
// @ts-expect-error | ||
document.execCommand('enableObjectResizing', false, false); | ||
}, 1); | ||
} | ||
} | ||
static sanitize(url) { | ||
return (0, _link.sanitize)(url, ['http', 'https', 'data']) ? url : '//:0'; | ||
return sanitize(url, ['http', 'https', 'data']) ? url : '//:0'; | ||
} | ||
@@ -59,3 +44,3 @@ static value(domNode) { | ||
} | ||
var _default = exports.default = Image; | ||
export default Image; | ||
//# sourceMappingURL=image.js.map |
@@ -1,9 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _parchment = require("parchment"); | ||
class IndentAttributor extends _parchment.ClassAttributor { | ||
import { ClassAttributor, Scope } from 'parchment'; | ||
class IndentAttributor extends ClassAttributor { | ||
add(node, value) { | ||
@@ -32,7 +26,7 @@ let normalizedValue = 0; | ||
const IndentClass = new IndentAttributor('indent', 'ql-indent', { | ||
scope: _parchment.Scope.BLOCK, | ||
scope: Scope.BLOCK, | ||
// @ts-expect-error | ||
whitelist: [1, 2, 3, 4, 5, 6, 7, 8] | ||
}); | ||
var _default = exports.default = IndentClass; | ||
export default IndentClass; | ||
//# sourceMappingURL=indent.js.map |
@@ -1,2 +0,2 @@ | ||
import Bold from './bold'; | ||
import Bold from './bold.js'; | ||
declare class Italic extends Bold { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,14 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _bold = _interopRequireDefault(require("./bold")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Italic extends _bold.default { | ||
import Bold from './bold.js'; | ||
class Italic extends Bold { | ||
static blotName = 'italic'; | ||
static tagName = ['EM', 'I']; | ||
} | ||
var _default = exports.default = Italic; | ||
export default Italic; | ||
//# sourceMappingURL=italic.js.map |
@@ -1,2 +0,2 @@ | ||
import Inline from '../blots/inline'; | ||
import Inline from '../blots/inline.js'; | ||
declare class Link extends Inline { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,11 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.sanitize = sanitize; | ||
var _inline = _interopRequireDefault(require("../blots/inline")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Link extends _inline.default { | ||
import Inline from '../blots/inline.js'; | ||
class Link extends Inline { | ||
static blotName = 'link'; | ||
@@ -37,3 +29,2 @@ static tagName = 'A'; | ||
} | ||
exports.default = Link; | ||
function sanitize(url, protocols) { | ||
@@ -45,2 +36,3 @@ const anchor = document.createElement('a'); | ||
} | ||
export { Link as default, sanitize }; | ||
//# sourceMappingURL=link.js.map |
@@ -1,4 +0,4 @@ | ||
import Block from '../blots/block'; | ||
import Container from '../blots/container'; | ||
import type Scroll from '../blots/scroll'; | ||
import Block from '../blots/block.js'; | ||
import Container from '../blots/container.js'; | ||
import type Scroll from '../blots/scroll.js'; | ||
declare class ListContainer extends Container { | ||
@@ -5,0 +5,0 @@ } |
@@ -1,16 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.ListContainer = void 0; | ||
var _block = _interopRequireDefault(require("../blots/block")); | ||
var _container = _interopRequireDefault(require("../blots/container")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class ListContainer extends _container.default {} | ||
exports.ListContainer = ListContainer; | ||
import Block from '../blots/block.js'; | ||
import Container from '../blots/container.js'; | ||
import Quill from '../core/quill.js'; | ||
class ListContainer extends Container {} | ||
ListContainer.blotName = 'list-container'; | ||
ListContainer.tagName = 'OL'; | ||
class ListItem extends _block.default { | ||
class ListItem extends Block { | ||
static create(value) { | ||
@@ -25,3 +17,3 @@ const node = super.create(); | ||
static register() { | ||
_quill.default.register(ListContainer); | ||
Quill.register(ListContainer); | ||
} | ||
@@ -54,3 +46,2 @@ constructor(scroll, domNode) { | ||
} | ||
exports.default = ListItem; | ||
ListItem.blotName = 'list'; | ||
@@ -60,2 +51,3 @@ ListItem.tagName = 'LI'; | ||
ListItem.requiredContainer = ListContainer; | ||
export { ListContainer, ListItem as default }; | ||
//# sourceMappingURL=list.js.map |
@@ -1,2 +0,2 @@ | ||
import Inline from '../blots/inline'; | ||
import Inline from '../blots/inline.js'; | ||
declare class Script extends Inline { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _inline = _interopRequireDefault(require("../blots/inline")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Script extends _inline.default { | ||
import Inline from '../blots/inline.js'; | ||
class Script extends Inline { | ||
static blotName = 'script'; | ||
@@ -27,3 +20,3 @@ static tagName = ['SUB', 'SUP']; | ||
} | ||
var _default = exports.default = Script; | ||
export default Script; | ||
//# sourceMappingURL=script.js.map |
@@ -1,16 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.SizeStyle = exports.SizeClass = void 0; | ||
var _parchment = require("parchment"); | ||
const SizeClass = exports.SizeClass = new _parchment.ClassAttributor('size', 'ql-size', { | ||
scope: _parchment.Scope.INLINE, | ||
import { ClassAttributor, Scope, StyleAttributor } from 'parchment'; | ||
const SizeClass = new ClassAttributor('size', 'ql-size', { | ||
scope: Scope.INLINE, | ||
whitelist: ['small', 'large', 'huge'] | ||
}); | ||
const SizeStyle = exports.SizeStyle = new _parchment.StyleAttributor('size', 'font-size', { | ||
scope: _parchment.Scope.INLINE, | ||
const SizeStyle = new StyleAttributor('size', 'font-size', { | ||
scope: Scope.INLINE, | ||
whitelist: ['10px', '18px', '32px'] | ||
}); | ||
export { SizeClass, SizeStyle }; | ||
//# sourceMappingURL=size.js.map |
@@ -1,2 +0,2 @@ | ||
import Bold from './bold'; | ||
import Bold from './bold.js'; | ||
declare class Strike extends Bold { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,14 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _bold = _interopRequireDefault(require("./bold")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Strike extends _bold.default { | ||
import Bold from './bold.js'; | ||
class Strike extends Bold { | ||
static blotName = 'strike'; | ||
static tagName = ['S', 'STRIKE']; | ||
} | ||
var _default = exports.default = Strike; | ||
export default Strike; | ||
//# sourceMappingURL=strike.js.map |
import type { LinkedList } from 'parchment'; | ||
import Block from '../blots/block'; | ||
import Container from '../blots/container'; | ||
import Block from '../blots/block.js'; | ||
import Container from '../blots/container.js'; | ||
declare class TableCell extends Block { | ||
@@ -5,0 +5,0 @@ static blotName: string; |
@@ -1,12 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.TableRow = exports.TableContainer = exports.TableCell = exports.TableBody = void 0; | ||
exports.tableId = tableId; | ||
var _block = _interopRequireDefault(require("../blots/block")); | ||
var _container = _interopRequireDefault(require("../blots/container")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class TableCell extends _block.default { | ||
import Block from '../blots/block.js'; | ||
import Container from '../blots/container.js'; | ||
class TableCell extends Block { | ||
static blotName = 'table'; | ||
@@ -55,4 +47,3 @@ static tagName = 'TD'; | ||
} | ||
exports.TableCell = TableCell; | ||
class TableRow extends _container.default { | ||
class TableRow extends Container { | ||
static blotName = 'table-row'; | ||
@@ -105,9 +96,7 @@ static tagName = 'TR'; | ||
} | ||
exports.TableRow = TableRow; | ||
class TableBody extends _container.default { | ||
class TableBody extends Container { | ||
static blotName = 'table-body'; | ||
static tagName = 'TBODY'; | ||
} | ||
exports.TableBody = TableBody; | ||
class TableContainer extends _container.default { | ||
class TableContainer extends Container { | ||
static blotName = 'table-container'; | ||
@@ -179,3 +168,2 @@ static tagName = 'TABLE'; | ||
} | ||
exports.TableContainer = TableContainer; | ||
TableContainer.allowedChildren = [TableBody]; | ||
@@ -191,2 +179,3 @@ TableBody.requiredContainer = TableContainer; | ||
} | ||
export { TableCell, TableRow, TableBody, TableContainer, tableId }; | ||
//# sourceMappingURL=table.js.map |
@@ -1,2 +0,2 @@ | ||
import Inline from '../blots/inline'; | ||
import Inline from '../blots/inline.js'; | ||
declare class Underline extends Inline { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,14 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _inline = _interopRequireDefault(require("../blots/inline")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Underline extends _inline.default { | ||
import Inline from '../blots/inline.js'; | ||
class Underline extends Inline { | ||
static blotName = 'underline'; | ||
static tagName = 'U'; | ||
} | ||
var _default = exports.default = Underline; | ||
export default Underline; | ||
//# sourceMappingURL=underline.js.map |
@@ -1,2 +0,2 @@ | ||
import { BlockEmbed } from '../blots/block'; | ||
import { BlockEmbed } from '../blots/block.js'; | ||
declare class Video extends BlockEmbed { | ||
@@ -3,0 +3,0 @@ static blotName: string; |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _block = require("../blots/block"); | ||
var _link = _interopRequireDefault(require("./link")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { BlockEmbed } from '../blots/block.js'; | ||
import Link from './link.js'; | ||
const ATTRIBUTES = ['height', 'width']; | ||
class Video extends _block.BlockEmbed { | ||
class Video extends BlockEmbed { | ||
static blotName = 'video'; | ||
@@ -31,3 +24,3 @@ static className = 'ql-video'; | ||
static sanitize(url) { | ||
return _link.default.sanitize(url); | ||
return Link.sanitize(url); | ||
} | ||
@@ -55,3 +48,3 @@ static value(domNode) { | ||
} | ||
var _default = exports.default = Video; | ||
export default Video; | ||
//# sourceMappingURL=video.js.map |
import type { ScrollBlot } from 'parchment'; | ||
import Delta from 'quill-delta'; | ||
import type { EmitterSource } from '../core/emitter'; | ||
import Module from '../core/module'; | ||
import Quill from '../core/quill'; | ||
import type { Range } from '../core/selection'; | ||
import type { EmitterSource } from '../core/emitter.js'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
import type { Range } from '../core/selection.js'; | ||
type Selector = string | Node['TEXT_NODE'] | Node['ELEMENT_NODE']; | ||
@@ -21,3 +21,4 @@ type Matcher = (node: Node, delta: Delta, scroll: ScrollBlot) => Delta; | ||
}, formats?: Record<string, unknown>): Delta; | ||
convertHTML(html: string): Delta; | ||
protected normalizeHTML(doc: Document): void; | ||
protected convertHTML(html: string): Delta; | ||
dangerouslyPasteHTML(html: string, source?: EmitterSource): void; | ||
@@ -41,3 +42,3 @@ dangerouslyPasteHTML(index: number, html: string, source?: EmitterSource): void; | ||
declare function matchNewline(node: Node, delta: Delta, scroll: ScrollBlot): Delta; | ||
declare function matchText(node: HTMLElement, delta: Delta): Delta; | ||
declare function matchText(node: HTMLElement, delta: Delta, scroll: ScrollBlot): Delta; | ||
export { Clipboard as default, matchAttributor, matchBlot, matchNewline, matchText, traverse, }; |
@@ -1,38 +0,27 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.matchAttributor = matchAttributor; | ||
exports.matchBlot = matchBlot; | ||
exports.matchNewline = matchNewline; | ||
exports.matchText = matchText; | ||
exports.traverse = traverse; | ||
var _parchment = require("parchment"); | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _block = require("../blots/block"); | ||
var _logger = _interopRequireDefault(require("../core/logger")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
var _align = require("../formats/align"); | ||
var _background = require("../formats/background"); | ||
var _code = _interopRequireDefault(require("../formats/code")); | ||
var _color = require("../formats/color"); | ||
var _direction = require("../formats/direction"); | ||
var _font = require("../formats/font"); | ||
var _size = require("../formats/size"); | ||
var _keyboard = require("./keyboard"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const debug = (0, _logger.default)('quill:clipboard'); | ||
const CLIPBOARD_CONFIG = [[Node.TEXT_NODE, matchText], [Node.TEXT_NODE, matchNewline], ['br', matchBreak], [Node.ELEMENT_NODE, matchNewline], [Node.ELEMENT_NODE, matchBlot], [Node.ELEMENT_NODE, matchAttributor], [Node.ELEMENT_NODE, matchStyles], ['li', matchIndent], ['ol, ul', matchList], ['pre', matchCodeBlock], ['tr', matchTable], ['b', matchAlias.bind(matchAlias, 'bold')], ['i', matchAlias.bind(matchAlias, 'italic')], ['strike', matchAlias.bind(matchAlias, 'strike')], ['style', matchIgnore]]; | ||
const ATTRIBUTE_ATTRIBUTORS = [_align.AlignAttribute, _direction.DirectionAttribute].reduce((memo, attr) => { | ||
import { Attributor, BlockBlot, ClassAttributor, EmbedBlot, Scope, StyleAttributor } from 'parchment'; | ||
import Delta from 'quill-delta'; | ||
import { BlockEmbed } from '../blots/block.js'; | ||
import logger from '../core/logger.js'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
import { AlignAttribute, AlignStyle } from '../formats/align.js'; | ||
import { BackgroundStyle } from '../formats/background.js'; | ||
import CodeBlock from '../formats/code.js'; | ||
import { ColorStyle } from '../formats/color.js'; | ||
import { DirectionAttribute, DirectionStyle } from '../formats/direction.js'; | ||
import { FontStyle } from '../formats/font.js'; | ||
import { SizeStyle } from '../formats/size.js'; | ||
import { deleteRange } from './keyboard.js'; | ||
import normalizeExternalHTML from './normalizeExternalHTML/index.js'; | ||
const debug = logger('quill:clipboard'); | ||
const CLIPBOARD_CONFIG = [[Node.TEXT_NODE, matchText], [Node.TEXT_NODE, matchNewline], ['br', matchBreak], [Node.ELEMENT_NODE, matchNewline], [Node.ELEMENT_NODE, matchBlot], [Node.ELEMENT_NODE, matchAttributor], [Node.ELEMENT_NODE, matchStyles], ['li', matchIndent], ['ol, ul', matchList], ['pre', matchCodeBlock], ['tr', matchTable], ['b', createMatchAlias('bold')], ['i', createMatchAlias('italic')], ['strike', createMatchAlias('strike')], ['style', matchIgnore]]; | ||
const ATTRIBUTE_ATTRIBUTORS = [AlignAttribute, DirectionAttribute].reduce((memo, attr) => { | ||
memo[attr.keyName] = attr; | ||
return memo; | ||
}, {}); | ||
const STYLE_ATTRIBUTORS = [_align.AlignStyle, _background.BackgroundStyle, _color.ColorStyle, _direction.DirectionStyle, _font.FontStyle, _size.SizeStyle].reduce((memo, attr) => { | ||
const STYLE_ATTRIBUTORS = [AlignStyle, BackgroundStyle, ColorStyle, DirectionStyle, FontStyle, SizeStyle].reduce((memo, attr) => { | ||
memo[attr.keyName] = attr; | ||
return memo; | ||
}, {}); | ||
class Clipboard extends _module.default { | ||
class Clipboard extends Module { | ||
constructor(quill, options) { | ||
@@ -59,9 +48,9 @@ super(quill, options); | ||
let formats = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (formats[_code.default.blotName]) { | ||
return new _quillDelta.default().insert(text || '', { | ||
[_code.default.blotName]: formats[_code.default.blotName] | ||
if (formats[CodeBlock.blotName]) { | ||
return new Delta().insert(text || '', { | ||
[CodeBlock.blotName]: formats[CodeBlock.blotName] | ||
}); | ||
} | ||
if (!html) { | ||
return new _quillDelta.default().insert(text || ''); | ||
return new Delta().insert(text || '', formats); | ||
} | ||
@@ -71,8 +60,12 @@ const delta = this.convertHTML(html); | ||
if (deltaEndsWith(delta, '\n') && (delta.ops[delta.ops.length - 1].attributes == null || formats.table)) { | ||
return delta.compose(new _quillDelta.default().retain(delta.length() - 1).delete(1)); | ||
return delta.compose(new Delta().retain(delta.length() - 1).delete(1)); | ||
} | ||
return delta; | ||
} | ||
normalizeHTML(doc) { | ||
normalizeExternalHTML(doc); | ||
} | ||
convertHTML(html) { | ||
const doc = new DOMParser().parseFromString(html, 'text/html'); | ||
this.normalizeHTML(doc); | ||
const container = doc.body; | ||
@@ -84,3 +77,3 @@ const nodeMatches = new WeakMap(); | ||
dangerouslyPasteHTML(index, html) { | ||
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _quill.default.sources.API; | ||
let source = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Quill.sources.API; | ||
if (typeof index === 'string') { | ||
@@ -93,3 +86,3 @@ const delta = this.convert({ | ||
this.quill.setContents(delta, html); | ||
this.quill.setSelection(0, _quill.default.sources.SILENT); | ||
this.quill.setSelection(0, Quill.sources.SILENT); | ||
} else { | ||
@@ -100,4 +93,4 @@ const paste = this.convert({ | ||
}); | ||
this.quill.updateContents(new _quillDelta.default().retain(index).concat(paste), source); | ||
this.quill.setSelection(index + paste.length(), _quill.default.sources.SILENT); | ||
this.quill.updateContents(new Delta().retain(index).concat(paste), source); | ||
this.quill.setSelection(index + paste.length(), Quill.sources.SILENT); | ||
} | ||
@@ -118,3 +111,3 @@ } | ||
if (isCut) { | ||
(0, _keyboard.deleteRange)({ | ||
deleteRange({ | ||
range, | ||
@@ -171,6 +164,6 @@ quill: this.quill | ||
}); | ||
const delta = new _quillDelta.default().retain(range.index).delete(range.length).concat(pastedDelta); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
const delta = new Delta().retain(range.index).delete(range.length).concat(pastedDelta); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
// range.length contributes to delta.length() | ||
this.quill.setSelection(delta.length() - range.length, _quill.default.sources.SILENT); | ||
this.quill.setSelection(delta.length() - range.length, Quill.sources.SILENT); | ||
this.quill.scrollSelectionIntoView(); | ||
@@ -205,11 +198,8 @@ } | ||
} | ||
exports.default = Clipboard; | ||
Clipboard.DEFAULTS = { | ||
matchers: [] | ||
}; | ||
function applyFormat(delta, format, value) { | ||
if (typeof format === 'object') { | ||
return Object.keys(format).reduce((newDelta, key) => { | ||
return applyFormat(newDelta, key, format[key]); | ||
}, delta); | ||
function applyFormat(delta, format, value, scroll) { | ||
if (!scroll.query(format)) { | ||
return delta; | ||
} | ||
@@ -228,3 +218,3 @@ return delta.reduce((newDelta, op) => { | ||
}); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
@@ -241,6 +231,12 @@ function deltaEndsWith(delta, text) { | ||
} | ||
function isLine(node) { | ||
if (node.childNodes.length === 0) return false; // Exclude embed blocks | ||
function isLine(node, scroll) { | ||
if (!(node instanceof Element)) return false; | ||
const match = scroll.query(node); | ||
// @ts-expect-error | ||
if (match && match.prototype instanceof EmbedBlot) return false; | ||
return ['address', 'article', 'blockquote', 'canvas', 'dd', 'div', 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'iframe', 'li', 'main', 'nav', 'ol', 'output', 'p', 'pre', 'section', 'table', 'td', 'tr', 'ul', 'video'].includes(node.tagName.toLowerCase()); | ||
} | ||
function isBetweenInlineElements(node, scroll) { | ||
return node.previousElementSibling && node.nextElementSibling && !isLine(node.previousElementSibling, scroll) && !isLine(node.nextElementSibling, scroll); | ||
} | ||
const preNodes = new WeakMap(); | ||
@@ -264,3 +260,3 @@ function isPre(node) { | ||
return matcher(node, delta, scroll); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
@@ -279,16 +275,18 @@ if (node.nodeType === node.ELEMENT_NODE) { | ||
return delta.concat(childrenDelta); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
return new _quillDelta.default(); | ||
return new Delta(); | ||
} | ||
function matchAlias(format, node, delta) { | ||
return applyFormat(delta, format, true); | ||
function createMatchAlias(format) { | ||
return (_node, delta, scroll) => { | ||
return applyFormat(delta, format, true, scroll); | ||
}; | ||
} | ||
function matchAttributor(node, delta, scroll) { | ||
const attributes = _parchment.Attributor.keys(node); | ||
const classes = _parchment.ClassAttributor.keys(node); | ||
const styles = _parchment.StyleAttributor.keys(node); | ||
const attributes = Attributor.keys(node); | ||
const classes = ClassAttributor.keys(node); | ||
const styles = StyleAttributor.keys(node); | ||
const formats = {}; | ||
attributes.concat(classes).concat(styles).forEach(name => { | ||
let attr = scroll.query(name, _parchment.Scope.ATTRIBUTE); | ||
let attr = scroll.query(name, Scope.ATTRIBUTE); | ||
if (attr != null) { | ||
@@ -308,6 +306,6 @@ formats[attr.attrName] = attr.value(node); | ||
}); | ||
if (Object.keys(formats).length > 0) { | ||
return applyFormat(delta, formats); | ||
} | ||
return delta; | ||
return Object.entries(formats).reduce((newDelta, _ref4) => { | ||
let [name, value] = _ref4; | ||
return applyFormat(newDelta, name, value, scroll); | ||
}, delta); | ||
} | ||
@@ -318,3 +316,3 @@ function matchBlot(node, delta, scroll) { | ||
// @ts-expect-error | ||
if (match.prototype instanceof _parchment.EmbedBlot) { | ||
if (match.prototype instanceof EmbedBlot) { | ||
const embed = {}; | ||
@@ -327,13 +325,11 @@ // @ts-expect-error | ||
// @ts-expect-error | ||
return new _quillDelta.default().insert(embed, match.formats(node, scroll)); | ||
return new Delta().insert(embed, match.formats(node, scroll)); | ||
} | ||
} else { | ||
// @ts-expect-error | ||
if (match.prototype instanceof _parchment.BlockBlot && !deltaEndsWith(delta, '\n')) { | ||
if (match.prototype instanceof BlockBlot && !deltaEndsWith(delta, '\n')) { | ||
delta.insert('\n'); | ||
} | ||
// @ts-expect-error | ||
if (typeof match.formats === 'function') { | ||
// @ts-expect-error | ||
return applyFormat(delta, match.blotName, match.formats(node, scroll)); | ||
if ('blotName' in match && 'formats' in match && typeof match.formats === 'function') { | ||
return applyFormat(delta, match.blotName, match.formats(node, scroll), scroll); | ||
} | ||
@@ -351,8 +347,7 @@ } | ||
const match = scroll.query('code-block'); | ||
// @ts-expect-error | ||
const language = match ? match.formats(node, scroll) : true; | ||
return applyFormat(delta, 'code-block', language); | ||
const language = match && 'formats' in match && typeof match.formats === 'function' ? match.formats(node, scroll) : true; | ||
return applyFormat(delta, 'code-block', language, scroll); | ||
} | ||
function matchIgnore() { | ||
return new _quillDelta.default(); | ||
return new Delta(); | ||
} | ||
@@ -385,13 +380,12 @@ function matchIndent(node, delta, scroll) { | ||
}); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
function matchList(node, delta) { | ||
function matchList(node, delta, scroll) { | ||
// @ts-expect-error | ||
const list = node.tagName === 'OL' ? 'ordered' : 'bullet'; | ||
return applyFormat(delta, 'list', list); | ||
return applyFormat(delta, 'list', list, scroll); | ||
} | ||
function matchNewline(node, delta, scroll) { | ||
if (!deltaEndsWith(delta, '\n')) { | ||
// @ts-expect-error | ||
if (isLine(node)) { | ||
if (isLine(node, scroll)) { | ||
return delta.insert('\n'); | ||
@@ -402,4 +396,3 @@ } | ||
while (nextSibling != null) { | ||
// @ts-expect-error | ||
if (isLine(nextSibling)) { | ||
if (isLine(nextSibling, scroll)) { | ||
return delta.insert('\n'); | ||
@@ -409,3 +402,3 @@ } | ||
// @ts-expect-error | ||
if (match && match.prototype instanceof _block.BlockEmbed) { | ||
if (match && match.prototype instanceof BlockEmbed) { | ||
return delta.insert('\n'); | ||
@@ -419,3 +412,3 @@ } | ||
} | ||
function matchStyles(node, delta) { | ||
function matchStyles(node, delta, scroll) { | ||
const formats = {}; | ||
@@ -437,13 +430,14 @@ const style = node.style || {}; | ||
} | ||
if (Object.keys(formats).length > 0) { | ||
delta = applyFormat(delta, formats); | ||
} | ||
delta = Object.entries(formats).reduce((newDelta, _ref5) => { | ||
let [name, value] = _ref5; | ||
return applyFormat(newDelta, name, value, scroll); | ||
}, delta); | ||
// @ts-expect-error | ||
if (parseFloat(style.textIndent || 0) > 0) { | ||
// Could be 0.5in | ||
return new _quillDelta.default().insert('\t').concat(delta); | ||
return new Delta().insert('\t').concat(delta); | ||
} | ||
return delta; | ||
} | ||
function matchTable(node, delta) { | ||
function matchTable(node, delta, scroll) { | ||
const table = node.parentElement?.tagName === 'TABLE' ? node.parentElement : node.parentElement?.parentElement; | ||
@@ -453,6 +447,7 @@ if (table != null) { | ||
const row = rows.indexOf(node) + 1; | ||
return applyFormat(delta, 'table', row); | ||
return applyFormat(delta, 'table', row, scroll); | ||
} | ||
return delta; | ||
} | ||
function matchText(node, delta) { | ||
function matchText(node, delta, scroll) { | ||
// @ts-expect-error | ||
@@ -465,3 +460,3 @@ let text = node.data; | ||
if (!isPre(node)) { | ||
if (text.trim().length === 0 && text.includes('\n')) { | ||
if (text.trim().length === 0 && text.includes('\n') && !isBetweenInlineElements(node, scroll)) { | ||
return delta; | ||
@@ -475,6 +470,6 @@ } | ||
text = text.replace(/\s\s+/g, replacer.bind(replacer, true)); // collapse whitespace | ||
if (node.previousSibling == null && node.parentElement != null && isLine(node.parentElement) || node.previousSibling instanceof Element && isLine(node.previousSibling)) { | ||
if (node.previousSibling == null && node.parentElement != null && isLine(node.parentElement, scroll) || node.previousSibling instanceof Element && isLine(node.previousSibling, scroll)) { | ||
text = text.replace(/^\s+/, replacer.bind(replacer, false)); | ||
} | ||
if (node.nextSibling == null && node.parentElement != null && isLine(node.parentElement) || node.nextSibling instanceof Element && isLine(node.nextSibling)) { | ||
if (node.nextSibling == null && node.parentElement != null && isLine(node.parentElement, scroll) || node.nextSibling instanceof Element && isLine(node.nextSibling, scroll)) { | ||
text = text.replace(/\s+$/, replacer.bind(replacer, false)); | ||
@@ -485,2 +480,3 @@ } | ||
} | ||
export { Clipboard as default, matchAttributor, matchBlot, matchNewline, matchText, traverse }; | ||
//# sourceMappingURL=clipboard.js.map |
import type Delta from 'quill-delta'; | ||
import Module from '../core/module'; | ||
import Quill from '../core/quill'; | ||
import type Scroll from '../blots/scroll'; | ||
import type { Range } from '../core/selection'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
import type Scroll from '../blots/scroll.js'; | ||
import type { Range } from '../core/selection.js'; | ||
export interface HistoryOptions { | ||
@@ -7,0 +7,0 @@ userOnly: boolean; |
@@ -1,13 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
exports.getLastChangeIndex = getLastChangeIndex; | ||
var _parchment = require("parchment"); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class History extends _module.default { | ||
import { Scope } from 'parchment'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
class History extends Module { | ||
lastRecorded = 0; | ||
@@ -22,10 +14,10 @@ ignoreChange = false; | ||
super(quill, options); | ||
this.quill.on(_quill.default.events.EDITOR_CHANGE, (eventName, value, oldValue, source) => { | ||
if (eventName === _quill.default.events.SELECTION_CHANGE) { | ||
if (value && source !== _quill.default.sources.SILENT) { | ||
this.quill.on(Quill.events.EDITOR_CHANGE, (eventName, value, oldValue, source) => { | ||
if (eventName === Quill.events.SELECTION_CHANGE) { | ||
if (value && source !== Quill.sources.SILENT) { | ||
this.currentRange = value; | ||
} | ||
} else if (eventName === _quill.default.events.TEXT_CHANGE) { | ||
} else if (eventName === Quill.events.TEXT_CHANGE) { | ||
if (!this.ignoreChange) { | ||
if (!this.options.userOnly || source === _quill.default.sources.USER) { | ||
if (!this.options.userOnly || source === Quill.sources.USER) { | ||
this.record(value, oldValue); | ||
@@ -44,3 +36,3 @@ } else { | ||
this.quill.keyboard.addBinding({ | ||
key: 'z', | ||
key: ['z', 'Z'], | ||
shortKey: true, | ||
@@ -77,3 +69,3 @@ shiftKey: true | ||
this.ignoreChange = true; | ||
this.quill.updateContents(item.delta, _quill.default.sources.USER); | ||
this.quill.updateContents(item.delta, Quill.sources.USER); | ||
this.ignoreChange = false; | ||
@@ -130,10 +122,9 @@ this.restoreSelection(item); | ||
if (stackItem.range) { | ||
this.quill.setSelection(stackItem.range, _quill.default.sources.USER); | ||
this.quill.setSelection(stackItem.range, Quill.sources.USER); | ||
} else { | ||
const index = getLastChangeIndex(this.quill.scroll, stackItem.delta); | ||
this.quill.setSelection(index, _quill.default.sources.USER); | ||
this.quill.setSelection(index, Quill.sources.USER); | ||
} | ||
} | ||
} | ||
exports.default = History; | ||
History.DEFAULTS = { | ||
@@ -166,3 +157,3 @@ delay: 1000, | ||
return Object.keys(lastOp.attributes).some(attr => { | ||
return scroll.query(attr, _parchment.Scope.BLOCK) != null; | ||
return scroll.query(attr, Scope.BLOCK) != null; | ||
}); | ||
@@ -191,2 +182,3 @@ } | ||
} | ||
export { History as default, getLastChangeIndex }; | ||
//# sourceMappingURL=history.js.map |
@@ -1,3 +0,3 @@ | ||
import Module from '../core/module'; | ||
import Quill from '../core/quill'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
declare class Input extends Module { | ||
@@ -4,0 +4,0 @@ constructor(quill: Quill, options: Record<string, never>); |
@@ -1,14 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
var _keyboard = require("./keyboard"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import Delta from 'quill-delta'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
import { deleteRange } from './keyboard.js'; | ||
const INSERT_TYPES = ['insertText', 'insertReplacementText']; | ||
class Input extends _module.default { | ||
class Input extends Module { | ||
constructor(quill, options) { | ||
@@ -23,3 +16,3 @@ super(quill, options); | ||
if (!/Android/i.test(navigator.userAgent)) { | ||
quill.on(_quill.default.events.COMPOSITION_BEFORE_START, () => { | ||
quill.on(Quill.events.COMPOSITION_BEFORE_START, () => { | ||
this.handleCompositionStart(); | ||
@@ -30,3 +23,3 @@ }); | ||
deleteRange(range) { | ||
(0, _keyboard.deleteRange)({ | ||
deleteRange({ | ||
range, | ||
@@ -43,7 +36,7 @@ quill: this.quill | ||
this.deleteRange(range); | ||
this.quill.updateContents(new _quillDelta.default().retain(range.index).insert(text, formats), _quill.default.sources.USER); | ||
this.quill.updateContents(new Delta().retain(range.index).insert(text, formats), Quill.sources.USER); | ||
} else { | ||
this.deleteRange(range); | ||
} | ||
this.quill.setSelection(range.index + text.length, 0, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range.index + text.length, 0, Quill.sources.SILENT); | ||
return true; | ||
@@ -92,3 +85,3 @@ } | ||
} | ||
var _default = exports.default = Input; | ||
export default Input; | ||
//# sourceMappingURL=input.js.map |
import type { BlockBlot } from 'parchment'; | ||
import Quill from '../core/quill'; | ||
import Module from '../core/module'; | ||
import type { BlockEmbed } from '../blots/block'; | ||
import type { Range } from '../core/selection'; | ||
import Quill from '../core/quill.js'; | ||
import Module from '../core/module.js'; | ||
import type { BlockEmbed } from '../blots/block.js'; | ||
import type { Range } from '../core/selection.js'; | ||
declare const SHORTKEY: string; | ||
@@ -7,0 +7,0 @@ export interface Context { |
@@ -1,21 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.SHORTKEY = void 0; | ||
exports.deleteRange = deleteRange; | ||
exports.normalize = normalize; | ||
var _lodashEs = require("lodash-es"); | ||
var _quillDelta = _interopRequireWildcard(require("quill-delta")); | ||
var _parchment = require("parchment"); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
var _logger = _interopRequireDefault(require("../core/logger")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
const debug = (0, _logger.default)('quill:keyboard'); | ||
const SHORTKEY = exports.SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey'; | ||
class Keyboard extends _module.default { | ||
import { cloneDeep, isEqual } from 'lodash-es'; | ||
import Delta, { AttributeMap } from 'quill-delta'; | ||
import { EmbedBlot, Scope, TextBlot } from 'parchment'; | ||
import Quill from '../core/quill.js'; | ||
import logger from '../core/logger.js'; | ||
import Module from '../core/module.js'; | ||
const debug = logger('quill:keyboard'); | ||
const SHORTKEY = /Mac/i.test(navigator.platform) ? 'metaKey' : 'ctrlKey'; | ||
class Keyboard extends Module { | ||
static match(evt, binding) { | ||
@@ -135,3 +124,3 @@ if (['altKey', 'ctrlKey', 'metaKey', 'shiftKey'].some(key => { | ||
// @ts-expect-error | ||
const blot = _quill.default.find(evt.target, true); | ||
const blot = Quill.find(evt.target, true); | ||
if (blot && blot.scroll !== this.quill.scroll) return; | ||
@@ -143,4 +132,4 @@ const range = this.quill.getSelection(); | ||
const [leafEnd, offsetEnd] = range.length === 0 ? [leafStart, offsetStart] : this.quill.getLeaf(range.index + range.length); | ||
const prefixText = leafStart instanceof _parchment.TextBlot ? leafStart.value().slice(0, offsetStart) : ''; | ||
const suffixText = leafEnd instanceof _parchment.TextBlot ? leafEnd.value().slice(offsetEnd) : ''; | ||
const prefixText = leafStart instanceof TextBlot ? leafStart.value().slice(0, offsetStart) : ''; | ||
const suffixText = leafEnd instanceof TextBlot ? leafEnd.value().slice(offsetEnd) : ''; | ||
const curContext = { | ||
@@ -180,3 +169,3 @@ collapsed: range.length === 0, | ||
// @ts-expect-error Fix me later | ||
return (0, _lodashEs.isEqual)(binding.format[name], curContext.format[name]); | ||
return isEqual(binding.format[name], curContext.format[name]); | ||
})) { | ||
@@ -206,3 +195,3 @@ return false; | ||
const [line] = this.quill.getLine(range.index); | ||
let delta = new _quillDelta.default().retain(range.index - length).delete(length); | ||
let delta = new Delta().retain(range.index - length).delete(length); | ||
if (context.offset === 0) { | ||
@@ -217,6 +206,6 @@ // Always deleting newline here, length always 1 | ||
const prevFormats = this.quill.getFormat(range.index - 1, 1); | ||
formats = _quillDelta.AttributeMap.diff(curFormats, prevFormats) || {}; | ||
formats = AttributeMap.diff(curFormats, prevFormats) || {}; | ||
if (Object.keys(formats).length > 0) { | ||
// line.length() - 1 targets \n in line, another -1 for newline being deleted | ||
const formatDelta = new _quillDelta.default() | ||
const formatDelta = new Delta() | ||
// @ts-expect-error Fix me later | ||
@@ -229,3 +218,3 @@ .retain(range.index + line.length() - 2).retain(1, formats); | ||
} | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.focus(); | ||
@@ -239,3 +228,3 @@ } | ||
const [line] = this.quill.getLine(range.index); | ||
let delta = new _quillDelta.default().retain(range.index).delete(length); | ||
let delta = new Delta().retain(range.index).delete(length); | ||
// @ts-expect-error Fix me later | ||
@@ -248,3 +237,3 @@ if (context.offset >= line.length() - 1) { | ||
const nextFormats = this.quill.getFormat(range.index, 1); | ||
formats = _quillDelta.AttributeMap.diff(curFormats, nextFormats) || {}; | ||
formats = AttributeMap.diff(curFormats, nextFormats) || {}; | ||
if (Object.keys(formats).length > 0) { | ||
@@ -255,3 +244,3 @@ delta = delta.retain(next.length() - 1).retain(1, formats); | ||
} | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.focus(); | ||
@@ -268,3 +257,3 @@ } | ||
const lineFormats = Object.keys(context.format).reduce((formats, format) => { | ||
if (this.quill.scroll.query(format, _parchment.Scope.BLOCK) && !Array.isArray(context.format[format])) { | ||
if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) { | ||
formats[format] = context.format[format]; | ||
@@ -274,9 +263,8 @@ } | ||
}, {}); | ||
const delta = new _quillDelta.default().retain(range.index).delete(range.length).insert('\n', lineFormats); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index + 1, _quill.default.sources.SILENT); | ||
const delta = new Delta().retain(range.index).delete(range.length).insert('\n', lineFormats); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(range.index + 1, Quill.sources.SILENT); | ||
this.quill.focus(); | ||
} | ||
} | ||
exports.default = Keyboard; | ||
const defaultOptions = { | ||
@@ -293,3 +281,3 @@ bindings: { | ||
if (context.collapsed && context.offset !== 0) return true; | ||
this.quill.format('indent', '+1', _quill.default.sources.USER); | ||
this.quill.format('indent', '+1', Quill.sources.USER); | ||
return false; | ||
@@ -305,3 +293,3 @@ } | ||
if (context.collapsed && context.offset !== 0) return true; | ||
this.quill.format('indent', '-1', _quill.default.sources.USER); | ||
this.quill.format('indent', '-1', Quill.sources.USER); | ||
return false; | ||
@@ -321,5 +309,5 @@ } | ||
if (context.format.indent != null) { | ||
this.quill.format('indent', '-1', _quill.default.sources.USER); | ||
this.quill.format('indent', '-1', Quill.sources.USER); | ||
} else if (context.format.list != null) { | ||
this.quill.format('list', false, _quill.default.sources.USER); | ||
this.quill.format('list', false, Quill.sources.USER); | ||
} | ||
@@ -336,3 +324,3 @@ } | ||
handler(range) { | ||
this.quill.deleteText(range.index - 1, 1, _quill.default.sources.USER); | ||
this.quill.deleteText(range.index - 1, 1, Quill.sources.USER); | ||
} | ||
@@ -345,6 +333,6 @@ }, | ||
this.quill.history.cutoff(); | ||
const delta = new _quillDelta.default().retain(range.index).delete(range.length).insert('\t'); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
const delta = new Delta().retain(range.index).delete(range.length).insert('\t'); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.history.cutoff(); | ||
this.quill.setSelection(range.index + 1, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range.index + 1, Quill.sources.SILENT); | ||
return false; | ||
@@ -359,3 +347,3 @@ } | ||
handler() { | ||
this.quill.format('blockquote', false, _quill.default.sources.USER); | ||
this.quill.format('blockquote', false, Quill.sources.USER); | ||
} | ||
@@ -375,3 +363,3 @@ }, | ||
} | ||
this.quill.formatLine(range.index, range.length, formats, _quill.default.sources.USER); | ||
this.quill.formatLine(range.index, range.length, formats, Quill.sources.USER); | ||
} | ||
@@ -392,3 +380,3 @@ }, | ||
}; | ||
const delta = new _quillDelta.default().retain(range.index).insert('\n', formats) | ||
const delta = new Delta().retain(range.index).insert('\n', formats) | ||
// @ts-expect-error Fix me later | ||
@@ -398,4 +386,4 @@ .retain(line.length() - offset - 1).retain(1, { | ||
}); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index + 1, _quill.default.sources.SILENT); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(range.index + 1, Quill.sources.SILENT); | ||
this.quill.scrollSelectionIntoView(); | ||
@@ -411,3 +399,3 @@ } | ||
const [line, offset] = this.quill.getLine(range.index); | ||
const delta = new _quillDelta.default().retain(range.index).insert('\n', context.format) | ||
const delta = new Delta().retain(range.index).insert('\n', context.format) | ||
// @ts-expect-error Fix me later | ||
@@ -417,4 +405,4 @@ .retain(line.length() - offset - 1).retain(1, { | ||
}); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index + 1, _quill.default.sources.SILENT); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(range.index + 1, Quill.sources.SILENT); | ||
this.quill.scrollSelectionIntoView(); | ||
@@ -450,10 +438,10 @@ } | ||
if (shift < 0) { | ||
const delta = new _quillDelta.default().retain(index).insert('\n'); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index + 1, range.length, _quill.default.sources.SILENT); | ||
const delta = new Delta().retain(index).insert('\n'); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(range.index + 1, range.length, Quill.sources.SILENT); | ||
} else if (shift > 0) { | ||
index += table.length(); | ||
const delta = new _quillDelta.default().retain(index).insert('\n'); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(index, _quill.default.sources.USER); | ||
const delta = new Delta().retain(index).insert('\n'); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(index, Quill.sources.USER); | ||
} | ||
@@ -474,5 +462,5 @@ } | ||
if (event.shiftKey) { | ||
this.quill.setSelection(offset - 1, _quill.default.sources.USER); | ||
this.quill.setSelection(offset - 1, Quill.sources.USER); | ||
} else { | ||
this.quill.setSelection(offset + cell.length(), _quill.default.sources.USER); | ||
this.quill.setSelection(offset + cell.length(), Quill.sources.USER); | ||
} | ||
@@ -514,5 +502,5 @@ } | ||
} | ||
this.quill.insertText(range.index, ' ', _quill.default.sources.USER); | ||
this.quill.insertText(range.index, ' ', Quill.sources.USER); | ||
this.quill.history.cutoff(); | ||
const delta = new _quillDelta.default().retain(range.index - offset).delete(length + 1) | ||
const delta = new Delta().retain(range.index - offset).delete(length + 1) | ||
// @ts-expect-error Fix me later | ||
@@ -522,5 +510,5 @@ .retain(line.length() - 2 - offset).retain(1, { | ||
}); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.history.cutoff(); | ||
this.quill.setSelection(range.index - length, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range.index - length, Quill.sources.SILENT); | ||
return false; | ||
@@ -545,3 +533,3 @@ } | ||
if (numLines <= 0) { | ||
const delta = new _quillDelta.default() | ||
const delta = new Delta() | ||
// @ts-expect-error Fix me later | ||
@@ -551,4 +539,4 @@ .retain(range.index + line.length() - offset - 2).retain(1, { | ||
}).delete(1); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index - 1, _quill.default.sources.SILENT); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(range.index - 1, Quill.sources.SILENT); | ||
return false; | ||
@@ -586,4 +574,4 @@ } | ||
if (range.length === 0 && !event.shiftKey) { | ||
this.quill.insertText(range.index, TAB, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index + TAB.length, _quill.default.sources.SILENT); | ||
this.quill.insertText(range.index, TAB, Quill.sources.USER); | ||
this.quill.setSelection(range.index + TAB.length, Quill.sources.SILENT); | ||
return; | ||
@@ -614,4 +602,4 @@ } | ||
}); | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.setSelection(index, length, _quill.default.sources.SILENT); | ||
this.quill.update(Quill.sources.USER); | ||
this.quill.setSelection(index, length, Quill.sources.SILENT); | ||
} | ||
@@ -635,13 +623,13 @@ }; | ||
const [leaf] = this.quill.getLeaf(index); | ||
if (!(leaf instanceof _parchment.EmbedBlot)) return true; | ||
if (!(leaf instanceof EmbedBlot)) return true; | ||
if (key === 'ArrowLeft') { | ||
if (shiftKey) { | ||
this.quill.setSelection(range.index - 1, range.length + 1, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index - 1, range.length + 1, Quill.sources.USER); | ||
} else { | ||
this.quill.setSelection(range.index - 1, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index - 1, Quill.sources.USER); | ||
} | ||
} else if (shiftKey) { | ||
this.quill.setSelection(range.index, range.length + 1, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index, range.length + 1, Quill.sources.USER); | ||
} else { | ||
this.quill.setSelection(range.index + range.length + 1, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index + range.length + 1, Quill.sources.USER); | ||
} | ||
@@ -657,3 +645,3 @@ return false; | ||
handler(range, context) { | ||
this.quill.format(format, !context.format[format], _quill.default.sources.USER); | ||
this.quill.format(format, !context.format[format], Quill.sources.USER); | ||
} | ||
@@ -683,3 +671,3 @@ }; | ||
const index = targetCell.offset(this.quill.scroll) + Math.min(context.offset, targetCell.length() - 1); | ||
this.quill.setSelection(index, 0, _quill.default.sources.USER); | ||
this.quill.setSelection(index, 0, Quill.sources.USER); | ||
} | ||
@@ -691,5 +679,5 @@ } else { | ||
if (up) { | ||
this.quill.setSelection(targetLine.offset(this.quill.scroll) + targetLine.length() - 1, 0, _quill.default.sources.USER); | ||
this.quill.setSelection(targetLine.offset(this.quill.scroll) + targetLine.length() - 1, 0, Quill.sources.USER); | ||
} else { | ||
this.quill.setSelection(targetLine.offset(this.quill.scroll), 0, _quill.default.sources.USER); | ||
this.quill.setSelection(targetLine.offset(this.quill.scroll), 0, Quill.sources.USER); | ||
} | ||
@@ -708,3 +696,3 @@ } | ||
} else if (typeof binding === 'object') { | ||
binding = (0, _lodashEs.cloneDeep)(binding); | ||
binding = cloneDeep(binding); | ||
} else { | ||
@@ -731,9 +719,9 @@ return null; | ||
const lastFormats = lines[lines.length - 1].formats(); | ||
formats = _quillDelta.AttributeMap.diff(lastFormats, firstFormats) || {}; | ||
formats = AttributeMap.diff(lastFormats, firstFormats) || {}; | ||
} | ||
quill.deleteText(range, _quill.default.sources.USER); | ||
quill.deleteText(range, Quill.sources.USER); | ||
if (Object.keys(formats).length > 0) { | ||
quill.formatLine(range.index, 1, formats, _quill.default.sources.USER); | ||
quill.formatLine(range.index, 1, formats, Quill.sources.USER); | ||
} | ||
quill.setSelection(range.index, _quill.default.sources.SILENT); | ||
quill.setSelection(range.index, Quill.sources.SILENT); | ||
} | ||
@@ -755,2 +743,3 @@ function tableSide(_table, row, cell, offset) { | ||
} | ||
export { Keyboard as default, SHORTKEY, normalize, deleteRange }; | ||
//# sourceMappingURL=keyboard.js.map |
import Delta from 'quill-delta'; | ||
import type { Blot, ScrollBlot } from 'parchment'; | ||
import Inline from '../blots/inline'; | ||
import Quill from '../core/quill'; | ||
import Module from '../core/module'; | ||
import CodeBlock, { CodeBlockContainer } from '../formats/code'; | ||
import Inline from '../blots/inline.js'; | ||
import Quill from '../core/quill.js'; | ||
import Module from '../core/module.js'; | ||
import CodeBlock, { CodeBlockContainer } from '../formats/code.js'; | ||
declare class CodeToken extends Inline { | ||
@@ -36,2 +36,3 @@ static formats(node: Element, scroll: ScrollBlot): any; | ||
}[]; | ||
hljs: any; | ||
} | ||
@@ -38,0 +39,0 @@ declare class Syntax extends Module<SyntaxOptions> { |
@@ -1,28 +0,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
import Delta from 'quill-delta'; | ||
import { ClassAttributor, Scope } from 'parchment'; | ||
import Inline from '../blots/inline.js'; | ||
import Quill from '../core/quill.js'; | ||
import Module from '../core/module.js'; | ||
import { blockDelta } from '../blots/block.js'; | ||
import BreakBlot from '../blots/break.js'; | ||
import CursorBlot from '../blots/cursor.js'; | ||
import TextBlot, { escapeText } from '../blots/text.js'; | ||
import CodeBlock, { CodeBlockContainer } from '../formats/code.js'; | ||
import { traverse } from './clipboard.js'; | ||
const TokenAttributor = new ClassAttributor('code-token', 'hljs', { | ||
scope: Scope.INLINE | ||
}); | ||
exports.default = exports.CodeToken = exports.CodeBlock = void 0; | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _parchment = require("parchment"); | ||
var _inline = _interopRequireDefault(require("../blots/inline")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
var _block = require("../blots/block"); | ||
var _break = _interopRequireDefault(require("../blots/break")); | ||
var _cursor = _interopRequireDefault(require("../blots/cursor")); | ||
var _text = _interopRequireWildcard(require("../blots/text")); | ||
var _code = _interopRequireWildcard(require("../formats/code")); | ||
var _clipboard = require("./clipboard"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const TokenAttributor = new _parchment.ClassAttributor('code-token', 'hljs', { | ||
scope: _parchment.Scope.INLINE | ||
}); | ||
class CodeToken extends _inline.default { | ||
class CodeToken extends Inline { | ||
static formats(node, scroll) { | ||
while (node != null && node !== scroll.domNode) { | ||
if (node.classList && node.classList.contains(_code.default.className)) { | ||
if (node.classList && node.classList.contains(CodeBlock.className)) { | ||
// @ts-expect-error | ||
@@ -59,6 +50,5 @@ return super.formats(node, scroll); | ||
} | ||
exports.CodeToken = CodeToken; | ||
CodeToken.blotName = 'code-token'; | ||
CodeToken.className = 'ql-token'; | ||
class SyntaxCodeBlock extends _code.default { | ||
class SyntaxCodeBlock extends CodeBlock { | ||
static create(value) { | ||
@@ -90,4 +80,3 @@ const domNode = super.create(value); | ||
} | ||
exports.CodeBlock = SyntaxCodeBlock; | ||
class SyntaxCodeBlockContainer extends _code.CodeBlockContainer { | ||
class SyntaxCodeBlockContainer extends CodeBlockContainer { | ||
attach() { | ||
@@ -124,4 +113,4 @@ super.attach(); | ||
// @ts-expect-error | ||
return delta.concat((0, _block.blockDelta)(child, false)); | ||
}, new _quillDelta.default()); | ||
return delta.concat(blockDelta(child, false)); | ||
}, new Delta()); | ||
const delta = highlight(text, language); | ||
@@ -154,3 +143,3 @@ oldDelta.diff(delta).reduce((index, _ref) => { | ||
const language = codeBlock ? SyntaxCodeBlock.formats(codeBlock.domNode) : 'plain'; | ||
return `<pre data-language="${language}">\n${(0, _text.escapeText)(this.code(index, length))}\n</pre>`; | ||
return `<pre data-language="${language}">\n${escapeText(this.code(index, length))}\n</pre>`; | ||
} | ||
@@ -172,13 +161,23 @@ optimize(context) { | ||
SyntaxCodeBlock.requiredContainer = SyntaxCodeBlockContainer; | ||
SyntaxCodeBlock.allowedChildren = [CodeToken, _cursor.default, _text.default, _break.default]; | ||
class Syntax extends _module.default { | ||
SyntaxCodeBlock.allowedChildren = [CodeToken, CursorBlot, TextBlot, BreakBlot]; | ||
const highlight = (lib, language, text) => { | ||
if (typeof lib.versionString === 'string') { | ||
const majorVersion = lib.versionString.split('.')[0]; | ||
if (parseInt(majorVersion, 10) >= 11) { | ||
return lib.highlight(text, { | ||
language | ||
}).value; | ||
} | ||
} | ||
return lib.highlight(language, text).value; | ||
}; | ||
class Syntax extends Module { | ||
static register() { | ||
_quill.default.register(CodeToken, true); | ||
Quill.register(CodeToken, true); | ||
// @ts-expect-error | ||
_quill.default.register(SyntaxCodeBlock, true); | ||
_quill.default.register(SyntaxCodeBlockContainer, true); | ||
Quill.register(SyntaxCodeBlock, true); | ||
Quill.register(SyntaxCodeBlockContainer, true); | ||
} | ||
constructor(quill, options) { | ||
super(quill, options); | ||
// @ts-expect-error | ||
if (this.options.hljs == null) { | ||
@@ -200,3 +199,3 @@ throw new Error('Syntax module requires highlight.js. Please include the library on the page before Quill.'); | ||
initListener() { | ||
this.quill.on(_quill.default.events.SCROLL_BLOT_MOUNT, blot => { | ||
this.quill.on(Quill.events.SCROLL_BLOT_MOUNT, blot => { | ||
if (!(blot instanceof SyntaxCodeBlockContainer)) return; | ||
@@ -230,3 +229,3 @@ const select = this.quill.root.ownerDocument.createElement('select'); | ||
let timer = null; | ||
this.quill.on(_quill.default.events.SCROLL_OPTIMIZE, () => { | ||
this.quill.on(Quill.events.SCROLL_OPTIMIZE, () => { | ||
if (timer) { | ||
@@ -245,3 +244,3 @@ clearTimeout(timer); | ||
if (this.quill.selection.composing) return; | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.update(Quill.sources.USER); | ||
const range = this.quill.getSelection(); | ||
@@ -252,5 +251,5 @@ const blots = blot == null ? this.quill.scroll.descendants(SyntaxCodeBlockContainer) : [blot]; | ||
}); | ||
this.quill.update(_quill.default.sources.SILENT); | ||
this.quill.update(Quill.sources.SILENT); | ||
if (range != null) { | ||
this.quill.setSelection(range, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range, Quill.sources.SILENT); | ||
} | ||
@@ -262,20 +261,19 @@ } | ||
if (language === 'plain') { | ||
return (0, _text.escapeText)(text).split('\n').reduce((delta, line, i) => { | ||
return escapeText(text).split('\n').reduce((delta, line, i) => { | ||
if (i !== 0) { | ||
delta.insert('\n', { | ||
[_code.default.blotName]: language | ||
[CodeBlock.blotName]: language | ||
}); | ||
} | ||
return delta.insert(line); | ||
}, new _quillDelta.default()); | ||
}, new Delta()); | ||
} | ||
const container = this.quill.root.ownerDocument.createElement('div'); | ||
container.classList.add(_code.default.className); | ||
// @ts-expect-error | ||
container.innerHTML = this.options.hljs.highlight(language, text).value; | ||
return (0, _clipboard.traverse)(this.quill.scroll, container, [(node, delta) => { | ||
container.classList.add(CodeBlock.className); | ||
container.innerHTML = highlight(this.options.hljs, language, text); | ||
return traverse(this.quill.scroll, container, [(node, delta) => { | ||
// @ts-expect-error | ||
const value = TokenAttributor.value(node); | ||
if (value) { | ||
return delta.compose(new _quillDelta.default().retain(delta.length(), { | ||
return delta.compose(new Delta().retain(delta.length(), { | ||
[CodeToken.blotName]: value | ||
@@ -289,3 +287,3 @@ })); | ||
if (i !== 0) memo.insert('\n', { | ||
[_code.default.blotName]: language | ||
[CodeBlock.blotName]: language | ||
}); | ||
@@ -297,3 +295,2 @@ return memo.insert(nodeText); | ||
} | ||
exports.default = Syntax; | ||
Syntax.DEFAULTS = { | ||
@@ -348,2 +345,3 @@ hljs: (() => { | ||
}; | ||
export { SyntaxCodeBlock as CodeBlock, CodeToken, Syntax as default }; | ||
//# sourceMappingURL=syntax.js.map |
@@ -1,3 +0,3 @@ | ||
import Module from '../core/module'; | ||
import { TableCell, TableRow } from '../formats/table'; | ||
import Module from '../core/module.js'; | ||
import { TableCell, TableRow } from '../formats/table.js'; | ||
declare class Table extends Module { | ||
@@ -10,3 +10,3 @@ static register(): void; | ||
deleteTable(): void; | ||
getTable(range?: import("../core/selection").Range | null): [null, null, null, -1] | [Table, TableRow, TableCell, number]; | ||
getTable(range?: import("../core/selection.js").Range | null): [null, null, null, -1] | [Table, TableRow, TableCell, number]; | ||
insertColumn(offset: number): void; | ||
@@ -13,0 +13,0 @@ insertColumnLeft(): void; |
@@ -1,18 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
var _table = require("../formats/table"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Table extends _module.default { | ||
import Delta from 'quill-delta'; | ||
import Quill from '../core/quill.js'; | ||
import Module from '../core/module.js'; | ||
import { TableCell, TableRow, TableBody, TableContainer, tableId } from '../formats/table.js'; | ||
class Table extends Module { | ||
static register() { | ||
_quill.default.register(_table.TableCell); | ||
_quill.default.register(_table.TableRow); | ||
_quill.default.register(_table.TableBody); | ||
_quill.default.register(_table.TableContainer); | ||
Quill.register(TableCell); | ||
Quill.register(TableRow); | ||
Quill.register(TableBody); | ||
Quill.register(TableContainer); | ||
} | ||
@@ -24,3 +17,3 @@ constructor() { | ||
balanceTables() { | ||
this.quill.scroll.descendants(_table.TableContainer).forEach(table => { | ||
this.quill.scroll.descendants(TableContainer).forEach(table => { | ||
table.balanceCells(); | ||
@@ -34,3 +27,3 @@ }); | ||
table.deleteColumn(cell.cellOffset()); | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.update(Quill.sources.USER); | ||
} | ||
@@ -41,3 +34,3 @@ deleteRow() { | ||
row.remove(); | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.update(Quill.sources.USER); | ||
} | ||
@@ -51,4 +44,4 @@ deleteTable() { | ||
table.remove(); | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.setSelection(offset, _quill.default.sources.SILENT); | ||
this.quill.update(Quill.sources.USER); | ||
this.quill.setSelection(offset, Quill.sources.SILENT); | ||
} | ||
@@ -59,3 +52,3 @@ getTable() { | ||
const [cell, offset] = this.quill.getLine(range.index); | ||
if (cell == null || cell.statics.blotName !== _table.TableCell.blotName) { | ||
if (cell == null || cell.statics.blotName !== TableCell.blotName) { | ||
return [null, null, null, -1]; | ||
@@ -75,3 +68,3 @@ } | ||
table.insertColumn(column + offset); | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.update(Quill.sources.USER); | ||
let shift = row.rowOffset(); | ||
@@ -81,3 +74,3 @@ if (offset === 0) { | ||
} | ||
this.quill.setSelection(range.index + shift, range.length, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range.index + shift, range.length, Quill.sources.SILENT); | ||
} | ||
@@ -97,7 +90,7 @@ insertColumnLeft() { | ||
table.insertRow(index + offset); | ||
this.quill.update(_quill.default.sources.USER); | ||
this.quill.update(Quill.sources.USER); | ||
if (offset > 0) { | ||
this.quill.setSelection(range, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range, Quill.sources.SILENT); | ||
} else { | ||
this.quill.setSelection(range.index + row.children.length, range.length, _quill.default.sources.SILENT); | ||
this.quill.setSelection(range.index + row.children.length, range.length, Quill.sources.SILENT); | ||
} | ||
@@ -117,15 +110,15 @@ } | ||
return memo.insert(text, { | ||
table: (0, _table.tableId)() | ||
table: tableId() | ||
}); | ||
}, new _quillDelta.default().retain(range.index)); | ||
this.quill.updateContents(delta, _quill.default.sources.USER); | ||
this.quill.setSelection(range.index, _quill.default.sources.SILENT); | ||
}, new Delta().retain(range.index)); | ||
this.quill.updateContents(delta, Quill.sources.USER); | ||
this.quill.setSelection(range.index, Quill.sources.SILENT); | ||
this.balanceTables(); | ||
} | ||
listenBalanceCells() { | ||
this.quill.on(_quill.default.events.SCROLL_OPTIMIZE, mutations => { | ||
this.quill.on(Quill.events.SCROLL_OPTIMIZE, mutations => { | ||
mutations.some(mutation => { | ||
if (['TD', 'TR', 'TBODY', 'TABLE'].includes(mutation.target.tagName)) { | ||
this.quill.once(_quill.default.events.TEXT_CHANGE, (delta, old, source) => { | ||
if (source !== _quill.default.sources.USER) return; | ||
this.quill.once(Quill.events.TEXT_CHANGE, (delta, old, source) => { | ||
if (source !== Quill.sources.USER) return; | ||
this.balanceTables(); | ||
@@ -140,3 +133,3 @@ }); | ||
} | ||
var _default = exports.default = Table; | ||
export default Table; | ||
//# sourceMappingURL=table.js.map |
import Delta from 'quill-delta'; | ||
import type { Op } from 'quill-delta'; | ||
import Module from '../core/module'; | ||
import Module from '../core/module.js'; | ||
export type CellData = { | ||
@@ -5,0 +5,0 @@ content?: Delta['ops']; |
@@ -1,12 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.tableHandler = exports.default = exports.composePosition = void 0; | ||
var _quillDelta = _interopRequireWildcard(require("quill-delta")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
import Delta, { OpIterator } from 'quill-delta'; | ||
import Module from '../core/module.js'; | ||
const parseCellIdentity = identity => { | ||
@@ -17,5 +8,5 @@ const parts = identity.split(':'); | ||
const stringifyCellIdentity = (row, column) => `${row + 1}:${column + 1}`; | ||
const composePosition = (delta, index) => { | ||
export const composePosition = (delta, index) => { | ||
let newIndex = index; | ||
const thisIter = new _quillDelta.OpIterator(delta.ops); | ||
const thisIter = new OpIterator(delta.ops); | ||
let offset = 0; | ||
@@ -44,3 +35,2 @@ while (thisIter.hasNext() && offset <= newIndex) { | ||
}; | ||
exports.composePosition = composePosition; | ||
const compactCellData = _ref => { | ||
@@ -98,9 +88,9 @@ let { | ||
}; | ||
const tableHandler = exports.tableHandler = { | ||
export const tableHandler = { | ||
compose(a, b, keepNull) { | ||
const rows = new _quillDelta.default(a.rows || []).compose(new _quillDelta.default(b.rows || [])); | ||
const columns = new _quillDelta.default(a.columns || []).compose(new _quillDelta.default(b.columns || [])); | ||
const rows = new Delta(a.rows || []).compose(new Delta(b.rows || [])); | ||
const columns = new Delta(a.columns || []).compose(new Delta(b.columns || [])); | ||
const cells = reindexCellIdentities(a.cells || {}, { | ||
rows: new _quillDelta.default(b.rows || []), | ||
columns: new _quillDelta.default(b.columns || []) | ||
rows: new Delta(b.rows || []), | ||
columns: new Delta(b.columns || []) | ||
}); | ||
@@ -111,4 +101,4 @@ Object.keys(b.cells || {}).forEach(identity => { | ||
const bCell = b.cells[identity]; | ||
const content = new _quillDelta.default(aCell.content || []).compose(new _quillDelta.default(bCell.content || [])); | ||
const attributes = _quillDelta.default.AttributeMap.compose(aCell.attributes, bCell.attributes, keepNull); | ||
const content = new Delta(aCell.content || []).compose(new Delta(bCell.content || [])); | ||
const attributes = Delta.AttributeMap.compose(aCell.attributes, bCell.attributes, keepNull); | ||
const cell = compactCellData({ | ||
@@ -132,8 +122,8 @@ content, | ||
const aDeltas = { | ||
rows: new _quillDelta.default(a.rows || []), | ||
columns: new _quillDelta.default(a.columns || []) | ||
rows: new Delta(a.rows || []), | ||
columns: new Delta(a.columns || []) | ||
}; | ||
const bDeltas = { | ||
rows: new _quillDelta.default(b.rows || []), | ||
columns: new _quillDelta.default(b.columns || []) | ||
rows: new Delta(b.rows || []), | ||
columns: new Delta(b.columns || []) | ||
}; | ||
@@ -159,4 +149,4 @@ const rows = aDeltas.rows.transform(bDeltas.rows, priority); | ||
if (bCell) { | ||
const content = new _quillDelta.default(aCell.content || []).transform(new _quillDelta.default(bCell.content || []), priority); | ||
const attributes = _quillDelta.default.AttributeMap.transform(aCell.attributes, bCell.attributes, priority); | ||
const content = new Delta(aCell.content || []).transform(new Delta(bCell.content || []), priority); | ||
const attributes = Delta.AttributeMap.transform(aCell.attributes, bCell.attributes, priority); | ||
const cell = compactCellData({ | ||
@@ -181,4 +171,4 @@ content, | ||
invert(change, base) { | ||
const rows = new _quillDelta.default(change.rows || []).invert(new _quillDelta.default(base.rows || [])); | ||
const columns = new _quillDelta.default(change.columns || []).invert(new _quillDelta.default(base.columns || [])); | ||
const rows = new Delta(change.rows || []).invert(new Delta(base.rows || [])); | ||
const columns = new Delta(change.columns || []).invert(new Delta(base.columns || [])); | ||
const cells = reindexCellIdentities(change.cells || {}, { | ||
@@ -191,4 +181,4 @@ rows, | ||
const baseCell = (base.cells || {})[identity] || {}; | ||
const content = new _quillDelta.default(changeCell.content || []).invert(new _quillDelta.default(baseCell.content || [])); | ||
const attributes = _quillDelta.default.AttributeMap.invert(changeCell.attributes, baseCell.attributes); | ||
const content = new Delta(changeCell.content || []).invert(new Delta(baseCell.content || [])); | ||
const attributes = Delta.AttributeMap.invert(changeCell.attributes, baseCell.attributes); | ||
const cell = compactCellData({ | ||
@@ -209,3 +199,3 @@ content, | ||
const [row, column] = parseCellIdentity(identity); | ||
if (composePosition(new _quillDelta.default(change.rows || []), row) === null || composePosition(new _quillDelta.default(change.columns || []), column) === null) { | ||
if (composePosition(new Delta(change.rows || []), row) === null || composePosition(new Delta(change.columns || []), column) === null) { | ||
// @ts-expect-error Fix me later | ||
@@ -222,8 +212,8 @@ cells[identity] = base.cells[identity]; | ||
}; | ||
class TableEmbed extends _module.default { | ||
class TableEmbed extends Module { | ||
static register() { | ||
_quillDelta.default.registerEmbed('table-embed', tableHandler); | ||
Delta.registerEmbed('table-embed', tableHandler); | ||
} | ||
} | ||
var _default = exports.default = TableEmbed; | ||
export default TableEmbed; | ||
//# sourceMappingURL=tableEmbed.js.map |
@@ -1,4 +0,4 @@ | ||
import Quill from '../core/quill'; | ||
import Module from '../core/module'; | ||
import type { Range } from '../core/selection'; | ||
import Quill from '../core/quill.js'; | ||
import Module from '../core/module.js'; | ||
import type { Range } from '../core/selection.js'; | ||
type Handler = (value: any) => void; | ||
@@ -5,0 +5,0 @@ export type ToolbarConfig = Array<string[] | Array<string | Record<string, unknown>>>; |
@@ -1,16 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.addControls = addControls; | ||
exports.default = void 0; | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _parchment = require("parchment"); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
var _logger = _interopRequireDefault(require("../core/logger")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
const debug = (0, _logger.default)('quill:toolbar'); | ||
class Toolbar extends _module.default { | ||
import Delta from 'quill-delta'; | ||
import { EmbedBlot, Scope } from 'parchment'; | ||
import Quill from '../core/quill.js'; | ||
import logger from '../core/logger.js'; | ||
import Module from '../core/module.js'; | ||
const debug = logger('quill:toolbar'); | ||
class Toolbar extends Module { | ||
constructor(quill, options) { | ||
@@ -48,8 +40,3 @@ super(quill, options); | ||
}); | ||
this.quill.on(_quill.default.events.EDITOR_CHANGE, (type, range) => { | ||
if (type === _quill.default.events.SELECTION_CHANGE) { | ||
this.update(range); | ||
} | ||
}); | ||
this.quill.on(_quill.default.events.SCROLL_OPTIMIZE, () => { | ||
this.quill.on(Quill.events.EDITOR_CHANGE, () => { | ||
const [range] = this.quill.selection.getRange(); // quill.getSelection triggers update | ||
@@ -105,6 +92,6 @@ this.update(range); | ||
// @ts-expect-error | ||
this.quill.scroll.query(format).prototype instanceof _parchment.EmbedBlot) { | ||
this.quill.scroll.query(format).prototype instanceof EmbedBlot) { | ||
value = prompt(`Enter ${format}`); // eslint-disable-line no-alert | ||
if (!value) return; | ||
this.quill.updateContents(new _quillDelta.default() | ||
this.quill.updateContents(new Delta() | ||
// @ts-expect-error Fix me later | ||
@@ -117,6 +104,6 @@ .retain(range.index) | ||
[format]: value | ||
}), _quill.default.sources.USER); | ||
}), Quill.sources.USER); | ||
} else { | ||
// @ts-expect-error Fix me later | ||
this.quill.format(format, value, _quill.default.sources.USER); | ||
this.quill.format(format, value, Quill.sources.USER); | ||
} | ||
@@ -170,3 +157,2 @@ this.update(range); | ||
} | ||
exports.default = Toolbar; | ||
Toolbar.DEFAULTS = {}; | ||
@@ -234,8 +220,8 @@ function addButton(container, format, value) { | ||
// Clean functionality in existing apps only clean inline formats | ||
if (this.quill.scroll.query(name, _parchment.Scope.INLINE) != null) { | ||
this.quill.format(name, false, _quill.default.sources.USER); | ||
if (this.quill.scroll.query(name, Scope.INLINE) != null) { | ||
this.quill.format(name, false, Quill.sources.USER); | ||
} | ||
}); | ||
} else { | ||
this.quill.removeFormat(range, _quill.default.sources.USER); | ||
this.quill.removeFormat(range, Quill.sources.USER); | ||
} | ||
@@ -248,7 +234,7 @@ }, | ||
if (value === 'rtl' && align == null) { | ||
this.quill.format('align', 'right', _quill.default.sources.USER); | ||
this.quill.format('align', 'right', Quill.sources.USER); | ||
} else if (!value && align === 'right') { | ||
this.quill.format('align', false, _quill.default.sources.USER); | ||
this.quill.format('align', false, Quill.sources.USER); | ||
} | ||
this.quill.format('direction', value, _quill.default.sources.USER); | ||
this.quill.format('direction', value, Quill.sources.USER); | ||
}, | ||
@@ -262,3 +248,3 @@ indent(value) { | ||
if (formats.direction === 'rtl') modifier *= -1; | ||
this.quill.format('indent', indent + modifier, _quill.default.sources.USER); | ||
this.quill.format('indent', indent + modifier, Quill.sources.USER); | ||
} | ||
@@ -271,3 +257,3 @@ }, | ||
this.quill.format('link', value, _quill.default.sources.USER); | ||
this.quill.format('link', value, Quill.sources.USER); | ||
}, | ||
@@ -279,8 +265,8 @@ list(value) { | ||
if (formats.list === 'checked' || formats.list === 'unchecked') { | ||
this.quill.format('list', false, _quill.default.sources.USER); | ||
this.quill.format('list', false, Quill.sources.USER); | ||
} else { | ||
this.quill.format('list', 'unchecked', _quill.default.sources.USER); | ||
this.quill.format('list', 'unchecked', Quill.sources.USER); | ||
} | ||
} else { | ||
this.quill.format('list', value, _quill.default.sources.USER); | ||
this.quill.format('list', value, Quill.sources.USER); | ||
} | ||
@@ -290,2 +276,3 @@ } | ||
}; | ||
export { Toolbar as default, addControls }; | ||
//# sourceMappingURL=toolbar.js.map |
@@ -1,3 +0,3 @@ | ||
import Module from '../core/module'; | ||
import Quill from '../core/quill'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
export declare const TTL_FOR_VALID_SELECTION_CHANGE = 100; | ||
@@ -4,0 +4,0 @@ declare class UINode extends Module { |
@@ -1,15 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.TTL_FOR_VALID_SELECTION_CHANGE = void 0; | ||
var _parchment = require("parchment"); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
var _quill = _interopRequireDefault(require("../core/quill")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { ParentBlot } from 'parchment'; | ||
import Module from '../core/module.js'; | ||
import Quill from '../core/quill.js'; | ||
const isMac = /Mac/i.test(navigator.platform); | ||
// Export for testing | ||
const TTL_FOR_VALID_SELECTION_CHANGE = exports.TTL_FOR_VALID_SELECTION_CHANGE = 100; | ||
export const TTL_FOR_VALID_SELECTION_CHANGE = 100; | ||
@@ -29,3 +22,3 @@ // A loose check to determine if the shortcut can move the caret before a UI node: | ||
}; | ||
class UINode extends _module.default { | ||
class UINode extends Module { | ||
isListening = false; | ||
@@ -48,3 +41,3 @@ selectionChangeDeadline = 0; | ||
} = _ref; | ||
if (!(line instanceof _parchment.ParentBlot) || !line.uiNode) { | ||
if (!(line instanceof ParentBlot) || !line.uiNode) { | ||
return true; | ||
@@ -56,3 +49,3 @@ } | ||
} | ||
this.quill.setSelection(range.index - 1, range.length + (event.shiftKey ? 1 : 0), _quill.default.sources.USER); | ||
this.quill.setSelection(range.index - 1, range.length + (event.shiftKey ? 1 : 0), Quill.sources.USER); | ||
return false; | ||
@@ -96,3 +89,3 @@ } | ||
const line = this.quill.scroll.find(range.startContainer); | ||
if (!(line instanceof _parchment.ParentBlot) || !line.uiNode) return; | ||
if (!(line instanceof ParentBlot) || !line.uiNode) return; | ||
const newRange = document.createRange(); | ||
@@ -105,3 +98,3 @@ newRange.setStartAfter(line.uiNode); | ||
} | ||
var _default = exports.default = UINode; | ||
export default UINode; | ||
//# sourceMappingURL=uiNode.js.map |
@@ -1,4 +0,4 @@ | ||
import type Quill from '../core/quill'; | ||
import Module from '../core/module'; | ||
import type { Range } from '../core/selection'; | ||
import type Quill from '../core/quill.js'; | ||
import Module from '../core/module.js'; | ||
import type { Range } from '../core/selection.js'; | ||
interface UploaderOptions { | ||
@@ -5,0 +5,0 @@ mimetypes: string[]; |
@@ -1,12 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _quillDelta = _interopRequireDefault(require("quill-delta")); | ||
var _emitter = _interopRequireDefault(require("../core/emitter")); | ||
var _module = _interopRequireDefault(require("../core/module")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class Uploader extends _module.default { | ||
import Delta from 'quill-delta'; | ||
import Emitter from '../core/emitter.js'; | ||
import Module from '../core/module.js'; | ||
class Uploader extends Module { | ||
constructor(quill, options) { | ||
@@ -67,9 +60,9 @@ super(quill, options); | ||
}); | ||
}, new _quillDelta.default().retain(range.index).delete(range.length)); | ||
this.quill.updateContents(update, _emitter.default.sources.USER); | ||
this.quill.setSelection(range.index + images.length, _emitter.default.sources.SILENT); | ||
}, new Delta().retain(range.index).delete(range.length)); | ||
this.quill.updateContents(update, Emitter.sources.USER); | ||
this.quill.setSelection(range.index + images.length, Emitter.sources.SILENT); | ||
}); | ||
} | ||
}; | ||
var _default = exports.default = Uploader; | ||
export default Uploader; | ||
//# sourceMappingURL=uploader.js.map |
{ | ||
"name": "quill", | ||
"version": "0.0.0-experimental-b9ebd32ba-20240125", | ||
"version": "0.0.0-experimental-d6d773267-20240311", | ||
"description": "Your powerful, rich text editor", | ||
@@ -8,2 +8,3 @@ "author": "Jason Chen <jhchen7@gmail.com>", | ||
"main": "quill.js", | ||
"type": "module", | ||
"dependencies": { | ||
@@ -33,6 +34,8 @@ "eventemitter3": "^5.0.1", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-import-resolver-typescript": "^3.6.1", | ||
"eslint-import-resolver-webpack": "^0.13.8", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jsx-a11y": "^6.8.0", | ||
"eslint-plugin-prettier": "^5.0.1", | ||
"eslint-plugin-require-extensions": "^0.1.3", | ||
"highlight.js": "^9.18.1", | ||
@@ -39,0 +42,0 @@ "html-loader": "^4.2.0", |
@@ -1,2 +0,2 @@ | ||
import Quill from './core'; | ||
import Quill from './core.js'; | ||
export default Quill; |
165
quill.js
@@ -1,90 +0,81 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _core = _interopRequireDefault(require("./core")); | ||
var _align = require("./formats/align"); | ||
var _direction = require("./formats/direction"); | ||
var _indent = _interopRequireDefault(require("./formats/indent")); | ||
var _blockquote = _interopRequireDefault(require("./formats/blockquote")); | ||
var _header = _interopRequireDefault(require("./formats/header")); | ||
var _list = _interopRequireDefault(require("./formats/list")); | ||
var _background = require("./formats/background"); | ||
var _color = require("./formats/color"); | ||
var _font = require("./formats/font"); | ||
var _size = require("./formats/size"); | ||
var _bold = _interopRequireDefault(require("./formats/bold")); | ||
var _italic = _interopRequireDefault(require("./formats/italic")); | ||
var _link = _interopRequireDefault(require("./formats/link")); | ||
var _script = _interopRequireDefault(require("./formats/script")); | ||
var _strike = _interopRequireDefault(require("./formats/strike")); | ||
var _underline = _interopRequireDefault(require("./formats/underline")); | ||
var _formula = _interopRequireDefault(require("./formats/formula")); | ||
var _image = _interopRequireDefault(require("./formats/image")); | ||
var _video = _interopRequireDefault(require("./formats/video")); | ||
var _code = _interopRequireWildcard(require("./formats/code")); | ||
var _syntax = _interopRequireDefault(require("./modules/syntax")); | ||
var _table = _interopRequireDefault(require("./modules/table")); | ||
var _toolbar = _interopRequireDefault(require("./modules/toolbar")); | ||
var _icons = _interopRequireDefault(require("./ui/icons")); | ||
var _picker = _interopRequireDefault(require("./ui/picker")); | ||
var _colorPicker = _interopRequireDefault(require("./ui/color-picker")); | ||
var _iconPicker = _interopRequireDefault(require("./ui/icon-picker")); | ||
var _tooltip = _interopRequireDefault(require("./ui/tooltip")); | ||
var _bubble = _interopRequireDefault(require("./themes/bubble")); | ||
var _snow = _interopRequireDefault(require("./themes/snow")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
_core.default.register({ | ||
'attributors/attribute/direction': _direction.DirectionAttribute, | ||
'attributors/class/align': _align.AlignClass, | ||
'attributors/class/background': _background.BackgroundClass, | ||
'attributors/class/color': _color.ColorClass, | ||
'attributors/class/direction': _direction.DirectionClass, | ||
'attributors/class/font': _font.FontClass, | ||
'attributors/class/size': _size.SizeClass, | ||
'attributors/style/align': _align.AlignStyle, | ||
'attributors/style/background': _background.BackgroundStyle, | ||
'attributors/style/color': _color.ColorStyle, | ||
'attributors/style/direction': _direction.DirectionStyle, | ||
'attributors/style/font': _font.FontStyle, | ||
'attributors/style/size': _size.SizeStyle | ||
import Quill from './core.js'; | ||
import { AlignClass, AlignStyle } from './formats/align.js'; | ||
import { DirectionAttribute, DirectionClass, DirectionStyle } from './formats/direction.js'; | ||
import Indent from './formats/indent.js'; | ||
import Blockquote from './formats/blockquote.js'; | ||
import Header from './formats/header.js'; | ||
import List from './formats/list.js'; | ||
import { BackgroundClass, BackgroundStyle } from './formats/background.js'; | ||
import { ColorClass, ColorStyle } from './formats/color.js'; | ||
import { FontClass, FontStyle } from './formats/font.js'; | ||
import { SizeClass, SizeStyle } from './formats/size.js'; | ||
import Bold from './formats/bold.js'; | ||
import Italic from './formats/italic.js'; | ||
import Link from './formats/link.js'; | ||
import Script from './formats/script.js'; | ||
import Strike from './formats/strike.js'; | ||
import Underline from './formats/underline.js'; | ||
import Formula from './formats/formula.js'; | ||
import Image from './formats/image.js'; | ||
import Video from './formats/video.js'; | ||
import CodeBlock, { Code as InlineCode } from './formats/code.js'; | ||
import Syntax from './modules/syntax.js'; | ||
import Table from './modules/table.js'; | ||
import Toolbar from './modules/toolbar.js'; | ||
import Icons from './ui/icons.js'; | ||
import Picker from './ui/picker.js'; | ||
import ColorPicker from './ui/color-picker.js'; | ||
import IconPicker from './ui/icon-picker.js'; | ||
import Tooltip from './ui/tooltip.js'; | ||
import BubbleTheme from './themes/bubble.js'; | ||
import SnowTheme from './themes/snow.js'; | ||
Quill.register({ | ||
'attributors/attribute/direction': DirectionAttribute, | ||
'attributors/class/align': AlignClass, | ||
'attributors/class/background': BackgroundClass, | ||
'attributors/class/color': ColorClass, | ||
'attributors/class/direction': DirectionClass, | ||
'attributors/class/font': FontClass, | ||
'attributors/class/size': SizeClass, | ||
'attributors/style/align': AlignStyle, | ||
'attributors/style/background': BackgroundStyle, | ||
'attributors/style/color': ColorStyle, | ||
'attributors/style/direction': DirectionStyle, | ||
'attributors/style/font': FontStyle, | ||
'attributors/style/size': SizeStyle | ||
}, true); | ||
_core.default.register({ | ||
'formats/align': _align.AlignClass, | ||
'formats/direction': _direction.DirectionClass, | ||
'formats/indent': _indent.default, | ||
'formats/background': _background.BackgroundStyle, | ||
'formats/color': _color.ColorStyle, | ||
'formats/font': _font.FontClass, | ||
'formats/size': _size.SizeClass, | ||
'formats/blockquote': _blockquote.default, | ||
'formats/code-block': _code.default, | ||
'formats/header': _header.default, | ||
'formats/list': _list.default, | ||
'formats/bold': _bold.default, | ||
'formats/code': _code.Code, | ||
'formats/italic': _italic.default, | ||
'formats/link': _link.default, | ||
'formats/script': _script.default, | ||
'formats/strike': _strike.default, | ||
'formats/underline': _underline.default, | ||
'formats/formula': _formula.default, | ||
'formats/image': _image.default, | ||
'formats/video': _video.default, | ||
'modules/syntax': _syntax.default, | ||
'modules/table': _table.default, | ||
'modules/toolbar': _toolbar.default, | ||
'themes/bubble': _bubble.default, | ||
'themes/snow': _snow.default, | ||
'ui/icons': _icons.default, | ||
'ui/picker': _picker.default, | ||
'ui/icon-picker': _iconPicker.default, | ||
'ui/color-picker': _colorPicker.default, | ||
'ui/tooltip': _tooltip.default | ||
Quill.register({ | ||
'formats/align': AlignClass, | ||
'formats/direction': DirectionClass, | ||
'formats/indent': Indent, | ||
'formats/background': BackgroundStyle, | ||
'formats/color': ColorStyle, | ||
'formats/font': FontClass, | ||
'formats/size': SizeClass, | ||
'formats/blockquote': Blockquote, | ||
'formats/code-block': CodeBlock, | ||
'formats/header': Header, | ||
'formats/list': List, | ||
'formats/bold': Bold, | ||
'formats/code': InlineCode, | ||
'formats/italic': Italic, | ||
'formats/link': Link, | ||
'formats/script': Script, | ||
'formats/strike': Strike, | ||
'formats/underline': Underline, | ||
'formats/formula': Formula, | ||
'formats/image': Image, | ||
'formats/video': Video, | ||
'modules/syntax': Syntax, | ||
'modules/table': Table, | ||
'modules/toolbar': Toolbar, | ||
'themes/bubble': BubbleTheme, | ||
'themes/snow': SnowTheme, | ||
'ui/icons': Icons, | ||
'ui/picker': Picker, | ||
'ui/icon-picker': IconPicker, | ||
'ui/color-picker': ColorPicker, | ||
'ui/tooltip': Tooltip | ||
}, true); | ||
var _default = exports.default = _core.default; | ||
export default Quill; | ||
//# sourceMappingURL=quill.js.map |
@@ -38,5 +38,5 @@ Note: This branch and README covers the upcoming 2.0 release. View [1.x docs here](https://github.com/quilljs/quill/tree/1.3.6). | ||
- [Contribute](https://github.com/quilljs/quill/blob/develop/.github/CONTRIBUTING.md) on [Issues](https://github.com/quilljs/quill/issues) | ||
- [Contribute](https://github.com/quilljs/quill/blob/main/.github/CONTRIBUTING.md) on [Issues](https://github.com/quilljs/quill/issues) | ||
- Follow [@jhchen](https://twitter.com/jhchen) and [@quilljs](https://twitter.com/quilljs) on Twitter | ||
- Ask questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/quill) | ||
- If privacy is required, email support@quilljs.com |
@@ -1,12 +0,12 @@ | ||
import type Quill from '../core/quill'; | ||
import Theme from '../core/theme'; | ||
import type { ThemeOptions } from '../core/theme'; | ||
import Picker from '../ui/picker'; | ||
import Tooltip from '../ui/tooltip'; | ||
import type { Range } from '../core/selection'; | ||
import type Clipboard from '../modules/clipboard'; | ||
import type History from '../modules/history'; | ||
import type Keyboard from '../modules/keyboard'; | ||
import type Uploader from '../modules/uploader'; | ||
import type Selection from '../core/selection'; | ||
import type Quill from '../core/quill.js'; | ||
import Theme from '../core/theme.js'; | ||
import type { ThemeOptions } from '../core/theme.js'; | ||
import Picker from '../ui/picker.js'; | ||
import Tooltip from '../ui/tooltip.js'; | ||
import type { Range } from '../core/selection.js'; | ||
import type Clipboard from '../modules/clipboard.js'; | ||
import type History from '../modules/history.js'; | ||
import type Keyboard from '../modules/keyboard.js'; | ||
import type Uploader from '../modules/uploader.js'; | ||
import type Selection from '../core/selection.js'; | ||
declare class BaseTheme extends Theme { | ||
@@ -13,0 +13,0 @@ pickers: Picker[]; |
@@ -1,15 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.BaseTooltip = void 0; | ||
var _lodashEs = require("lodash-es"); | ||
var _emitter = _interopRequireDefault(require("../core/emitter")); | ||
var _theme = _interopRequireDefault(require("../core/theme")); | ||
var _colorPicker = _interopRequireDefault(require("../ui/color-picker")); | ||
var _iconPicker = _interopRequireDefault(require("../ui/icon-picker")); | ||
var _picker = _interopRequireDefault(require("../ui/picker")); | ||
var _tooltip = _interopRequireDefault(require("../ui/tooltip")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { merge } from 'lodash-es'; | ||
import Emitter from '../core/emitter.js'; | ||
import Theme from '../core/theme.js'; | ||
import ColorPicker from '../ui/color-picker.js'; | ||
import IconPicker from '../ui/icon-picker.js'; | ||
import Picker from '../ui/picker.js'; | ||
import Tooltip from '../ui/tooltip.js'; | ||
const ALIGNS = [false, 'center', 'right', 'justify']; | ||
@@ -20,3 +13,3 @@ 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']; | ||
const SIZES = ['small', false, 'large', 'huge']; | ||
class BaseTheme extends _theme.default { | ||
class BaseTheme extends Theme { | ||
constructor(quill, options) { | ||
@@ -87,3 +80,3 @@ super(quill, options); | ||
if (typeof icons.align === 'object') { | ||
return new _iconPicker.default(select, icons.align); | ||
return new IconPicker(select, icons.align); | ||
} | ||
@@ -96,3 +89,3 @@ } | ||
} | ||
return new _colorPicker.default(select, icons[format]); | ||
return new ColorPicker(select, icons[format]); | ||
} | ||
@@ -108,3 +101,3 @@ if (select.querySelector('option') == null) { | ||
} | ||
return new _picker.default(select); | ||
return new Picker(select); | ||
}); | ||
@@ -116,7 +109,6 @@ const update = () => { | ||
}; | ||
this.quill.on(_emitter.default.events.EDITOR_CHANGE, update); | ||
this.quill.on(Emitter.events.EDITOR_CHANGE, update); | ||
} | ||
} | ||
exports.default = BaseTheme; | ||
BaseTheme.DEFAULTS = (0, _lodashEs.merge)({}, _theme.default.DEFAULTS, { | ||
BaseTheme.DEFAULTS = merge({}, Theme.DEFAULTS, { | ||
modules: { | ||
@@ -151,3 +143,3 @@ toolbar: { | ||
}); | ||
class BaseTooltip extends _tooltip.default { | ||
class BaseTooltip extends Tooltip { | ||
constructor(quill, boundsContainer) { | ||
@@ -210,7 +202,7 @@ super(quill, boundsContainer); | ||
if (this.linkRange) { | ||
this.quill.formatText(this.linkRange, 'link', value, _emitter.default.sources.USER); | ||
this.quill.formatText(this.linkRange, 'link', value, Emitter.sources.USER); | ||
delete this.linkRange; | ||
} else { | ||
this.restoreFocus(); | ||
this.quill.format('link', value, _emitter.default.sources.USER); | ||
this.quill.format('link', value, Emitter.sources.USER); | ||
} | ||
@@ -233,7 +225,7 @@ this.quill.root.scrollTop = scrollTop; | ||
// @ts-expect-error Fix me later | ||
this.root.getAttribute('data-mode'), value, _emitter.default.sources.USER); | ||
this.root.getAttribute('data-mode'), value, Emitter.sources.USER); | ||
if (this.root.getAttribute('data-mode') === 'formula') { | ||
this.quill.insertText(index + 1, ' ', _emitter.default.sources.USER); | ||
this.quill.insertText(index + 1, ' ', Emitter.sources.USER); | ||
} | ||
this.quill.setSelection(index + 2, _emitter.default.sources.USER); | ||
this.quill.setSelection(index + 2, Emitter.sources.USER); | ||
} | ||
@@ -249,3 +241,2 @@ break; | ||
} | ||
exports.BaseTooltip = BaseTooltip; | ||
function extractVideoUrl(url) { | ||
@@ -274,2 +265,3 @@ 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_-]+)/); | ||
} | ||
export { BaseTooltip, BaseTheme as default }; | ||
//# sourceMappingURL=base.js.map |
@@ -1,6 +0,6 @@ | ||
import BaseTheme, { BaseTooltip } from './base'; | ||
import type { Bounds } from '../core/selection'; | ||
import type Quill from '../core'; | ||
import type { ThemeOptions } from '../core/theme'; | ||
import type Toolbar from '../modules/toolbar'; | ||
import BaseTheme, { BaseTooltip } from './base.js'; | ||
import type { Bounds } from '../core/selection.js'; | ||
import type Quill from '../core.js'; | ||
import type { ThemeOptions } from '../core/theme.js'; | ||
import type Toolbar from '../modules/toolbar.js'; | ||
declare class BubbleTooltip extends BaseTooltip { | ||
@@ -14,2 +14,3 @@ static TEMPLATE: string; | ||
declare class BubbleTheme extends BaseTheme { | ||
tooltip: BubbleTooltip; | ||
constructor(quill: Quill, options: ThemeOptions); | ||
@@ -16,0 +17,0 @@ extendToolbar(toolbar: Toolbar): void; |
@@ -1,15 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = exports.BubbleTooltip = void 0; | ||
var _lodashEs = require("lodash-es"); | ||
var _emitter = _interopRequireDefault(require("../core/emitter")); | ||
var _base = _interopRequireWildcard(require("./base")); | ||
var _selection = require("../core/selection"); | ||
var _icons = _interopRequireDefault(require("../ui/icons")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { merge } from 'lodash-es'; | ||
import Emitter from '../core/emitter.js'; | ||
import BaseTheme, { BaseTooltip } from './base.js'; | ||
import { Range } from '../core/selection.js'; | ||
import icons from '../ui/icons.js'; | ||
const TOOLBAR_CONFIG = [['bold', 'italic', 'link'], [{ | ||
@@ -20,9 +11,9 @@ header: 1 | ||
}, 'blockquote']]; | ||
class BubbleTooltip extends _base.BaseTooltip { | ||
class BubbleTooltip extends BaseTooltip { | ||
static TEMPLATE = ['<span class="ql-tooltip-arrow"></span>', '<div class="ql-tooltip-editor">', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-close"></a>', '</div>'].join(''); | ||
constructor(quill, bounds) { | ||
super(quill, bounds); | ||
this.quill.on(_emitter.default.events.EDITOR_CHANGE, (type, range, oldRange, source) => { | ||
if (type !== _emitter.default.events.SELECTION_CHANGE) return; | ||
if (range != null && range.length > 0 && source === _emitter.default.sources.USER) { | ||
this.quill.on(Emitter.events.EDITOR_CHANGE, (type, range, oldRange, source) => { | ||
if (type !== Emitter.events.SELECTION_CHANGE) return; | ||
if (range != null && range.length > 0 && source === Emitter.sources.USER) { | ||
this.show(); | ||
@@ -43,3 +34,3 @@ // Lock our width so we will expand beyond our offsetParent boundaries | ||
const length = Math.min(lastLine.length() - 1, range.index + range.length - index); | ||
const indexBounds = this.quill.getBounds(new _selection.Range(index, length)); | ||
const indexBounds = this.quill.getBounds(new Range(index, length)); | ||
if (indexBounds != null) { | ||
@@ -60,3 +51,3 @@ this.position(indexBounds); | ||
}); | ||
this.quill.on(_emitter.default.events.SCROLL_OPTIMIZE, () => { | ||
this.quill.on(Emitter.events.SCROLL_OPTIMIZE, () => { | ||
// Let selection be restored by toolbar handlers before repositioning | ||
@@ -90,4 +81,3 @@ setTimeout(() => { | ||
} | ||
exports.BubbleTooltip = BubbleTooltip; | ||
class BubbleTheme extends _base.default { | ||
class BubbleTheme extends BaseTheme { | ||
constructor(quill, options) { | ||
@@ -105,9 +95,8 @@ if (options.modules.toolbar != null && options.modules.toolbar.container == null) { | ||
this.tooltip.root.appendChild(toolbar.container); | ||
this.buildButtons(toolbar.container.querySelectorAll('button'), _icons.default); | ||
this.buildPickers(toolbar.container.querySelectorAll('select'), _icons.default); | ||
this.buildButtons(toolbar.container.querySelectorAll('button'), icons); | ||
this.buildPickers(toolbar.container.querySelectorAll('select'), icons); | ||
} | ||
} | ||
} | ||
exports.default = BubbleTheme; | ||
BubbleTheme.DEFAULTS = (0, _lodashEs.merge)({}, _base.default.DEFAULTS, { | ||
BubbleTheme.DEFAULTS = merge({}, BaseTheme.DEFAULTS, { | ||
modules: { | ||
@@ -127,2 +116,3 @@ toolbar: { | ||
}); | ||
export { BubbleTooltip, BubbleTheme as default }; | ||
//# sourceMappingURL=bubble.js.map |
@@ -1,5 +0,5 @@ | ||
import BaseTheme from './base'; | ||
import type Quill from '../core'; | ||
import type Toolbar from '../modules/toolbar'; | ||
import type { ThemeOptions } from '../core/theme'; | ||
import BaseTheme from './base.js'; | ||
import type Quill from '../core.js'; | ||
import type Toolbar from '../modules/toolbar.js'; | ||
import type { ThemeOptions } from '../core/theme.js'; | ||
declare class SnowTheme extends BaseTheme { | ||
@@ -6,0 +6,0 @@ constructor(quill: Quill, options: ThemeOptions); |
@@ -1,16 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _lodashEs = require("lodash-es"); | ||
var _emitter = _interopRequireDefault(require("../core/emitter")); | ||
var _base = _interopRequireWildcard(require("./base")); | ||
var _link = _interopRequireDefault(require("../formats/link")); | ||
var _selection = require("../core/selection"); | ||
var _icons = _interopRequireDefault(require("../ui/icons")); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } | ||
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
import { merge } from 'lodash-es'; | ||
import Emitter from '../core/emitter.js'; | ||
import BaseTheme, { BaseTooltip } from './base.js'; | ||
import LinkBlot from '../formats/link.js'; | ||
import { Range } from '../core/selection.js'; | ||
import icons from '../ui/icons.js'; | ||
const TOOLBAR_CONFIG = [[{ | ||
@@ -23,3 +14,3 @@ header: ['1', '2', '3', false] | ||
}], ['clean']]; | ||
class SnowTooltip extends _base.BaseTooltip { | ||
class SnowTooltip extends BaseTooltip { | ||
static TEMPLATE = ['<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>', '<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">', '<a class="ql-action"></a>', '<a class="ql-remove"></a>'].join(''); | ||
@@ -44,3 +35,3 @@ preview = this.root.querySelector('a.ql-preview'); | ||
this.restoreFocus(); | ||
this.quill.formatText(range, 'link', false, _emitter.default.sources.USER); | ||
this.quill.formatText(range, 'link', false, Emitter.sources.USER); | ||
delete this.linkRange; | ||
@@ -51,9 +42,9 @@ } | ||
}); | ||
this.quill.on(_emitter.default.events.SELECTION_CHANGE, (range, oldRange, source) => { | ||
this.quill.on(Emitter.events.SELECTION_CHANGE, (range, oldRange, source) => { | ||
if (range == null) return; | ||
if (range.length === 0 && source === _emitter.default.sources.USER) { | ||
const [link, offset] = this.quill.scroll.descendant(_link.default, range.index); | ||
if (range.length === 0 && source === Emitter.sources.USER) { | ||
const [link, offset] = this.quill.scroll.descendant(LinkBlot, range.index); | ||
if (link != null) { | ||
this.linkRange = new _selection.Range(range.index - offset, link.length()); | ||
const preview = _link.default.formats(link.domNode); | ||
this.linkRange = new Range(range.index - offset, link.length()); | ||
const preview = LinkBlot.formats(link.domNode); | ||
// @ts-expect-error Fix me later | ||
@@ -81,3 +72,3 @@ this.preview.textContent = preview; | ||
} | ||
class SnowTheme extends _base.default { | ||
class SnowTheme extends BaseTheme { | ||
constructor(quill, options) { | ||
@@ -93,4 +84,4 @@ if (options.modules.toolbar != null && options.modules.toolbar.container == null) { | ||
toolbar.container.classList.add('ql-snow'); | ||
this.buildButtons(toolbar.container.querySelectorAll('button'), _icons.default); | ||
this.buildPickers(toolbar.container.querySelectorAll('select'), _icons.default); | ||
this.buildButtons(toolbar.container.querySelectorAll('button'), icons); | ||
this.buildPickers(toolbar.container.querySelectorAll('select'), icons); | ||
// @ts-expect-error | ||
@@ -109,3 +100,3 @@ this.tooltip = new SnowTooltip(this.quill, this.options.bounds); | ||
} | ||
SnowTheme.DEFAULTS = (0, _lodashEs.merge)({}, _base.default.DEFAULTS, { | ||
SnowTheme.DEFAULTS = merge({}, BaseTheme.DEFAULTS, { | ||
modules: { | ||
@@ -134,3 +125,3 @@ toolbar: { | ||
}); | ||
var _default = exports.default = SnowTheme; | ||
export default SnowTheme; | ||
//# sourceMappingURL=snow.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
//# sourceMappingURL=types.d.js.map |
@@ -1,2 +0,2 @@ | ||
import Picker from './picker'; | ||
import Picker from './picker.js'; | ||
declare class ColorPicker extends Picker { | ||
@@ -3,0 +3,0 @@ constructor(select: HTMLSelectElement, label: string); |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _picker = _interopRequireDefault(require("./picker")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class ColorPicker extends _picker.default { | ||
import Picker from './picker.js'; | ||
class ColorPicker extends Picker { | ||
constructor(select, label) { | ||
@@ -36,3 +29,3 @@ super(select); | ||
} | ||
var _default = exports.default = ColorPicker; | ||
export default ColorPicker; | ||
//# sourceMappingURL=color-picker.js.map |
@@ -1,2 +0,2 @@ | ||
import Picker from './picker'; | ||
import Picker from './picker.js'; | ||
declare class IconPicker extends Picker { | ||
@@ -3,0 +3,0 @@ defaultItem: HTMLElement | null; |
@@ -1,10 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _picker = _interopRequireDefault(require("./picker")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
class IconPicker extends _picker.default { | ||
import Picker from './picker.js'; | ||
class IconPicker extends Picker { | ||
constructor(select, icons) { | ||
@@ -28,3 +21,3 @@ super(select); | ||
} | ||
var _default = exports.default = IconPicker; | ||
export default IconPicker; | ||
//# sourceMappingURL=icon-picker.js.map |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const alignLeftIcon = "<svg viewbox=\"0 0 18 18\"><line class=\"ql-stroke\" x1=\"3\" x2=\"15\" y1=\"9\" y2=\"9\"/><line class=\"ql-stroke\" x1=\"3\" x2=\"13\" y1=\"14\" y2=\"14\"/><line class=\"ql-stroke\" x1=\"3\" x2=\"9\" y1=\"4\" y2=\"4\"/></svg>"; | ||
@@ -36,3 +30,3 @@ const alignCenterIcon = "<svg viewbox=\"0 0 18 18\"><line class=\"ql-stroke\" x1=\"15\" x2=\"3\" y1=\"9\" y2=\"9\"/><line class=\"ql-stroke\" x1=\"14\" x2=\"4\" y1=\"14\" y2=\"14\"/><line class=\"ql-stroke\" x1=\"12\" x2=\"6\" y1=\"4\" y2=\"4\"/></svg>"; | ||
const videoIcon = "<svg viewbox=\"0 0 18 18\"><rect class=\"ql-stroke\" height=\"12\" width=\"12\" x=\"3\" y=\"3\"/><rect class=\"ql-fill\" height=\"12\" width=\"1\" x=\"5\" y=\"3\"/><rect class=\"ql-fill\" height=\"12\" width=\"1\" x=\"12\" y=\"3\"/><rect class=\"ql-fill\" height=\"2\" width=\"8\" x=\"5\" y=\"8\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"3\" y=\"5\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"3\" y=\"7\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"3\" y=\"10\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"3\" y=\"12\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"12\" y=\"5\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"12\" y=\"7\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"12\" y=\"10\"/><rect class=\"ql-fill\" height=\"1\" width=\"3\" x=\"12\" y=\"12\"/></svg>"; | ||
var _default = exports.default = { | ||
export default { | ||
align: { | ||
@@ -39,0 +33,0 @@ '': alignLeftIcon, |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const DropdownIcon = "<svg viewbox=\"0 0 18 18\"><polygon class=\"ql-stroke\" points=\"7 11 9 13 11 11 7 11\"/><polygon class=\"ql-stroke\" points=\"7 7 9 5 11 7 7 7\"/></svg>"; | ||
@@ -176,3 +170,3 @@ let optionsCounter = 0; | ||
} | ||
var _default = exports.default = Picker; | ||
export default Picker; | ||
//# sourceMappingURL=picker.js.map |
@@ -1,3 +0,3 @@ | ||
import type Quill from '../core'; | ||
import type { Bounds } from '../core/selection'; | ||
import type Quill from '../core.js'; | ||
import type { Bounds } from '../core/selection.js'; | ||
declare class Tooltip { | ||
@@ -4,0 +4,0 @@ quill: Quill; |
@@ -1,7 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
const isScrollable = el => { | ||
@@ -61,3 +55,3 @@ const { | ||
} | ||
var _default = exports.default = Tooltip; | ||
export default Tooltip; | ||
//# sourceMappingURL=tooltip.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
293
Yes
2957550
43
9549