lineHeight.js:
1 import Quill from "quill"; 2 let Parchment = Quill.import("parchment"); 3 console.log(Parchment); 4 class lineHeightAttributor extends Parchment.Attributor.Style {} 5 const lineHeightStyle = new lineHeightAttributor("lineHeight", "line-height", { 6 scope: Parchment.Scope.INLINE, 7 whitelist: ["initial", "1", "1.5", "1.75", "2", "3", "4"] 8 }); 9 10 export { lineHeightStyle };
使用時引入
import { lineHeightStyle } from "@/utils/lineheight";
quillEditor 組件 ready 事件中調用:(更詳細的在上一節)
1 <quill-editor 2 @ready="ready($event)" 3 > 4 </quill-editor>
ready:
1 ready() { 2 Quill.register({ "formats/lineHeight": lineHeightStyle }, true); 3 },