UNPKG

@opentiny/fluent-editor

Version:

A rich text editor based on Quill 2.0, which extends rich modules and formats on the basis of Quill. It's powerful and out-of-the-box.

57 lines (56 loc) 1.89 kB
"use strict"; var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const Quill = require("quill"); const mindMapBlot = require("./formats/mind-map-blot.cjs.js"); class MindMapModule { constructor(quill, options) { __publicField(this, "quill"); __publicField(this, "toolbar"); __publicField(this, "options"); quill.container.__quillInstance = quill; this.quill = quill; this.options = options; this.toolbar = quill.getModule("toolbar"); if (this.toolbar) { this.toolbar.addHandler("mind-map", () => { this.insertMindMapEditor(); }); } } static register() { Quill.register("formats/mind-map", mindMapBlot.default, true); } insertMindMapEditor() { const range = this.quill.getSelection(); if (range) { const defaultData = { data: { text: "根节点", expand: true, uid: "36bae545-da0b-4c08-be14-ff05f7f05d0a", isActive: false }, children: [ { data: { text: "二级节点", uid: "ef0895d2-b5cc-4214-b0ee-e29f8f02420d", expand: true, richText: false, isActive: false }, children: [] } ] }; this.quill.insertText(range.index, "\n", "user"); this.quill.insertEmbed(range.index + 1, "mind-map", defaultData, "user"); this.quill.insertText(range.index + 2, "\n", "user"); } } } exports.MindMapModule = MindMapModule; //# sourceMappingURL=index.cjs.js.map