react-reason-editor 1.0.96 → 1.0.98
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/dist/{BubbleMenus-F5PFH6eV.cjs → BubbleMenus-3RiQc4lw.cjs} +1 -1
- package/dist/{BubbleMenus-eYDoohA4.js → BubbleMenus-CFzQBrVG.js} +1 -1
- package/dist/{ImportWord-cr386RpI.js → ImportWord-DtON-y5N.js} +1 -1
- package/dist/ImportWord.cjs +1 -1
- package/dist/ImportWord.js +1 -1
- package/dist/{Pagination-yjRu_qJK.cjs → Pagination-CGxVvD1Y.cjs} +1 -1
- package/dist/{Pagination-B8rfYYi_.js → Pagination-DYCCm6cp.js} +1 -1
- package/dist/Pagination.cjs +1 -1
- package/dist/Pagination.js +1 -1
- package/dist/{ReasonDocs-D_c14vkF.js → ReasonDocs-BXtUm4zk.js} +2 -2
- package/dist/{ReasonDocs-cELUZvnA.cjs → ReasonDocs-CsmZMk6W.cjs} +1 -1
- package/dist/{RichTextProvider-B5fdgtFs.js → RichTextProvider-BcsYTR6Z.js} +1 -1
- package/dist/{RichTextProvider-DJWvDmyS.cjs → RichTextProvider-KRSFedCE.cjs} +1 -1
- package/dist/docs-agent/plate/kits/markdown-kit.d.ts +8 -0
- package/dist/docs-agent/plate/plate-editor-config.d.ts +30 -0
- package/dist/docs-agent.cjs +1 -1
- package/dist/docs-agent.js +1 -1
- package/dist/editor-kit.cjs +1 -1
- package/dist/editor-kit.js +1 -1
- package/dist/{editorConfig-Duji4hwm.js → editorConfig-9-ZxkRbw.js} +1 -1
- package/dist/{editorConfig-2pHxtmeI.cjs → editorConfig-DF8EAH_P.cjs} +1 -1
- package/dist/extensions/Twitter/Twitter.d.ts +6 -1
- package/dist/{html-to-docx.esm-BLUcO7pp-DLRiI93_.cjs → html-to-docx.esm-BLUcO7pp-BKB2FJoB.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/reason-docs.cjs +1 -1
- package/dist/reason-docs.js +1 -1
- package/dist/reason-toolbar-skin-DY4w9SRA.cjs +1 -0
- package/dist/{reason-toolbar-skin-CQzJJqJy.js → reason-toolbar-skin-DarRq6V-.js} +4 -4
- package/package.json +3 -3
- package/dist/reason-toolbar-skin-SPGcsiuT.cjs +0 -1
package/dist/ImportWord.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as o,t as r}from"./ImportWord-
|
|
1
|
+
import{n as o,t as r}from"./ImportWord-DtON-y5N.js";export{r as ImportWord,o as RichTextImportWord};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=require("@tiptap/core"),t=require("@tiptap/pm/state"),a=require("@tiptap/pm/view"),n=require("@tiptap/pm/transform");var o=(e,t)=>{const a={"rm-page-height":`${t.pageHeight}px`,"rm-margin-top":`${t.marginTop}px`,"rm-margin-bottom":`${t.marginBottom}px`,"rm-margin-left":`${t.marginLeft}px`,"rm-margin-right":`${t.marginRight}px`,"rm-content-margin-top":`${t.contentMarginTop}px`,"rm-content-margin-bottom":`${t.contentMarginBottom}px`,"rm-page-gap-border-color":`${t.pageGapBorderColor}`,"rm-page-width":`${t.pageWidth}px`};Object.entries(a).forEach(([t,a])=>{e.style.setProperty(`--${t}`,a)})},r=(e,t,a,n,o,r)=>({pageHeight:e,pageWidth:t,marginTop:a,marginBottom:n,marginLeft:o,marginRight:r}),i=(e,t)=>"actual"===t?`.rm-page-header-${e}`:`.rm-page-header-${e} .rm-page-header-content`,g=(e,t)=>"actual"===t?`.rm-page-footer-${e}`:`.rm-page-footer-${e} .rm-page-footer-content`;function p(e,t){if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return!1;const a=[{x:e,y:t}];for(;a.length;){const e=a.pop();if(!e)continue;const{x:t,y:n}=e;if(t===n)continue;if(typeof t!=typeof n)return!1;if("object"!=typeof t)return!1;if(null==t||null==n)return!1;const o=Object.keys(t),r=Object.keys(n);if(o.length!==r.length)return!1;for(const i of o){if(!(i in n))return!1;const e=t[i],o=n[i];if(e!==o)if("object"==typeof e&&"object"==typeof o)a.push({x:e,y:o});else if(e!==o)return!1}}return!0}function s(e,t){return[...Object.keys(e),...Object.keys(t)].map(Number)}function d(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-footer"),o.classList.add(`rm-page-footer-${n||0}`),o.style.overflow="visible",o.style.position="relative",o.style.cursor="pointer";const r=document.createElement("div");r.classList.add("rm-page-footer-content"),r.style.width="100%",r.style.overflow="hidden";const i=e.replace("{page}",'<span class="rm-page-number"></span>'),g=t.replace("{page}",'<span class="rm-page-number"></span>'),p=document.createElement("div");p.classList.add("rm-page-footer-left"),p.innerHTML=g;const s=document.createElement("div");return s.classList.add("rm-page-footer-right"),s.innerHTML=i,r.append(p,s),o.append(r),o.addEventListener("click",a),o}function m(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-header"),o.classList.add(`rm-page-header-${n||0}`),o.style.overflow="hidden",o.style.cursor="pointer",o.style.position="relative";const r=document.createElement("div");r.classList.add("rm-page-header-content"),r.style.width="100%",r.style.overflow="hidden";const i=t.replace("{page}",'<span class="rm-page-number-plus"></span>'),g=e.replace("{page}",'<span class="rm-page-number-plus"></span>'),p=document.createElement("div");p.classList.add("rm-page-header-left"),p.innerHTML=i;const s=document.createElement("div");return s.classList.add("rm-page-header-right"),s.innerHTML=g,r.append(p,s),o.append(r),o.addEventListener("click",a),o}var l=(e,t,a)=>{const n=e.contentMarginTop+e.marginTop+t,o=e.contentMarginBottom+e.marginBottom+a;return{_pageHeaderHeight:n,_pageFooterHeight:o,_pageHeight:e.pageHeight-n-o}},c=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},h=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},f=new t.PluginKey("brDecoration");function u(e){const t=[];return e.descendants((e,n)=>{if("hardBreak"===e.type.name){const e=n+1,o=a.Decoration.widget(e,()=>{const e=document.createElement("span");return e.classList.add("rm-br-decoration"),e});t.push(o)}}),a.DecorationSet.create(e,t)}var b={enabled:!0,pageBreakBackground:"#ffffff",pageHeight:800,pageWidth:789,marginTop:20,marginBottom:20,marginLeft:50,marginRight:50,pageGap:50,contentMarginTop:10,contentMarginBottom:10,footerRight:"{page}",footerLeft:"",headerRight:"",headerLeft:"",customHeader:{},customFooter:{}},v=Object.assign({pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5"},b),y=(e,t=!0)=>{var a;const n=e.querySelector("[data-rm-pagination]");if(t){if(e.removeAttribute("rm-pagination-disabled"),n){const t=null===(a=n.lastElementChild)||void 0===a?void 0:a.querySelector(".breaker");if(t){const a=t.offsetTop+t.offsetHeight;e.style.minHeight=`calc(${a}px + 2px)`}}}else e.setAttribute("rm-pagination-disabled",""),e.style.minHeight="auto"},w=(e,t)=>{var a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,y,w;const L={enabled:null!==(a=e.enabled)&&void 0!==a?a:v.enabled,pageBreakBackground:null!==(n=e.pageBreakBackground)&&void 0!==n?n:v.pageBreakBackground,pageHeight:null!==(o=e.pageHeight)&&void 0!==o?o:v.pageHeight,pageWidth:null!==(r=e.pageWidth)&&void 0!==r?r:b.pageWidth,marginTop:null!==(i=e.marginTop)&&void 0!==i?i:b.marginTop,marginBottom:null!==(g=e.marginBottom)&&void 0!==g?g:b.marginBottom,marginLeft:null!==(p=e.marginLeft)&&void 0!==p?p:b.marginLeft,marginRight:null!==(s=e.marginRight)&&void 0!==s?s:b.marginRight,pageGap:null!==(d=e.pageGap)&&void 0!==d?d:b.pageGap,contentMarginTop:null!==(m=e.contentMarginTop)&&void 0!==m?m:b.contentMarginTop,contentMarginBottom:null!==(l=e.contentMarginBottom)&&void 0!==l?l:b.contentMarginBottom,footerRight:null!==(c=e.footerRight)&&void 0!==c?c:b.footerRight,footerLeft:null!==(h=e.footerLeft)&&void 0!==h?h:b.footerLeft,headerRight:null!==(f=e.headerRight)&&void 0!==f?f:b.headerRight,headerLeft:null!==(u=e.headerLeft)&&void 0!==u?u:b.headerLeft,customHeader:null!==(y=e.customHeader)&&void 0!==y?y:b.customHeader,customFooter:null!==(w=e.customFooter)&&void 0!==w?w:b.customFooter};return{config:L,options:Object.assign(Object.assign({},t),L)}},L=e=>{var t,a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,y;return{enabled:null!==(t=e.enabled)&&void 0!==t?t:v.enabled,pageBreakBackground:null!==(a=e.pageBreakBackground)&&void 0!==a?a:v.pageBreakBackground,pageHeight:null!==(n=e.pageHeight)&&void 0!==n?n:v.pageHeight,pageWidth:null!==(o=e.pageWidth)&&void 0!==o?o:b.pageWidth,marginTop:null!==(r=e.marginTop)&&void 0!==r?r:b.marginTop,marginBottom:null!==(i=e.marginBottom)&&void 0!==i?i:b.marginBottom,marginLeft:null!==(g=e.marginLeft)&&void 0!==g?g:b.marginLeft,marginRight:null!==(p=e.marginRight)&&void 0!==p?p:b.marginRight,pageGap:null!==(s=e.pageGap)&&void 0!==s?s:b.pageGap,contentMarginTop:null!==(d=e.contentMarginTop)&&void 0!==d?d:b.contentMarginTop,contentMarginBottom:null!==(m=e.contentMarginBottom)&&void 0!==m?m:b.contentMarginBottom,footerRight:null!==(l=e.footerRight)&&void 0!==l?l:b.footerRight,footerLeft:null!==(c=e.footerLeft)&&void 0!==c?c:b.footerLeft,headerRight:null!==(h=e.headerRight)&&void 0!==h?h:b.headerRight,headerLeft:null!==(f=e.headerLeft)&&void 0!==f?f:b.headerLeft,customHeader:null!==(u=e.customHeader)&&void 0!==u?u:b.customHeader,customFooter:null!==(y=e.customFooter)&&void 0!==y?y:b.customFooter}},H=new t.PluginKey("pagination"),B=e.Extension.create({name:"PaginationPlus",addOptions:()=>v,addStorage:()=>Object.assign(Object.assign({},v),{headerHeight:new Map,footerHeight:new Map,appliedConfig:b}),onCreate(){const{options:e}=w(this.storage,this.options),t=L(this.options),a=this.editor.view.dom;a.classList.add("rm-with-pagination"),a.style.border="1px solid var(--rm-page-gap-border-color)",a.style.paddingLeft="var(--rm-margin-left)",a.style.paddingRight="var(--rm-margin-right)",a.style.width="var(--rm-page-width)",o(a,Object.assign(Object.assign({},e),t));const n=document.createElement("style");n.dataset.rmPaginationStyle="",n.textContent="\n .rm-pagination-gap{\n border-top: 1px solid;\n border-bottom: 1px solid;\n border-color: var(--rm-page-gap-border-color);\n }\n .rm-with-pagination,\n .rm-with-pagination .rm-first-page-header {\n counter-reset: page-number page-number-plus 1;\n }\n .rm-with-pagination .image-plus-wrapper,\n .rm-with-pagination .table-plus td,\n .rm-with-pagination .table-plus th {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n }\n .rm-with-pagination .image-plus-wrapper {\n overflow-y: visible;\n }\n .rm-with-pagination .rm-page-break {\n counter-increment: page-number page-number-plus;\n }\n \n .rm-with-pagination .rm-page-break:last-child .rm-pagination-gap {\n display: none;\n }\n .rm-with-pagination .rm-page-break:last-child .rm-page-header {\n display: none;\n }\n \n .rm-with-pagination table tr td,\n .rm-with-pagination table tr th {\n word-break: break-all;\n }\n .rm-with-pagination table > tr {\n display: grid;\n min-width: 100%;\n }\n .rm-with-pagination table {\n border-collapse: collapse;\n width: 100%;\n display: contents;\n }\n .rm-with-pagination table tbody{\n display: table;\n max-height: 300px;\n overflow-y: auto;\n }\n .rm-with-pagination table tbody > tr{\n display: table-row !important;\n }\n .rm-with-pagination *:has(>br.ProseMirror-trailingBreak:only-child) {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .rm-br-decoration {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .table-row-group {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n width: 100%;\n }\n .rm-with-pagination .rm-page-footer-left,\n .rm-with-pagination .rm-page-footer-right,\n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-header-right {\n display: inline-block;\n }\n \n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-footer-left{\n float: left;\n margin-left: var(--rm-margin-left);\n }\n .rm-with-pagination .rm-page-header-right,\n .rm-with-pagination .rm-page-footer-right{\n float: right;\n margin-right: var(--rm-margin-right);\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-right{\n margin-right: 0px !important;\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-left{\n margin-left: 0px !important;\n }\n .rm-with-pagination .rm-page-number::before {\n content: counter(page-number);\n }\n .rm-with-pagination .rm-page-number-plus::before {\n content: counter(page-number-plus);\n }\n .rm-with-pagination .rm-page-header,\n .rm-with-pagination .rm-page-footer{\n width: 100%;\n }\n .rm-with-pagination .rm-page-header{\n padding-bottom: var(--rm-content-margin-top) !important;\n padding-top: var(--rm-margin-top) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-margin-top) - var(--rm-content-margin-top));\n overflow-y: hidden;\n }\n .rm-with-pagination .rm-page-footer{\n padding-top: var(--rm-content-margin-bottom) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-content-margin-bottom) - var(--rm-margin-bottom));\n overflow-y: hidden;\n }\n .rm-with-pagination[rm-pagination-disabled] {\n padding-top: var(--rm-margin-top) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n }\n ",document.head.appendChild(n),y(a,e.enabled)},addProseMirrorPlugins(){const e=this.editor,r=this.storage;return[new t.Plugin({key:H,state:{init:(e,t)=>{const n=L(this.options),o=L(this.options),i=M(Object.assign(Object.assign({},this.options),n),new Map,new Map);return r.pageBreakBackground=n.pageBreakBackground,r.pageHeight=n.pageHeight,r.pageWidth=n.pageWidth,r.marginTop=n.marginTop,r.marginBottom=n.marginBottom,r.marginLeft=n.marginLeft,r.marginRight=n.marginRight,r.pageGap=n.pageGap,r.contentMarginTop=n.contentMarginTop,r.contentMarginBottom=n.contentMarginBottom,r.footerRight=n.footerRight,r.footerLeft=n.footerLeft,r.headerRight=n.headerRight,r.headerLeft=n.headerLeft,r.customHeader=n.customHeader,r.customFooter=n.customFooter,r.headerHeight=new Map,r.footerHeight=new Map,r.appliedConfig=o,{decorations:a.DecorationSet.create(t.doc,i)}},apply:(t,n,i,g)=>{const{options:s,config:d}=w(r,this.options);if(r.enabled===r.appliedConfig.enabled&&!1===r.enabled&&!1===r.appliedConfig.enabled)return n;const m=k(e.view,Object.assign(Object.assign({},s),d));return(m>1?m:1)===R(e.view)&&r.enabled===r.appliedConfig.enabled&&r.pageBreakBackground===r.appliedConfig.pageBreakBackground&&r.pageHeight===r.appliedConfig.pageHeight&&r.pageWidth===r.appliedConfig.pageWidth&&r.marginTop===r.appliedConfig.marginTop&&r.marginBottom===r.appliedConfig.marginBottom&&r.marginLeft===r.appliedConfig.marginLeft&&r.marginRight===r.appliedConfig.marginRight&&r.pageGap===r.appliedConfig.pageGap&&r.contentMarginTop===r.appliedConfig.contentMarginTop&&r.contentMarginBottom===r.appliedConfig.contentMarginBottom&&r.headerLeft===r.appliedConfig.headerLeft&&r.headerRight===r.appliedConfig.headerRight&&r.footerLeft===r.appliedConfig.footerLeft&&r.footerRight===r.appliedConfig.footerRight&&p(r.appliedConfig.customHeader,r.customHeader)&&p(r.appliedConfig.customFooter,r.customFooter)?n:(()=>{const{options:t,config:n}=w(r,this.options);o(e.view.dom,t);let i="headerHeight"in this.storage?this.storage.headerHeight:new Map,p="footerHeight"in this.storage?this.storage.footerHeight:new Map;const s=M(Object.assign(Object.assign({},t),n),i,p);return r.appliedConfig=n,r.headerHeight=i,r.footerHeight=p,{decorations:a.DecorationSet.create(g.doc,[...s]),footerHeight:p}})()}},props:{decorations(e){var t;return null===(t=this.getState(e))||void 0===t?void 0:t.decorations}},view:e=>({update:e=>{const{options:t,config:a}=w(r,this.options);if(!a.enabled&&!e.dom.hasAttribute("rm-pagination-disabled"))return void y(e.dom,!1);const n=k(e,Object.assign(Object.assign({},t),a));if(R(e)!==n)return void requestAnimationFrame(()=>{const t=e.state.tr.setMeta("PAGE_COUNT_META_KEY",{footerHeight:o});e.dispatch(t)});var o;const p=((e,t,a)=>{const n=new Map,o=e.querySelector(i(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(i(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,s(t.customHeader,{}),"content"),d=((e,t,a)=>{const n=new Map,o=e.querySelector(g(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(g(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,s({},t.customFooter),"content"),m=new Map;for(let r=0;r<=n;r++)d.has(r)&&m.set(r,d.get(r)||0);const c=new Map;for(let r=0;r<=n;r++)p.has(r)&&c.set(r,p.get(r)||0);const h=new Set([1,...m.keys(),...c.keys()]);let f;for(let r=1;r<=n;r++)if(!h.has(r)){f=r;break}f&&h.add(f),h.delete(0);let u,b={};for(const r of h){const e=c.has(r)?c.get(r)||0:c.get(0)||0,a=m.has(r)?m.get(r)||0:m.get(0)||0,{_pageHeaderHeight:n,_pageHeight:o}=l(t,e,a),i=1===r?o+n:o;1===r&&(b["rm-page-content-first"]=`${i}px`),r===f?b["rm-page-content-general"]=`${i}px`:b[`rm-page-content-${r}`]=`${i}px`,(void 0===u||i<u)&&(u=i)}u&&e.dom.style.setProperty("--rm-max-content-child-height",u-10+"px"),Object.entries(b).forEach(([t,a])=>{e.dom.style.setProperty(`--${t}`,a)}),y(e.dom,t.enabled)}})}),new t.Plugin({key:f,state:{init:(e,t)=>u(t.doc),apply:(e,t)=>e.docChanged||e.steps.some(e=>e instanceof n.ReplaceStep)||e.steps.some(e=>e instanceof n.ReplaceAroundStep)||e.steps.some(e=>e instanceof n.AddMarkStep)||e.steps.some(e=>e instanceof n.RemoveMarkStep)||e.steps.some(e=>e instanceof n.RemoveNodeMarkStep)||e.steps.some(e=>e instanceof n.AttrStep)?u(e.doc):t},props:{decorations(e){var t;return null!==(t=f.getState(e))&&void 0!==t?t:a.DecorationSet.empty}}})]},addCommands(){return{updatePageBreakBackground:e=>()=>(this.storage.pageBreakBackground=e,!0),updatePageSize:e=>()=>(this.storage.pageHeight=e.pageHeight,this.storage.pageWidth=e.pageWidth,this.storage.marginTop=e.marginTop,this.storage.marginBottom=e.marginBottom,this.storage.marginLeft=e.marginLeft,this.storage.marginRight=e.marginRight,!0),updatePageWidth:e=>()=>(this.storage.pageWidth=e,!0),updatePageHeight:e=>()=>(this.storage.pageHeight=e,!0),updatePageGap:e=>()=>(this.storage.pageGap=e,!0),updateMargins:e=>()=>(this.storage.marginTop=e.top,this.storage.marginBottom=e.bottom,this.storage.marginLeft=e.left,this.storage.marginRight=e.right,!0),updateContentMargins:e=>()=>(this.storage.contentMarginTop=e.top,this.storage.contentMarginBottom=e.bottom,!0),updateHeaderContent:(e,t,a)=>()=>(a?this.storage.customHeader=Object.assign(Object.assign({},this.storage.customHeader),{[a]:{headerLeft:e,headerRight:t}}):(this.storage.headerLeft=e,this.storage.headerRight=t),!0),updateFooterContent:(e,t,a)=>()=>(a?this.storage.customFooter=Object.assign(Object.assign({},this.storage.customFooter),{[a]:{footerLeft:e,footerRight:t}}):(this.storage.footerLeft=e,this.storage.footerRight=t),!0),togglePagination:()=>()=>(this.storage.enabled=!this.storage.enabled,!0),enablePagination:()=>()=>(this.storage.enabled=!0,!0),disablePagination:()=>()=>(this.storage.enabled=!1,!0)}}}),R=e=>{const t=e.dom.querySelector("[data-rm-pagination]");return t?t.children.length:0},k=(e,t)=>{if(t.enabled){const a=((e,t,a=0,n=0)=>{var o;const r=e.dom,i=t.contentMarginTop+t.marginTop+a,g=t.contentMarginBottom+t.marginBottom+n,p=t.pageHeight-i-g,s=r.querySelector("[data-rm-pagination]"),d=R(e);if(s){const e=r.lastElementChild,t=null===(o=s.lastElementChild)||void 0===o?void 0:o.querySelector(".breaker");if(e&&t){const a=e.getBoundingClientRect(),n=t.getBoundingClientRect(),o=a.bottom-n.bottom;if(o>0)return d+Math.ceil(o/p);{const e=Array.from(s.querySelectorAll(".breaker")).filter(e=>e.getBoundingClientRect().top>a.bottom).length;return e>1?d-e:d}}return 1}{const e=r.scrollHeight;let t=Math.ceil(e/p);return t=t<=0?1:t,t}})(e,t);return a<=1?1:a}return 0};function M(e,t,n){if(!e.enabled)return[];const o={headerLeft:e.headerLeft,headerRight:e.headerRight},r={footerLeft:e.footerLeft,footerRight:e.footerRight};return[a.Decoration.widget(0,a=>{const i=e.pageGap,g=e.pageBreakBackground,p=document.createElement("div");p.dataset.rmPagination="true";const s=(t,a,n,o,r,p)=>{const{_pageHeaderHeight:s,_pageHeight:d}=l(e,o,r),m=document.createElement("div");m.classList.add("rm-page-break");const c=document.createElement("div");c.classList.add("page"),c.style.position="relative",c.style.float="left",c.style.clear="both";const h=t?`calc(${s}px + ${d}px)`:d+"px";c.style.marginTop=p?`var(--rm-page-content-${p}, ${h})`:t?`var(--rm-page-content-first, ${h})`:`var(--rm-page-content-general, ${h})`;const f=document.createElement("div");f.classList.add("breaker"),f.style.width="calc(100% + var(--rm-margin-left) + var(--rm-margin-right))",f.style.marginLeft="calc(-1 * var(--rm-margin-left))",f.style.marginRight="calc(-1 * var(--rm-margin-right))",f.style.position="relative",f.style.float="left",f.style.clear="both",f.style.left="0px",f.style.right="0px",f.style.zIndex="2";const u=document.createElement("div");return u.classList.add("rm-pagination-gap"),u.style.height=i+"px",u.style.borderLeft="1px solid",u.style.borderRight="1px solid",u.style.position="relative",u.style.setProperty("width","calc(100% + 2px)","important"),u.style.left="-1px",u.style.backgroundColor=g,u.style.borderLeftColor=g,u.style.borderRightColor=g,f.append(n,u,a),m.append(c,f),m},f=t.get(0)||0,u=n.get(0)||0,b=document.createDocumentFragment(),v=k(a,e);for(let l=0;l<v;l++){const a=l+1,i=l+2;if(i in e.customHeader||a in e.customFooter||a in e.customHeader){let g=o,p=r,v=f,y=u;i in e.customHeader&&(g=e.customHeader[i]||o,v=t.get(i)||0),a in e.customFooter&&(p=e.customFooter[a]||r,y=n.get(a)||0);let w=s(0===l,m(g.headerRight,g.headerLeft,c(i,e.onHeaderClick),i),d(p.footerRight,p.footerLeft,h(a,e.onFooterClick),a),v,y,a);b.appendChild(w)}else{const t=m(o.headerRight,o.headerLeft,c(i,e.onHeaderClick)),n=d(r.footerRight,r.footerLeft,h(a,e.onFooterClick));b.appendChild(s(0===l,t,n,f,u))}}return p.append(b),p.id="pages",p.classList.add("rm-pages-wrapper"),p},{side:-1}),a.Decoration.widget(0,()=>{let t=o;1 in e.customHeader&&(t=e.customHeader[1]);const a=m(t.headerRight,t.headerLeft,c(1,e.onHeaderClick));return a.classList.add("rm-first-page-header"),a},{side:-1})]}r(1123,794,95,95,76,76),r(1591,1123,95,95,76,76),r(794,419,76,76,57,57),r(1060,818,96,96,96,96),r(1404,818,96,96,96,96),r(1635,1060,96,96,96,96);var C=B.extend({addOptions(){return{...this.parent?.(),pageHeight:1056,pageWidth:816,pageGap:50,pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5",pageBreakBackground:"#ffffff",marginTop:48,marginBottom:48,marginLeft:72,marginRight:72,contentMarginTop:10,contentMarginBottom:10,headerLeft:"",headerRight:"Page {page}",footerLeft:"",footerRight:"",customHeader:{},customFooter:{}}},addKeyboardShortcuts:()=>({"Mod-Shift-p":()=>!0})});Object.defineProperty(exports,"Pagination",{enumerable:!0,get:function(){return C}});
|
|
1
|
+
let e=require("@tiptap/core"),t=require("@tiptap/pm/state"),a=require("@tiptap/pm/view"),n=require("@tiptap/pm/transform");var o=(e,t)=>{const a={"rm-page-height":`${t.pageHeight}px`,"rm-margin-top":`${t.marginTop}px`,"rm-margin-bottom":`${t.marginBottom}px`,"rm-margin-left":`${t.marginLeft}px`,"rm-margin-right":`${t.marginRight}px`,"rm-content-margin-top":`${t.contentMarginTop}px`,"rm-content-margin-bottom":`${t.contentMarginBottom}px`,"rm-page-gap-border-color":`${t.pageGapBorderColor}`,"rm-page-width":`${t.pageWidth}px`};Object.entries(a).forEach(([t,a])=>{e.style.setProperty(`--${t}`,a)})},r=(e,t,a,n,o,r)=>({pageHeight:e,pageWidth:t,marginTop:a,marginBottom:n,marginLeft:o,marginRight:r}),i=(e,t)=>"actual"===t?`.rm-page-header-${e}`:`.rm-page-header-${e} .rm-page-header-content`,g=(e,t)=>"actual"===t?`.rm-page-footer-${e}`:`.rm-page-footer-${e} .rm-page-footer-content`;function p(e,t){if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return!1;const a=[{x:e,y:t}];for(;a.length;){const e=a.pop();if(!e)continue;const{x:t,y:n}=e;if(t===n)continue;if(typeof t!=typeof n)return!1;if("object"!=typeof t)return!1;if(null==t||null==n)return!1;const o=Object.keys(t),r=Object.keys(n);if(o.length!==r.length)return!1;for(const i of o){if(!(i in n))return!1;const e=t[i],o=n[i];if(e!==o)if("object"==typeof e&&"object"==typeof o)a.push({x:e,y:o});else if(e!==o)return!1}}return!0}function s(e,t){return[...Object.keys(e),...Object.keys(t)].map(Number)}function d(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-footer"),o.classList.add(`rm-page-footer-${n||0}`),o.style.overflow="visible",o.style.position="relative",o.style.cursor="pointer";const r=document.createElement("div");r.classList.add("rm-page-footer-content"),r.style.width="100%",r.style.overflow="hidden";const i=e.replace("{page}",'<span class="rm-page-number"></span>'),g=t.replace("{page}",'<span class="rm-page-number"></span>'),p=document.createElement("div");p.classList.add("rm-page-footer-left"),p.innerHTML=g;const s=document.createElement("div");return s.classList.add("rm-page-footer-right"),s.innerHTML=i,r.append(p,s),o.append(r),o.addEventListener("click",a),o}function m(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-header"),o.classList.add(`rm-page-header-${n||0}`),o.style.overflow="hidden",o.style.cursor="pointer",o.style.position="relative";const r=document.createElement("div");r.classList.add("rm-page-header-content"),r.style.width="100%",r.style.overflow="hidden";const i=t.replace("{page}",'<span class="rm-page-number-plus"></span>'),g=e.replace("{page}",'<span class="rm-page-number-plus"></span>'),p=document.createElement("div");p.classList.add("rm-page-header-left"),p.innerHTML=i;const s=document.createElement("div");return s.classList.add("rm-page-header-right"),s.innerHTML=g,r.append(p,s),o.append(r),o.addEventListener("click",a),o}var l=(e,t,a)=>{const n=e.contentMarginTop+e.marginTop+t,o=e.contentMarginBottom+e.marginBottom+a;return{_pageHeaderHeight:n,_pageFooterHeight:o,_pageHeight:e.pageHeight-n-o}},c=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},h=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},f=new t.PluginKey("brDecoration");function u(e){const t=[];return e.descendants((e,n)=>{if("hardBreak"===e.type.name){const e=n+1,o=a.Decoration.widget(e,()=>{const e=document.createElement("span");return e.classList.add("rm-br-decoration"),e});t.push(o)}}),a.DecorationSet.create(e,t)}var b={enabled:!0,pageBreakBackground:"#ffffff",pageHeight:800,pageWidth:789,marginTop:20,marginBottom:20,marginLeft:50,marginRight:50,pageGap:50,contentMarginTop:10,contentMarginBottom:10,footerRight:"{page}",footerLeft:"",headerRight:"",headerLeft:"",customHeader:{},customFooter:{}},v=Object.assign({pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5"},b),y=(e,t=!0)=>{var a;const n=e.querySelector("[data-rm-pagination]");if(t){if(e.removeAttribute("rm-pagination-disabled"),n){const t=null===(a=n.lastElementChild)||void 0===a?void 0:a.querySelector(".breaker");if(t){const a=t.offsetTop+t.offsetHeight;e.style.minHeight=`calc(${a}px + 2px)`}}}else e.setAttribute("rm-pagination-disabled",""),e.style.minHeight="auto"},w=(e,t)=>{var a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,y,w;const L={enabled:null!==(a=e.enabled)&&void 0!==a?a:v.enabled,pageBreakBackground:null!==(n=e.pageBreakBackground)&&void 0!==n?n:v.pageBreakBackground,pageHeight:null!==(o=e.pageHeight)&&void 0!==o?o:v.pageHeight,pageWidth:null!==(r=e.pageWidth)&&void 0!==r?r:b.pageWidth,marginTop:null!==(i=e.marginTop)&&void 0!==i?i:b.marginTop,marginBottom:null!==(g=e.marginBottom)&&void 0!==g?g:b.marginBottom,marginLeft:null!==(p=e.marginLeft)&&void 0!==p?p:b.marginLeft,marginRight:null!==(s=e.marginRight)&&void 0!==s?s:b.marginRight,pageGap:null!==(d=e.pageGap)&&void 0!==d?d:b.pageGap,contentMarginTop:null!==(m=e.contentMarginTop)&&void 0!==m?m:b.contentMarginTop,contentMarginBottom:null!==(l=e.contentMarginBottom)&&void 0!==l?l:b.contentMarginBottom,footerRight:null!==(c=e.footerRight)&&void 0!==c?c:b.footerRight,footerLeft:null!==(h=e.footerLeft)&&void 0!==h?h:b.footerLeft,headerRight:null!==(f=e.headerRight)&&void 0!==f?f:b.headerRight,headerLeft:null!==(u=e.headerLeft)&&void 0!==u?u:b.headerLeft,customHeader:null!==(y=e.customHeader)&&void 0!==y?y:b.customHeader,customFooter:null!==(w=e.customFooter)&&void 0!==w?w:b.customFooter};return{config:L,options:Object.assign(Object.assign({},t),L)}},L=e=>{var t,a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,y;return{enabled:null!==(t=e.enabled)&&void 0!==t?t:v.enabled,pageBreakBackground:null!==(a=e.pageBreakBackground)&&void 0!==a?a:v.pageBreakBackground,pageHeight:null!==(n=e.pageHeight)&&void 0!==n?n:v.pageHeight,pageWidth:null!==(o=e.pageWidth)&&void 0!==o?o:b.pageWidth,marginTop:null!==(r=e.marginTop)&&void 0!==r?r:b.marginTop,marginBottom:null!==(i=e.marginBottom)&&void 0!==i?i:b.marginBottom,marginLeft:null!==(g=e.marginLeft)&&void 0!==g?g:b.marginLeft,marginRight:null!==(p=e.marginRight)&&void 0!==p?p:b.marginRight,pageGap:null!==(s=e.pageGap)&&void 0!==s?s:b.pageGap,contentMarginTop:null!==(d=e.contentMarginTop)&&void 0!==d?d:b.contentMarginTop,contentMarginBottom:null!==(m=e.contentMarginBottom)&&void 0!==m?m:b.contentMarginBottom,footerRight:null!==(l=e.footerRight)&&void 0!==l?l:b.footerRight,footerLeft:null!==(c=e.footerLeft)&&void 0!==c?c:b.footerLeft,headerRight:null!==(h=e.headerRight)&&void 0!==h?h:b.headerRight,headerLeft:null!==(f=e.headerLeft)&&void 0!==f?f:b.headerLeft,customHeader:null!==(u=e.customHeader)&&void 0!==u?u:b.customHeader,customFooter:null!==(y=e.customFooter)&&void 0!==y?y:b.customFooter}},H=new t.PluginKey("pagination"),B=e.Extension.create({name:"PaginationPlus",addOptions:()=>v,addStorage:()=>Object.assign(Object.assign({},v),{headerHeight:new Map,footerHeight:new Map,appliedConfig:b}),onCreate(){const{options:e}=w(this.storage,this.options),t=L(this.options),a=this.editor.view.dom;a.classList.add("rm-with-pagination"),a.style.border="1px solid var(--rm-page-gap-border-color)",a.style.paddingLeft="var(--rm-margin-left)",a.style.paddingRight="var(--rm-margin-right)",a.style.width="var(--rm-page-width)",o(a,Object.assign(Object.assign({},e),t));const n=document.createElement("style");n.dataset.rmPaginationStyle="",n.textContent="\n .rm-pagination-gap{\n border-top: 1px solid;\n border-bottom: 1px solid;\n border-color: var(--rm-page-gap-border-color);\n }\n .rm-with-pagination,\n .rm-with-pagination .rm-first-page-header {\n counter-reset: page-number page-number-plus 1;\n }\n .rm-with-pagination .image-plus-wrapper,\n .rm-with-pagination .table-plus td,\n .rm-with-pagination .table-plus th {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n }\n .rm-with-pagination .image-plus-wrapper {\n overflow-y: visible;\n }\n .rm-with-pagination .rm-page-break {\n counter-increment: page-number page-number-plus;\n }\n \n .rm-with-pagination .rm-page-break:last-child .rm-pagination-gap {\n display: none;\n }\n .rm-with-pagination .rm-page-break:last-child .rm-page-header {\n display: none;\n }\n \n .rm-with-pagination table tr td,\n .rm-with-pagination table tr th {\n word-break: break-all;\n }\n .rm-with-pagination table > tr {\n display: grid;\n min-width: 100%;\n }\n .rm-with-pagination table {\n border-collapse: collapse;\n width: 100%;\n display: contents;\n }\n .rm-with-pagination table tbody{\n display: table;\n max-height: 300px;\n overflow-y: auto;\n }\n .rm-with-pagination table tbody > tr{\n display: table-row !important;\n }\n .rm-with-pagination *:has(>br.ProseMirror-trailingBreak:only-child) {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .rm-br-decoration {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .table-row-group {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n width: 100%;\n }\n .rm-with-pagination .rm-page-footer-left,\n .rm-with-pagination .rm-page-footer-right,\n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-header-right {\n display: inline-block;\n }\n \n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-footer-left{\n float: left;\n margin-left: var(--rm-margin-left);\n }\n .rm-with-pagination .rm-page-header-right,\n .rm-with-pagination .rm-page-footer-right{\n float: right;\n margin-right: var(--rm-margin-right);\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-right{\n margin-right: 0px !important;\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-left{\n margin-left: 0px !important;\n }\n .rm-with-pagination .rm-page-number::before {\n content: counter(page-number);\n }\n .rm-with-pagination .rm-page-number-plus::before {\n content: counter(page-number-plus);\n }\n .rm-with-pagination .rm-page-header,\n .rm-with-pagination .rm-page-footer{\n width: 100%;\n }\n .rm-with-pagination .rm-page-header{\n padding-bottom: var(--rm-content-margin-top) !important;\n padding-top: var(--rm-margin-top) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-margin-top) - var(--rm-content-margin-top));\n overflow-y: hidden;\n }\n .rm-with-pagination .rm-page-footer{\n padding-top: var(--rm-content-margin-bottom) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-content-margin-bottom) - var(--rm-margin-bottom));\n overflow-y: hidden;\n }\n .rm-with-pagination[rm-pagination-disabled] {\n padding-top: var(--rm-margin-top) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n }\n ",document.head.appendChild(n),y(a,e.enabled)},addProseMirrorPlugins(){const e=this.editor,r=this.storage;return[new t.Plugin({key:H,state:{init:(e,t)=>{const n=L(this.options),o=L(this.options),i=M(Object.assign(Object.assign({},this.options),n),new Map,new Map);return r.pageBreakBackground=n.pageBreakBackground,r.pageHeight=n.pageHeight,r.pageWidth=n.pageWidth,r.marginTop=n.marginTop,r.marginBottom=n.marginBottom,r.marginLeft=n.marginLeft,r.marginRight=n.marginRight,r.pageGap=n.pageGap,r.contentMarginTop=n.contentMarginTop,r.contentMarginBottom=n.contentMarginBottom,r.footerRight=n.footerRight,r.footerLeft=n.footerLeft,r.headerRight=n.headerRight,r.headerLeft=n.headerLeft,r.customHeader=n.customHeader,r.customFooter=n.customFooter,r.headerHeight=new Map,r.footerHeight=new Map,r.appliedConfig=o,{decorations:a.DecorationSet.create(t.doc,i)}},apply:(t,n,i,g)=>{const{options:s,config:d}=w(r,this.options);if(r.enabled===r.appliedConfig.enabled&&!1===r.enabled&&!1===r.appliedConfig.enabled)return n;const m=k(e.view,Object.assign(Object.assign({},s),d));return(m>1?m:1)===R(e.view)&&r.enabled===r.appliedConfig.enabled&&r.pageBreakBackground===r.appliedConfig.pageBreakBackground&&r.pageHeight===r.appliedConfig.pageHeight&&r.pageWidth===r.appliedConfig.pageWidth&&r.marginTop===r.appliedConfig.marginTop&&r.marginBottom===r.appliedConfig.marginBottom&&r.marginLeft===r.appliedConfig.marginLeft&&r.marginRight===r.appliedConfig.marginRight&&r.pageGap===r.appliedConfig.pageGap&&r.contentMarginTop===r.appliedConfig.contentMarginTop&&r.contentMarginBottom===r.appliedConfig.contentMarginBottom&&r.headerLeft===r.appliedConfig.headerLeft&&r.headerRight===r.appliedConfig.headerRight&&r.footerLeft===r.appliedConfig.footerLeft&&r.footerRight===r.appliedConfig.footerRight&&p(r.appliedConfig.customHeader,r.customHeader)&&p(r.appliedConfig.customFooter,r.customFooter)?n:(()=>{const{options:t,config:n}=w(r,this.options);o(e.view.dom,t);let i="headerHeight"in this.storage?this.storage.headerHeight:new Map,p="footerHeight"in this.storage?this.storage.footerHeight:new Map;const s=M(Object.assign(Object.assign({},t),n),i,p);return r.appliedConfig=n,r.headerHeight=i,r.footerHeight=p,{decorations:a.DecorationSet.create(g.doc,[...s]),footerHeight:p}})()}},props:{decorations(e){var t;return null===(t=this.getState(e))||void 0===t?void 0:t.decorations}},view:e=>({update:e=>{const{options:t,config:a}=w(r,this.options);if(!a.enabled&&!e.dom.hasAttribute("rm-pagination-disabled"))return void y(e.dom,!1);const n=k(e,Object.assign(Object.assign({},t),a));if(R(e)!==n)return void requestAnimationFrame(()=>{const t=e.state.tr.setMeta("PAGE_COUNT_META_KEY",{footerHeight:o});e.dispatch(t)});var o;const p=((e,t,a)=>{const n=new Map,o=e.querySelector(i(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(i(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,s(t.customHeader,{}),"content"),d=((e,t,a)=>{const n=new Map,o=e.querySelector(g(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(g(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,s({},t.customFooter),"content"),m=new Map;for(let r=0;r<=n;r++)d.has(r)&&m.set(r,d.get(r)||0);const c=new Map;for(let r=0;r<=n;r++)p.has(r)&&c.set(r,p.get(r)||0);const h=new Set([1,...m.keys(),...c.keys()]);let f;for(let r=1;r<=n;r++)if(!h.has(r)){f=r;break}f&&h.add(f),h.delete(0);let u,b={};for(const r of h){const e=c.has(r)?c.get(r)||0:c.get(0)||0,a=m.has(r)?m.get(r)||0:m.get(0)||0,{_pageHeaderHeight:n,_pageHeight:o}=l(t,e,a),i=1===r?o+n:o;1===r&&(b["rm-page-content-first"]=`${i}px`),r===f?b["rm-page-content-general"]=`${i}px`:b[`rm-page-content-${r}`]=`${i}px`,(void 0===u||i<u)&&(u=i)}u&&e.dom.style.setProperty("--rm-max-content-child-height",u-10+"px"),Object.entries(b).forEach(([t,a])=>{e.dom.style.setProperty(`--${t}`,a)}),y(e.dom,t.enabled)}})}),new t.Plugin({key:f,state:{init:(e,t)=>u(t.doc),apply:(e,t)=>e.docChanged||e.steps.some(e=>e instanceof n.ReplaceStep)||e.steps.some(e=>e instanceof n.ReplaceAroundStep)||e.steps.some(e=>e instanceof n.AddMarkStep)||e.steps.some(e=>e instanceof n.RemoveMarkStep)||e.steps.some(e=>e instanceof n.RemoveNodeMarkStep)||e.steps.some(e=>e instanceof n.AttrStep)?u(e.doc):t},props:{decorations(e){var t;return null!==(t=f.getState(e))&&void 0!==t?t:a.DecorationSet.empty}}})]},addCommands(){return{updatePageBreakBackground:e=>()=>(this.storage.pageBreakBackground=e,!0),updatePageSize:e=>()=>(this.storage.pageHeight=e.pageHeight,this.storage.pageWidth=e.pageWidth,this.storage.marginTop=e.marginTop,this.storage.marginBottom=e.marginBottom,this.storage.marginLeft=e.marginLeft,this.storage.marginRight=e.marginRight,!0),updatePageWidth:e=>()=>(this.storage.pageWidth=e,!0),updatePageHeight:e=>()=>(this.storage.pageHeight=e,!0),updatePageGap:e=>()=>(this.storage.pageGap=e,!0),updateMargins:e=>()=>(this.storage.marginTop=e.top,this.storage.marginBottom=e.bottom,this.storage.marginLeft=e.left,this.storage.marginRight=e.right,!0),updateContentMargins:e=>()=>(this.storage.contentMarginTop=e.top,this.storage.contentMarginBottom=e.bottom,!0),updateHeaderContent:(e,t,a)=>()=>(a?this.storage.customHeader=Object.assign(Object.assign({},this.storage.customHeader),{[a]:{headerLeft:e,headerRight:t}}):(this.storage.headerLeft=e,this.storage.headerRight=t),!0),updateFooterContent:(e,t,a)=>()=>(a?this.storage.customFooter=Object.assign(Object.assign({},this.storage.customFooter),{[a]:{footerLeft:e,footerRight:t}}):(this.storage.footerLeft=e,this.storage.footerRight=t),!0),togglePagination:()=>()=>(this.storage.enabled=!this.storage.enabled,!0),enablePagination:()=>()=>(this.storage.enabled=!0,!0),disablePagination:()=>()=>(this.storage.enabled=!1,!0)}}}),R=e=>{const t=e.dom.querySelector("[data-rm-pagination]");return t?t.children.length:0},k=(e,t)=>{if(t.enabled){const a=((e,t,a=0,n=0)=>{var o;const r=e.dom,i=t.contentMarginTop+t.marginTop+a,g=t.contentMarginBottom+t.marginBottom+n,p=t.pageHeight-i-g,s=r.querySelector("[data-rm-pagination]"),d=R(e);if(s){const e=r.lastElementChild,t=null===(o=s.lastElementChild)||void 0===o?void 0:o.querySelector(".breaker");if(e&&t){const a=e.getBoundingClientRect(),n=t.getBoundingClientRect(),o=a.bottom-n.bottom;if(o>0)return d+Math.ceil(o/p);{const e=Array.from(s.querySelectorAll(".breaker")).filter(e=>e.getBoundingClientRect().top>a.bottom).length;return e>1?d-e:d}}return 1}{const e=r.scrollHeight;let t=Math.ceil(e/p);return t=t<=0?1:t,t}})(e,t);return a<=1?1:a}return 0};function M(e,t,n){if(!e.enabled)return[];const o={headerLeft:e.headerLeft,headerRight:e.headerRight},r={footerLeft:e.footerLeft,footerRight:e.footerRight};return[a.Decoration.widget(0,a=>{const i=e.pageGap,g=e.pageBreakBackground,p=document.createElement("div");p.dataset.rmPagination="true";const s=(t,a,n,o,r,p)=>{const{_pageHeaderHeight:s,_pageHeight:d}=l(e,o,r),m=document.createElement("div");m.classList.add("rm-page-break");const c=document.createElement("div");c.classList.add("page"),c.style.position="relative",c.style.float="left",c.style.clear="both";const h=t?`calc(${s}px + ${d}px)`:d+"px";c.style.marginTop=p?`var(--rm-page-content-${p}, ${h})`:t?`var(--rm-page-content-first, ${h})`:`var(--rm-page-content-general, ${h})`;const f=document.createElement("div");f.classList.add("breaker"),f.style.width="calc(100% + var(--rm-margin-left) + var(--rm-margin-right))",f.style.marginLeft="calc(-1 * var(--rm-margin-left))",f.style.marginRight="calc(-1 * var(--rm-margin-right))",f.style.position="relative",f.style.float="left",f.style.clear="both",f.style.left="0px",f.style.right="0px",f.style.zIndex="2";const u=document.createElement("div");return u.classList.add("rm-pagination-gap"),u.style.height=i+"px",u.style.borderLeft="1px solid",u.style.borderRight="1px solid",u.style.position="relative",u.style.setProperty("width","calc(100% + 2px)","important"),u.style.left="-1px",u.style.backgroundColor=g,u.style.borderLeftColor=g,u.style.borderRightColor=g,f.append(n,u,a),m.append(c,f),m},f=t.get(0)||0,u=n.get(0)||0,b=document.createDocumentFragment(),v=k(a,e);for(let l=0;l<v;l++){const a=l+1,i=l+2;if(i in e.customHeader||a in e.customFooter||a in e.customHeader){let g=o,p=r,v=f,y=u;i in e.customHeader&&(g=e.customHeader[i]||o,v=t.get(i)||0),a in e.customFooter&&(p=e.customFooter[a]||r,y=n.get(a)||0);let w=s(0===l,m(g.headerRight,g.headerLeft,c(i,e.onHeaderClick),i),d(p.footerRight,p.footerLeft,h(a,e.onFooterClick),a),v,y,a);b.appendChild(w)}else{const t=m(o.headerRight,o.headerLeft,c(i,e.onHeaderClick)),n=d(r.footerRight,r.footerLeft,h(a,e.onFooterClick));b.appendChild(s(0===l,t,n,f,u))}}return p.append(b),p.id="pages",p.classList.add("rm-pages-wrapper"),p},{side:-1}),a.Decoration.widget(0,()=>{let t=o;1 in e.customHeader&&(t=e.customHeader[1]);const a=m(t.headerRight,t.headerLeft,c(1,e.onHeaderClick));return a.classList.add("rm-first-page-header"),a},{side:-1})]}r(1123,794,95,95,76,76),r(1591,1123,95,95,76,76),r(794,419,76,76,57,57),r(1060,818,96,96,96,96),r(1404,818,96,96,96,96),r(1635,1060,96,96,96,96);var C=B.extend({addOptions(){const e=this.parent;return{...e?.(),pageHeight:1056,pageWidth:816,pageGap:50,pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5",pageBreakBackground:"#ffffff",marginTop:48,marginBottom:48,marginLeft:72,marginRight:72,contentMarginTop:10,contentMarginBottom:10,headerLeft:"",headerRight:"Page {page}",footerLeft:"",footerRight:"",customHeader:{},customFooter:{}}},addKeyboardShortcuts:()=>({"Mod-Shift-p":()=>!0})});Object.defineProperty(exports,"Pagination",{enumerable:!0,get:function(){return C}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Extension as e}from"@tiptap/core";import{Plugin as t,PluginKey as a}from"@tiptap/pm/state";import{Decoration as n,DecorationSet as o}from"@tiptap/pm/view";import{AddMarkStep as r,AttrStep as i,RemoveMarkStep as g,RemoveNodeMarkStep as p,ReplaceAroundStep as s,ReplaceStep as d}from"@tiptap/pm/transform";var m=(e,t)=>{const a={"rm-page-height":`${t.pageHeight}px`,"rm-margin-top":`${t.marginTop}px`,"rm-margin-bottom":`${t.marginBottom}px`,"rm-margin-left":`${t.marginLeft}px`,"rm-margin-right":`${t.marginRight}px`,"rm-content-margin-top":`${t.contentMarginTop}px`,"rm-content-margin-bottom":`${t.contentMarginBottom}px`,"rm-page-gap-border-color":`${t.pageGapBorderColor}`,"rm-page-width":`${t.pageWidth}px`};Object.entries(a).forEach(([t,a])=>{e.style.setProperty(`--${t}`,a)})},l=(e,t,a,n,o,r)=>({pageHeight:e,pageWidth:t,marginTop:a,marginBottom:n,marginLeft:o,marginRight:r}),c=(e,t)=>"actual"===t?`.rm-page-header-${e}`:`.rm-page-header-${e} .rm-page-header-content`,h=(e,t)=>"actual"===t?`.rm-page-footer-${e}`:`.rm-page-footer-${e} .rm-page-footer-content`;function f(e,t){if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return!1;const a=[{x:e,y:t}];for(;a.length;){const e=a.pop();if(!e)continue;const{x:t,y:n}=e;if(t===n)continue;if(typeof t!=typeof n)return!1;if("object"!=typeof t)return!1;if(null==t||null==n)return!1;const o=Object.keys(t),r=Object.keys(n);if(o.length!==r.length)return!1;for(const i of o){if(!(i in n))return!1;const e=t[i],o=n[i];if(e!==o)if("object"==typeof e&&"object"==typeof o)a.push({x:e,y:o});else if(e!==o)return!1}}return!0}function u(e,t){return[...Object.keys(e),...Object.keys(t)].map(Number)}function b(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-footer"),o.classList.add(`rm-page-footer-${n||0}`),o.style.overflow="visible",o.style.position="relative",o.style.cursor="pointer";const r=document.createElement("div");r.classList.add("rm-page-footer-content"),r.style.width="100%",r.style.overflow="hidden";const i=e.replace("{page}",'<span class="rm-page-number"></span>'),g=t.replace("{page}",'<span class="rm-page-number"></span>'),p=document.createElement("div");p.classList.add("rm-page-footer-left"),p.innerHTML=g;const s=document.createElement("div");return s.classList.add("rm-page-footer-right"),s.innerHTML=i,r.append(p,s),o.append(r),o.addEventListener("click",a),o}function v(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-header"),o.classList.add(`rm-page-header-${n||0}`),o.style.overflow="hidden",o.style.cursor="pointer",o.style.position="relative";const r=document.createElement("div");r.classList.add("rm-page-header-content"),r.style.width="100%",r.style.overflow="hidden";const i=t.replace("{page}",'<span class="rm-page-number-plus"></span>'),g=e.replace("{page}",'<span class="rm-page-number-plus"></span>'),p=document.createElement("div");p.classList.add("rm-page-header-left"),p.innerHTML=i;const s=document.createElement("div");return s.classList.add("rm-page-header-right"),s.innerHTML=g,r.append(p,s),o.append(r),o.addEventListener("click",a),o}var y=(e,t,a)=>{const n=e.contentMarginTop+e.marginTop+t,o=e.contentMarginBottom+e.marginBottom+a;return{_pageHeaderHeight:n,_pageFooterHeight:o,_pageHeight:e.pageHeight-n-o}},w=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},L=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},H=new a("brDecoration");function B(e){const t=[];return e.descendants((e,a)=>{if("hardBreak"===e.type.name){const e=a+1,o=n.widget(e,()=>{const e=document.createElement("span");return e.classList.add("rm-br-decoration"),e});t.push(o)}}),o.create(e,t)}var R={enabled:!0,pageBreakBackground:"#ffffff",pageHeight:800,pageWidth:789,marginTop:20,marginBottom:20,marginLeft:50,marginRight:50,pageGap:50,contentMarginTop:10,contentMarginBottom:10,footerRight:"{page}",footerLeft:"",headerRight:"",headerLeft:"",customHeader:{},customFooter:{}},k=Object.assign({pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5"},R),M=(e,t=!0)=>{var a;const n=e.querySelector("[data-rm-pagination]");if(t){if(e.removeAttribute("rm-pagination-disabled"),n){const t=null===(a=n.lastElementChild)||void 0===a?void 0:a.querySelector(".breaker");if(t){const a=t.offsetTop+t.offsetHeight;e.style.minHeight=`calc(${a}px + 2px)`}}}else e.setAttribute("rm-pagination-disabled",""),e.style.minHeight="auto"},C=(e,t)=>{var a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,b,v;const y={enabled:null!==(a=e.enabled)&&void 0!==a?a:k.enabled,pageBreakBackground:null!==(n=e.pageBreakBackground)&&void 0!==n?n:k.pageBreakBackground,pageHeight:null!==(o=e.pageHeight)&&void 0!==o?o:k.pageHeight,pageWidth:null!==(r=e.pageWidth)&&void 0!==r?r:R.pageWidth,marginTop:null!==(i=e.marginTop)&&void 0!==i?i:R.marginTop,marginBottom:null!==(g=e.marginBottom)&&void 0!==g?g:R.marginBottom,marginLeft:null!==(p=e.marginLeft)&&void 0!==p?p:R.marginLeft,marginRight:null!==(s=e.marginRight)&&void 0!==s?s:R.marginRight,pageGap:null!==(d=e.pageGap)&&void 0!==d?d:R.pageGap,contentMarginTop:null!==(m=e.contentMarginTop)&&void 0!==m?m:R.contentMarginTop,contentMarginBottom:null!==(l=e.contentMarginBottom)&&void 0!==l?l:R.contentMarginBottom,footerRight:null!==(c=e.footerRight)&&void 0!==c?c:R.footerRight,footerLeft:null!==(h=e.footerLeft)&&void 0!==h?h:R.footerLeft,headerRight:null!==(f=e.headerRight)&&void 0!==f?f:R.headerRight,headerLeft:null!==(u=e.headerLeft)&&void 0!==u?u:R.headerLeft,customHeader:null!==(b=e.customHeader)&&void 0!==b?b:R.customHeader,customFooter:null!==(v=e.customFooter)&&void 0!==v?v:R.customFooter};return{config:y,options:Object.assign(Object.assign({},t),y)}},x=e=>{var t,a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,b;return{enabled:null!==(t=e.enabled)&&void 0!==t?t:k.enabled,pageBreakBackground:null!==(a=e.pageBreakBackground)&&void 0!==a?a:k.pageBreakBackground,pageHeight:null!==(n=e.pageHeight)&&void 0!==n?n:k.pageHeight,pageWidth:null!==(o=e.pageWidth)&&void 0!==o?o:R.pageWidth,marginTop:null!==(r=e.marginTop)&&void 0!==r?r:R.marginTop,marginBottom:null!==(i=e.marginBottom)&&void 0!==i?i:R.marginBottom,marginLeft:null!==(g=e.marginLeft)&&void 0!==g?g:R.marginLeft,marginRight:null!==(p=e.marginRight)&&void 0!==p?p:R.marginRight,pageGap:null!==(s=e.pageGap)&&void 0!==s?s:R.pageGap,contentMarginTop:null!==(d=e.contentMarginTop)&&void 0!==d?d:R.contentMarginTop,contentMarginBottom:null!==(m=e.contentMarginBottom)&&void 0!==m?m:R.contentMarginBottom,footerRight:null!==(l=e.footerRight)&&void 0!==l?l:R.footerRight,footerLeft:null!==(c=e.footerLeft)&&void 0!==c?c:R.footerLeft,headerRight:null!==(h=e.headerRight)&&void 0!==h?h:R.headerRight,headerLeft:null!==(f=e.headerLeft)&&void 0!==f?f:R.headerLeft,customHeader:null!==(u=e.customHeader)&&void 0!==u?u:R.customHeader,customFooter:null!==(b=e.customFooter)&&void 0!==b?b:R.customFooter}},T=new a("pagination"),j=e.create({name:"PaginationPlus",addOptions:()=>k,addStorage:()=>Object.assign(Object.assign({},k),{headerHeight:/* @__PURE__ */new Map,footerHeight:/* @__PURE__ */new Map,appliedConfig:R}),onCreate(){const{options:e}=C(this.storage,this.options),t=x(this.options),a=this.editor.view.dom;a.classList.add("rm-with-pagination"),a.style.border="1px solid var(--rm-page-gap-border-color)",a.style.paddingLeft="var(--rm-margin-left)",a.style.paddingRight="var(--rm-margin-right)",a.style.width="var(--rm-page-width)",m(a,Object.assign(Object.assign({},e),t));const n=document.createElement("style");n.dataset.rmPaginationStyle="",n.textContent="\n .rm-pagination-gap{\n border-top: 1px solid;\n border-bottom: 1px solid;\n border-color: var(--rm-page-gap-border-color);\n }\n .rm-with-pagination,\n .rm-with-pagination .rm-first-page-header {\n counter-reset: page-number page-number-plus 1;\n }\n .rm-with-pagination .image-plus-wrapper,\n .rm-with-pagination .table-plus td,\n .rm-with-pagination .table-plus th {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n }\n .rm-with-pagination .image-plus-wrapper {\n overflow-y: visible;\n }\n .rm-with-pagination .rm-page-break {\n counter-increment: page-number page-number-plus;\n }\n \n .rm-with-pagination .rm-page-break:last-child .rm-pagination-gap {\n display: none;\n }\n .rm-with-pagination .rm-page-break:last-child .rm-page-header {\n display: none;\n }\n \n .rm-with-pagination table tr td,\n .rm-with-pagination table tr th {\n word-break: break-all;\n }\n .rm-with-pagination table > tr {\n display: grid;\n min-width: 100%;\n }\n .rm-with-pagination table {\n border-collapse: collapse;\n width: 100%;\n display: contents;\n }\n .rm-with-pagination table tbody{\n display: table;\n max-height: 300px;\n overflow-y: auto;\n }\n .rm-with-pagination table tbody > tr{\n display: table-row !important;\n }\n .rm-with-pagination *:has(>br.ProseMirror-trailingBreak:only-child) {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .rm-br-decoration {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .table-row-group {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n width: 100%;\n }\n .rm-with-pagination .rm-page-footer-left,\n .rm-with-pagination .rm-page-footer-right,\n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-header-right {\n display: inline-block;\n }\n \n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-footer-left{\n float: left;\n margin-left: var(--rm-margin-left);\n }\n .rm-with-pagination .rm-page-header-right,\n .rm-with-pagination .rm-page-footer-right{\n float: right;\n margin-right: var(--rm-margin-right);\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-right{\n margin-right: 0px !important;\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-left{\n margin-left: 0px !important;\n }\n .rm-with-pagination .rm-page-number::before {\n content: counter(page-number);\n }\n .rm-with-pagination .rm-page-number-plus::before {\n content: counter(page-number-plus);\n }\n .rm-with-pagination .rm-page-header,\n .rm-with-pagination .rm-page-footer{\n width: 100%;\n }\n .rm-with-pagination .rm-page-header{\n padding-bottom: var(--rm-content-margin-top) !important;\n padding-top: var(--rm-margin-top) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-margin-top) - var(--rm-content-margin-top));\n overflow-y: hidden;\n }\n .rm-with-pagination .rm-page-footer{\n padding-top: var(--rm-content-margin-bottom) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-content-margin-bottom) - var(--rm-margin-bottom));\n overflow-y: hidden;\n }\n .rm-with-pagination[rm-pagination-disabled] {\n padding-top: var(--rm-margin-top) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n }\n ",document.head.appendChild(n),M(a,e.enabled)},addProseMirrorPlugins(){const e=this.editor,a=this.storage;return[new t({key:T,state:{init:(e,t)=>{const n=x(this.options),r=x(this.options),i=E(Object.assign(Object.assign({},this.options),n),/* @__PURE__ */new Map,/* @__PURE__ */new Map);return a.pageBreakBackground=n.pageBreakBackground,a.pageHeight=n.pageHeight,a.pageWidth=n.pageWidth,a.marginTop=n.marginTop,a.marginBottom=n.marginBottom,a.marginLeft=n.marginLeft,a.marginRight=n.marginRight,a.pageGap=n.pageGap,a.contentMarginTop=n.contentMarginTop,a.contentMarginBottom=n.contentMarginBottom,a.footerRight=n.footerRight,a.footerLeft=n.footerLeft,a.headerRight=n.headerRight,a.headerLeft=n.headerLeft,a.customHeader=n.customHeader,a.customFooter=n.customFooter,a.headerHeight=/* @__PURE__ */new Map,a.footerHeight=/* @__PURE__ */new Map,a.appliedConfig=r,{decorations:o.create(t.doc,i)}},apply:(t,n,r,i)=>{const{options:g,config:p}=C(a,this.options);if(a.enabled===a.appliedConfig.enabled&&!1===a.enabled&&!1===a.appliedConfig.enabled)return n;const s=$(e.view,Object.assign(Object.assign({},g),p));return(s>1?s:1)===O(e.view)&&a.enabled===a.appliedConfig.enabled&&a.pageBreakBackground===a.appliedConfig.pageBreakBackground&&a.pageHeight===a.appliedConfig.pageHeight&&a.pageWidth===a.appliedConfig.pageWidth&&a.marginTop===a.appliedConfig.marginTop&&a.marginBottom===a.appliedConfig.marginBottom&&a.marginLeft===a.appliedConfig.marginLeft&&a.marginRight===a.appliedConfig.marginRight&&a.pageGap===a.appliedConfig.pageGap&&a.contentMarginTop===a.appliedConfig.contentMarginTop&&a.contentMarginBottom===a.appliedConfig.contentMarginBottom&&a.headerLeft===a.appliedConfig.headerLeft&&a.headerRight===a.appliedConfig.headerRight&&a.footerLeft===a.appliedConfig.footerLeft&&a.footerRight===a.appliedConfig.footerRight&&f(a.appliedConfig.customHeader,a.customHeader)&&f(a.appliedConfig.customFooter,a.customFooter)?n:(()=>{const{options:t,config:n}=C(a,this.options);m(e.view.dom,t);let r="headerHeight"in this.storage?this.storage.headerHeight:/* @__PURE__ */new Map,g="footerHeight"in this.storage?this.storage.footerHeight:/* @__PURE__ */new Map;const p=E(Object.assign(Object.assign({},t),n),r,g);return a.appliedConfig=n,a.headerHeight=r,a.footerHeight=g,{decorations:o.create(i.doc,[...p]),footerHeight:g}})()}},props:{decorations(e){var t;return null===(t=this.getState(e))||void 0===t?void 0:t.decorations}},view:e=>({update:e=>{const{options:t,config:n}=C(a,this.options);if(!n.enabled&&!e.dom.hasAttribute("rm-pagination-disabled"))return void M(e.dom,!1);const o=$(e,Object.assign(Object.assign({},t),n));if(O(e)!==o)return void requestAnimationFrame(()=>{const t=e.state.tr.setMeta("PAGE_COUNT_META_KEY",{footerHeight:r});e.dispatch(t)});var r;const i=((e,t,a)=>{const n=/* @__PURE__ */new Map,o=e.querySelector(c(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(c(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,u(t.customHeader,{}),"content"),g=((e,t,a)=>{const n=/* @__PURE__ */new Map,o=e.querySelector(h(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(h(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,u({},t.customFooter),"content"),p=/* @__PURE__ */new Map;for(let a=0;a<=o;a++)g.has(a)&&p.set(a,g.get(a)||0);const s=/* @__PURE__ */new Map;for(let a=0;a<=o;a++)i.has(a)&&s.set(a,i.get(a)||0);const d=/* @__PURE__ */new Set([1,...p.keys(),...s.keys()]);let m;for(let a=1;a<=o;a++)if(!d.has(a)){m=a;break}m&&d.add(m),d.delete(0);let l,f={};for(const a of d){const e=s.has(a)?s.get(a)||0:s.get(0)||0,n=p.has(a)?p.get(a)||0:p.get(0)||0,{_pageHeaderHeight:o,_pageHeight:r}=y(t,e,n),i=1===a?r+o:r;1===a&&(f["rm-page-content-first"]=`${i}px`),a===m?f["rm-page-content-general"]=`${i}px`:f[`rm-page-content-${a}`]=`${i}px`,(void 0===l||i<l)&&(l=i)}l&&e.dom.style.setProperty("--rm-max-content-child-height",l-10+"px"),Object.entries(f).forEach(([t,a])=>{e.dom.style.setProperty(`--${t}`,a)}),M(e.dom,t.enabled)}})}),new t({key:H,state:{init:(e,t)=>B(t.doc),apply:(e,t)=>e.docChanged||e.steps.some(e=>e instanceof d)||e.steps.some(e=>e instanceof s)||e.steps.some(e=>e instanceof r)||e.steps.some(e=>e instanceof g)||e.steps.some(e=>e instanceof p)||e.steps.some(e=>e instanceof i)?B(e.doc):t},props:{decorations(e){var t;return null!==(t=H.getState(e))&&void 0!==t?t:o.empty}}})]},addCommands(){return{updatePageBreakBackground:e=>()=>(this.storage.pageBreakBackground=e,!0),updatePageSize:e=>()=>(this.storage.pageHeight=e.pageHeight,this.storage.pageWidth=e.pageWidth,this.storage.marginTop=e.marginTop,this.storage.marginBottom=e.marginBottom,this.storage.marginLeft=e.marginLeft,this.storage.marginRight=e.marginRight,!0),updatePageWidth:e=>()=>(this.storage.pageWidth=e,!0),updatePageHeight:e=>()=>(this.storage.pageHeight=e,!0),updatePageGap:e=>()=>(this.storage.pageGap=e,!0),updateMargins:e=>()=>(this.storage.marginTop=e.top,this.storage.marginBottom=e.bottom,this.storage.marginLeft=e.left,this.storage.marginRight=e.right,!0),updateContentMargins:e=>()=>(this.storage.contentMarginTop=e.top,this.storage.contentMarginBottom=e.bottom,!0),updateHeaderContent:(e,t,a)=>()=>(a?this.storage.customHeader=Object.assign(Object.assign({},this.storage.customHeader),{[a]:{headerLeft:e,headerRight:t}}):(this.storage.headerLeft=e,this.storage.headerRight=t),!0),updateFooterContent:(e,t,a)=>()=>(a?this.storage.customFooter=Object.assign(Object.assign({},this.storage.customFooter),{[a]:{footerLeft:e,footerRight:t}}):(this.storage.footerLeft=e,this.storage.footerRight=t),!0),togglePagination:()=>()=>(this.storage.enabled=!this.storage.enabled,!0),enablePagination:()=>()=>(this.storage.enabled=!0,!0),disablePagination:()=>()=>(this.storage.enabled=!1,!0)}}}),O=e=>{const t=e.dom.querySelector("[data-rm-pagination]");return t?t.children.length:0},$=(e,t)=>{if(t.enabled){const a=((e,t,a=0,n=0)=>{var o;const r=e.dom,i=t.contentMarginTop+t.marginTop+a,g=t.contentMarginBottom+t.marginBottom+n,p=t.pageHeight-i-g,s=r.querySelector("[data-rm-pagination]"),d=O(e);if(s){const e=r.lastElementChild,t=null===(o=s.lastElementChild)||void 0===o?void 0:o.querySelector(".breaker");if(e&&t){const a=e.getBoundingClientRect(),n=t.getBoundingClientRect(),o=a.bottom-n.bottom;if(o>0)return d+Math.ceil(o/p);{const e=Array.from(s.querySelectorAll(".breaker")).filter(e=>e.getBoundingClientRect().top>a.bottom).length;return e>1?d-e:d}}return 1}{const e=r.scrollHeight;let t=Math.ceil(e/p);return t=t<=0?1:t,t}})(e,t);return a<=1?1:a}return 0};function E(e,t,a){if(!e.enabled)return[];const o={headerLeft:e.headerLeft,headerRight:e.headerRight},r={footerLeft:e.footerLeft,footerRight:e.footerRight};return[n.widget(0,n=>{const i=e.pageGap,g=e.pageBreakBackground,p=document.createElement("div");p.dataset.rmPagination="true";const s=(t,a,n,o,r,p)=>{const{_pageHeaderHeight:s,_pageHeight:d}=y(e,o,r),m=document.createElement("div");m.classList.add("rm-page-break");const l=document.createElement("div");l.classList.add("page"),l.style.position="relative",l.style.float="left",l.style.clear="both";const c=t?`calc(${s}px + ${d}px)`:d+"px";l.style.marginTop=p?`var(--rm-page-content-${p}, ${c})`:t?`var(--rm-page-content-first, ${c})`:`var(--rm-page-content-general, ${c})`;const h=document.createElement("div");h.classList.add("breaker"),h.style.width="calc(100% + var(--rm-margin-left) + var(--rm-margin-right))",h.style.marginLeft="calc(-1 * var(--rm-margin-left))",h.style.marginRight="calc(-1 * var(--rm-margin-right))",h.style.position="relative",h.style.float="left",h.style.clear="both",h.style.left="0px",h.style.right="0px",h.style.zIndex="2";const f=document.createElement("div");return f.classList.add("rm-pagination-gap"),f.style.height=i+"px",f.style.borderLeft="1px solid",f.style.borderRight="1px solid",f.style.position="relative",f.style.setProperty("width","calc(100% + 2px)","important"),f.style.left="-1px",f.style.backgroundColor=g,f.style.borderLeftColor=g,f.style.borderRightColor=g,h.append(n,f,a),m.append(l,h),m},d=t.get(0)||0,m=a.get(0)||0,l=document.createDocumentFragment(),c=$(n,e);for(let h=0;h<c;h++){const n=h+1,i=h+2;if(i in e.customHeader||n in e.customFooter||n in e.customHeader){let g=o,p=r,c=d,f=m;i in e.customHeader&&(g=e.customHeader[i]||o,c=t.get(i)||0),n in e.customFooter&&(p=e.customFooter[n]||r,f=a.get(n)||0);let u=s(0===h,v(g.headerRight,g.headerLeft,w(i,e.onHeaderClick),i),b(p.footerRight,p.footerLeft,L(n,e.onFooterClick),n),c,f,n);l.appendChild(u)}else{const t=v(o.headerRight,o.headerLeft,w(i,e.onHeaderClick)),a=b(r.footerRight,r.footerLeft,L(n,e.onFooterClick));l.appendChild(s(0===h,t,a,d,m))}}return p.append(l),p.id="pages",p.classList.add("rm-pages-wrapper"),p},{side:-1}),n.widget(0,()=>{let t=o;1 in e.customHeader&&(t=e.customHeader[1]);const a=v(t.headerRight,t.headerLeft,w(1,e.onHeaderClick));return a.classList.add("rm-first-page-header"),a},{side:-1})]}l(1123,794,95,95,76,76),l(1591,1123,95,95,76,76),l(794,419,76,76,57,57),l(1060,818,96,96,96,96),l(1404,818,96,96,96,96),l(1635,1060,96,96,96,96);var F=j.extend({addOptions(){return{...this.parent?.(),pageHeight:1056,pageWidth:816,pageGap:50,pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5",pageBreakBackground:"#ffffff",marginTop:48,marginBottom:48,marginLeft:72,marginRight:72,contentMarginTop:10,contentMarginBottom:10,headerLeft:"",headerRight:"Page {page}",footerLeft:"",footerRight:"",customHeader:{},customFooter:{}}},addKeyboardShortcuts:()=>({"Mod-Shift-p":()=>!0})});export{F as t};
|
|
1
|
+
import{Extension as e}from"@tiptap/core";import{Plugin as t,PluginKey as a}from"@tiptap/pm/state";import{Decoration as n,DecorationSet as o}from"@tiptap/pm/view";import{AddMarkStep as r,AttrStep as i,RemoveMarkStep as g,RemoveNodeMarkStep as p,ReplaceAroundStep as s,ReplaceStep as d}from"@tiptap/pm/transform";var m=(e,t)=>{const a={"rm-page-height":`${t.pageHeight}px`,"rm-margin-top":`${t.marginTop}px`,"rm-margin-bottom":`${t.marginBottom}px`,"rm-margin-left":`${t.marginLeft}px`,"rm-margin-right":`${t.marginRight}px`,"rm-content-margin-top":`${t.contentMarginTop}px`,"rm-content-margin-bottom":`${t.contentMarginBottom}px`,"rm-page-gap-border-color":`${t.pageGapBorderColor}`,"rm-page-width":`${t.pageWidth}px`};Object.entries(a).forEach(([t,a])=>{e.style.setProperty(`--${t}`,a)})},l=(e,t,a,n,o,r)=>({pageHeight:e,pageWidth:t,marginTop:a,marginBottom:n,marginLeft:o,marginRight:r}),c=(e,t)=>"actual"===t?`.rm-page-header-${e}`:`.rm-page-header-${e} .rm-page-header-content`,h=(e,t)=>"actual"===t?`.rm-page-footer-${e}`:`.rm-page-footer-${e} .rm-page-footer-content`;function f(e,t){if(e===t)return!0;if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return!1;const a=[{x:e,y:t}];for(;a.length;){const e=a.pop();if(!e)continue;const{x:t,y:n}=e;if(t===n)continue;if(typeof t!=typeof n)return!1;if("object"!=typeof t)return!1;if(null==t||null==n)return!1;const o=Object.keys(t),r=Object.keys(n);if(o.length!==r.length)return!1;for(const i of o){if(!(i in n))return!1;const e=t[i],o=n[i];if(e!==o)if("object"==typeof e&&"object"==typeof o)a.push({x:e,y:o});else if(e!==o)return!1}}return!0}function u(e,t){return[...Object.keys(e),...Object.keys(t)].map(Number)}function b(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-footer"),o.classList.add(`rm-page-footer-${n||0}`),o.style.overflow="visible",o.style.position="relative",o.style.cursor="pointer";const r=document.createElement("div");r.classList.add("rm-page-footer-content"),r.style.width="100%",r.style.overflow="hidden";const i=e.replace("{page}",'<span class="rm-page-number"></span>'),g=t.replace("{page}",'<span class="rm-page-number"></span>'),p=document.createElement("div");p.classList.add("rm-page-footer-left"),p.innerHTML=g;const s=document.createElement("div");return s.classList.add("rm-page-footer-right"),s.innerHTML=i,r.append(p,s),o.append(r),o.addEventListener("click",a),o}function v(e,t,a,n){const o=document.createElement("div");o.classList.add("rm-page-header"),o.classList.add(`rm-page-header-${n||0}`),o.style.overflow="hidden",o.style.cursor="pointer",o.style.position="relative";const r=document.createElement("div");r.classList.add("rm-page-header-content"),r.style.width="100%",r.style.overflow="hidden";const i=t.replace("{page}",'<span class="rm-page-number-plus"></span>'),g=e.replace("{page}",'<span class="rm-page-number-plus"></span>'),p=document.createElement("div");p.classList.add("rm-page-header-left"),p.innerHTML=i;const s=document.createElement("div");return s.classList.add("rm-page-header-right"),s.innerHTML=g,r.append(p,s),o.append(r),o.addEventListener("click",a),o}var y=(e,t,a)=>{const n=e.contentMarginTop+e.marginTop+t,o=e.contentMarginBottom+e.marginBottom+a;return{_pageHeaderHeight:n,_pageFooterHeight:o,_pageHeight:e.pageHeight-n-o}},w=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},L=(e,t)=>a=>{null==t||t({event:a,pageNumber:e})},H=new a("brDecoration");function B(e){const t=[];return e.descendants((e,a)=>{if("hardBreak"===e.type.name){const e=a+1,o=n.widget(e,()=>{const e=document.createElement("span");return e.classList.add("rm-br-decoration"),e});t.push(o)}}),o.create(e,t)}var R={enabled:!0,pageBreakBackground:"#ffffff",pageHeight:800,pageWidth:789,marginTop:20,marginBottom:20,marginLeft:50,marginRight:50,pageGap:50,contentMarginTop:10,contentMarginBottom:10,footerRight:"{page}",footerLeft:"",headerRight:"",headerLeft:"",customHeader:{},customFooter:{}},k=Object.assign({pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5"},R),M=(e,t=!0)=>{var a;const n=e.querySelector("[data-rm-pagination]");if(t){if(e.removeAttribute("rm-pagination-disabled"),n){const t=null===(a=n.lastElementChild)||void 0===a?void 0:a.querySelector(".breaker");if(t){const a=t.offsetTop+t.offsetHeight;e.style.minHeight=`calc(${a}px + 2px)`}}}else e.setAttribute("rm-pagination-disabled",""),e.style.minHeight="auto"},C=(e,t)=>{var a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,b,v;const y={enabled:null!==(a=e.enabled)&&void 0!==a?a:k.enabled,pageBreakBackground:null!==(n=e.pageBreakBackground)&&void 0!==n?n:k.pageBreakBackground,pageHeight:null!==(o=e.pageHeight)&&void 0!==o?o:k.pageHeight,pageWidth:null!==(r=e.pageWidth)&&void 0!==r?r:R.pageWidth,marginTop:null!==(i=e.marginTop)&&void 0!==i?i:R.marginTop,marginBottom:null!==(g=e.marginBottom)&&void 0!==g?g:R.marginBottom,marginLeft:null!==(p=e.marginLeft)&&void 0!==p?p:R.marginLeft,marginRight:null!==(s=e.marginRight)&&void 0!==s?s:R.marginRight,pageGap:null!==(d=e.pageGap)&&void 0!==d?d:R.pageGap,contentMarginTop:null!==(m=e.contentMarginTop)&&void 0!==m?m:R.contentMarginTop,contentMarginBottom:null!==(l=e.contentMarginBottom)&&void 0!==l?l:R.contentMarginBottom,footerRight:null!==(c=e.footerRight)&&void 0!==c?c:R.footerRight,footerLeft:null!==(h=e.footerLeft)&&void 0!==h?h:R.footerLeft,headerRight:null!==(f=e.headerRight)&&void 0!==f?f:R.headerRight,headerLeft:null!==(u=e.headerLeft)&&void 0!==u?u:R.headerLeft,customHeader:null!==(b=e.customHeader)&&void 0!==b?b:R.customHeader,customFooter:null!==(v=e.customFooter)&&void 0!==v?v:R.customFooter};return{config:y,options:Object.assign(Object.assign({},t),y)}},x=e=>{var t,a,n,o,r,i,g,p,s,d,m,l,c,h,f,u,b;return{enabled:null!==(t=e.enabled)&&void 0!==t?t:k.enabled,pageBreakBackground:null!==(a=e.pageBreakBackground)&&void 0!==a?a:k.pageBreakBackground,pageHeight:null!==(n=e.pageHeight)&&void 0!==n?n:k.pageHeight,pageWidth:null!==(o=e.pageWidth)&&void 0!==o?o:R.pageWidth,marginTop:null!==(r=e.marginTop)&&void 0!==r?r:R.marginTop,marginBottom:null!==(i=e.marginBottom)&&void 0!==i?i:R.marginBottom,marginLeft:null!==(g=e.marginLeft)&&void 0!==g?g:R.marginLeft,marginRight:null!==(p=e.marginRight)&&void 0!==p?p:R.marginRight,pageGap:null!==(s=e.pageGap)&&void 0!==s?s:R.pageGap,contentMarginTop:null!==(d=e.contentMarginTop)&&void 0!==d?d:R.contentMarginTop,contentMarginBottom:null!==(m=e.contentMarginBottom)&&void 0!==m?m:R.contentMarginBottom,footerRight:null!==(l=e.footerRight)&&void 0!==l?l:R.footerRight,footerLeft:null!==(c=e.footerLeft)&&void 0!==c?c:R.footerLeft,headerRight:null!==(h=e.headerRight)&&void 0!==h?h:R.headerRight,headerLeft:null!==(f=e.headerLeft)&&void 0!==f?f:R.headerLeft,customHeader:null!==(u=e.customHeader)&&void 0!==u?u:R.customHeader,customFooter:null!==(b=e.customFooter)&&void 0!==b?b:R.customFooter}},T=new a("pagination"),j=e.create({name:"PaginationPlus",addOptions:()=>k,addStorage:()=>Object.assign(Object.assign({},k),{headerHeight:/* @__PURE__ */new Map,footerHeight:/* @__PURE__ */new Map,appliedConfig:R}),onCreate(){const{options:e}=C(this.storage,this.options),t=x(this.options),a=this.editor.view.dom;a.classList.add("rm-with-pagination"),a.style.border="1px solid var(--rm-page-gap-border-color)",a.style.paddingLeft="var(--rm-margin-left)",a.style.paddingRight="var(--rm-margin-right)",a.style.width="var(--rm-page-width)",m(a,Object.assign(Object.assign({},e),t));const n=document.createElement("style");n.dataset.rmPaginationStyle="",n.textContent="\n .rm-pagination-gap{\n border-top: 1px solid;\n border-bottom: 1px solid;\n border-color: var(--rm-page-gap-border-color);\n }\n .rm-with-pagination,\n .rm-with-pagination .rm-first-page-header {\n counter-reset: page-number page-number-plus 1;\n }\n .rm-with-pagination .image-plus-wrapper,\n .rm-with-pagination .table-plus td,\n .rm-with-pagination .table-plus th {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n }\n .rm-with-pagination .image-plus-wrapper {\n overflow-y: visible;\n }\n .rm-with-pagination .rm-page-break {\n counter-increment: page-number page-number-plus;\n }\n \n .rm-with-pagination .rm-page-break:last-child .rm-pagination-gap {\n display: none;\n }\n .rm-with-pagination .rm-page-break:last-child .rm-page-header {\n display: none;\n }\n \n .rm-with-pagination table tr td,\n .rm-with-pagination table tr th {\n word-break: break-all;\n }\n .rm-with-pagination table > tr {\n display: grid;\n min-width: 100%;\n }\n .rm-with-pagination table {\n border-collapse: collapse;\n width: 100%;\n display: contents;\n }\n .rm-with-pagination table tbody{\n display: table;\n max-height: 300px;\n overflow-y: auto;\n }\n .rm-with-pagination table tbody > tr{\n display: table-row !important;\n }\n .rm-with-pagination *:has(>br.ProseMirror-trailingBreak:only-child) {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .rm-br-decoration {\n display: table;\n width: 100%;\n }\n .rm-with-pagination .table-row-group {\n max-height: var(--rm-max-content-child-height);\n overflow-y: auto;\n width: 100%;\n }\n .rm-with-pagination .rm-page-footer-left,\n .rm-with-pagination .rm-page-footer-right,\n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-header-right {\n display: inline-block;\n }\n \n .rm-with-pagination .rm-page-header-left,\n .rm-with-pagination .rm-page-footer-left{\n float: left;\n margin-left: var(--rm-margin-left);\n }\n .rm-with-pagination .rm-page-header-right,\n .rm-with-pagination .rm-page-footer-right{\n float: right;\n margin-right: var(--rm-margin-right);\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-right{\n margin-right: 0px !important;\n }\n .rm-with-pagination .rm-first-page-header .rm-page-header-left{\n margin-left: 0px !important;\n }\n .rm-with-pagination .rm-page-number::before {\n content: counter(page-number);\n }\n .rm-with-pagination .rm-page-number-plus::before {\n content: counter(page-number-plus);\n }\n .rm-with-pagination .rm-page-header,\n .rm-with-pagination .rm-page-footer{\n width: 100%;\n }\n .rm-with-pagination .rm-page-header{\n padding-bottom: var(--rm-content-margin-top) !important;\n padding-top: var(--rm-margin-top) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-margin-top) - var(--rm-content-margin-top));\n overflow-y: hidden;\n }\n .rm-with-pagination .rm-page-footer{\n padding-top: var(--rm-content-margin-bottom) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n display: inline-flex;\n justify-content: space-between;\n max-height: calc(calc(var(--rm-page-height) * 0.45) - var(--rm-content-margin-bottom) - var(--rm-margin-bottom));\n overflow-y: hidden;\n }\n .rm-with-pagination[rm-pagination-disabled] {\n padding-top: var(--rm-margin-top) !important;\n padding-bottom: var(--rm-margin-bottom) !important;\n }\n ",document.head.appendChild(n),M(a,e.enabled)},addProseMirrorPlugins(){const e=this.editor,a=this.storage;return[new t({key:T,state:{init:(e,t)=>{const n=x(this.options),r=x(this.options),i=E(Object.assign(Object.assign({},this.options),n),/* @__PURE__ */new Map,/* @__PURE__ */new Map);return a.pageBreakBackground=n.pageBreakBackground,a.pageHeight=n.pageHeight,a.pageWidth=n.pageWidth,a.marginTop=n.marginTop,a.marginBottom=n.marginBottom,a.marginLeft=n.marginLeft,a.marginRight=n.marginRight,a.pageGap=n.pageGap,a.contentMarginTop=n.contentMarginTop,a.contentMarginBottom=n.contentMarginBottom,a.footerRight=n.footerRight,a.footerLeft=n.footerLeft,a.headerRight=n.headerRight,a.headerLeft=n.headerLeft,a.customHeader=n.customHeader,a.customFooter=n.customFooter,a.headerHeight=/* @__PURE__ */new Map,a.footerHeight=/* @__PURE__ */new Map,a.appliedConfig=r,{decorations:o.create(t.doc,i)}},apply:(t,n,r,i)=>{const{options:g,config:p}=C(a,this.options);if(a.enabled===a.appliedConfig.enabled&&!1===a.enabled&&!1===a.appliedConfig.enabled)return n;const s=$(e.view,Object.assign(Object.assign({},g),p));return(s>1?s:1)===O(e.view)&&a.enabled===a.appliedConfig.enabled&&a.pageBreakBackground===a.appliedConfig.pageBreakBackground&&a.pageHeight===a.appliedConfig.pageHeight&&a.pageWidth===a.appliedConfig.pageWidth&&a.marginTop===a.appliedConfig.marginTop&&a.marginBottom===a.appliedConfig.marginBottom&&a.marginLeft===a.appliedConfig.marginLeft&&a.marginRight===a.appliedConfig.marginRight&&a.pageGap===a.appliedConfig.pageGap&&a.contentMarginTop===a.appliedConfig.contentMarginTop&&a.contentMarginBottom===a.appliedConfig.contentMarginBottom&&a.headerLeft===a.appliedConfig.headerLeft&&a.headerRight===a.appliedConfig.headerRight&&a.footerLeft===a.appliedConfig.footerLeft&&a.footerRight===a.appliedConfig.footerRight&&f(a.appliedConfig.customHeader,a.customHeader)&&f(a.appliedConfig.customFooter,a.customFooter)?n:(()=>{const{options:t,config:n}=C(a,this.options);m(e.view.dom,t);let r="headerHeight"in this.storage?this.storage.headerHeight:/* @__PURE__ */new Map,g="footerHeight"in this.storage?this.storage.footerHeight:/* @__PURE__ */new Map;const p=E(Object.assign(Object.assign({},t),n),r,g);return a.appliedConfig=n,a.headerHeight=r,a.footerHeight=g,{decorations:o.create(i.doc,[...p]),footerHeight:g}})()}},props:{decorations(e){var t;return null===(t=this.getState(e))||void 0===t?void 0:t.decorations}},view:e=>({update:e=>{const{options:t,config:n}=C(a,this.options);if(!n.enabled&&!e.dom.hasAttribute("rm-pagination-disabled"))return void M(e.dom,!1);const o=$(e,Object.assign(Object.assign({},t),n));if(O(e)!==o)return void requestAnimationFrame(()=>{const t=e.state.tr.setMeta("PAGE_COUNT_META_KEY",{footerHeight:r});e.dispatch(t)});var r;const i=((e,t,a)=>{const n=/* @__PURE__ */new Map,o=e.querySelector(c(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(c(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,u(t.customHeader,{}),"content"),g=((e,t,a)=>{const n=/* @__PURE__ */new Map,o=e.querySelector(h(0,a));return n.set(0,o?o.clientHeight:0),t.forEach(t=>{const o=e.querySelector(h(t,a)),r=o?o.clientHeight:0;n.set(t,r)}),n})(e.dom,u({},t.customFooter),"content"),p=/* @__PURE__ */new Map;for(let a=0;a<=o;a++)g.has(a)&&p.set(a,g.get(a)||0);const s=/* @__PURE__ */new Map;for(let a=0;a<=o;a++)i.has(a)&&s.set(a,i.get(a)||0);const d=/* @__PURE__ */new Set([1,...p.keys(),...s.keys()]);let m;for(let a=1;a<=o;a++)if(!d.has(a)){m=a;break}m&&d.add(m),d.delete(0);let l,f={};for(const a of d){const e=s.has(a)?s.get(a)||0:s.get(0)||0,n=p.has(a)?p.get(a)||0:p.get(0)||0,{_pageHeaderHeight:o,_pageHeight:r}=y(t,e,n),i=1===a?r+o:r;1===a&&(f["rm-page-content-first"]=`${i}px`),a===m?f["rm-page-content-general"]=`${i}px`:f[`rm-page-content-${a}`]=`${i}px`,(void 0===l||i<l)&&(l=i)}l&&e.dom.style.setProperty("--rm-max-content-child-height",l-10+"px"),Object.entries(f).forEach(([t,a])=>{e.dom.style.setProperty(`--${t}`,a)}),M(e.dom,t.enabled)}})}),new t({key:H,state:{init:(e,t)=>B(t.doc),apply:(e,t)=>e.docChanged||e.steps.some(e=>e instanceof d)||e.steps.some(e=>e instanceof s)||e.steps.some(e=>e instanceof r)||e.steps.some(e=>e instanceof g)||e.steps.some(e=>e instanceof p)||e.steps.some(e=>e instanceof i)?B(e.doc):t},props:{decorations(e){var t;return null!==(t=H.getState(e))&&void 0!==t?t:o.empty}}})]},addCommands(){return{updatePageBreakBackground:e=>()=>(this.storage.pageBreakBackground=e,!0),updatePageSize:e=>()=>(this.storage.pageHeight=e.pageHeight,this.storage.pageWidth=e.pageWidth,this.storage.marginTop=e.marginTop,this.storage.marginBottom=e.marginBottom,this.storage.marginLeft=e.marginLeft,this.storage.marginRight=e.marginRight,!0),updatePageWidth:e=>()=>(this.storage.pageWidth=e,!0),updatePageHeight:e=>()=>(this.storage.pageHeight=e,!0),updatePageGap:e=>()=>(this.storage.pageGap=e,!0),updateMargins:e=>()=>(this.storage.marginTop=e.top,this.storage.marginBottom=e.bottom,this.storage.marginLeft=e.left,this.storage.marginRight=e.right,!0),updateContentMargins:e=>()=>(this.storage.contentMarginTop=e.top,this.storage.contentMarginBottom=e.bottom,!0),updateHeaderContent:(e,t,a)=>()=>(a?this.storage.customHeader=Object.assign(Object.assign({},this.storage.customHeader),{[a]:{headerLeft:e,headerRight:t}}):(this.storage.headerLeft=e,this.storage.headerRight=t),!0),updateFooterContent:(e,t,a)=>()=>(a?this.storage.customFooter=Object.assign(Object.assign({},this.storage.customFooter),{[a]:{footerLeft:e,footerRight:t}}):(this.storage.footerLeft=e,this.storage.footerRight=t),!0),togglePagination:()=>()=>(this.storage.enabled=!this.storage.enabled,!0),enablePagination:()=>()=>(this.storage.enabled=!0,!0),disablePagination:()=>()=>(this.storage.enabled=!1,!0)}}}),O=e=>{const t=e.dom.querySelector("[data-rm-pagination]");return t?t.children.length:0},$=(e,t)=>{if(t.enabled){const a=((e,t,a=0,n=0)=>{var o;const r=e.dom,i=t.contentMarginTop+t.marginTop+a,g=t.contentMarginBottom+t.marginBottom+n,p=t.pageHeight-i-g,s=r.querySelector("[data-rm-pagination]"),d=O(e);if(s){const e=r.lastElementChild,t=null===(o=s.lastElementChild)||void 0===o?void 0:o.querySelector(".breaker");if(e&&t){const a=e.getBoundingClientRect(),n=t.getBoundingClientRect(),o=a.bottom-n.bottom;if(o>0)return d+Math.ceil(o/p);{const e=Array.from(s.querySelectorAll(".breaker")).filter(e=>e.getBoundingClientRect().top>a.bottom).length;return e>1?d-e:d}}return 1}{const e=r.scrollHeight;let t=Math.ceil(e/p);return t=t<=0?1:t,t}})(e,t);return a<=1?1:a}return 0};function E(e,t,a){if(!e.enabled)return[];const o={headerLeft:e.headerLeft,headerRight:e.headerRight},r={footerLeft:e.footerLeft,footerRight:e.footerRight};return[n.widget(0,n=>{const i=e.pageGap,g=e.pageBreakBackground,p=document.createElement("div");p.dataset.rmPagination="true";const s=(t,a,n,o,r,p)=>{const{_pageHeaderHeight:s,_pageHeight:d}=y(e,o,r),m=document.createElement("div");m.classList.add("rm-page-break");const l=document.createElement("div");l.classList.add("page"),l.style.position="relative",l.style.float="left",l.style.clear="both";const c=t?`calc(${s}px + ${d}px)`:d+"px";l.style.marginTop=p?`var(--rm-page-content-${p}, ${c})`:t?`var(--rm-page-content-first, ${c})`:`var(--rm-page-content-general, ${c})`;const h=document.createElement("div");h.classList.add("breaker"),h.style.width="calc(100% + var(--rm-margin-left) + var(--rm-margin-right))",h.style.marginLeft="calc(-1 * var(--rm-margin-left))",h.style.marginRight="calc(-1 * var(--rm-margin-right))",h.style.position="relative",h.style.float="left",h.style.clear="both",h.style.left="0px",h.style.right="0px",h.style.zIndex="2";const f=document.createElement("div");return f.classList.add("rm-pagination-gap"),f.style.height=i+"px",f.style.borderLeft="1px solid",f.style.borderRight="1px solid",f.style.position="relative",f.style.setProperty("width","calc(100% + 2px)","important"),f.style.left="-1px",f.style.backgroundColor=g,f.style.borderLeftColor=g,f.style.borderRightColor=g,h.append(n,f,a),m.append(l,h),m},d=t.get(0)||0,m=a.get(0)||0,l=document.createDocumentFragment(),c=$(n,e);for(let h=0;h<c;h++){const n=h+1,i=h+2;if(i in e.customHeader||n in e.customFooter||n in e.customHeader){let g=o,p=r,c=d,f=m;i in e.customHeader&&(g=e.customHeader[i]||o,c=t.get(i)||0),n in e.customFooter&&(p=e.customFooter[n]||r,f=a.get(n)||0);let u=s(0===h,v(g.headerRight,g.headerLeft,w(i,e.onHeaderClick),i),b(p.footerRight,p.footerLeft,L(n,e.onFooterClick),n),c,f,n);l.appendChild(u)}else{const t=v(o.headerRight,o.headerLeft,w(i,e.onHeaderClick)),a=b(r.footerRight,r.footerLeft,L(n,e.onFooterClick));l.appendChild(s(0===h,t,a,d,m))}}return p.append(l),p.id="pages",p.classList.add("rm-pages-wrapper"),p},{side:-1}),n.widget(0,()=>{let t=o;1 in e.customHeader&&(t=e.customHeader[1]);const a=v(t.headerRight,t.headerLeft,w(1,e.onHeaderClick));return a.classList.add("rm-first-page-header"),a},{side:-1})]}l(1123,794,95,95,76,76),l(1591,1123,95,95,76,76),l(794,419,76,76,57,57),l(1060,818,96,96,96,96),l(1404,818,96,96,96,96),l(1635,1060,96,96,96,96);var F=j.extend({addOptions(){const e=this.parent;return{...e?.(),pageHeight:1056,pageWidth:816,pageGap:50,pageGapBorderSize:1,pageGapBorderColor:"#e5e5e5",pageBreakBackground:"#ffffff",marginTop:48,marginBottom:48,marginLeft:72,marginRight:72,contentMarginTop:10,contentMarginBottom:10,headerLeft:"",headerRight:"Page {page}",footerLeft:"",footerRight:"",customHeader:{},customFooter:{}}},addKeyboardShortcuts:()=>({"Mod-Shift-p":()=>!0})});export{F as t};
|
package/dist/Pagination.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./Pagination-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./rolldown-runtime-BeavJI0R.cjs");const e=require("./Pagination-CGxVvD1Y.cjs");exports.Pagination=e.Pagination;
|
package/dist/Pagination.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as o}from"./Pagination-
|
|
1
|
+
import{t as o}from"./Pagination-DYCCm6cp.js";export{o as Pagination};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{s as e,t}from"./dist-DmY5xFkC.js";import{_ as r,g as n,h as a,l as o,o as i,p as s,u as l,w as c,x as d,y as u}from"./tooltip-G11f5UOp.js";import{i as h,m as p,n as m,t as f}from"./editorConfig-
|
|
1
|
+
import{s as e,t}from"./dist-DmY5xFkC.js";import{_ as r,g as n,h as a,l as o,o as i,p as s,u as l,w as c,x as d,y as u}from"./tooltip-G11f5UOp.js";import{i as h,m as p,n as m,t as f}from"./editorConfig-9-ZxkRbw.js";import{n as g}from"./locales-rT_qjKW9.js";import{n as v,t as y}from"./BubbleMenus-CFzQBrVG.js";import{t as b}from"./Icon-B4rxamCu.js";import{a as x,c as w,i as S,l as k,o as C,s as N,t as T,u as A}from"./Comment-DcnVhRwn.js";import{$ as M,W as D,Z as E,c as I,ct as R,dt as z,f as _,h as P,i as O,l as L,lt as F,n as B,ot as V,q as $,r as H,s as j,st as q,t as U,u as G,ut as W}from"./reason-toolbar-skin-DarRq6V-.js";import{themeActions as K,useTheme as Y}from"./theme.js";import"./katex.min-CveY35r9.js";import*as X from"react";import Z,{Children as J,Component as Q,Fragment as ee,createContext as te,createElement as re,forwardRef as ne,isValidElement as ae,memo as oe,useCallback as ie,useContext as se,useEffect as le,useId as ce,useImperativeHandle as de,useInsertionEffect as ue,useLayoutEffect as he,useMemo as pe,useRef as me,useState as fe}from"react";import{Slot as ge}from"@radix-ui/react-slot";import ve from"clsx";import{Fragment as ye,jsx as be,jsxs as xe}from"react/jsx-runtime";import{Building2 as we,Check as Se,CheckIcon as ke,ChevronDown as Ce,ChevronRight as Ne,ChevronRightIcon as Te,ChevronUp as Ae,CircleIcon as Me,Cloud as De,Command as Ee,Crown as Ie,Database as Re,Edit2 as ze,Edit3 as _e,Eye as Pe,FileText as Oe,Globe as Le,HardDrive as Fe,HelpCircle as Be,Info as Ve,Keyboard as $e,Link2 as He,Lock as je,LogIn as qe,Mail as Ue,Menu as Ge,MessageSquare as We,MessageSquarePlus as Ke,Monitor as Ye,Moon as Xe,Paintbrush as Ze,PanelRight as Je,Plus as Qe,RotateCcw as et,Search as tt,Server as rt,Settings as nt,Shield as at,Sun as ot,Trash2 as it,UserPlus as st,Users as lt,Wand2 as ct,Workflow as dt,X as ut,XIcon as ht}from"lucide-react";import*as pt from"@radix-ui/react-dialog";import{createDialogScope as mt}from"@radix-ui/react-dialog";import*as ft from"react-dom";import gt,{createPortal as vt}from"react-dom";import*as yt from"@radix-ui/react-dropdown-menu";import*as bt from"@radix-ui/react-label";import*as xt from"@radix-ui/react-select";import*as wt from"@radix-ui/react-separator";import*as St from"@radix-ui/react-tooltip";import*as kt from"@radix-ui/react-switch";import*as Ct from"@radix-ui/react-tabs";import Nt from"grab-url";import{Resizable as Tt}from"re-resizable";var At=Object.defineProperty,Mt=(e,t)=>At(e,"name",{value:t,configurable:!0}),[Dt,Et]=A("AlertDialog",[mt]),It=mt(),Rt=/* @__PURE__ */Mt(e=>{const{__scopeAlertDialog:t,...r}=e,n=It(t);/* @__PURE__ */
|
|
2
2
|
return be(pt.Root,{...n,...r,modal:!0})},"AlertDialog"),zt=(/* @__PURE__ */X.forwardRef(/* @__PURE__ */Mt(function(e,t){const{__scopeAlertDialog:r,...n}=e,a=It(r);/* @__PURE__ */
|
|
3
3
|
return be(pt.Trigger,{...a,...n,ref:t})},"AlertDialogTrigger")),Mt(e=>{const{__scopeAlertDialog:t,...r}=e,n=It(t);/* @__PURE__ */
|
|
4
4
|
return be(pt.Portal,{...n,...r})},"AlertDialogPortal")),_t=X.forwardRef(/* @__PURE__ */Mt(function(e,t){const{__scopeAlertDialog:r,...n}=e,a=It(r);/* @__PURE__ */
|
|
@@ -421,7 +421,7 @@ return xe(ye,{children:[
|
|
|
421
421
|
/* @__PURE__ */be(hE,{open:!!d,onOpenChange:()=>u(null),children:/* @__PURE__ */xe(fE,{children:[/* @__PURE__ */xe(gE,{children:[/* @__PURE__ */be(yE,{children:"Remove Team Member"}),/* @__PURE__ */xe(bE,{children:["Are you sure you want to remove ",d?.name," from the team? They will lose access to all team resources."]})]}),/* @__PURE__ */xe(vE,{children:[/* @__PURE__ */be(wE,{children:"Cancel"}),/* @__PURE__ */be(xE,{onClick:()=>{return d&&(e=d.id,void(a&&i&&(n(t=>t.map(t=>t.id===a?{...t,teams:t.teams.map(t=>t.id===i?{...t,members:t.members.filter(t=>t.id!==e),updatedAt:/* @__PURE__ */new Date}:t)}:t)),u(null),BD.success("Member removed"))));var e},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})};function TE({className:e,...t}){/* @__PURE__ */
|
|
422
422
|
return be(kt.Root,{"data-slot":"switch",className:ec("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:/* @__PURE__ */be(kt.Thumb,{"data-slot":"switch-thumb",className:ec("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}var AE=({open:e,onOpenChange:t,documentTitle:r,documentId:n,sharingInfo:a,teams:o=[],onUpdateSharing:i})=>{const[s,l]=fe(""),[c,d]=fe("editor"),[u,h]=fe(a?.isPublic||!1),[p,m]=fe(a?.sharedWith||[]),[f,g]=fe(a?.shareLink||null),[v,y]=fe(!1),b=()=>{if(!s.trim())return;if(p.find(e=>e.email===s))return void BD.error("Already shared with this user");const e={email:s,role:c,sharedAt:/* @__PURE__ */(new Date).toISOString()},t=[...p,e];m(t),i&&i({...a,isPublic:u,sharedWith:t}),l(""),BD.success(`Invited ${s}`)},x=async()=>{if(!v){y(!0);try{const e=await Nt("doc/share",{method:"POST",headers:{"Content-Type":"application/json"},body:{documentId:n}});return e.success?(g(e.data.shareUrl),i&&i({...a,isPublic:u,sharedWith:p,shareLink:e.data.shareUrl}),e.data.shareUrl):(BD.error(e.error||"Failed to generate share link"),null)}catch(e){return BD.error(e.message||"Failed to generate share link"),null}finally{y(!1)}}};/* @__PURE__ */
|
|
423
423
|
return be(IM,{open:e,onOpenChange:t,children:/* @__PURE__ */xe(_M,{className:"max-w-2xl max-h-[85vh]",children:[/* @__PURE__ */xe(PM,{children:[/* @__PURE__ */xe("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */be(st,{className:"h-5 w-5"}),/* @__PURE__ */xe(LM,{children:['Share "',r,'"']})]}),/* @__PURE__ */be(FM,{children:"Invite people or share with teams"})]}),/* @__PURE__ */xe("div",{className:"space-y-6",children:[
|
|
424
|
-
/* @__PURE__ */xe("div",{className:"flex items-center justify-between p-4 rounded-lg border bg-muted/30",children:[/* @__PURE__ */xe("div",{className:"flex items-center gap-3",children:[u?/* @__PURE__ */be(Le,{className:"h-5 w-5 text-primary"}):/* @__PURE__ */be(je,{className:"h-5 w-5 text-muted-foreground"}),/* @__PURE__ */xe("div",{children:[/* @__PURE__ */be("p",{className:"font-medium text-sm",children:u?"Public Access":"Private"}),/* @__PURE__ */be("p",{className:"text-xs text-muted-foreground",children:u?"Anyone with the link can view":"Only invited people can access"})]})]}),/* @__PURE__ */xe("div",{className:"flex items-center gap-2",children:[u&&/* @__PURE__ */be(oc,{variant:"ghost",size:"sm",onClick:async()=>{let e=f;(e||(e=await x(),e))&&(navigator.clipboard.writeText(e),BD.success("Link copied to clipboard"))},className:"h-8",children:/* @__PURE__ */be(He,{className:"h-4 w-4"})}),/* @__PURE__ */be(TE,{checked:u,onCheckedChange:async e=>{h(e),e&&!f&&await x(),i&&i({...a,isPublic:e,sharedWith:p,shareLink:f}),BD.success(e?"Document is now public":"Document is now private")}})]})]}),
|
|
424
|
+
/* @__PURE__ */xe("div",{className:"flex items-center justify-between p-4 rounded-lg border bg-muted/30",children:[/* @__PURE__ */xe("div",{className:"flex items-center gap-3",children:[u?/* @__PURE__ */be(Le,{className:"h-5 w-5 text-primary"}):/* @__PURE__ */be(je,{className:"h-5 w-5 text-muted-foreground"}),/* @__PURE__ */xe("div",{children:[/* @__PURE__ */be("p",{className:"font-medium text-sm",children:u?"Public Access":"Private"}),/* @__PURE__ */be("p",{className:"text-xs text-muted-foreground",children:u?"Anyone with the link can view":"Only invited people can access"})]})]}),/* @__PURE__ */xe("div",{className:"flex items-center gap-2",children:[u&&/* @__PURE__ */be(oc,{variant:"ghost",size:"sm",onClick:async()=>{let e=f;(e||(e=await x(),e))&&(navigator.clipboard.writeText(e),BD.success("Link copied to clipboard"))},className:"h-8",children:/* @__PURE__ */be(He,{className:"h-4 w-4"})}),/* @__PURE__ */be(TE,{checked:u,onCheckedChange:async e=>{h(e),e&&!f&&await x(),i&&i({...a,isPublic:e,sharedWith:p,shareLink:f??void 0}),BD.success(e?"Document is now public":"Document is now private")}})]})]}),
|
|
425
425
|
/* @__PURE__ */xe("div",{className:"space-y-3",children:[/* @__PURE__ */be(xD,{children:"Invite by email"}),/* @__PURE__ */xe("div",{className:"flex gap-2",children:[
|
|
426
426
|
/* @__PURE__ */xe("div",{className:"relative flex-1",children:[/* @__PURE__ */be(Ue,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),/* @__PURE__ */be(BM,{type:"email",placeholder:"colleague@example.com",value:s,onChange:e=>l(e.target.value),onKeyPress:e=>"Enter"===e.key&&b(),className:"pl-9"})]}),
|
|
427
427
|
/* @__PURE__ */xe(oE,{value:c,onValueChange:e=>d(e),children:[/* @__PURE__ */be(sE,{className:"w-36",children:/* @__PURE__ */be(iE,{})}),/* @__PURE__ */xe(dE,{children:[
|