reactjs-tiptap-editor 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{ActionMenuButton-C53IYt_R.js → ActionMenuButton-8cTG45Ft.js} +1 -1
- package/lib/{ActionMenuButton-Da0H9Beu.cjs → ActionMenuButton-CXeFhner.cjs} +1 -1
- package/lib/Attachment.cjs +1 -1
- package/lib/Attachment.js +3 -3
- package/lib/Blockquote.cjs +1 -1
- package/lib/Blockquote.js +2 -2
- package/lib/Bold.cjs +1 -1
- package/lib/Bold.js +2 -2
- package/lib/BulletList.cjs +1 -1
- package/lib/BulletList.js +2 -2
- package/lib/{Callout-CdXbDkZ6.cjs → Callout-DWOMZPiP.cjs} +1 -1
- package/lib/{Callout-igc-a1lj.js → Callout-ZlPQrMEt.js} +3 -3
- package/lib/Callout.cjs +1 -1
- package/lib/Callout.js +4 -4
- package/lib/Clear.cjs +1 -1
- package/lib/Clear.js +2 -2
- package/lib/Code.cjs +1 -1
- package/lib/Code.js +6 -6
- package/lib/CodeBlock.cjs +1 -1
- package/lib/CodeBlock.js +27 -27
- package/lib/CodeView.cjs +1 -1
- package/lib/CodeView.js +2 -2
- package/lib/Color.cjs +1 -1
- package/lib/Color.js +3 -3
- package/lib/Column.cjs +1 -1
- package/lib/Column.js +7 -7
- package/lib/{Drawer-DzroBQds.js → Drawer-C-EO1uoK.js} +20 -20
- package/lib/{Drawer-CrMuQNbZ.cjs → Drawer-TJY4NuHx.cjs} +1 -1
- package/lib/Drawer.cjs +1 -1
- package/lib/Drawer.js +4 -4
- package/lib/Emoji.cjs +1 -1
- package/lib/Emoji.js +4311 -1859
- package/lib/Excalidraw.cjs +1 -1
- package/lib/Excalidraw.js +3 -3
- package/lib/ExportPdf.cjs +1 -1
- package/lib/ExportPdf.js +2 -2
- package/lib/ExportWord.cjs +1 -1
- package/lib/ExportWord.js +2 -2
- package/lib/FontFamily.cjs +1 -1
- package/lib/FontFamily.js +4 -4
- package/lib/FontSize.cjs +1 -1
- package/lib/FontSize.js +4 -4
- package/lib/Heading.cjs +1 -1
- package/lib/Heading.js +9 -9
- package/lib/Highlight.cjs +1 -1
- package/lib/Highlight.js +79 -50
- package/lib/History.cjs +1 -1
- package/lib/History.js +556 -418
- package/lib/HorizontalRule.cjs +1 -1
- package/lib/HorizontalRule.js +2 -2
- package/lib/{Iframe-DVLx3H0m.cjs → Iframe-5zx43DL4.cjs} +1 -1
- package/lib/{Iframe-Dt2Styg8.js → Iframe-CGb6-2LD.js} +3 -3
- package/lib/Iframe.cjs +1 -1
- package/lib/Iframe.js +3 -3
- package/lib/Image.cjs +1 -1
- package/lib/Image.js +3 -3
- package/lib/ImageGif.cjs +1 -1
- package/lib/ImageGif.js +4 -4
- package/lib/ImportWord.cjs +1 -1
- package/lib/ImportWord.js +2 -2
- package/lib/{Indent-BCZFJKcN.js → Indent-CdMYsDNS.js} +4 -4
- package/lib/{Indent-CQCn1r9U.cjs → Indent-DuwV8s1t.cjs} +1 -1
- package/lib/Indent.cjs +1 -1
- package/lib/Indent.js +2 -2
- package/lib/Italic.cjs +1 -1
- package/lib/Italic.js +2 -2
- package/lib/{Katex--VT0zcjU.js → Katex-CCP_ZQz2.js} +4 -4
- package/lib/{Katex-By61XteD.cjs → Katex-D9FP7EUE.cjs} +1 -1
- package/lib/Katex.cjs +1 -1
- package/lib/Katex.js +3 -3
- package/lib/LineHeight.cjs +1 -1
- package/lib/LineHeight.js +3 -3
- package/lib/Link.cjs +1 -1
- package/lib/Link.js +2 -2
- package/lib/{LinkEditBlock-C_F9zWEj.js → LinkEditBlock-B1m-TVMu.js} +222 -224
- package/lib/LinkEditBlock-DQ8-iufJ.cjs +5 -0
- package/lib/MarkdownPaste.cjs +1 -1
- package/lib/MarkdownPaste.js +1 -1
- package/lib/Mention.cjs +1 -1
- package/lib/Mention.js +8 -8
- package/lib/Mermaid.cjs +1 -1
- package/lib/Mermaid.js +27 -27
- package/lib/MoreMark.cjs +1 -1
- package/lib/MoreMark.js +3 -3
- package/lib/OrderedList.cjs +1 -1
- package/lib/OrderedList.js +2 -2
- package/lib/SearchAndReplace.cjs +1 -1
- package/lib/SearchAndReplace.js +3 -3
- package/lib/SlashCommand.cjs +1 -1
- package/lib/SlashCommand.js +6 -6
- package/lib/{SlashCommandNodeView-Aqc77oRC.cjs → SlashCommandNodeView-DNixmQGa.cjs} +1 -1
- package/lib/{SlashCommandNodeView-DxlBPKPV.js → SlashCommandNodeView-Dt6n1SP9.js} +1 -1
- package/lib/Strike.cjs +1 -1
- package/lib/Strike.js +2 -2
- package/lib/Table-C5JxBXef.cjs +9 -0
- package/lib/Table-DdEgaUwa.js +1984 -0
- package/lib/Table.cjs +1 -1
- package/lib/Table.js +1 -1
- package/lib/TaskList.cjs +1 -1
- package/lib/TaskList.js +2 -2
- package/lib/TextAlign.cjs +1 -1
- package/lib/TextAlign.js +3 -3
- package/lib/TextDirection.cjs +1 -1
- package/lib/TextDirection.js +3 -3
- package/lib/TextUnderline.cjs +1 -1
- package/lib/TextUnderline.js +2 -2
- package/lib/{Twitter-f-oMDZuV.cjs → Twitter--tfifMt1.cjs} +1 -1
- package/lib/{Twitter-DP_9V0zb.js → Twitter-Dnz9qyW0.js} +4 -4
- package/lib/Twitter.cjs +1 -1
- package/lib/Twitter.js +3 -3
- package/lib/Video.cjs +1 -1
- package/lib/Video.js +2 -2
- package/lib/bubble.cjs +6 -6
- package/lib/bubble.js +1573 -1561
- package/lib/{clsx-Bg-2aTKh.js → clsx-0OU6n9va.js} +379 -353
- package/lib/clsx-D6gYQn3o.cjs +33 -0
- package/lib/{dropdown-menu-uIj8M0jD.js → dropdown-menu-ROihzXsP.js} +1 -1
- package/lib/{dropdown-menu-DeBV2h9-.cjs → dropdown-menu-yQ-sQ1k4.cjs} +1 -1
- package/lib/index-BAb_UADw.cjs +1 -0
- package/lib/index-BF3EVCB1.cjs +2 -0
- package/lib/{index-D0EmqTpe.js → index-BblvcbTH.js} +1130 -1064
- package/lib/index-Bcj8cyOO.cjs +24 -0
- package/lib/index-CGjT-a9h.js +1377 -0
- package/lib/index-CPTpXLfX.cjs +11 -0
- package/lib/{index-C3dgmjIF.cjs → index-CUvjYuRp.cjs} +1 -1
- package/lib/{index-DXtVL0al.js → index-Cal5SPfB.js} +189 -134
- package/lib/{index-CjLxMm5d.js → index-D-Ouz0vF.js} +1 -1
- package/lib/{index-ezTXvA7H.cjs → index-Gi752TMk.cjs} +1 -1
- package/lib/{index-BVtsbzV8.js → index-X6WZUM9O.js} +15 -15
- package/lib/{index-CbkpBnTX.js → index-zw-Kd38i.js} +47 -50
- package/lib/index.cjs +1 -1
- package/lib/index.js +2 -2
- package/lib/{popover-Cq1iLY7i.cjs → popover-BPzkMuyi.cjs} +1 -1
- package/lib/{popover-mlZeH-7I.js → popover-BfWFqCIs.js} +1 -1
- package/lib/{renderNodeView-CbxCTni3.js → renderNodeView-CfWJK4rG.js} +2 -2
- package/lib/{renderNodeView-DFVrJy0l.cjs → renderNodeView-D--fDFov.cjs} +1 -1
- package/lib/{separator-Bh_ttGZg.js → separator-CBPrZizK.js} +2 -2
- package/lib/{separator-DvAvl5_5.cjs → separator-DpaS43Gt.cjs} +1 -1
- package/lib/{textarea-MU5imD7D.js → textarea-Bl64keav.js} +1 -1
- package/lib/{textarea-CKXzGwId.cjs → textarea-wvARZKyA.cjs} +1 -1
- package/lib/updatePosition-BwzAsiY0.js +16 -0
- package/lib/{updatePosition-CQE1ct18.cjs → updatePosition-DGPtRfWN.cjs} +1 -1
- package/package.json +60 -60
- package/lib/LinkEditBlock-BLkA2CYZ.cjs +0 -5
- package/lib/Table-DqXkwJAY.cjs +0 -9
- package/lib/Table-r09L4PvT.js +0 -1945
- package/lib/clsx-DSAWW32g.cjs +0 -33
- package/lib/index-C4WLt4NA.cjs +0 -24
- package/lib/index-DlxZt4_j.cjs +0 -1
- package/lib/index-P5_MyY0i.js +0 -1362
- package/lib/index-TcJ2UKnv.cjs +0 -1
- package/lib/index-fbGGohBT.cjs +0 -12
- package/lib/updatePosition-BGD41Hbg.js +0 -16
package/lib/Excalidraw.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var z=Object.create;var M=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var U=(e,s,i,d)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of V(s))!$.call(e,o)&&o!==i&&M(e,o,{get:()=>s[o],enumerable:!(d=P(s,o))||d.enumerable});return e};var R=(e,s,i)=>(i=e!=null?z(B(e)):{},U(s||!e||!e.__esModule?M(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-
|
|
1
|
+
"use strict";var z=Object.create;var M=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var U=(e,s,i,d)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of V(s))!$.call(e,o)&&o!==i&&M(e,o,{get:()=>s[o],enumerable:!(d=P(s,o))||d.enumerable});return e};var R=(e,s,i)=>(i=e!=null?z(B(e)):{},U(s||!e||!e.__esModule?M(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("./index-Bcj8cyOO.cjs"),y=require("./clsx-D6gYQn3o.cjs"),t=require("react/jsx-runtime"),F=require("re-resizable"),r=require("react"),a=require("./index-Gi752TMk.cjs"),v=require("./dom-dataset-BqoJhJXt.cjs"),X="_wrap_dra8y_1",Y="_renderWrap_dra8y_7",G="_handlerWrap_dra8y_30",J="_disabled_dra8y_40",T={wrap:X,renderWrap:Y,handlerWrap:G,disabled:J},K=10,Q=200,O=15,W={width:"100%",height:"100%",maxWidth:"100%"};function ee({editor:e,node:s,updateAttributes:i}){const d=r.useRef(null),o=a.useEditableEditor(),x=e.isActive(_.name),{data:p,width:c,height:A}=s.attrs,[m,I]=r.useState(null),[b,D]=r.useState(!0),[u,g]=r.useState(null),[E,S]=r.useState(100),f=r.useCallback(n=>()=>{S(h=>a.clamp(n==="minus"?h-O:h+O,K,Q))},[]);r.useEffect(()=>{let n=!1;return import("@excalidraw/excalidraw").then(h=>{n||(d.current=h.exportToSvg)}).catch(h=>!n&&g(h)).finally(()=>!n&&D(!1)),()=>{n=!0}},[p]),r.useEffect(()=>{let n=!1;return(async()=>{if(!d.current||n||b||u||!p)return;const w=await d.current(p);n||(w.setAttribute("width","100%"),w.setAttribute("height","100%"),w.setAttribute("display","block"),I(w))})(),()=>{n=!0}},[p,b,u]);const L=n=>{i({width:n.width,height:n.height})};return t.jsx(y.NodeViewWrapper,{className:y.clsx(T.wrap,{[T.active]:x,[T.disabled]:!o}),children:t.jsx(F.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(A)},onResizeStop:(n,h,w,j)=>{L({width:Number.parseInt(c)+j.width,height:Number.parseInt(A)+j.height})},children:t.jsxs("div",{className:y.clsx(T.renderWrap,"render-wrapper"),style:{...W,overflow:"hidden"},children:[u&&t.jsx("div",{style:W,children:t.jsx("p",{children:u.message||u})}),b&&t.jsx("p",{children:"Loading..."}),!b&&!u&&m&&t.jsx("div",{dangerouslySetInnerHTML:{__html:(m==null?void 0:m.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${E/100})`,transition:"all ease-in-out .3s"}}),t.jsxs("div",{className:T.handlerWrap,children:[t.jsx(a.ActionButton,{action:f("minus"),disabled:!o,icon:"ZoomOut",tooltip:"Zoom Out"}),t.jsx(a.ActionButton,{action:f("plus"),disabled:!o,icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})}function te(){const e=a.useEditorInstance(),s=a.useButtonProps(_.name),i=a.useExtension(_.name),{tooltipOptions:d={},isActive:o=void 0}=(s==null?void 0:s.componentProps)??{},{editorDisabled:x}=a.useToggleActive(o),p=r.useMemo(()=>(i==null?void 0:i.options)||{},[i]),[c,A]=r.useState(null),[m,I]=r.useState({}),[b,D]=r.useState({elements:[],appState:{isLoading:!1},files:null}),[u,g]=r.useState(!1),[E,S]=r.useState(!0),[f,L]=r.useState(null),n=r.useCallback(l=>{l&&import("@excalidraw/excalidraw").then(C=>{A(C.Excalidraw)}).catch(L).finally(()=>S(!1))},[S]),h=r.useCallback(l=>{setTimeout(()=>{l.refresh()})},[]),w=r.useCallback((l,C,q)=>{I({elements:l,appState:{isLoading:!1},files:q})},[]),j=r.useCallback(()=>{if(!c){g(!1);return}e.chain().focus().setExcalidraw({data:m}).run(),g(!1)},[c,e,m,g]),k=l=>{g(!0),l!=null&&l.data&&D(l==null?void 0:l.data)},Z=a.EVENTS.EXCALIDRAW(e.id);return a.useListener(k,[Z]),r.useEffect(()=>{!E&&c&&u&&setTimeout(()=>{window.dispatchEvent(new Event("resize"))},400)},[E,c,u]),t.jsxs(a.Dialog,{onOpenChange:g,open:u,children:[t.jsx(a.DialogTrigger,{asChild:!0,children:t.jsx(a.ActionButton,{disabled:x,icon:"Excalidraw",tooltip:"Excalidraw",tooltipOptions:d,action:()=>{x||g(!0)}})}),t.jsxs(a.DialogContent,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(a.DialogTitle,{children:"Excalidraw"}),t.jsxs("div",{style:{height:"100%",borderWidth:1},children:[E&&t.jsx("p",{children:"Loading..."}),f&&t.jsx("p",{children:f&&f.message||"Error"}),t.jsx("div",{ref:n,style:{width:"100%",height:600},children:!E&&!f&&c?t.jsx(c,{initialData:b,langCode:"en",onChange:w,ref:h,...p.excalidrawProps}):null})]}),t.jsx(a.DialogFooter,{children:t.jsx(a.Button,{disabled:!c,onClick:j,type:"button",children:"Save changes"})})]})]})}const H={elements:[]},_=N.Node3.create({name:"excalidraw",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes(){return{defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:v.getDatasetAttribute("width")},height:{default:240,parseHTML:v.getDatasetAttribute("height")},data:{default:H,parseHTML:v.getDatasetAttribute("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},excalidrawProps:{},button:()=>({componentProps:{}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:s}){return["div",N.mergeAttributes(this.options.HTMLAttributes,e,v.nodeAttrsToDataset(s))]},addCommands(){return{setExcalidraw:e=>({tr:s,commands:i,chain:d})=>{var o,x,p;return e=e||{},e.data=e.data||H,((p=(x=(o=s.selection)==null?void 0:o.node)==null?void 0:x.type)==null?void 0:p.name)==this.name?i.updateAttributes(this.name,e):d().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return y.ReactNodeViewRenderer(ee)},addInputRules(){return[N.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});exports.Excalidraw=_;exports.RichTextExcalidraw=te;
|
package/lib/Excalidraw.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { N as k, n as $, m as B } from "./index-
|
|
2
|
-
import { N as U, c as R, a as j } from "./clsx-
|
|
1
|
+
import { N as k, n as $, m as B } from "./index-BblvcbTH.js";
|
|
2
|
+
import { N as U, c as R, a as j } from "./clsx-0OU6n9va.js";
|
|
3
3
|
import { jsx as t, jsxs as T } from "react/jsx-runtime";
|
|
4
4
|
import { Resizable as F } from "re-resizable";
|
|
5
5
|
import { useRef as X, useState as o, useCallback as v, useEffect as M, useMemo as q } from "react";
|
|
6
|
-
import { F as G, q as Y, A as S, h as J, u as K, m as Q, d as ee, E as te, G as re, D as ae, r as ne, s as ie, v as se, w as oe, B as le } from "./index-
|
|
6
|
+
import { F as G, q as Y, A as S, h as J, u as K, m as Q, d as ee, E as te, G as re, D as ae, r as ne, s as ie, v as se, w as oe, B as le } from "./index-X6WZUM9O.js";
|
|
7
7
|
import { n as de, g as D } from "./dom-dataset-CIEeltF6.js";
|
|
8
8
|
const ce = "_wrap_dra8y_1", ue = "_renderWrap_dra8y_7", he = "_handlerWrap_dra8y_30", pe = "_disabled_dra8y_40", x = {
|
|
9
9
|
wrap: ce,
|
package/lib/ExportPdf.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-Bcj8cyOO.cjs"),l=require("react/jsx-runtime"),m=require("./index-Gi752TMk.cjs");require("react");require("./theme.cjs");function y(e,n){var u;const t=document.createElement("iframe");t.setAttribute("style","position: absolute; width: 0; height: 0; top: 0; left: 0;"),document.body.appendChild(t);const o=t.contentDocument||((u=t.contentWindow)==null?void 0:u.document);if(!o)return;const{paperSize:d,title:i="React Tiptap Editor",margins:{top:s,right:a,bottom:r,left:c}}=n,p=`
|
|
2
2
|
<!DOCTYPE html>
|
|
3
3
|
<html lang="en">
|
|
4
4
|
<head>
|
package/lib/ExportPdf.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { E as b } from "./index-
|
|
1
|
+
import { E as b } from "./index-BblvcbTH.js";
|
|
2
2
|
import { jsx as f, Fragment as v } from "react/jsx-runtime";
|
|
3
|
-
import { u as y, d as x, A as E } from "./index-
|
|
3
|
+
import { u as y, d as x, A as E } from "./index-X6WZUM9O.js";
|
|
4
4
|
import "react";
|
|
5
5
|
import "./theme.js";
|
|
6
6
|
function P(o, i) {
|
package/lib/ExportWord.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./index-Bcj8cyOO.cjs"),u=require("docx"),n=require("prosemirror-docx"),i=require("react/jsx-runtime"),y=require("react"),a=require("./index-Gi752TMk.cjs");require("./theme.cjs");const g=typeof window<"u";function v(o,e){if(g){const r=window.URL.createObjectURL(o),t=document.createElement("a");return t.href=r,t.download=e,t.click(),window.URL.revokeObjectURL(r),Promise.resolve()}return console.error("Download is not supported in Node.js"),Promise.resolve()}function B(){const o=a.useButtonProps(p.name),[e,r]=y.useState(!1),{icon:t=void 0,tooltip:c=void 0,shortcutKeys:s=void 0,tooltipOptions:f={},action:d=void 0,isActive:m=void 0}=(o==null?void 0:o.componentProps)??{},{dataState:x,disabled:l,update:w}=a.useToggleActive(m),b=async()=>{l||e||d&&(r(!0),await d(),w(),r(!1))};return o?i.jsx(a.ActionButton,{action:b,dataState:x,disabled:l||e,icon:e?"Loader":t,shortcutKeys:s,tooltip:c,tooltipOptions:f}):i.jsx(i.Fragment,{})}const E={...n.defaultNodes,hardBreak:n.defaultNodes.hard_break,codeBlock:n.defaultNodes.code_block,orderedList:n.defaultNodes.ordered_list,listItem:n.defaultNodes.list_item,bulletList:n.defaultNodes.bullet_list,horizontalRule:n.defaultNodes.horizontal_rule,image(o,e){o.renderInline(e),o.closeBlock(e)},table(o,e){o.table(e,{tableOptions:{width:{size:100,type:u.WidthType.PERCENTAGE}}})}},W=new n.DocxSerializer(E,n.defaultMarks),p=h.Extension.create({name:"exportWord",addOptions(){var o;return{...(o=this.parent)==null?void 0:o.call(this),button:({editor:e,t:r})=>({componentProps:{icon:"ExportWord",action:()=>{var t;return e==null?void 0:e.commands.exportToWord((t=e==null?void 0:e.state)==null?void 0:t.doc)},tooltip:r("editor.exportWord.tooltip"),isActive:()=>!1,disabled:!1}})}},addCommands(){return{exportToWord:o=>async()=>{try{const e={getImageBuffer:async t=>{const s=await(await fetch(t)).arrayBuffer();return new Uint8Array(s)}},r=W.serialize(o,e);return u.Packer.toBlob(r).then(t=>v(new Blob([t]),"richtext-export-document.docx")),!0}catch(e){return console.error("Error exporting to Word:",e),!1}}}}});exports.ExportWord=p;exports.RichTextExportWord=B;
|
package/lib/ExportWord.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as w } from "./index-
|
|
1
|
+
import { E as w } from "./index-BblvcbTH.js";
|
|
2
2
|
import { Packer as x, WidthType as b } from "docx";
|
|
3
3
|
import { defaultNodes as n, DocxSerializer as h, defaultMarks as B } from "prosemirror-docx";
|
|
4
4
|
import { jsx as d, Fragment as v } from "react/jsx-runtime";
|
|
5
5
|
import { useState as y } from "react";
|
|
6
|
-
import { u as E, d as g, A as k } from "./index-
|
|
6
|
+
import { u as E, d as g, A as k } from "./index-X6WZUM9O.js";
|
|
7
7
|
import "./theme.js";
|
|
8
8
|
const W = typeof window < "u";
|
|
9
9
|
function A(e, o) {
|
package/lib/FontFamily.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("./index-BAb_UADw.cjs"),F=require("./index-CWw4s87s.cjs"),f=require("./index-Gi752TMk.cjs"),e=require("react/jsx-runtime"),m=require("react"),x=require("./ActionMenuButton-CXeFhner.cjs");require("./theme.cjs");const d=require("./dropdown-menu-yQ-sQ1k4.cjs");function M(){const{t:l}=F.useLocale(),o=f.useButtonProps(p.name),{icon:a=void 0,tooltip:u=void 0,items:r=[],isActive:s=void 0}=(o==null?void 0:o.componentProps)??{},{disabled:c,dataState:t}=f.useActive(s),n=m.useMemo(()=>(t==null?void 0:t.font)||l("editor.fontFamily.default.tooltip"),[t]);return o?e.jsxs(d.DropdownMenu,{children:[e.jsx(d.DropdownMenuTrigger,{asChild:!0,disabled:c,children:e.jsx(x.ActionMenuButton,{disabled:c,icon:a,title:(n==null?void 0:n.length)>12?`${n==null?void 0:n.slice(0,12)}...`:n,tooltip:u})}),e.jsx(d.DropdownMenuContent,{className:"richtext-w-full",children:r==null?void 0:r.map((i,y)=>{const h=i.font===l("editor.fontFamily.default.tooltip")?{}:{fontFamily:i.font};return e.jsxs(m.Fragment,{children:[e.jsx(d.DropdownMenuCheckboxItem,{checked:n===i.font,onClick:i.action,children:e.jsx("div",{className:"richtext-ml-1 richtext-h-full",style:h,children:i.font})}),i.font===l("editor.fontFamily.default.tooltip")&&e.jsx(d.DropdownMenuSeparator,{})]},`font-family-${y}`)})})]}):e.jsx(e.Fragment,{})}const p=v.FontFamily.extend({addOptions(){var l;return{...(l=this.parent)==null?void 0:l.call(this),fontFamilyList:F.DEFAULT_FONT_FAMILY_LIST,button({editor:o,extension:a,t:u}){var c;const r=f.ensureNameValueOptions(((c=a==null?void 0:a.options)==null?void 0:c.fontFamilyList)||[]),s=r.map(t=>({action:()=>{if(t.value==="Default"){o.chain().focus().unsetFontFamily().run();return}o.chain().focus().setFontFamily(t.value).run()},isActive:()=>o.isActive("textStyle",{fontFamily:t.value})||!1,title:t.name,font:t.value,default:t.value==="Default"}));return{componentProps:{tooltip:u("editor.fontFamily.tooltip"),disabled:!1,items:s,isActive:()=>{const t=s==null?void 0:s.find(i=>i.isActive());return t&&!t.default?t:{title:u("editor.fontFamily.default.tooltip"),font:u("editor.fontFamily.default.tooltip"),isActive:()=>!1,disabled:!1}},icon:"MenuDown",fontFamilyList:r}}}}}});exports.FontFamily=p;exports.RichTextFontFamily=M;
|
package/lib/FontFamily.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { F as p } from "./index-
|
|
1
|
+
import { F as p } from "./index-zw-Kd38i.js";
|
|
2
2
|
import { u as F, D as y } from "./index-oj858lQO.js";
|
|
3
|
-
import { u as h, e as v, f as A } from "./index-
|
|
3
|
+
import { u as h, e as v, f as A } from "./index-X6WZUM9O.js";
|
|
4
4
|
import { jsx as i, Fragment as D, jsxs as f } from "react/jsx-runtime";
|
|
5
5
|
import { useMemo as M, Fragment as w } from "react";
|
|
6
|
-
import { A as L } from "./ActionMenuButton-
|
|
6
|
+
import { A as L } from "./ActionMenuButton-8cTG45Ft.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { D as g, a as x, b, c as T, d as C } from "./dropdown-menu-
|
|
8
|
+
import { D as g, a as x, b, c as T, d as C } from "./dropdown-menu-ROihzXsP.js";
|
|
9
9
|
function S() {
|
|
10
10
|
const { t: a } = F(), n = h(N.name), {
|
|
11
11
|
icon: s = void 0,
|
package/lib/FontSize.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./index-Bcj8cyOO.cjs"),x=require("./index-CWw4s87s.cjs"),S=require("./index-Gi752TMk.cjs"),o=require("react/jsx-runtime"),p=require("react"),h=require("./ActionMenuButton-CXeFhner.cjs");require("./theme.cjs");const l=require("./dropdown-menu-yQ-sQ1k4.cjs");function v(){const{t}=x.useLocale(),n=S.useButtonProps(z.name),{icon:d=void 0,tooltip:s=void 0,items:c=[],isActive:a=void 0}=(n==null?void 0:n.componentProps)??{},{disabled:u,dataState:e}=S.useActive(a),r=p.useMemo(()=>(e==null?void 0:e.title)||t("editor.fontSize.default.tooltip"),[e]);return n?o.jsxs(l.DropdownMenu,{children:[o.jsx(l.DropdownMenuTrigger,{asChild:!0,disabled:u,children:o.jsx(h.ActionMenuButton,{disabled:u,icon:d,title:r,tooltip:s})}),o.jsx(l.DropdownMenuContent,{className:"richtext-max-h-96 richtext-w-32 richtext-overflow-y-auto",children:c==null?void 0:c.map((i,f)=>o.jsxs(p.Fragment,{children:[o.jsx(l.DropdownMenuCheckboxItem,{checked:r===i.title,onClick:i.action,children:o.jsx("div",{className:"richtext-ml-1 richtext-h-full",children:i.title})}),i.title===t("editor.fontSize.default.tooltip")&&o.jsx(l.DropdownMenuSeparator,{})]},`font-size-${f}`))})]}):o.jsx(o.Fragment,{})}const z=m.Extension.create({name:"fontSize",addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),types:["textStyle"],fontSizes:x.DEFAULT_FONT_SIZE_LIST,button({editor:n,extension:d,t:s}){var u;const a=S.ensureNameValueOptions((u=d.options)==null?void 0:u.fontSizes).map(e=>({title:e.value==="Default"?s("editor.fontSize.default.tooltip"):String(e.name),isActive:()=>{const{fontSize:r}=n.getAttributes("textStyle"),i=e.value==="Default",f=r==null||r==="";return i&&f?!0:n.isActive({fontSize:String(e.value)})||!1},action:()=>{if(e.value==="Default"){n.commands.unsetFontSize();return}n.commands.setFontSize(String(e.value))},default:e.value==="Default"||!1}));return{componentProps:{editor:n,tooltip:s("editor.fontSize.tooltip"),disabled:!1,items:a,maxHeight:280,icon:"MenuDown",isActive:()=>{const e=(a||[]).find(i=>i.isActive());return e&&!e.default?e:{title:s("editor.fontSize.default.tooltip"),isActive:()=>!1}}}}}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize.replaceAll(/["']+/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}});exports.FontSize=z;exports.RichTextFontSize=v;
|
package/lib/FontSize.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { E as m } from "./index-
|
|
1
|
+
import { E as m } from "./index-BblvcbTH.js";
|
|
2
2
|
import { u as p, h as S } from "./index-oj858lQO.js";
|
|
3
|
-
import { u as z, e as h, f as v } from "./index-
|
|
3
|
+
import { u as z, e as h, f as v } from "./index-X6WZUM9O.js";
|
|
4
4
|
import { jsx as r, Fragment as x, jsxs as d } from "react/jsx-runtime";
|
|
5
5
|
import { useMemo as A, Fragment as D } from "react";
|
|
6
|
-
import { A as y } from "./ActionMenuButton-
|
|
6
|
+
import { A as y } from "./ActionMenuButton-8cTG45Ft.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { D as F, a as M, b as g, c as w, d as T } from "./dropdown-menu-
|
|
8
|
+
import { D as F, a as M, b as g, c as w, d as T } from "./dropdown-menu-ROihzXsP.js";
|
|
9
9
|
function $() {
|
|
10
10
|
const { t: e } = p(), n = z(b.name), {
|
|
11
11
|
icon: f = void 0,
|
package/lib/Heading.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./index-Bcj8cyOO.cjs"),M=require("./index-CWw4s87s.cjs"),s=require("react/jsx-runtime"),x=require("react"),v=require("./index-Gi752TMk.cjs"),b=require("./ActionMenuButton-CXeFhner.cjs");require("./theme.cjs");const h=require("./dropdown-menu-yQ-sQ1k4.cjs");var j=f.Node3.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,f.mergeAttributes(this.options.HTMLAttributes,t),0]},parseMarkdown:(e,t)=>t.createNode("heading",{level:e.depth||1},t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>{var l;const i=(l=e.attrs)!=null&&l.level?parseInt(e.attrs.level,10):1,a="#".repeat(i);return e.content?`${a} ${t.renderChildren(e.content)}`:""},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,"paragraph",e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>f.textblockTypeInputRule({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});function m(){const{t:e}=M.useLocale(),t=v.useButtonProps(A.name),{icon:l=void 0,tooltip:i=void 0,isActive:a=void 0,items:o=[]}=(t==null?void 0:t.componentProps)??{},{disabled:p,dataState:d}=v.useActive(a),r=x.useMemo(()=>(d==null?void 0:d.title)||e("editor.paragraph.tooltip"),[d]);return t?s.jsxs(h.DropdownMenu,{children:[s.jsx(h.DropdownMenuTrigger,{asChild:!0,disabled:p,children:s.jsx(b.ActionMenuButton,{disabled:p,icon:l,title:r,tooltip:i})}),s.jsx(h.DropdownMenuContent,{className:"richtext-w-full",children:o==null?void 0:o.map((n,c)=>{var u,g;return s.jsxs(x.Fragment,{children:[s.jsxs(h.DropdownMenuCheckboxItem,{checked:r===n.title,onClick:n.action,children:[s.jsx("div",{className:v.cn("richtext-ml-1 richtext-h-full",{"":n.level==="Paragraph","heading-1":n.level===1,"heading-2":n.level===2,"heading-3":n.level===3,"heading-4":n.level===4,"heading-5":n.level===5,"heading-6":n.level===6}),children:n.title}),!!((u=n==null?void 0:n.shortcutKeys)!=null&&u.length)&&s.jsx(h.DropdownMenuShortcut,{className:"richtext-pl-4",children:(g=n==null?void 0:n.shortcutKeys)==null?void 0:g.map(H=>v.getShortcutKey(H)).join(" ")})]}),n.level==="Paragraph"&&s.jsx(h.DropdownMenuSeparator,{})]},`heading-k-${c}`)})})]}):s.jsx(s.Fragment,{})}const A=j.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),levels:M.HEADINGS,button({editor:t,extension:l,t:i}){var d;const a=((d=l.options)==null?void 0:d.levels)||[],o=a.map(r=>{var c;const n=r==="Paragraph";return{action:()=>{if(n){const u=a.find(g=>t.isActive("heading",{level:g}));u&&u!=="Paragraph"&&t.commands.toggleHeading({level:u});return}t.commands.toggleHeading({level:r})},isActive:()=>n?!1:t.isActive("heading",{level:r})||!1,disabled:!t.can().toggleHeading({level:r}),title:i(n?"editor.paragraph.tooltip":`editor.heading.h${r}.tooltip`),level:r,shortcutKeys:((c=l.options.shortcutKeys)==null?void 0:c[r])??["alt","mod",`${r}`],default:n}}),p=o.filter(r=>r.disabled).length===o.length;return{componentProps:{tooltip:i("editor.heading.tooltip"),disabled:p,items:o,icon:"MenuDown",isActive:()=>{const r=o==null?void 0:o.find(c=>c.isActive());return r&&!r.default?r:{title:i("editor.paragraph.tooltip"),level:0,isActive:()=>!1}},levels:a}}}}}});exports.Heading=A;exports.RichTextHeading=m;
|
package/lib/Heading.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { N as f, t as m, m as A } from "./index-
|
|
1
|
+
import { N as f, t as m, m as A } from "./index-BblvcbTH.js";
|
|
2
2
|
import { u as M, H } from "./index-oj858lQO.js";
|
|
3
3
|
import { jsx as d, Fragment as $, jsxs as g } from "react/jsx-runtime";
|
|
4
4
|
import { useMemo as b, Fragment as w } from "react";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { u as x, e as D, c as y, l as N } from "./index-X6WZUM9O.js";
|
|
6
|
+
import { A as k } from "./ActionMenuButton-8cTG45Ft.js";
|
|
7
7
|
import "./theme.js";
|
|
8
|
-
import { D as L, a as C, b as T, c as I, e as K, d as P } from "./dropdown-menu-
|
|
8
|
+
import { D as L, a as C, b as T, c as I, e as K, d as P } from "./dropdown-menu-ROihzXsP.js";
|
|
9
9
|
var R = f.create({
|
|
10
10
|
name: "heading",
|
|
11
11
|
addOptions() {
|
|
@@ -66,15 +66,15 @@ var R = f.create({
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
function z() {
|
|
69
|
-
const { t: e } = M(), t =
|
|
69
|
+
const { t: e } = M(), t = x(S.name), {
|
|
70
70
|
icon: a = void 0,
|
|
71
71
|
tooltip: o = void 0,
|
|
72
72
|
isActive: i = void 0,
|
|
73
73
|
items: s = []
|
|
74
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: p, dataState: l } =
|
|
74
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: p, dataState: l } = D(i), r = b(() => (l == null ? void 0 : l.title) || e("editor.paragraph.tooltip"), [l]);
|
|
75
75
|
return t ? /* @__PURE__ */ g(L, { children: [
|
|
76
76
|
/* @__PURE__ */ d(C, { asChild: !0, disabled: p, children: /* @__PURE__ */ d(
|
|
77
|
-
|
|
77
|
+
k,
|
|
78
78
|
{
|
|
79
79
|
disabled: p,
|
|
80
80
|
icon: a,
|
|
@@ -89,7 +89,7 @@ function z() {
|
|
|
89
89
|
/* @__PURE__ */ d(
|
|
90
90
|
"div",
|
|
91
91
|
{
|
|
92
|
-
className:
|
|
92
|
+
className: y("richtext-ml-1 richtext-h-full", {
|
|
93
93
|
"": n.level === "Paragraph",
|
|
94
94
|
"heading-1": n.level === 1,
|
|
95
95
|
"heading-2": n.level === 2,
|
|
@@ -101,7 +101,7 @@ function z() {
|
|
|
101
101
|
children: n.title
|
|
102
102
|
}
|
|
103
103
|
),
|
|
104
|
-
!!((u = n == null ? void 0 : n.shortcutKeys) != null && u.length) && /* @__PURE__ */ d(K, { className: "richtext-pl-4", children: (h = n == null ? void 0 : n.shortcutKeys) == null ? void 0 : h.map((v) =>
|
|
104
|
+
!!((u = n == null ? void 0 : n.shortcutKeys) != null && u.length) && /* @__PURE__ */ d(K, { className: "richtext-pl-4", children: (h = n == null ? void 0 : n.shortcutKeys) == null ? void 0 : h.map((v) => N(v)).join(" ") })
|
|
105
105
|
] }),
|
|
106
106
|
n.level === "Paragraph" && /* @__PURE__ */ d(P, {})
|
|
107
107
|
] }, `heading-k-${c}`);
|
package/lib/Highlight.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-Bcj8cyOO.cjs"),r=require("react/jsx-runtime"),p=require("react"),h=require("./index-Gi752TMk.cjs"),m=require("./separator-DpaS43Gt.cjs");require("./theme.cjs");var L=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,k=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,H=l.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||l.getStyleProperty(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",l.mergeAttributes(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,s){const i=/^(==)([^=]+)(==)/.exec(t);if(i){const n=i[2].trim(),u=s.inlineTokens(n);return{type:"highlight",raw:i[0],text:n,tokens:u}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[l.markInputRule({find:L,type:this.type})]},addPasteRules(){return[l.markPasteRule({find:k,type:this.type})]}});function M({fill:t}){return r.jsx("svg",{height:"18px",version:"1.1",viewBox:"0 0 256 256",width:"18px",xmlns:"http://www.w3.org/2000/svg",children:r.jsx("g",{fill:"none",fillRule:"evenodd",stroke:"none",strokeWidth:1,children:r.jsxs("g",{id:"icon/背景颜色",children:[r.jsx("g",{fill:"currentColor",children:r.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",children:[r.jsx("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),r.jsx("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),r.jsx("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),r.jsx("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",fill:typeof t=="string"?t:"none",id:"矩形"})]})})})}function v(){const t=h.useButtonProps(f.name),{tooltip:e=void 0,isActive:s=void 0,defaultColor:o=void 0,colors:i,action:n,shortcutKeys:u}=(t==null?void 0:t.componentProps)??{},{disabled:c,dataState:a}=h.useActive(s),[x,g]=p.useState(o);p.useEffect(()=>{g(a)},[a]);function C(d){c||n&&(n==null||n(d),g(d))}return t?r.jsx(m.ColorPicker,{colors:i,disabled:c,highlight:!0,onChange:C,value:x,children:r.jsx(h.ActionButton,{disabled:c,tooltip:e,shortcutKeys:u,children:r.jsxs("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm",children:[r.jsx(M,{fill:a}),r.jsx(h.IconComponent,{className:"!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",name:"MenuDown"})]})})}):r.jsx(r.Fragment,{})}const f=H.extend({addStorage(){return{currentColor:this.options.defaultColor||void 0}},addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),multicolor:!0,button:({editor:e,t:s,extension:o})=>({componentProps:{action:i=>{if(typeof i=="string"){e.storage.highlight.currentColor=i,e.chain().focus().setHighlight({color:i}).run();return}e.chain().focus().unsetHighlight().run()},isActive:()=>{const{color:i}=e.getAttributes("highlight");return i},disabled:!1,shortcutKeys:o.options.shortcutKeys??["⇧","mod","H"],tooltip:s("editor.highlight.tooltip"),defaultColor:o.options.defaultColor}})}},addKeyboardShortcuts(){var t;return{...(t=this.parent)==null?void 0:t.call(this),"Mod-Shift-h":()=>{const e=this.storage.currentColor||this.options.defaultColor;if(!e){const{color:o}=this.editor.getAttributes("highlight");return o?this.editor.chain().focus().unsetHighlight().run():!1}return this.editor.isActive("highlight",{color:e})?this.editor.chain().focus().unsetHighlight().run():this.editor.chain().focus().setHighlight({color:e}).run()}}}});exports.Highlight=f;exports.RichTextHighlight=v;
|
package/lib/Highlight.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { M as f,
|
|
2
|
-
import { jsx as r, jsxs as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { u as H, e as
|
|
5
|
-
import { C as
|
|
1
|
+
import { M as f, h as m, j as C, m as L, g as x } from "./index-BblvcbTH.js";
|
|
2
|
+
import { jsx as r, jsxs as u, Fragment as k } from "react/jsx-runtime";
|
|
3
|
+
import { useState as M, useEffect as v } from "react";
|
|
4
|
+
import { u as H, e as y, A, I as b } from "./index-X6WZUM9O.js";
|
|
5
|
+
import { C as w } from "./separator-CBPrZizK.js";
|
|
6
6
|
import "./theme.js";
|
|
7
|
-
|
|
7
|
+
var R = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, T = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, S = f.create({
|
|
8
8
|
name: "highlight",
|
|
9
9
|
addOptions() {
|
|
10
10
|
return {
|
|
@@ -16,7 +16,11 @@ const k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, b = /(?:^|\s)(==(?!\s+
|
|
|
16
16
|
return this.options.multicolor ? {
|
|
17
17
|
color: {
|
|
18
18
|
default: null,
|
|
19
|
-
|
|
19
|
+
// Prefer `data-color` (set by our own `renderHTML`) for lossless
|
|
20
|
+
// round-trips. Otherwise parse the raw inline `style` attribute so
|
|
21
|
+
// the original color format (e.g. `#rrggbb`) is preserved instead of
|
|
22
|
+
// the canonicalized `rgb(...)` value from `element.style.backgroundColor`.
|
|
23
|
+
parseHTML: (t) => t.getAttribute("data-color") || x(t, "background-color") || t.style.backgroundColor,
|
|
20
24
|
renderHTML: (t) => t.color ? {
|
|
21
25
|
"data-color": t.color,
|
|
22
26
|
style: `background-color: ${t.color}; color: inherit`
|
|
@@ -32,7 +36,26 @@ const k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, b = /(?:^|\s)(==(?!\s+
|
|
|
32
36
|
];
|
|
33
37
|
},
|
|
34
38
|
renderHTML({ HTMLAttributes: t }) {
|
|
35
|
-
return ["mark",
|
|
39
|
+
return ["mark", L(this.options.HTMLAttributes, t), 0];
|
|
40
|
+
},
|
|
41
|
+
renderMarkdown: (t, e) => `==${e.renderChildren(t)}==`,
|
|
42
|
+
parseMarkdown: (t, e) => e.applyMark("highlight", e.parseInline(t.tokens || [])),
|
|
43
|
+
markdownTokenizer: {
|
|
44
|
+
name: "highlight",
|
|
45
|
+
level: "inline",
|
|
46
|
+
start: (t) => t.indexOf("=="),
|
|
47
|
+
tokenize(t, e, s) {
|
|
48
|
+
const i = /^(==)([^=]+)(==)/.exec(t);
|
|
49
|
+
if (i) {
|
|
50
|
+
const n = i[2].trim(), l = s.inlineTokens(n);
|
|
51
|
+
return {
|
|
52
|
+
type: "highlight",
|
|
53
|
+
raw: i[0],
|
|
54
|
+
text: n,
|
|
55
|
+
tokens: l
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
36
59
|
},
|
|
37
60
|
addCommands() {
|
|
38
61
|
return {
|
|
@@ -48,22 +71,22 @@ const k = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, b = /(?:^|\s)(==(?!\s+
|
|
|
48
71
|
},
|
|
49
72
|
addInputRules() {
|
|
50
73
|
return [
|
|
51
|
-
|
|
52
|
-
find:
|
|
74
|
+
C({
|
|
75
|
+
find: R,
|
|
53
76
|
type: this.type
|
|
54
77
|
})
|
|
55
78
|
];
|
|
56
79
|
},
|
|
57
80
|
addPasteRules() {
|
|
58
81
|
return [
|
|
59
|
-
|
|
60
|
-
find:
|
|
82
|
+
m({
|
|
83
|
+
find: T,
|
|
61
84
|
type: this.type
|
|
62
85
|
})
|
|
63
86
|
];
|
|
64
87
|
}
|
|
65
88
|
});
|
|
66
|
-
function
|
|
89
|
+
function I({ fill: t }) {
|
|
67
90
|
return /* @__PURE__ */ r(
|
|
68
91
|
"svg",
|
|
69
92
|
{
|
|
@@ -72,8 +95,8 @@ function w({ fill: t }) {
|
|
|
72
95
|
viewBox: "0 0 256 256",
|
|
73
96
|
width: "18px",
|
|
74
97
|
xmlns: "http://www.w3.org/2000/svg",
|
|
75
|
-
children: /* @__PURE__ */ r("g", { fill: "none", fillRule: "evenodd", stroke: "none", strokeWidth: 1, children: /* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */ r("g", { fill: "currentColor", children: /* @__PURE__ */
|
|
98
|
+
children: /* @__PURE__ */ r("g", { fill: "none", fillRule: "evenodd", stroke: "none", strokeWidth: 1, children: /* @__PURE__ */ u("g", { id: "icon/背景颜色", children: [
|
|
99
|
+
/* @__PURE__ */ r("g", { fill: "currentColor", children: /* @__PURE__ */ u("g", { transform: "translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)", children: [
|
|
77
100
|
/* @__PURE__ */ r(
|
|
78
101
|
"path",
|
|
79
102
|
{
|
|
@@ -108,36 +131,39 @@ function w({ fill: t }) {
|
|
|
108
131
|
}
|
|
109
132
|
);
|
|
110
133
|
}
|
|
111
|
-
function
|
|
112
|
-
const t = H(
|
|
134
|
+
function E() {
|
|
135
|
+
const t = H(P.name), {
|
|
113
136
|
tooltip: e = void 0,
|
|
114
|
-
isActive:
|
|
115
|
-
defaultColor:
|
|
116
|
-
colors:
|
|
117
|
-
action:
|
|
118
|
-
shortcutKeys:
|
|
119
|
-
} = (t == null ? void 0 : t.componentProps) ?? {}, {
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
isActive: s = void 0,
|
|
138
|
+
defaultColor: o = void 0,
|
|
139
|
+
colors: i,
|
|
140
|
+
action: n,
|
|
141
|
+
shortcutKeys: l
|
|
142
|
+
} = (t == null ? void 0 : t.componentProps) ?? {}, { disabled: h, dataState: a } = y(s), [g, c] = M(o);
|
|
143
|
+
v(() => {
|
|
144
|
+
c(a);
|
|
145
|
+
}, [a]);
|
|
146
|
+
function p(d) {
|
|
147
|
+
h || n && (n == null || n(d), c(d));
|
|
122
148
|
}
|
|
123
149
|
return t ? /* @__PURE__ */ r(
|
|
124
|
-
|
|
150
|
+
w,
|
|
125
151
|
{
|
|
126
|
-
colors:
|
|
127
|
-
disabled:
|
|
152
|
+
colors: i,
|
|
153
|
+
disabled: h,
|
|
128
154
|
highlight: !0,
|
|
129
|
-
onChange:
|
|
130
|
-
value:
|
|
155
|
+
onChange: p,
|
|
156
|
+
value: g,
|
|
131
157
|
children: /* @__PURE__ */ r(
|
|
132
|
-
|
|
158
|
+
A,
|
|
133
159
|
{
|
|
134
|
-
disabled:
|
|
160
|
+
disabled: h,
|
|
135
161
|
tooltip: e,
|
|
136
|
-
shortcutKeys:
|
|
137
|
-
children: /* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */ r(
|
|
162
|
+
shortcutKeys: l,
|
|
163
|
+
children: /* @__PURE__ */ u("span", { className: "richtext-flex richtext-items-center richtext-justify-center richtext-gap-[4px] richtext-text-sm", children: [
|
|
164
|
+
/* @__PURE__ */ r(I, { fill: a }),
|
|
139
165
|
/* @__PURE__ */ r(
|
|
140
|
-
|
|
166
|
+
b,
|
|
141
167
|
{
|
|
142
168
|
className: "!richtext-h-3 !richtext-w-3 richtext-text-zinc-500",
|
|
143
169
|
name: "MenuDown"
|
|
@@ -147,9 +173,9 @@ function z() {
|
|
|
147
173
|
}
|
|
148
174
|
)
|
|
149
175
|
}
|
|
150
|
-
) : /* @__PURE__ */ r(
|
|
176
|
+
) : /* @__PURE__ */ r(k, {});
|
|
151
177
|
}
|
|
152
|
-
const
|
|
178
|
+
const P = /* @__PURE__ */ S.extend({
|
|
153
179
|
addStorage() {
|
|
154
180
|
return {
|
|
155
181
|
// Stores the currently selected highlight color; undefined indicates "No Fill".
|
|
@@ -162,20 +188,23 @@ const T = /* @__PURE__ */ R.extend({
|
|
|
162
188
|
return {
|
|
163
189
|
...(t = this.parent) == null ? void 0 : t.call(this),
|
|
164
190
|
multicolor: !0,
|
|
165
|
-
button: ({ editor: e, t:
|
|
191
|
+
button: ({ editor: e, t: s, extension: o }) => ({
|
|
166
192
|
componentProps: {
|
|
167
|
-
action: (
|
|
168
|
-
if (typeof
|
|
169
|
-
e.storage.highlight.currentColor =
|
|
193
|
+
action: (i) => {
|
|
194
|
+
if (typeof i == "string") {
|
|
195
|
+
e.storage.highlight.currentColor = i, e.chain().focus().setHighlight({ color: i }).run();
|
|
170
196
|
return;
|
|
171
197
|
}
|
|
172
198
|
e.chain().focus().unsetHighlight().run();
|
|
173
199
|
},
|
|
174
|
-
isActive: () =>
|
|
200
|
+
isActive: () => {
|
|
201
|
+
const { color: i } = e.getAttributes("highlight");
|
|
202
|
+
return i;
|
|
203
|
+
},
|
|
175
204
|
disabled: !1,
|
|
176
|
-
shortcutKeys:
|
|
177
|
-
tooltip:
|
|
178
|
-
defaultColor:
|
|
205
|
+
shortcutKeys: o.options.shortcutKeys ?? ["⇧", "mod", "H"],
|
|
206
|
+
tooltip: s("editor.highlight.tooltip"),
|
|
207
|
+
defaultColor: o.options.defaultColor
|
|
179
208
|
}
|
|
180
209
|
})
|
|
181
210
|
};
|
|
@@ -187,8 +216,8 @@ const T = /* @__PURE__ */ R.extend({
|
|
|
187
216
|
"Mod-Shift-h": () => {
|
|
188
217
|
const e = this.storage.currentColor || this.options.defaultColor;
|
|
189
218
|
if (!e) {
|
|
190
|
-
const { color:
|
|
191
|
-
return
|
|
219
|
+
const { color: o } = this.editor.getAttributes("highlight");
|
|
220
|
+
return o ? this.editor.chain().focus().unsetHighlight().run() : !1;
|
|
192
221
|
}
|
|
193
222
|
return this.editor.isActive("highlight", {
|
|
194
223
|
color: e
|
|
@@ -198,6 +227,6 @@ const T = /* @__PURE__ */ R.extend({
|
|
|
198
227
|
}
|
|
199
228
|
});
|
|
200
229
|
export {
|
|
201
|
-
|
|
202
|
-
|
|
230
|
+
P as Highlight,
|
|
231
|
+
E as RichTextHighlight
|
|
203
232
|
};
|