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.

46 lines (45 loc) 1.65 kB
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); import Quill from "quill"; import FlowChartPlaceholderBlot from "./formats/flow-chart-blot.es.js"; class FlowChartModule { 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("flow-chart", () => { this.insertFlowChartEditor(); }); } } static register() { Quill.register("formats/flow-chart", FlowChartPlaceholderBlot, true); } insertFlowChartEditor() { const range = this.quill.getSelection(); if (range) { const defaultData = { nodes: [ { id: "node1", type: "rect", x: 100, y: 150, text: "开始" }, { id: "node2", type: "rect", x: 300, y: 150, text: "结束" } ], edges: [ { id: "edge1", sourceNodeId: "node1", targetNodeId: "node2", type: "polyline" } ] }; this.quill.insertText(range.index, "\n", "user"); this.quill.insertEmbed(range.index + 1, "flow-chart", defaultData, "user"); this.quill.insertText(range.index + 2, "\n", "user"); } } } export { FlowChartModule }; //# sourceMappingURL=index.es.js.map