revise 2.1.0 → 2.2.0
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/CHANGELOG.md +94 -0
- package/assets/historyMaterializeWorker-B51R08XN.js +612 -0
- package/backend.d.ts +8 -2
- package/backend.js +1 -1
- package/chunks/AgentPageRenderer-CH8kSTJn.js +1 -0
- package/chunks/AgentPageRenderer-P23XVguo.js +1 -0
- package/chunks/AttachmentDocumentImporter-B1WOaa7d.js +1 -0
- package/chunks/AttachmentDocumentImporter-CT_PJp_e.js +1 -0
- package/chunks/{BidiText-C8PBPSQY.js → BidiText-Swm5fl9J.js} +74 -74
- package/chunks/DocumentMutator-btiDK57e.js +31 -0
- package/chunks/{DocumentScrubber-DS4LFDKS.js → DocumentScrubber-CMPfm_HF.js} +1 -1
- package/chunks/{DocumentScrubber-COPepQKE.js → DocumentScrubber-Cm2kH8op.js} +1 -1
- package/chunks/{DocumentScrubber-Cf_QqHhF.js → DocumentScrubber-bJoKijol.js} +1 -1
- package/chunks/DocumentStylesheet-DreoD7sD.js +7 -0
- package/chunks/DocxConverter-BcVG-p5K.js +13 -0
- package/chunks/DocxConverter-D2bO5RE-.js +1125 -0
- package/chunks/DocxConverter-haCfRuWb.js +13 -0
- package/chunks/{DocxGraft-Ba63IRP4.js → DocxGraft-BRKh4mHQ.js} +1 -1
- package/chunks/{DocxGraft-DjERgl-z.js → DocxGraft-BxSQtl12.js} +2 -2
- package/chunks/{DocxGraft-cYlmw4Ab.js → DocxGraft-C9MBQCnf.js} +1 -1
- package/chunks/FileImporter-CszqRfVU.js +1 -0
- package/chunks/FileImporter-DObFoCCn.js +1 -0
- package/chunks/{HtmlConverter-Sd9t49vH.js → HtmlConverter-DwXB4IDh.js} +12 -12
- package/chunks/{MarkdownConverter-BdJgh8xt.js → MarkdownConverter-CUC8GgsS.js} +1 -1
- package/chunks/MathRenderer-DT6GyJXb.js +68 -0
- package/chunks/OdtConverter-7h9HHMpL.js +125 -0
- package/chunks/OdtConverter-Ct4qypJk.js +6 -0
- package/chunks/OdtConverter-DFl__sJc.js +6 -0
- package/chunks/OfficeImportShared-BY6FdZ8d.js +1 -0
- package/chunks/OfficeImportShared-BrZoDM0j.js +30 -0
- package/chunks/OfficeImportShared-Bvm-mOyj.js +1 -0
- package/chunks/PdfConverter-1wyvoT7X.js +21 -0
- package/chunks/PdfConverter-BAoEHILo.js +21 -0
- package/chunks/PdfConverter-CKEvFj11.js +448 -0
- package/chunks/{PdfImportService-CQCgsRX1.js → PdfImportService-BhLPp5uG.js} +2 -2
- package/chunks/{PdfImportService-xl7fstr-.js → PdfImportService-xbzrN__L.js} +2 -2
- package/chunks/RtfConverter-Bxn-enp8.js +15 -0
- package/chunks/RtfConverter-LZPzBDSr.js +15 -0
- package/chunks/RtfConverter-_bacXqr1.js +186 -0
- package/chunks/{TableBorders-Cdkc62cX.js → TableBorders-CwnF3jvH.js} +1 -1
- package/chunks/{TxtConverter-C-oiFUAp.js → TxtConverter-C7FOwHpH.js} +1 -1
- package/chunks/XmlConverter-7oo8oeQB.js +2 -0
- package/chunks/XmlConverter-DGORHJcZ.js +96 -0
- package/chunks/XmlConverter-DeLHReK_.js +2 -0
- package/chunks/ar-ComXvtmh.js +13 -0
- package/chunks/backend-DecaBz-I.js +490 -0
- package/chunks/base64-sSPOzq-u.js +198 -0
- package/chunks/{browser-module-CYGCfEyx.js → browser-module-Dj5o3kuL.js} +1 -1
- package/chunks/{browser-module-DgvTMhpA.js → browser-module-UuM_O36W.js} +1 -1
- package/chunks/{capture-BAJ2in5p.js → capture-1btcWcPF.js} +1 -1
- package/chunks/{carrier-C5VZRMxZ.js → carrier-DQeng6yq.js} +1 -1
- package/chunks/de-BkbpIKxx.js +13 -0
- package/chunks/es-CKkXujOF.js +13 -0
- package/chunks/fil-piIHMc8F.js +13 -0
- package/chunks/{footnoteFlatten-Bekh8ZfM.js → footnoteFlatten-DUQticYy.js} +1 -1
- package/chunks/fr-DuA8qLje.js +13 -0
- package/chunks/{graftExport-CRRm1Oe_.js → graftExport-CYnStOdU.js} +1 -1
- package/chunks/index-2TBhRkX7.js +387 -0
- package/chunks/{index-B1idHquf.js → index-Bf14eTEW.js} +231 -229
- package/chunks/index-BwcX_r62.js +387 -0
- package/chunks/{index.es-Bwt05m_b.js → index.es-CI7cDExj.js} +1 -1
- package/chunks/{index.es-DAQD57G4.js → index.es-DHpGt6Y5.js} +1 -1
- package/chunks/ja-DgrSs555.js +13 -0
- package/chunks/{jspdf.es.min-DlTF8uTw.js → jspdf.es.min--GshOuIm.js} +1 -1
- package/chunks/{jspdf.es.min-CnNRolk9.js → jspdf.es.min-DurJZ1zW.js} +1 -1
- package/chunks/pseudoLocale-BoYTjmiK.js +1 -0
- package/chunks/pseudoLocale-DG2NnZmz.js +1 -0
- package/chunks/serverDocumentSession-CJ1EH3Tp.js +15 -0
- package/chunks/{signatures-CBF7NZUy.js → signatures-Bwt_OGik.js} +1 -1
- package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
- package/chunks/zh-9OF3SWWO.js +13 -0
- package/full.js +1 -1
- package/index.d.ts +13 -5
- package/index.js +1 -1
- package/package.json +1 -1
- package/root.js +2 -2
- package/style.css +1 -1
- package/assets/historyMaterializeWorker-C4uxcZEh.js +0 -607
- package/chunks/AgentPageRenderer-BFB0arQL.js +0 -1
- package/chunks/AgentPageRenderer-Dn6SaRjW.js +0 -1
- package/chunks/AttachmentDocumentImporter-BHDJAdky.js +0 -1
- package/chunks/AttachmentDocumentImporter-CxOZqzt1.js +0 -1
- package/chunks/DocumentMutator-4vBJQ74L.js +0 -31
- package/chunks/DocumentStylesheet-byN5dtC6.js +0 -7
- package/chunks/DocxConverter-BCEB7jWY.js +0 -1083
- package/chunks/DocxConverter-C3NflpDr.js +0 -11
- package/chunks/DocxConverter-D9ZNn4nX.js +0 -11
- package/chunks/FileImporter-CHXj9sNX.js +0 -1
- package/chunks/FileImporter-DetvRoJc.js +0 -1
- package/chunks/MathRenderer-B0Y1h1JU.js +0 -62
- package/chunks/OdtConverter-BKtyx012.js +0 -1
- package/chunks/OdtConverter-Ce9j8PRt.js +0 -1
- package/chunks/OdtConverter-D709qfYb.js +0 -31
- package/chunks/PdfConverter-BA8XLTAM.js +0 -21
- package/chunks/PdfConverter-CkDClffR.js +0 -438
- package/chunks/PdfConverter-CxLxd-LJ.js +0 -21
- package/chunks/RtfConverter-BZOnMUGH.js +0 -14
- package/chunks/RtfConverter-Bs81AfXt.js +0 -14
- package/chunks/RtfConverter-DfuE5olb.js +0 -45
- package/chunks/XmlConverter-C0FnrVYk.js +0 -70
- package/chunks/XmlConverter-CQa8baOF.js +0 -2
- package/chunks/XmlConverter-DjEYaIyf.js +0 -2
- package/chunks/ar-BdmGnaKI.js +0 -14
- package/chunks/backend-BIhAX-Gi.js +0 -484
- package/chunks/base64-Qx0OzT4p.js +0 -196
- package/chunks/de-DldIXRFC.js +0 -14
- package/chunks/es-CnyKlSPK.js +0 -14
- package/chunks/index-C-4H81OE.js +0 -378
- package/chunks/index-iZC8xN0t.js +0 -378
- package/chunks/pseudoLocale-BoJwIubw.js +0 -1
- package/chunks/pseudoLocale-DWAm7Dpa.js +0 -1
- package/chunks/serverDocumentSession-DASrQAbW.js +0 -15
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
import{x as G,u as kt,t as
|
|
1
|
+
import{bw as q,M as rt,w as Z,bx as Tt,i as It,by as Ot,bz as yn,bA as kn,bB as Qe,b7 as vn,bC as bt,bD as Cn,bE as Ze,bF as Rt,bG as Sn,bH as wn,x as tt,aN as Tn,aQ as ti,O as Bt,bI as At,aR as ei,f as fe,
|
|
2
|
+
bm as In,bl as ii,G as ni,bc as xt,Q as qt,ao as Pn,bn as ri,aj as Mn,bo as Wt,bp as yt}from"./backend-DecaBz-I.js";import{l as Ln,s as On,d as Rn,i as Bn}from"./HorizontalRuleOrnaments-gmUZ3R7Q.js";import*as st from"yjs";
|
|
3
|
+
import{x as G,u as kt,t as An,y as me,r as Gt,e as ot,z as Wn,v as Ut,F as Ht,L as Fn,c as zn,w as pe,g as Dn,A as Hn,k as si,B as oi}from"./BidiText-Swm5fl9J.js";import{d as Vt,I as Jt,M as En}from"./MathRenderer-DT6GyJXb.js";
|
|
4
4
|
import{a as Pt,l as Mt,g as $n,b as _t,c as Nn}from"./UnicodeUtils-CXtusU4g.js";import{o as jn,s as ai,r as Xn,n as li,p as ci}from"./ListNumbering-Qlu6AuRZ.js";import{n as Yn,b as be,c as Kn}from"./TableGrid-DbroRucl.js";
|
|
5
|
-
import{r as qn,a as Gn,b as Un,q as Vn,u as Et,t as Jn}from"./TableBorders-
|
|
5
|
+
import{r as qn,a as Gn,b as Un,q as Vn,u as Et,t as Jn}from"./TableBorders-CwnF3jvH.js";const di=.001;function _n(c){return{length:c.length,at:t=>c[Math.max(0,Math.min(t,c.length-1))],indexForY:t=>{let e=0,
|
|
6
6
|
i=c.length-1,n=0;for(;e<=i;){const r=e+i>>1;c[r].top<=t+di?(n=r,e=r+1):i=r-1}return n}}}function hi(c){return c.pageHeight+c.pageSpacing}function xe(c){return c.pageMarginTop??c.pageMargin}function ui(c){
|
|
7
7
|
return c.pageMarginRight??c.pageMargin}function ye(c){return c.pageMarginBottom??c.pageMargin}function gi(c){return c.pageMarginLeft??c.pageMargin}function ke(c,t){const e=c.footnotePageInsets?.[t];return typeof e==
|
|
8
8
|
"number"&&Number.isFinite(e)?Math.max(0,e):0}function fi(c,t){const e=c.pageContentTopOffsets?.[t];return typeof e=="number"&&Number.isFinite(e)?Math.max(e,c.textStartY):c.textStartY}function dt(c,t){
|
|
@@ -243,84 +243,85 @@ r1e6 1sync 1syth3i2 swimm6 5tab1o1lism ta3gon. talk1a5 t1a1min t6ap6ath 5tar2rh
|
|
|
243
243
|
y3sc 2t3i4an. ti2n3o1m t1li2er tolo2gy tot3ic trai3tor1 tra1vers travers3a3b treach1e tr4ial. 3tro1le1um trof4ic. tro3fit tro1p2is 3trop1o5les 3trop1o5lis t1ro1pol3it tsch3ie ttrib1ut1 turn3ar t1wh ty\
|
|
244
244
|
2p5al ua3drati uad1ratu u5do3ny uea1m u2r1al. uri4al. us2er. v1ativ v1oir5du1 va6guer vaude3v 1verely. v1er1eig ves1tite vi1vip3a3r voice1p waste3w6a2 wave1g4 w3c week1n wide5sp wo4k1en wrap3aro writ6\
|
|
245
245
|
er. x1q xquis3 y5che3d ym5e5try y1stro yes5ter1y z3ian. z3o1phr z2z3w ",cr=["as-so-ciate","as-so-ciates","dec-li-na-tion","oblig-a-tory","phil-an-thropic","present","presents","project","projects","re\
|
|
246
|
-
ci-procity","re-cog-ni-zance","ref-or-ma-tion","ret-ri-bu-tion","ta-ble"],
|
|
246
|
+
ci-procity","re-cog-ni-zance","ref-or-ma-tion","ret-ri-bu-tion","ta-ble"],Ri=2,Bi=3,dr=5;let Le=null,Ai=null;function hr(c,t){const e=[],i=[];let n=0;for(const s of t)s>="0"&&s<="9"?n=s.charCodeAt(0)-
|
|
247
247
|
48:(i.push(n),e.push(s),n=0);i.push(n);let r=c;for(const s of e){let o=r.children.get(s);o||(o={children:new Map},r.children.set(s,o)),r=o}r.points=i}function ur(){const c={children:new Map};for(const t of lr.
|
|
248
248
|
split(" "))t&&hr(c,t);return c}function gr(){const c=new Map;for(const t of cr){const e=t.replace(/-/g,""),i=[];let n=0;for(const r of t)r==="-"?i.push(n):n+=1;c.set(e,i)}return c}const ee=new Map,fr=2e4,
|
|
249
|
-
mr=Object.freeze([]);function
|
|
250
|
-
const t=c.toLowerCase(),e=ee.get(t);if(e!==void 0)return e;Le===null&&(Le=ur(),
|
|
249
|
+
mr=Object.freeze([]);function Wi(c){if(c.length<dr)return!1;for(let t=0;t<c.length;t++){const e=c.charCodeAt(t),i=e>=97&&e<=122,n=e>=65&&e<=90;if(!i&&!n)return!1}return!0}function pr(c){if(!Wi(c))return mr;
|
|
250
|
+
const t=c.toLowerCase(),e=ee.get(t);if(e!==void 0)return e;Le===null&&(Le=ur(),Ai=gr());let i;const n=Ai.get(t);return n!==void 0?i=Object.freeze(n.filter(r=>r>=Ri&&r<=t.length-Bi)):i=br(t),ee.size>=fr&&
|
|
251
251
|
ee.clear(),ee.set(t,i),i}function br(c){const t=`.${c}.`,e=new Array(t.length+1).fill(0);for(let n=0;n<t.length;n++){let r=Le;for(let s=n;s<t.length;s++){const o=r.children.get(t[s]);if(!o)break;r=o;const a=r.
|
|
252
|
-
points;if(a)for(let l=0;l<a.length;l++){const d=n+l;a[l]>e[d]&&(e[d]=a[l])}}}const i=[];for(let n=
|
|
253
|
-
segments)t+=e.text||"";return t}function Fi(c,t){if(c.tabLayout)return null;for(const n of c.segments)if(n.marks?.latex)return null;const e=zt(c);if(t==="ltr"&&!
|
|
252
|
+
points;if(a)for(let l=0;l<a.length;l++){const d=n+l;a[l]>e[d]&&(e[d]=a[l])}}}const i=[];for(let n=Ri;n<=c.length-Bi;n++)e[n+1]%2===1&&i.push(n);return Object.freeze(i)}function zt(c){let t="";for(const e of c.
|
|
253
|
+
segments)t+=e.text||"";return t}function Fi(c,t){if(c.tabLayout)return null;for(const n of c.segments)if(n.marks?.latex)return null;const e=zt(c);if(t==="ltr"&&!An(e))return null;const i=me(e,t,0,e.length);
|
|
254
254
|
return e.length===0||i.length===1&&!i[0].rtl&&t==="ltr"?null:{runs:i,lineLength:e.length}}function xr(c,t,e){let i=0;for(let n=0;n<t;n++)i+=e(c.runs[n].start,c.runs[n].end);return i}function Oe(c,t,e,i="\
|
|
255
255
|
trailing"){const n=Math.max(0,Math.min(t,c.lineLength)),r=()=>c.runs.findIndex(u=>u.start<=n&&n<u.end),s=()=>c.runs.findIndex(u=>u.end===n),o=()=>c.runs.findIndex(u=>u.start===n);let a;if(i==="leading"?
|
|
256
|
-
(a=r(),a===-1&&(a=o()),a===-1&&(a=s())):(a=s(),a===-1&&(a=r()),a===-1&&(a=o())),a===-1)return 0;const l=c.runs[a],d=xr(c,a,e);return l.rtl?d+e(n,l.end):d+e(l.start,n)}function
|
|
256
|
+
(a=r(),a===-1&&(a=o()),a===-1&&(a=s())):(a=s(),a===-1&&(a=r()),a===-1&&(a=o())),a===-1)return 0;const l=c.runs[a],d=xr(c,a,e);return l.rtl?d+e(n,l.end):d+e(l.start,n)}function Re(c,t,e,i){if(c.runs.length===
|
|
257
257
|
0)return{offset:0,beforeChar:!0};let n=0,r=null,s=0;for(let u=0;u<c.runs.length;u++){const h=i(c.runs[u].start,c.runs[u].end);if(t<n+h||u===c.runs.length-1){r=c.runs[u],s=n;break}n+=h}r||(r=c.runs[c.runs.
|
|
258
258
|
length-1]);const o=i(r.start,r.end),a=t-s,l=r.rtl?o-a:Math.max(0,a);if(l<=0)return{offset:r.start,beforeChar:!0};if(l>=o)return{offset:r.end,beforeChar:!1};let d=0;for(let u=r.start;u<r.end;){const h=Math.
|
|
259
259
|
min(Pt(e,u),r.end),g=i(r.start,h),f=d+(g-d)/2;if(l<f)return{offset:u,beforeChar:!0};if(l<g)return{offset:h,beforeChar:!1};d=g,u=h}return{offset:r.end,beforeChar:!1}}function zi(c,t,e,i){const n=[];let r=0;
|
|
260
260
|
for(const o of c.runs){const a=i(o.start,o.end),l=Math.max(t,o.start),d=Math.min(e,o.end);if(l<d){let u,h;o.rtl?(u=r+i(d,o.end),h=r+i(l,o.end)):(u=r+i(o.start,l),h=r+i(o.start,d)),n.push({x:u,width:Math.
|
|
261
261
|
max(0,h-u)})}r+=a}n.sort((o,a)=>o.x-a.x);const s=[];for(const o of n){const a=s[s.length-1];if(a&&o.x<=a.x+a.width+.5){const l=Math.max(a.x+a.width,o.x+o.width);a.width=l-a.x}else s.push({...o})}return s}
|
|
262
|
-
function
|
|
262
|
+
function Be(c,t,e,i=!1){const n=zt(c),r=[];let s=0;for(let l=0;l<c.segments.length;l++){const d=c.segments[l].text?.length??0;r.push({start:s,end:s+d,segmentIndex:l}),s+=d}const o=[];let a=0;for(const l of t.
|
|
263
263
|
runs){const d=[];for(const u of r){const h=Math.max(l.start,u.start),g=Math.min(l.end,u.end);if(h>=g)continue;if(!i){d.push({start:h,end:g,segmentIndex:u.segmentIndex});continue}let f=h;for(let m=h+1;m<=
|
|
264
264
|
g;m++)(m===g||n[m]===" "!=(n[f]===" "))&&(d.push({start:f,end:m,segmentIndex:u.segmentIndex}),f=m)}l.rtl&&d.reverse();for(const u of d){const h=e(u.start,u.end);o.push({start:u.start,end:u.end,rtl:l.rtl,
|
|
265
265
|
segmentIndex:u.segmentIndex,x:a,width:h}),a+=h}}return o}const yr=/^[\p{Pe}\p{Pf}、。,.!?:;%‰℃¢°・…‥ー々〻ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ]/u,
|
|
266
|
-
kr=/^[\p{Ps}\p{Pi}]$/u;function
|
|
266
|
+
kr=/^[\p{Ps}\p{Pi}]$/u;function Ae(c,t,e){if(!c)return 0;const i=$n(c);let n=0,r=i.length-1;for(;n<r;){const o=Math.floor((n+r+1)/2);e(c.slice(0,i[o]))<=t?n=o:r=o-1}let s=i[n];if(s===0)return 0;if(s<c.
|
|
267
267
|
length){const o=Pt(c,s);if(yr.test(c.slice(s,o))){const l=_t(c,s);l>0&&(s=l)}const a=_t(c,s);a>0&&kr.test(c.slice(a,s))&&(s=a)}return s}function vr(c,t,e){let i=e?.fontSize??t;(e?.superscript||e?.subscript)&&
|
|
268
|
-
(i=Math.round(i*.7));const n=ot(),r=Vt(c,!1,n.text);if(r.image){const s=i/16*Jt;return r.contentWidth*s}return c.length*i*.6}const ie=.8;function
|
|
268
|
+
(i=Math.round(i*.7));const n=ot(),r=Vt(c,!1,n.text);if(r.image){const s=i/16*Jt;return r.contentWidth*s}return c.length*i*.6}const ie=.8;function We(c,t){const e=[];let i="",n=!1;for(const r of c){const s=r!==
|
|
269
269
|
Mt(r,t);i&&s===n?i+=r:(i&&e.push({text:i,lower:n}),i=r,n=s)}return i&&e.push({text:i,lower:n}),e}function Fe(c){const t=!!c?.allCaps,e=!!(c?.smallCaps&&!c?.allCaps),i=typeof c?.letterSpacing=="number"&&
|
|
270
270
|
Number.isFinite(c.letterSpacing)?c.letterSpacing:0;return!t&&!e&&i===0?null:{...t?{uppercase:!0}:{},...e?{smallCaps:!0}:{},...i!==0?{letterSpacingPx:i}:{},...c?.lang?{locale:c.lang}:{}}}function ze(c,t,e){
|
|
271
|
-
let i;if(t?.uppercase)i=e(Mt(c,t.locale));else if(t?.smallCaps){i=0;for(const r of
|
|
271
|
+
let i;if(t?.uppercase)i=e(Mt(c,t.locale));else if(t?.smallCaps){i=0;for(const r of We(c,t.locale))i+=r.lower?e(Mt(r.text,t.locale))*ie:e(r.text)}else i=e(c);const n=t?.letterSpacingPx;return n?i+n*c.length:
|
|
272
272
|
i}let Di=null,De;function Cr(){return typeof document>"u"?null:(De!==void 0||(Di=document.createElement("canvas"),De=Di.getContext("2d")),De)}const Dt=new Map,Sr=32,wr=48,Tr=1e5;let $t=0,ne=null,Hi=!1;
|
|
273
273
|
function Ir(){Hi||typeof document>"u"||(Hi=!0,document.fonts?.addEventListener?.("loadingdone",()=>{Dt.clear(),$t=0}))}function He(c){let t=Dt.get(c);return t||(Dt.size>=Sr&&(Dt.clear(),$t=0),t=new Map,
|
|
274
274
|
Dt.set(c,t)),t}function Ee(c){const t=Cr(),e=t??c;if(Ir(),!t){let o=null;return{measureText:a=>({width:ze(a,o,l=>e.measureText(l).width)}),setFont:a=>{c.font=a,o=null},setMarkAdjustments:a=>{o=a}}}let i=null,
|
|
275
275
|
n=null,r=null;const s=o=>{n||(i=e.font,ne=i,n=He(i));let a=n.get(o);return a===void 0&&(ne!==i&&i!==null&&(e.font=i,ne=i),a=e.measureText(o).width,o.length<=wr&&($t>=Tr&&(Dt.clear(),$t=0,n=He(i??"")),
|
|
276
276
|
n.set(o,a),$t+=1)),a};return{measureText:o=>({width:ze(o,r,s)}),setFont:o=>{c.font=o,e.font=o,i=o,ne=o,n=He(o),r=null},setMarkAdjustments:o=>{r=o}}}function Pr(c,t){if(c===t)return!0;if(!c||!t)return!1;
|
|
277
277
|
const e=c,i=t;for(const n in e){const r=e[n];if(r===void 0)continue;const s=i[n];if(r!==s&&!(typeof r=="object"&&typeof s=="object"&&r!==null&&s!==null&&JSON.stringify(r)===JSON.stringify(s)))return!1}
|
|
278
|
-
for(const n in i)if(i[n]!==void 0&&e[n]===void 0)return!1;return!0}function mt(c,t,e,i,n){c.setFont(Me(t,kt(e),i.fontFamily,{para:e,doc:n})),c.setMarkAdjustments?.(Fe(t))}function Mr(c,t,e,i){let n=0
|
|
279
|
-
for(const
|
|
280
|
-
|
|
278
|
+
for(const n in i)if(i[n]!==void 0&&e[n]===void 0)return!1;return!0}function mt(c,t,e,i,n){c.setFont(Me(t,kt(e),i.fontFamily,{para:e,doc:n})),c.setMarkAdjustments?.(Fe(t))}function Mr(c,t,e,i){let n=0,
|
|
279
|
+
r=0;for(const s of c.children)s.type!=="text"||!s.text||(mt(t,s.marks,c,e,i),s.text.split(`
|
|
280
|
+
`).forEach((o,a)=>{a>0&&(n=Math.max(n,r),r=0),o&&(r+=t.measureText(o).width)}));return Math.max(n,r)}const Lr=.1;function Or(c){let t="";for(const n of c.children)n.type==="text"&&(t+=n.text);let e=t.
|
|
281
|
+
length;for(;e>0&&(t[e-1]===" "||t[e-1]===`
|
|
281
282
|
`);)e--;if(e===0)return-1;let i=e-1;for(;i>0&&t[i-1]!==" "&&t[i-1]!==`
|
|
282
|
-
`;)i--;return i}function
|
|
283
|
-
u=a+c.slice(0,d),h=r.measureText(u).width+o;if(i+h<=n)return{breakOffset:d,prefixText:u,hyphenWidth:o}}return null}const Ei=48,Ct=.5;function
|
|
284
|
-
includes(" "))return!0;return!1}function re(c,t){if(c){for(const e of c)if(e.pos>t+Ct)return e}return{pos:(Math.floor((t+Ct)/Ei)+1)*Ei,align:"left"}}function
|
|
283
|
+
`;)i--;return i}function Rr(c,t,e,i,n,r){if(!Wi(c)||!e&&n-i<=n*Lr)return null;const s=pr(c);if(s.length===0)return null;const o=r.measureText("-").width,a=t?" ":"";for(let l=s.length-1;l>=0;l--){const d=s[l],
|
|
284
|
+
u=a+c.slice(0,d),h=r.measureText(u).width+o;if(i+h<=n)return{breakOffset:d,prefixText:u,hyphenWidth:o}}return null}const Ei=48,Ct=.5;function Br(c){for(const t of c.children)if(t.type==="text"&&t.text.
|
|
285
|
+
includes(" "))return!0;return!1}function re(c,t){if(c){for(const e of c)if(e.pos>t+Ct)return e}return{pos:(Math.floor((t+Ct)/Ei)+1)*Ei,align:"left"}}function Ar(c,t,e,i){const n=vn(c.tabStops);let r="";
|
|
285
286
|
for(const h of c.children)if(h.type==="text"){if(h.marks?.latex)return null;r+=h.text}const s=Gt(c.direction,r)==="rtl",o=[[]];for(const h of c.children){if(h.type!=="text")continue;const g=h.text.split(
|
|
286
287
|
`
|
|
287
288
|
`);for(let f=0;f<g.length;f++)f>0&&o.push([]),g[f]&&o[o.length-1].push({text:g[f],marks:h.marks})}const a=h=>(mt(t,h.marks,c,e,i),t.measureText(h.text).width),l=h=>{let g=0,f=-1;for(const m of h){if(f<
|
|
288
289
|
0){const b=m.text.indexOf(".");b>=0&&(mt(t,m.marks,c,e,i),f=g+t.measureText(m.text.slice(0,b)).width)}g+=a(m)}return{width:g,beforeDecimal:f<0?g:f}},d=[];let u=0;for(let h=0;h<o.length;h++){h>0&&(u+=1);
|
|
289
|
-
const g=o[h],f=bt(e.availableWidth,c,h,e.indentStepPx),m=[];let b=[];for(const I of g){const
|
|
290
|
-
marks:I.marks})),
|
|
291
|
-
d.push({segments:y,startCharOffset:p,endCharOffset:u,...C?{tabLayout:{segments:x,...s?{rtl:!0,width:f}:{}}}:{}}),p=u,y=[],x=[],k=0,C=!1},S=I=>{const
|
|
292
|
-
[]){const
|
|
293
|
-
0),O=I=>{for(const
|
|
294
|
-
|
|
295
|
-
text).join(""),F=me(
|
|
296
|
-
length);Y<et&&(mt(t,U.marks,c,e,i),J+=t.measureText(U.text.slice(Y-X,et-X)).width),X+=U.text.length}return J},E=
|
|
290
|
+
const g=o[h],f=bt(e.availableWidth,c,h,e.indentStepPx),m=[];let b=[];for(const I of g){const A=I.text.split(" ");for(let T=0;T<A.length;T++)T>0&&(m.push({kind:"chunk",pieces:b}),b=[],m.push({kind:"tab",
|
|
291
|
+
marks:I.marks})),A[T]&&b.push({text:A[T],marks:I.marks})}m.push({kind:"chunk",pieces:b});let p=u,y=[],x=[],k=0,C=!1;const v=()=>{y.length===0&&(y.push({text:"",marks:g[0]?.marks}),x.push({startX:0,endX:0})),
|
|
292
|
+
d.push({segments:y,startCharOffset:p,endCharOffset:u,...C?{tabLayout:{segments:x,...s?{rtl:!0,width:f}:{}}}:{}}),p=u,y=[],x=[],k=0,C=!1},S=I=>{const A=[];for(const T of I)for(const L of T.text.match(/ +|[^ ]+/g)??
|
|
293
|
+
[]){const R=L[0]===" "?"space":"word",F=A[A.length-1];F&&F.kind===R?F.pieces.push({text:L,marks:T.marks}):A.push({kind:R,pieces:[{text:L,marks:T.marks}]})}return A},w=I=>I.pieces.reduce((A,T)=>A+a(T),
|
|
294
|
+
0),O=I=>{for(const A of I){const T=a(A);y.push({text:A.text,marks:A.marks}),x.push({startX:k,endX:k+T}),k+=T,u+=A.text.length}},P=I=>{let A=0,T=-1;for(const L of I){if(T<0){const R=L.text.search(/[.,٫]/);
|
|
295
|
+
R>=0&&(mt(t,L.marks,c,e,i),T=A+t.measureText(L.text.slice(0,R)).width)}A+=a(L)}return{width:A,beforeDecimal:T<0?A:T}},M=(I,A)=>{if(I.length===0)return;const T=I.reduce((D,z)=>D+a(z),0),L=A-T,R=I.map(D=>D.
|
|
296
|
+
text).join(""),F=me(R,"rtl",0,R.length),W={segments:I.map(D=>({text:D.text,marks:D.marks})),endCharOffset:R.length},$=(D,z)=>{let J=0,X=0;for(const U of I){const Y=Math.max(D,X),et=Math.min(z,X+U.text.
|
|
297
|
+
length);Y<et&&(mt(t,U.marks,c,e,i),J+=t.measureText(U.text.slice(Y-X,et-X)).width),X+=U.text.length}return J},E=Be(W,{runs:F,lineLength:R.length},$),H=I.map(()=>({min:Number.POSITIVE_INFINITY,max:Number.
|
|
297
298
|
NEGATIVE_INFINITY}));for(const D of E){const z=H[D.segmentIndex];z.min=Math.min(z.min,D.x),z.max=Math.max(z.max,D.x+D.width)}for(let D=0;D<I.length;D++){const z=H[D];y.push({text:I[D].text,marks:I[D].
|
|
298
|
-
marks}),x.push({startX:L+(Number.isFinite(z.min)?z.min:0),endX:L+(Number.isFinite(z.max)?z.max:0)}),u+=I[D].text.length}};if(s){let I=f;const
|
|
299
|
-
t,
|
|
300
|
-
M([{text:$,marks:
|
|
301
|
-
F-E<-.5&&(
|
|
302
|
-
F=m[L+1];let
|
|
303
|
-
2;break;case"decimal":z=E-D+H;break;default:z=E;break}mt(t,
|
|
304
|
-
{leader:$.leader}:{}}),u+=1,M(F.pieces,z),I=z-H;else{const X=Math.max(z,0);y.push({text:" ",marks:
|
|
305
|
-
for(const L of T){let
|
|
306
|
-
O([{text:
|
|
307
|
-
const L=T.reduce((
|
|
308
|
-
beforeDecimal:E}=l(
|
|
309
|
-
" ").width;if(H<F+D&&(H=F+D),H+$<=f+Ct)y.push({text:" ",marks:L.marks}),x.push({startX:F,endX:H,...
|
|
310
|
-
marks}),x.push({startX:F,endX:z,...
|
|
299
|
+
marks}),x.push({startX:L+(Number.isFinite(z.min)?z.min:0),endX:L+(Number.isFinite(z.max)?z.max:0)}),u+=I[D].text.length}};if(s){let I=f;const A=L=>{for(const R of L){let F=R.text;for(;F.length>0;){mt(
|
|
300
|
+
t,R.marks,c,e,i);let W=Ae(F,Math.max(0,I),H=>t.measureText(H).width);if(W===0)if(y.length===0)W=Pt(F,0);else{v(),I=f;continue}const $=F.substring(0,W);mt(t,R.marks,c,e,i);const E=t.measureText($).width;
|
|
301
|
+
M([{text:$,marks:R.marks}],I),I-=E,F=F.substring(W),F.length>0&&(v(),I=f)}}},T=L=>{let R=[],F=0;const W=()=>{R.length>0&&(M(R,I),I-=F,R=[],F=0)};for(const $ of S(L)){const E=w($);if($.kind==="word"&&I-
|
|
302
|
+
F-E<-.5&&(W(),y.length>0&&(v(),I=f),E>f+Ct)){A($.pieces);continue}R.push(...$.pieces),F+=E}W()};(L=>{const{width:R}=P(L);I-R>=-.5?(M(L,I),I-=R):T(L)})(m[0].pieces);for(let L=1;L<m.length;L+=2){const R=m[L],
|
|
303
|
+
F=m[L+1];let W=I,$=re(n,f-I);$.pos>f+Ct&&y.length>0&&(v(),I=f,W=I,$=re(n,0)),C=!0;const E=f-$.pos,{width:H,beforeDecimal:D}=P(F.pieces);let z;switch($.align){case"right":z=E+H;break;case"center":z=E+H/
|
|
304
|
+
2;break;case"decimal":z=E-D+H;break;default:z=E;break}mt(t,R.marks,c,e,i);const J=t.measureText(" ").width;if(z>W-J&&(z=W-J),z-H>=-.5)y.push({text:" ",marks:R.marks}),x.push({startX:z,endX:W,...$.leader?
|
|
305
|
+
{leader:$.leader}:{}}),u+=1,M(F.pieces,z),I=z-H;else{const X=Math.max(z,0);y.push({text:" ",marks:R.marks}),x.push({startX:X,endX:W,...$.leader?{leader:$.leader}:{}}),u+=1,I=X,T(F.pieces)}}}else{const I=T=>{
|
|
306
|
+
for(const L of T){let R=L.text;for(;R.length>0;){mt(t,L.marks,c,e,i);let F=Ae(R,Math.max(0,f-k),$=>t.measureText($).width);if(F===0)if(y.length===0)F=Pt(R,0);else{v();continue}const W=R.substring(0,F);
|
|
307
|
+
O([{text:W,marks:L.marks}]),R=R.substring(F),R.length>0&&v()}}},A=T=>{for(const L of S(T)){const R=w(L);if(L.kind==="word"&&k+R>f+Ct&&(y.length>0&&v(),R>f+Ct)){I(L.pieces);continue}O(L.pieces)}};(T=>{
|
|
308
|
+
const L=T.reduce((R,F)=>R+a(F),0);k+L<=f+Ct?O(T):A(T)})(m[0].pieces);for(let T=1;T<m.length;T+=2){const L=m[T],R=m[T+1];let F=k,W=re(n,k);W.pos>f+Ct&&y.length>0&&(v(),F=0,W=re(n,0)),C=!0;const{width:$,
|
|
309
|
+
beforeDecimal:E}=l(R.pieces);let H;switch(W.align){case"right":H=W.pos-$;break;case"center":H=W.pos-$/2;break;case"decimal":H=W.pos-E;break;default:H=W.pos;break}mt(t,L.marks,c,e,i);const D=t.measureText(
|
|
310
|
+
" ").width;if(H<F+D&&(H=F+D),H+$<=f+Ct)y.push({text:" ",marks:L.marks}),x.push({startX:F,endX:H,...W.leader?{leader:W.leader}:{}}),u+=1,k=H,O(R.pieces);else{const z=Math.min(H,f);y.push({text:" ",marks:L.
|
|
311
|
+
marks}),x.push({startX:F,endX:z,...W.leader?{leader:W.leader}:{}}),u+=1,k=z,A(R.pieces)}}}v()}return d}function Wr(c){const t=[];let e=null;for(const i of c){if(i.type!=="text")continue;if(i.marks?.latex){
|
|
311
312
|
t.push({kind:"latex",text:i.text,marks:i.marks}),e=null;continue}const n=i.text.split(`
|
|
312
313
|
`);for(let r=0;r<n.length;r++){r>0&&(t.push({kind:"newline"}),e=null);const s=n[r].includes(" "),o=s?n[r].split(/([ \t])/):n[r].split(" ");for(let a=0;a<o.length;a+=s?2:1)a===0&&e?e.pieces.push({text:o[0],
|
|
313
|
-
marks:i.marks}):(e={kind:"word",pieces:[{text:o[a],marks:i.marks}],leadingWhitespace:a>0?s?o[a-1]:" ":""},t.push(e))}}return t}function $i(c,t,e,i){if(c.tabStops!==void 0||
|
|
314
|
+
marks:i.marks}):(e={kind:"word",pieces:[{text:o[a],marks:i.marks}],leadingWhitespace:a>0?s?o[a-1]:" ":""},t.push(e))}}return t}function $i(c,t,e,i){if(c.tabStops!==void 0||Br(c)){const n=Ar(c,t,e,i);if(n)
|
|
314
315
|
return n}return Fr(c,t,e,i)}function Fr(c,t,e,i){const n=c.align,r=e.hyphenationEnabled===!0&&!c.heading&&(n===void 0||n==="left"||n==="justify")&&Gt(c.direction,c.children.map(s=>s.text??"").join(""))!==
|
|
315
316
|
"rtl";return Ni(c.children,t,{getAvailableWidth:s=>bt(e.availableWidth,c,s,e.indentStepPx),setFont:s=>mt(t,s,c,e,i),measureLatex:(s,o)=>vr(s,kt(c),o),hyphenation:r?{justify:n==="justify",lastWordStartOffset:Or(
|
|
316
317
|
c)}:void 0})}function Ni(c,t,e){const i=[];let n=[],r=0,s=0,o=0,a=e.getAvailableWidth(0),l=!1,d;const u=m=>{(!l||d!==m)&&(e.setFont(m),l=!0,d=m)},h=(m,b)=>{const p=n[n.length-1];p&&Pr(p.marks,b)?p.text+=
|
|
317
318
|
m:n.push({text:m,marks:b})},g=m=>{i.push({segments:n,startCharOffset:o,endCharOffset:s,...m?{hyphenTrailing:m}:{}}),n=[],r=0,a=e.getAvailableWidth(i.length)},f=m=>{const b=m.map(C=>C.text).join("");let p=0,
|
|
318
|
-
y=0,x=0;const k=C=>{const v=p+C.length;let S=x,w=0;for(let O=y;O<m.length&&S<v;O++){const P=m[O],M=S+P.text.length,I=Math.max(0,p-S),
|
|
319
|
-
slice(I,
|
|
320
|
-
x<w;){const O=m[y],P=x+O.text.length,M=Math.max(0,p-x),I=Math.min(O.text.length,w-x);if(M<I&&h(O.text.slice(M,I),O.marks),P>w)break;x=P,y++}s+=S,p=w,p<b.length&&(g(),o=s)}};for(const m of
|
|
319
|
+
y=0,x=0;const k=C=>{const v=p+C.length;let S=x,w=0;for(let O=y;O<m.length&&S<v;O++){const P=m[O],M=S+P.text.length,I=Math.max(0,p-S),A=Math.min(P.text.length,v-S);I<A&&(u(P.marks),w+=t.measureText(P.text.
|
|
320
|
+
slice(I,A)).width),S=M}return w};for(;p<b.length;){const C=b.slice(p),v=a-r;let S=Ae(C,Math.max(0,v),k);if(S===0){if(n.length>0){g(),o=s;continue}S=Pt(C,0)}r+=k(C.slice(0,S));const w=p+S;for(;y<m.length&&
|
|
321
|
+
x<w;){const O=m[y],P=x+O.text.length,M=Math.max(0,p-x),I=Math.min(O.text.length,w-x);if(M<I&&h(O.text.slice(M,I),O.marks),P>w)break;x=P,y++}s+=S,p=w,p<b.length&&(g(),o=s)}};for(const m of Wr(c)){if(m.
|
|
321
322
|
kind==="newline"){n.length>0&&(g(),s+=1,o=s);continue}if(m.kind==="latex"){const x=e.measureLatex(m.text,m.marks);r+x>a&&n.length>0&&(g(),o=s),n.push({text:m.text,marks:m.marks}),r+=x,s+=m.text.length;
|
|
322
323
|
continue}const{pieces:b,leadingWhitespace:p}=m;let y=0;for(let x=0;x<b.length;x++)u(b[x].marks),y+=t.measureText(x===0?p+b[x].text:b[x].text).width;if(r+y>a&&n.length>0){const x=b.length===1?b[0]:null;
|
|
323
|
-
let k=null;if(e.hyphenation&&x&&(!x.marks?.lang||/^en(?:-|$)/i.test(x.marks.lang))&&s+p.length!==e.hyphenation.lastWordStartOffset&&(u(x.marks),k=
|
|
324
|
+
let k=null;if(e.hyphenation&&x&&(!x.marks?.lang||/^en(?:-|$)/i.test(x.marks.lang))&&s+p.length!==e.hyphenation.lastWordStartOffset&&(u(x.marks),k=Rr(x.text,p===" ",e.hyphenation.justify,r,a,t)),k&&x){
|
|
324
325
|
h(k.prefixText,x.marks),s+=k.prefixText.length,g({width:k.hyphenWidth}),o=s;const C=x.text.slice(k.breakOffset);n=[{text:C,marks:x.marks}],r=t.measureText(C).width,s+=C.length,r>a&&(s=o,n=[],r=0,f([{text:C,
|
|
325
326
|
marks:x.marks}]))}else{e.retainWrapSpace&&p?(u(b[0].marks),r+t.measureText(p).width<=a?(h(p,b[0].marks),s+=p.length,g()):(g(),s+=p.length)):(g(),s+=p.length),o=s;for(const C of b)u(C.marks),h(C.text,C.
|
|
326
327
|
marks),r+=t.measureText(C.text).width,s+=C.text.length;r>a&&(s=o,n=[],r=0,f(b))}}else{const x=n.length===0;for(let k=0;k<b.length;k++)h(k===0?p+b[k].text:b[k].text,b[k].marks);r+=y,s+=p.length;for(const k of b)
|
|
@@ -348,13 +349,13 @@ l.end?null:{kind:"replace",suggestionIds:wt([...a.suggestionIds,...l.suggestionI
|
|
|
348
349
|
t"}}function Yi(c,t,e){const i=Yr(e);if(!e&&t)return Xi(c,t);const n=[],r=[],s=[];let o=0;for(let g=0;g<c.length;g+=1){const f=c[g],m=f.text.length,b=o,p=b+m;if(m===0)continue;const y=Kr(f,e);if(y==="\
|
|
349
350
|
hide"){r.push({start:b,end:p}),o=p;continue}if(y==="show"){n.push(f),o=p;continue}if(e&&t&&(f.marks?.insertion||f.marks?.deletion)){n.push(f),o=p;continue}if(f.marks?.insertion){const x=[],k=[],C=b;let v=b,
|
|
350
351
|
S=g,w=o;for(;S<c.length;){const L=c[S];if(L.type!=="text")break;if(L.text.length===0){S+=1;continue}if(!L.marks?.insertion)break;x.push(L),k.push(L.marks?.suggestionId),n.push(L),v=w+L.text.length,w=v,
|
|
351
|
-
S+=1}const O=[],P=[];let M=v,I=v,
|
|
352
|
-
marks?.suggestionId),I=T+L.text.length,T=I,
|
|
353
|
-
k),suggestionIds:wt([...P,...k]),hiddenStart:M,hiddenEnd:I,insertionStart:C,insertionEnd:v}),g=
|
|
354
|
-
const T=c[S];if(T.type!=="text")break;if(T.text.length===0){S+=1;continue}if(!T.marks?.deletion)break;x.push(T),k.push(T.marks?.suggestionId),v=w+T.text.length,w=v,S+=1}const O=[],P=[];let M=v,I=S,
|
|
355
|
-
for(;I<c.length;){const T=c[I];if(T.type!=="text")break;if(T.text.length===0){I+=1;continue}if(!T.marks?.insertion)break;O.push(T),P.push(T.marks?.suggestionId),n.push(T),M=
|
|
352
|
+
S+=1}const O=[],P=[];let M=v,I=v,A=S,T=w;for(;A<c.length;){const L=c[A];if(L.type!=="text")break;if(L.text.length===0){A+=1;continue}if(!L.marks?.deletion)break;O.length===0&&(M=T),O.push(L),P.push(L.
|
|
353
|
+
marks?.suggestionId),I=T+L.text.length,T=I,A+=1}if(O.length>0){r.push({start:M,end:I}),s.push({oldText:O.map(L=>L.text).join(""),newText:x.map(L=>L.text).join(""),deletionSuggestionIds:wt(P),insertionSuggestionIds:wt(
|
|
354
|
+
k),suggestionIds:wt([...P,...k]),hiddenStart:M,hiddenEnd:I,insertionStart:C,insertionEnd:v}),g=A-1,o=T;continue}g=S-1,o=w;continue}if(f.marks?.deletion){const x=[],k=[];let C=b,v=b,S=g,w=o;for(;S<c.length;){
|
|
355
|
+
const T=c[S];if(T.type!=="text")break;if(T.text.length===0){S+=1;continue}if(!T.marks?.deletion)break;x.push(T),k.push(T.marks?.suggestionId),v=w+T.text.length,w=v,S+=1}const O=[],P=[];let M=v,I=S,A=w;
|
|
356
|
+
for(;I<c.length;){const T=c[I];if(T.type!=="text")break;if(T.text.length===0){I+=1;continue}if(!T.marks?.insertion)break;O.push(T),P.push(T.marks?.suggestionId),n.push(T),M=A+T.text.length,A=M,I+=1}if(O.
|
|
356
357
|
length>0){r.push({start:C,end:v}),s.push({oldText:x.map(T=>T.text).join(""),newText:O.map(T=>T.text).join(""),deletionSuggestionIds:wt(k),insertionSuggestionIds:wt(P),suggestionIds:wt([...k,...P]),hiddenStart:C,
|
|
357
|
-
hiddenEnd:v,insertionStart:v,insertionEnd:M}),g=I-1,o=
|
|
358
|
+
hiddenEnd:v,insertionStart:v,insertionEnd:M}),g=I-1,o=A;continue}g=S-1,o=w,n.push(...x);continue}n.push(f),o=p}if(r.length===0)return Xi(c,t,i??void 0);const a=n.map(g=>g.text).join(""),l=c.reduce((g,f)=>g+
|
|
358
359
|
f.text.length,0),d=g=>{const f=Nt(g,0,l);let m=0;for(const b of r){const p=b.end-b.start;if(f<=b.start)break;if(f<b.end)return b.start-m;m+=p}return f-m},u=(g,f="forward")=>{const m=Nt(g,0,a.length);let b=0;
|
|
359
360
|
for(const p of r){const y=p.end-p.start,x=p.start-b;if(m<x)break;if(m===x)return f==="backward"?p.start:p.end;b+=y}return Nt(m+b,0,l)},h=g=>{for(const f of s){const m=Math.min(f.hiddenStart,f.insertionStart),
|
|
360
361
|
b=Math.max(f.hiddenEnd,f.insertionEnd);if(g>=m&&g<=b)return f}return null};return{showRemovals:t,visibleChildren:n,visibleText:a,hiddenRanges:r,replacements:s,toVisibleOffset:d,toActualOffset:u,getReplacementAtActualOffset:h,
|
|
@@ -379,7 +380,7 @@ h-d+g,t,h-d)}else c.lineTo(t,h);if(c.lineTo(t,e+o),o>0){const g=o*oe;c.bezierCur
|
|
|
379
380
|
"string"){if(!e)return i;for(let n=t.indexOf(e);n!==-1;n=t.indexOf(e,n+1))i.push({text:e,startOffset:n,endOffset:n+e.length})}else{const n=new RegExp(e.source,e.global?e.flags:e.flags+"g");for(const r of t.
|
|
380
381
|
matchAll(n))r[0]&&i.push({text:r[0],startOffset:r.index,endOffset:r.index+r[0].length})}return i}static getAdjacentCaretOffset(t,e,i){const n=_(t),r=Math.max(0,Math.min(n.toVisibleOffset(e),n.visibleText.
|
|
381
382
|
length)),s=i==="forward";if(s?r>=n.visibleText.length:r<=0)return null;let o=s?Pt(n.visibleText,r):_t(n.visibleText,r),a=0;for(const l of n.visibleChildren){const d=a+l.text.length;if(o>a&&o<d&&l.marks?.
|
|
382
|
-
latex){o=s?d:a;break}if(d>=o)break;a=d}return n.toActualOffset(o,i)}static renderLineSegments(t,e,i,n,r={}){let s=i;const o=(a,l,d,u)=>{const h=t.direction,g=t.textAlign;try{for(const f of
|
|
383
|
+
latex){o=s?d:a;break}if(d>=o)break;a=d}return n.toActualOffset(o,i)}static renderLineSegments(t,e,i,n,r={}){let s=i;const o=(a,l,d,u)=>{const h=t.direction,g=t.textAlign;try{for(const f of Be(a,l.slices,
|
|
383
384
|
l.measure,r.justify)){const m=a.segments[f.segmentIndex];m&&(t.direction=f.rtl?"rtl":"ltr",t.textAlign="left",n({text:l.lineText.slice(f.start,f.end),marks:m.marks},d+f.x,u+f.start),s=Math.max(s,d+f.x+
|
|
384
385
|
f.width))}}finally{t.direction=h,t.textAlign=g}};if(r.bidiGeometry)o(e,r.bidiGeometry,i,0);else if(r.rtlTabEntries){for(const a of r.rtlTabEntries)a.kind==="tab"?a.leader&&r.renderTab?.(a.marks,i+a.left,
|
|
385
386
|
i+a.right,a.leader):o({segments:a.segments,startCharOffset:0,endCharOffset:a.text.length},{...a,lineText:a.text},i+a.left,a.charStart);s=i+(N.getTabLineWidth(e)??0)}else{let a=0;for(let l=0;l<e.segments.
|
|
@@ -393,9 +394,9 @@ measureLineRange(t,u,h,e,i,n,r,s,o);return{slices:l,lineText:zt(t),measure:d,dir
|
|
|
393
394
|
n==="rtl",s=i.measureText(t).width;let o=e;if(r){if(e<=0)return{offset:t.length,beforeChar:!1};if(e>=s)return{offset:0,beforeChar:!0};o=s-e}else{if(e<=0)return{offset:0,beforeChar:!0};if(e>=s)return{offset:t.
|
|
394
395
|
length,beforeChar:!1}}let a=0,l=0;for(let d=0;d<t.length;){const u=t.codePointAt(d);if(u===void 0)break;const h=String.fromCodePoint(u),g=d+h.length,f=i.measureText(t.slice(0,g)).width,m=Math.max(0,f-
|
|
395
396
|
a),b=a+m/2;if(o<b)return{offset:l,beforeChar:!0};if(l+=h.length,o<f)return{offset:l,beforeChar:!1};a=f,d=g}return{offset:t.length,beforeChar:!1}}static findCharacterAtXWithFormatting(t,e,i,n,r,s,o,a=0){
|
|
396
|
-
const l=s?.type==="paragraph"?s.heading:void 0,d=t.segments.reduce((b,p)=>b+(p.text?.length??0),0),u=N.getLineBidiGeometry(t,i,n,r,s,o,a);if(u)return
|
|
397
|
+
const l=s?.type==="paragraph"?s.heading:void 0,d=t.segments.reduce((b,p)=>b+(p.text?.length??0),0),u=N.getLineBidiGeometry(t,i,n,r,s,o,a);if(u)return Re(u.slices,e,u.lineText,u.measure);if(t.tabLayout?.
|
|
397
398
|
rtl){const b=N.getRtlTabLineEntries(t,i,n,r,s,o);for(const p of b){if(e>=p.right)return{offset:p.charStart,beforeChar:!0};if(e>=p.left){if(p.kind==="tab"){const x=(p.left+p.right)/2;return e>=x?{offset:p.
|
|
398
|
-
charStart,beforeChar:!0}:{offset:p.charStart+1,beforeChar:!1}}const y=
|
|
399
|
+
charStart,beforeChar:!0}:{offset:p.charStart+1,beforeChar:!1}}const y=Re(p.slices,e-p.left,p.text,p.measure);return{offset:p.charStart+y.offset,beforeChar:y.beforeChar}}}return{offset:d,beforeChar:!1}}
|
|
399
400
|
const h=N.isRtlLine(t);let g=e;if(h){const b=N.measureLineRange(t,0,d,i,n,r,s,o,a);if(e<=0)return{offset:d,beforeChar:!1};if(e>=b)return{offset:0,beforeChar:!0};g=b-e}else if(e<=0)return{offset:0,beforeChar:!0};
|
|
400
401
|
if(t.tabLayout){const b=t.tabLayout.segments;let p=0;for(let y=0;y<t.segments.length;y++){const x=t.segments[y],k=x.text||"",C=b[y];if(!k||!C){p+=k.length;continue}if(g<C.endX){if(k===" "){const S=(C.
|
|
401
402
|
startX+C.endX)/2;return g<S?{offset:p,beforeChar:!0}:{offset:p+1,beforeChar:!1}}N.setMeasurementFont(i,n,r,x.marks,l,s,o);const v=N.findCharacterAtX(k,g-C.startX,i,"ltr");return{offset:p+v.offset,beforeChar:v.
|
|
@@ -406,7 +407,7 @@ if(!t)return{offset:0,beforeChar:!0};if(e<=0)return{offset:0,beforeChar:!0};let
|
|
|
406
407
|
length,h=i.measureText(t.slice(0,u)).width,g=Math.max(0,h-r)+(d===" "?n:0),f=s+g,m=s+g/2;if(e<m)return{offset:o,beforeChar:!0};if(o+=d.length,e<f)return{offset:o,beforeChar:!1};r=h,s=f,a=u}return{offset:t.
|
|
407
408
|
length,beforeChar:!1}}static computeLineAlignment(t,e,i,n){let r=0;return t==="center"?r=(i-e)/2:t==="right"&&(r=i-e),{startX:r,extraSpacePerGap:0}}static renderUnderline(t,e,i,n,r,s){t.save(),t.strokeStyle=
|
|
408
409
|
s||r?.text||"#000000",t.lineWidth=1;const o=i+2;t.beginPath(),t.moveTo(e,o),t.lineTo(e+n,o),t.stroke(),t.restore()}static measureSmallCapsRuns(t,e,i){const n="letterSpacing"in t,r=n?t.letterSpacing:void 0;
|
|
409
|
-
n&&r!=="0px"&&(t.letterSpacing="0px");const s=
|
|
410
|
+
n&&r!=="0px"&&(t.letterSpacing="0px");const s=We(e,i).map(o=>({...o,rawWidth:o.lower?t.measureText(Mt(o.text,i)).width*ie:t.measureText(o.text).width}));return n&&r!=="0px"&&(t.letterSpacing=r??"0px"),
|
|
410
411
|
s}static measureSmallCapsWidth(t,e,i=0,n){return N.measureSmallCapsRuns(t,e,n).reduce((r,s)=>r+s.rawWidth,0)+i*e.length}static measureSegmentDisplayWidth(t,e,i){const n=typeof i?.letterSpacing=="numbe\
|
|
411
412
|
r"&&Number.isFinite(i.letterSpacing)?i.letterSpacing:0;if(i?.smallCaps&&!i?.allCaps)return N.measureSmallCapsWidth(t,e,n,i.lang);const r=i?.allCaps?Mt(e,i.lang):e,s="letterSpacing"in t,o=s?t.letterSpacing:
|
|
412
413
|
void 0,a=s&&o!=="0px"&&!!o;a&&(t.letterSpacing="0px");const l=t.measureText(r).width;return a&&(t.letterSpacing=o),l+n*e.length}static fillSmallCapsText(t,e,i,n,r=0,s){const o=N.measureSmallCapsRuns(t,
|
|
@@ -422,7 +423,7 @@ null)continue;const g=Math.max(u,i),f=Math.min(h,n);if(g>=f)continue;const m=g-i
|
|
|
422
423
|
x,s,k,d.color,d.opacity??1)}}static renderCommentBackground(t,e,i,n,r,s,o){if(n<=0)return;const a=(s??ot()).isDark,l=is(),d=rs(),u=(o??"").split(",").filter(b=>!d.has(b));if(u.length===0)return;const h=u.
|
|
423
424
|
some(b=>l.includes(b))?1:.6,g=h;t.save(),t.fillStyle=a?`rgba(214, 158, 46, ${.22*h})`:`rgba(247, 201, 72, ${.28*h})`;const f=i-r*.93,m=r+Math.max(2,Math.round(r*.2));t.fillRect(e,f,n,m),t.fillStyle=a?
|
|
424
425
|
`rgba(214, 158, 46, ${.9*g})`:`rgba(202, 138, 4, ${.9*g})`,t.fillRect(e,f+m-1.5,n,1.5),t.restore()}static renderCodeBackground(t,e,i,n,r,s,o){t.save();const a=o?.background||"rgba(0, 0, 0, 0.06)";t.fillStyle=
|
|
425
|
-
a;const l=2,d=3,u=e-l,h=r+l*2,g=i-r*.93,f=n+l*2;t.beginPath(),Lt(t,u,g,f,h,d),t.fill(),t.restore()}static renderInlineHighlightBackground(t,e,i,n,r,s,o){if(!s||n<=0)return;const a=(o??ot()).isDark,l=
|
|
426
|
+
a;const l=2,d=3,u=e-l,h=r+l*2,g=i-r*.93,f=n+l*2;t.beginPath(),Lt(t,u,g,f,h,d),t.fill(),t.restore()}static renderInlineHighlightBackground(t,e,i,n,r,s,o){if(!s||n<=0)return;const a=(o??ot()).isDark,l=Wn(
|
|
426
427
|
s,a)??s;t.save(),t.globalAlpha=1,t.fillStyle=l;const d=Math.max(1,Math.round(r*.04)),u=Math.max(1,Math.round(r*.08)),h=Math.max(2,Math.round(r*.2)),g=e-d,f=i-r*.93-u,m=n+d*2,b=r+u+h;t.fillRect(g,f,m,b),
|
|
427
428
|
t.restore()}static getInlineCodeTextColor(t){return t?.default||t?.text||null}static getInlineTextColor(t,e,i,n,r){if(e)return this.getTextColorForDiffSegment(e,i);if(t?.link)return i.linkText;if(r&&(t?.
|
|
428
429
|
color||!t?.code)){const s=Cn(t?.color,r);if(s)return s}if(t?.color){const s=Ze(t.color,i.isDark);if(s)return s}return t?.code&&this.getInlineCodeTextColor(n)||i.text}static getTextFill(t,e){const i=t,
|
|
@@ -434,12 +435,12 @@ e.text;case"format":return e.diffFormatChangeText||e.text;default:return e.text}
|
|
|
434
435
|
o.text,e,o.marks);a>r&&(r=a)}else{const a=o.marks?.fontSize??e;a>n&&(n=a)}n===0&&(n=e);const s=n*(t.lineSpacingOverride??i);return r>s*1.25?r:s}static getWrappedLineBoxHeight(t,e,i){return this.getWrappedLineHeight(
|
|
435
436
|
t,e,i)+(t.spaceBefore??0)+(t.spaceAfter??0)}static calculateSelectionRectsForLines(t,e,i,n,r,s,o,a,l,d,u,h,g,f,m,b){const p=[],y=d??0,x=Math.min(u??t.length,t.length),k=s/a,C=P=>this.getWrappedLineHeight(
|
|
436
437
|
P,a,k),v=[],S=[];let w=r;for(let P=y;P<x;P++){const M=t[P];if(!M)continue;const I=C(M);S[P]=I,v[P]=w+(M.spaceBefore??0),w+=I+(M.spaceBefore??0)+(M.spaceAfter??0)}const O=(h?.type==="paragraph"?h.align:
|
|
437
|
-
void 0)==="justify";for(let P=y;P<x;P++){const M=t[P];if(!M)continue;const I=M.startCharOffset,
|
|
438
|
-
L,
|
|
438
|
+
void 0)==="justify";for(let P=y;P<x;P++){const M=t[P];if(!M)continue;const I=M.startCharOffset,A=M.endCharOffset,T=f?.[P]??n,L=v[P]??r,R=S[P]??s,F=this.getLineMaxTextFontSize(M,a),W=this.getSelectionRectTop(
|
|
439
|
+
L,R,F);if(I===A&&e<=I&&i>=A){p.push({x:T,y:W,width:this.getEmptyLineVisualWidth(o,a),height:R});continue}if(e<A&&i>I){const $=Math.max(0,e-I),E=Math.min(A-I,i-I);if($<E){const H=this.resolveBaseFontFamily(
|
|
439
440
|
l,h);let D=null,z=0;const J=P===t.length-1;if(O&&!J&&m){const V=this.measureLineRange(M,0,Math.max(0,M.endCharOffset-M.startCharOffset),o,a,H,h,g),pt=bt(m,h??{},P,b);z=this.computeJustifyExtraSpacePerGap(
|
|
440
441
|
M,V,pt)}const X=this.getLineBidiGeometry(M,o,a,H,h,g,z);X?D=zi(X.slices,$,E,X.measure):M.tabLayout?.rtl&&(D=this.getRtlTabLineSelectionSpans(M,$,E,o,a,H,h,g));const U=D?0:this.measureLineRange(M,$,E,o,
|
|
441
442
|
a,H,h,g,z),Y=Math.max(0,M.endCharOffset-M.startCharOffset),et=!D&&this.isRtlLine(M),at=(()=>{if(D)return T;if(!et)return T+this.measureLineRange(M,0,$,o,a,H,h,g,z);const V=this.measureLineRange(M,0,Y,
|
|
442
|
-
o,a,H,h,g,z),pt=this.measureLineRange(M,0,E,o,a,H,h,g,z);return T+(V-pt)})();let K=
|
|
443
|
+
o,a,H,h,g,z),pt=this.measureLineRange(M,0,E,o,a,H,h,g,z);return T+(V-pt)})();let K=W,j=R,St=!1,it=!1,ct=0;for(const V of M.segments){const pt=ct+(V.text?.length||0);ct<E&&pt>$&&(V.marks?.superscript&&
|
|
443
444
|
(St=!0),V.marks?.subscript&&(it=!0)),ct=pt}if(St){const V=Math.round(a*.4);K-=V,j+=V}if(it){const V=Math.round(a*.15);j+=V}if(D)for(const V of D)p.push({x:at+V.x,y:K,width:V.width,height:j});else p.push(
|
|
444
445
|
{x:at,y:K,width:U,height:j})}}}return p}static resolveBaseFontFamily(t,e){return t||"sans-serif"}static getTabLineWidth(t){const e=t.tabLayout;return!e||e.segments.length===0?null:e.width!==void 0?e.width:
|
|
445
446
|
e.segments[e.segments.length-1].endX}static getRtlTabLineEntries(t,e,i,n,r,s){const o=t.tabLayout?.segments??[],a=[];let l=0,d=[],u=0,h=0,g=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY;const m=()=>{
|
|
@@ -464,39 +465,39 @@ const r=e+(t.hyphenTrailing?.width??0);return Math.max(0,(i-r)/n)}static countSp
|
|
|
464
465
|
e);i&&t.setMarkAdjustments(i)}static measureLatexSegment(t,e,i){const n=N.getEffectiveFontSize(e,i),r=ot(),s=Vt(t,!1,r.text);if(s.loading||!s.image)return t.length*n*.5;const o=n/16*Jt;return s.contentWidth*
|
|
465
466
|
o}static getLatexSegmentHeight(t,e,i){const n=N.getEffectiveFontSize(e,i),r=ot(),s=Vt(t,!1,r.text);if(s.loading||!s.image)return n;const o=n/16*Jt;return s.contentHeight*o}};ae.SELECTION_DESCENDER_RATIO=
|
|
466
467
|
.15,ae.RTL_SCRIPT_CHAR_REGEX=/[\p{Script=Arabic}\p{Script=Hebrew}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Adlam}]/u,ae.LTR_SCRIPT_CHAR_REGEX=/[\p{Script=Latin}\p{Script=Cyrillic}\p{Script=Greek}]/u;
|
|
467
|
-
let
|
|
468
|
+
let B=ae;class Ui{constructor(){this.isTextBased=!0}toVisualOffset(t,e,i){return e}toDocumentOffset(t,e,i,n){return e}getFontSize(t){return kt(t)}getLineHeight(t){return Ut(t)}getBaseFontFamily(t,e){return e.
|
|
468
469
|
fontFamily||"sans-serif"}getCharacterAtPoint(t,e,i,n,r,s,o,a){const l=e-n.x,d=i-n.y,u=Ft(s,n),h=this.getWrappedLines(t,r,u,o);if(h.length===0)return null;const g=this.getLineHeight(t),f=this.getFontSize(
|
|
469
|
-
t),m=g/f,b=a?.lineRange?.start??0,p=a?.lineRange?.end??h.length;if(b>=p)return null;const y=[],x=[];let k=0;for(let T=b;T<p;T++){const L=h[T];if(!L)continue;x[T]=k;const
|
|
470
|
-
y[T]=
|
|
471
|
-
t,s);let O=0;if(t.align==="justify"&&C<h.length-1){const T=v.endCharOffset-v.startCharOffset,L=
|
|
472
|
-
L,
|
|
473
|
-
(
|
|
470
|
+
t),m=g/f,b=a?.lineRange?.start??0,p=a?.lineRange?.end??h.length;if(b>=p)return null;const y=[],x=[];let k=0;for(let T=b;T<p;T++){const L=h[T];if(!L)continue;x[T]=k;const R=B.getWrappedLineHeight(L,f,m);
|
|
471
|
+
y[T]=R,k+=R}let C=b;for(let T=b;T<p;T++){const L=x[T]??0,R=y[T]??g;if(d>=L&&d<L+R){C=T;break}T===p-1&&(C=T)}d<0&&(C=b);const v=h[C];if(!v)return null;const S=this.getLineStartX(t,C,n,h,u,r,o),w=this.getBaseFontFamily(
|
|
472
|
+
t,s);let O=0;if(t.align==="justify"&&C<h.length-1){const T=v.endCharOffset-v.startCharOffset,L=B.measureLineRange(v,0,T,r,f,w,t,o),R=bt(n.width,t,C,s.indentStepPx);O=B.computeJustifyExtraSpacePerGap(v,
|
|
473
|
+
L,R)}const P=B.findCharacterAtXWithFormatting(v,l-S,r,f,w,t,o,O),M=v.startCharOffset+P.offset,I=this.toDocumentOffset(t,M,o,P.beforeChar?"backward":"forward"),A=this.convertOffsetToPosition(t,I);return A&&
|
|
474
|
+
(A.bidiAffinity=P.beforeChar?"leading":"trailing"),{offset:I,position:A,beforeChar:P.beforeChar}}getLineStartX(t,e,i,n,r,s,o){const a=t,l=n[e],d=B.getBlockDirection(t,l),u=Rt(a,e,d,r.indentStepPx);if(!l)
|
|
474
475
|
return u;let h=t.align||(d==="rtl"?"right":"left");if(h==="justify"&&d==="rtl"&&(e===n.length-1||l.tabLayout)&&(h="right"),h==="left")return u;const g=this.getFontSize(t),f=this.getBaseFontFamily(t,r),
|
|
475
|
-
m=l.endCharOffset-l.startCharOffset,b=
|
|
476
|
+
m=l.endCharOffset-l.startCharOffset,b=B.getTabLineWidth(l)??B.measureLineRange(l,0,m,s,g,f,t,o),p=bt(i.width,a,e,r.indentStepPx),y=B.computeLineAlignment(h,b,p,e===n.length-1);return u+y.startX}getSelectionRects(t,e,i,n,r,s,o,a){
|
|
476
477
|
const l=Ft(s,n),d=this.getWrappedLines(t,r,l,o);if(d.length===0)return[];const u=e?this.toVisualOffset(t,this.convertPositionToOffset(t,e),o):0,h=i?this.toVisualOffset(t,this.convertPositionToOffset(t,
|
|
477
478
|
i),o):this.toVisualOffset(t,this.getPlainText(t).length,o),g=a?.lineRange?.start??0,f=Math.min(a?.lineRange?.end??d.length,d.length),m=d[g],b=d[f-1];if(m&&b&&(h<m.startCharOffset||u>b.endCharOffset))return[];
|
|
478
479
|
const p=this.getFontSize(t),y=this.getLineHeight(t),x=this.getBaseFontFamily(t,s),k=[];for(let C=g;C<f;C++){const v=d[C];v&&(v.endCharOffset<u||v.startCharOffset>h)||(k[C]=n.x+this.getLineStartX(t,C,n,
|
|
479
|
-
d,l,r,o))}return
|
|
480
|
-
return this.getPlainText(t).length}findMatches(t,e){return
|
|
480
|
+
d,l,r,o))}return B.calculateSelectionRectsForLines(d,u,h,n.x,n.y,y,r,p,x,a?.lineRange?.start,a?.lineRange?.end,t,o,k,n.width,s.indentStepPx)}getWordCount(t){return Nn(this.getPlainText(t))}getCharCount(t){
|
|
481
|
+
return this.getPlainText(t).length}findMatches(t,e){return B.findTextMatches(this.getPlainText(t),e)}toPlainText(t){return this.getPlainText(t)}shouldRenderActiveSuggestionBackground(t,e,i,n,r){if(typeof e?.
|
|
481
482
|
suggestionId=="string"&&e.suggestionId.length)return r?.has(e.suggestionId)||qi(e.suggestionId)?!0:typeof i!="number"?!1:ts(t,i,e.suggestionId);const s=typeof n=="string"&&n.length>0?n:t.structuralSuggestionKind===
|
|
482
483
|
"insert"&&typeof t.structuralSuggestionId=="string"&&t.structuralSuggestionId.length>0?t.structuralSuggestionId:null;if(!s)return!1;if(r?.has(s)||qi(s))return!0;if(typeof i!="number")return!1;const o=t.
|
|
483
|
-
children.reduce((a,l)=>a+(l.type==="text"?l.text.length:0),0);return i>=0&&i<=o}renderSegment(t,e,i,n,r,s,o,a,l){const d=a?.theme??ot(),u=a?.syntaxTheme,h=l?.diffState!==void 0?l.diffState:
|
|
484
|
-
e.marks)||(o.structuralSuggestionKind==="insert"?"insert":o.structuralSuggestionKind==="delete"?"delete":null),g=
|
|
484
|
+
children.reduce((a,l)=>a+(l.type==="text"?l.text.length:0),0);return i>=0&&i<=o}renderSegment(t,e,i,n,r,s,o,a,l){const d=a?.theme??ot(),u=a?.syntaxTheme,h=l?.diffState!==void 0?l.diffState:B.getDiffState(
|
|
485
|
+
e.marks)||(o.structuralSuggestionKind==="insert"?"insert":o.structuralSuggestionKind==="delete"?"delete":null),g=B.getEffectiveFontSize(r,e.marks);if(e.marks?.latex)return this.renderLatexSegment(t,e.
|
|
485
486
|
text,i,n,r,s,o,e.marks,h,a,l?.suggestionContainer);const f=!!(e.marks?.smallCaps&&!e.marks?.allCaps),m=typeof e.marks?.letterSpacing=="number"&&Number.isFinite(e.marks.letterSpacing)?e.marks.letterSpacing:
|
|
486
|
-
0,b="letterSpacing"in t,p=b?t.letterSpacing:void 0;m!==0&&b&&(t.letterSpacing=`${m}px`);const y=()=>{m!==0&&b&&(t.letterSpacing=p||"0px")},x=l?.extraSpacePerGap??0,k=
|
|
487
|
-
e.marks)+(x>0?
|
|
488
|
-
t,i,n,k,g,e.marks.backgroundColor,d):e.marks?.code&&!h&&
|
|
489
|
-
this.shouldRenderActiveSuggestionBackground(l?.suggestionContainer??o,e.marks,S,void 0,a?.activeSuggestionIds);(h==="insert"||h==="format"||T||h==="delete"&&k===0)&&
|
|
490
|
-
C,n,s,r,d,a?.renderCtx,T)}const w=!!e.marks?.link,O=d.linkText;t.fillStyle=
|
|
491
|
-
P=n-r*.4:e.marks?.subscript&&(P=n+r*.15);const M=!!e.marks?.hidden;M&&(t.save(),t.globalAlpha*=.6);const I=(T,L)=>{const
|
|
492
|
-
lang);else if(m!==0&&!b){const F=t;let
|
|
493
|
-
e.text[
|
|
487
|
+
0,b="letterSpacing"in t,p=b?t.letterSpacing:void 0;m!==0&&b&&(t.letterSpacing=`${m}px`);const y=()=>{m!==0&&b&&(t.letterSpacing=p||"0px")},x=l?.extraSpacePerGap??0,k=B.measureSegmentDisplayWidth(t,e.text,
|
|
488
|
+
e.marks)+(x>0?B.countSpaces(e.text)*x:0),C=h&&k===0?B.getEmptyLineVisualWidth(t,g):k;e.marks?.comment&&B.renderCommentBackground(t,i,n,k,g,d,e.marks.comment),e.marks?.backgroundColor&&!h?B.renderInlineHighlightBackground(
|
|
489
|
+
t,i,n,k,g,e.marks.backgroundColor,d):e.marks?.code&&!h&&B.renderCodeBackground(t,i,n,k,g,d,u);const v=a?.cursorPosition;let S=null;if(v&&v.block===o.id&&(S=v.offset),h){const T=l?.renderActiveSuggestionBackground??
|
|
490
|
+
this.shouldRenderActiveSuggestionBackground(l?.suggestionContainer??o,e.marks,S,void 0,a?.activeSuggestionIds);(h==="insert"||h==="format"||T||h==="delete"&&k===0)&&B.drawDiffBackground(t,h,e.marks,i,
|
|
491
|
+
C,n,s,r,d,a?.renderCtx,T)}const w=!!e.marks?.link,O=d.linkText;t.fillStyle=B.getInlineTextColor(e.marks,h,d,u,B.getTextFill(o,a)),l?.textColor&&!h&&(t.fillStyle=l.textColor);let P=n;e.marks?.superscript?
|
|
492
|
+
P=n-r*.4:e.marks?.subscript&&(P=n+r*.15);const M=!!e.marks?.hidden;M&&(t.save(),t.globalAlpha*=.6);const I=(T,L)=>{const R=e.marks?.allCaps?Mt(T,e.marks.lang):T;if(f)B.fillSmallCapsText(t,T,L,P,m,e.marks?.
|
|
493
|
+
lang);else if(m!==0&&!b){const F=t;let W=L;for(const $ of R)F.fillText($,W,P),W+=F.measureText($).width+m}else t.fillText(R,L,P)};if(x>0){let T=0,L=0;for(let R=0;R<=e.text.length;R++)if(!(R!==e.text.length&&
|
|
494
|
+
e.text[R]!==" ")){if(R>T){const F=B.measureSegmentDisplayWidth(t,e.text.slice(0,T),e.marks);I(e.text.slice(T,R),i+F+L*x)}T=R+1,L++}}else I(e.text,i);if(M){t.restore(),t.save(),t.strokeStyle=String(t.fillStyle),
|
|
494
495
|
t.globalAlpha*=.75,t.lineWidth=1,t.setLineDash([2,2]),t.beginPath();const T=P+3;t.moveTo(i,T),t.lineTo(i+k,T),t.stroke(),t.restore()}if((e.marks?.strikethrough||e.marks?.doubleStrikethrough)&&!h){const T=String(
|
|
495
|
-
t.fillStyle);e.marks?.doubleStrikethrough?(
|
|
496
|
-
marks?.underline||w||
|
|
497
|
-
const h=d?.theme??ot(),g=
|
|
498
|
-
id&&(v=C.offset),l){const w=this.shouldRenderActiveSuggestionBackground(u??o,a,v,void 0,d?.activeSuggestionIds);(l==="insert"||w)&&
|
|
499
|
-
return a?.superscript?S-=r*.4:a?.subscript&&(S+=r*.15),f.image&&!f.loading&&t.drawImage(f.image,i-k,S,y,x),l==="delete"&&h&&!Ne(a?.suggestionId)&&
|
|
496
|
+
t.fillStyle);e.marks?.doubleStrikethrough?(B.renderStrikethrough(t,i,P+g*.09,k,g,T),B.renderStrikethrough(t,i,P-g*.09,k,g,T)):B.renderStrikethrough(t,i,P,k,g,T)}const A=h==="insert"&&Vr()==="word";return(e.
|
|
497
|
+
marks?.underline||w||A)&&!e.marks?.code&&B.renderUnderline(t,i,P,k,d,w?O:void 0),h==="delete"&&d&&!Ne(e.marks?.suggestionId)&&B.renderStrikethrough(t,i,P,C,g,d.diffDelete),y(),k===0&&h?C:k}renderLatexSegment(t,e,i,n,r,s,o,a,l,d,u){
|
|
498
|
+
const h=d?.theme??ot(),g=B.getEffectiveFontSize(r,a),f=Vt(e,!1,h.text),m=g/16*Jt,b=f.contentWidth*m,p=f.contentHeight*m,y=f.width*m,x=f.height*m,k=En*m,C=d?.cursorPosition;let v=null;if(C&&C.block===o.
|
|
499
|
+
id&&(v=C.offset),l){const w=this.shouldRenderActiveSuggestionBackground(u??o,a,v,void 0,d?.activeSuggestionIds);(l==="insert"||w)&&B.drawDiffBackground(t,l,a,i,b,n,s,r,h,d?.renderCtx,w)}let S=n-p*.7-k;
|
|
500
|
+
return a?.superscript?S-=r*.4:a?.subscript&&(S+=r*.15),f.image&&!f.loading&&t.drawImage(f.image,i-k,S,y,x),l==="delete"&&h&&!Ne(a?.suggestionId)&&B.renderStrikethrough(t,i,n,b,g,h.diffDelete),b}canEdit(){
|
|
500
501
|
return!0}isAtomic(){return!1}allowsInternalCursor(){return!0}}let as=0;const Vi=new WeakMap;function ls(c){const t=Vi.get(c);if(t&&t.childrenRef===c.children&&t.heading===c.heading&&t.align===c.align&&
|
|
501
502
|
t.leftIndent===c.leftIndent&&t.firstLineIndent===c.firstLineIndent&&t.tabStops===c.tabStops)return t.hash;const e=JSON.stringify({children:c.children,heading:c.heading,align:c.align,leftIndent:c.leftIndent,
|
|
502
503
|
firstLineIndent:c.firstLineIndent,tabStops:c.tabStops});return Vi.set(c,{hash:e,childrenRef:c.children,heading:c.heading,align:c.align,leftIndent:c.leftIndent,firstLineIndent:c.firstLineIndent,tabStops:c.
|
|
@@ -521,11 +522,11 @@ t.structuralSuggestionKind==="insert"||t.structuralSuggestionKind==="delete")ret
|
|
|
521
522
|
lineY??(a?e.y+e.height/2:l?e.y+e.height-2:e.y+2),u=10,h=7,g=18,f=g/2,m=8,b=.5,p=n(o)+h*2,y=r?.railX??e.x+1.5,x=r?.placeLabelAfterBoundary?y+m:r?Math.max(8,y-p-m):Math.max(8,e.x-p-m),k=r?Math.max(e.y+2,
|
|
522
523
|
Math.min(e.y+e.height-g-2,d-g/2-1)):a?e.y+Math.max(2,(e.height-g)/2):l?Math.max(e.y+2,d-g-3):Math.min(e.y+e.height-g-2,d+3),C=r?.placeLabelAfterBoundary?y+4:x+p+4,v=r?r.placeLabelAfterBoundary?x-4:y-4:
|
|
523
524
|
e.x+8,S=Math.max(e.y+2,k-2),w=Math.min(e.y+e.height-2,k+g+2),O=G(s,.14),P=G(s,.55),M=t.structuralSuggestionKind==="merge"?i.diffDeleteText:i.diffInsertText;return{label:o,accentColor:s,textColor:M,pillFill:O,
|
|
524
|
-
pillStroke:P,pillFontSize:u,pillTextYAdjust:b,pillX:x,pillY:k,pillWidth:p,pillHeight:g,pillRadius:f,railX:y,railTop:S,railBottom:w,connectorStartX:C,connectorEndX:v,lineY:d}}getSegmentDiffState(t,e){return
|
|
525
|
+
pillStroke:P,pillFontSize:u,pillTextYAdjust:b,pillX:x,pillY:k,pillWidth:p,pillHeight:g,pillRadius:f,railX:y,railTop:S,railBottom:w,connectorStartX:C,connectorEndX:v,lineY:d}}getSegmentDiffState(t,e){return B.
|
|
525
526
|
getDiffState(e)||(t.structuralSuggestionKind==="insert"?"insert":t.structuralSuggestionKind==="delete"?"delete":null)}getStructuralSuggestionMarkerAnchor(t,e,i,n,r,s,o){if(!e.structuralSuggestionRole||
|
|
526
|
-
e.structuralSuggestionKind!=="split"&&e.structuralSuggestionKind!=="merge"||r.length===0)return null;const a=e.structuralSuggestionRole==="before"?r.length-1:0,l=r[a];if(!l)return null;let d=
|
|
527
|
-
l)??0;l.segments.forEach(x=>{if(!l.tabLayout){if(x.marks?.latex){d+=
|
|
528
|
-
x.marks)}});const u=
|
|
527
|
+
e.structuralSuggestionKind!=="split"&&e.structuralSuggestionKind!=="merge"||r.length===0)return null;const a=e.structuralSuggestionRole==="before"?r.length-1:0,l=r[a];if(!l)return null;let d=B.getTabLineWidth(
|
|
528
|
+
l)??0;l.segments.forEach(x=>{if(!l.tabLayout){if(x.marks?.latex){d+=B.measureLatexSegment(x.text,kt(e),x.marks);return}vt(t,x.marks,n.fontSize,n.fontFamily,e,o),d+=B.measureSegmentDisplayWidth(t,x.text,
|
|
529
|
+
x.marks)}});const u=B.getBlockDirection(e,r[a]),h=Rt(e,a,u,n.indentStepPx),g=bt(i.width,e,a,n.indentStepPx);let f=i.x+h;const m=e.align||(u==="rtl"?"right":"left"),b=a===r.length-1;m==="center"?f=i.x+
|
|
529
530
|
h+(g-d)/2:m==="right"&&(f=i.x+h+g-d);const p=e.structuralSuggestionRole==="before"?f+d:f,y=s[a]??i.y+kt(e);return{railX:p,lineY:y,placeLabelAfterBoundary:e.structuralSuggestionRole==="before"&&b}}renderStructuralSuggestionMarker(t,e,i,n,r,s,o,a){
|
|
530
531
|
const l=this.getStructuralSuggestionMarkerAnchor(t,e,i,r,s,o,a?.doc),d=this.getStructuralSuggestionMarkerLayout(e,i,n,u=>{t.save(),t.font="500 10px Arial, sans-serif";const h=t.measureText(u).width;return t.
|
|
531
532
|
restore(),h},l);d&&(t.save(),t.strokeStyle=G(d.accentColor,.45),t.lineWidth=1.5,t.beginPath(),t.moveTo(d.railX,d.railTop),t.lineTo(d.railX,d.railBottom),t.stroke(),t.beginPath(),t.moveTo(d.connectorStartX,
|
|
@@ -537,89 +538,89 @@ getPlainText(t),n=Math.max(0,Math.min(e,i.length));return t.id?{block:t.id,offse
|
|
|
537
538
|
0,i))}offsetToChildPosition(t,e){const i=this.getPlainText(t).length;let n=Math.max(0,Math.min(e.offset??0,i));for(let r=0;r<t.children.length;r++){const s=t.children[r];if(s.type!=="text")continue;const o=s.
|
|
538
539
|
text.length;if(n<=o)return{index:r,offset:n};n-=o}return{index:t.children.length-1,offset:n}}renderParagraphDecoration(t,e,i){if(!e.shading&&!e.borders||(e.shading&&e.shading!=="transparent"&&(t.save(),
|
|
539
540
|
t.fillStyle=e.shading,t.fillRect(i.x,i.y,i.width,i.height),t.restore()),!e.borders))return;let n;try{n=JSON.parse(e.borders)}catch{return}const r=(m,b,p,y,x)=>{const k=n[m];if(!k||k.style==="none")return;
|
|
540
|
-
const C=Math.max(.5,k.width??1),v=p===x;if(v&&
|
|
541
|
+
const C=Math.max(.5,k.width??1),v=p===x;if(v&&Bn(k.style)){this.drawOrnamentRule(t,k.style,b,y,p,C,k.color??"#000000");return}t.save(),t.strokeStyle=k.color??"#000000",t.lineWidth=C,k.style==="dashed"?
|
|
541
542
|
t.setLineDash([6,3]):k.style==="dotted"&&t.setLineDash([2,2]);const S=w=>{t.beginPath(),t.moveTo(b+(v?0:w),p+(v?w:0)),t.lineTo(y+(v?0:w),x+(v?w:0)),t.stroke()};k.style==="double"?(S(-C),S(C)):S(0),t.restore()},
|
|
542
543
|
{x:s,y:o,width:a,height:l}=i,d=m=>Math.max(0,n[m]?.space??0),u=o-d("top"),h=o+l+d("bottom"),g=s-d("left"),f=s+a+d("right");r("top",s,u,s+a,u),r("bottom",s,h,s+a,h),r("left",g,o,g,o+l),r("right",f,o,f,
|
|
543
544
|
o+l)}drawOrnamentRule(t,e,i,n,r,s,o){const a=Ln(i,n);t.save(),t.strokeStyle=o,t.fillStyle=o,t.lineWidth=s;for(const l of a.lines)t.beginPath(),t.moveTo(l.from,r),t.lineTo(l.to,r),t.stroke();for(const l of a.
|
|
544
|
-
ornaments)if(e==="stars")for(const d of On(l.cx,r,l.radius))t.beginPath(),t.moveTo(d.x1,d.y1),t.lineTo(d.x2,d.y2),t.stroke();else{const d=
|
|
545
|
+
ornaments)if(e==="stars")for(const d of On(l.cx,r,l.radius))t.beginPath(),t.moveTo(d.x1,d.y1),t.lineTo(d.x2,d.y2),t.stroke();else{const d=Rn(l.cx,r,l.radius);t.beginPath(),t.moveTo(d[0].x,d[0].y);for(const u of d.
|
|
545
546
|
slice(1))t.lineTo(u.x,u.y);t.closePath(),t.fill()}t.restore()}render(t,e,i,n,r){const s=Ee(t),o=this.getWrappedLines(e,s,n,r?.doc),a=Ut(e),l=kt(e),d=a/l,u=r?.theme??ot();this.renderParagraphDecoration(
|
|
546
|
-
t,e,i);const h=k=>
|
|
547
|
+
t,e,i);const h=k=>B.getWrappedLineHeight(k,l,d),g=[],f=[];if(o.length>0){let k=i.y;for(let C=0;C<o.length;C++){const v=h(o[C]);f.push(v),g.push(k+B.getLineMaxTextFontSize(o[C],l)),k+=v}}if(this.renderStructuralSuggestionMarker(
|
|
547
548
|
t,e,i,u,n,o,g,r),o.length===0){if(u&&e.children.length>0){const k=e.children[0];if(k.type==="text"&&k.marks){const C=this.getSegmentDiffState(e,k.marks);if(C){const v=this.shouldRenderActiveSuggestionSegment(
|
|
548
|
-
e,k.marks,r);if(C==="insert"||C==="format"||v||C==="delete"){const S=
|
|
549
|
+
e,k.marks,r);if(C==="insert"||C==="format"||v||C==="delete"){const S=Rt(e,0,B.getBlockDirection(e),n.indentStepPx),w=bt(i.width,e,0,n.indentStepPx);B.drawDiffBackground(t,C,k.marks,i.x+S,w,i.y+l,a,l,u,
|
|
549
550
|
r?.renderCtx,v)}}}}return}const m=r?.fragment,b=o.length,p=Math.max(0,Math.min(m?.lineRange?.start??0,b)),y=Math.max(p,Math.min(m?.lineRange?.end??b,b));if(p>=y)return;const x=f.slice(0,p).reduce((k,C)=>k+
|
|
550
|
-
C,0);for(let k=p;k<y;k++){const C=o[k],v=g[k]-x,S=f[k];let w=
|
|
551
|
-
n.fontFamily,e,r?.doc),w+=
|
|
552
|
-
"rtl"?"right":"left"),T=k===o.length-1,L=
|
|
553
|
-
C,w,M):0,F=
|
|
554
|
-
return r?.annotations&&e.id&&
|
|
555
|
-
tabLayout?.rtl?
|
|
556
|
-
|
|
557
|
-
fillStyle=
|
|
558
|
-
t),l=kt(t),d=a/l,{top:u,bottom:h}=pi(t,r,a*r.paragraphSpacing),g=b=>
|
|
559
|
-
p,0,p.endCharOffset-p.startCharOffset,n,l,this.getBaseFontFamily(t,r),t,s),k=bt(r.availableWidth,t,b,r.indentStepPx);return
|
|
560
|
-
e+y)+x},m=o.length?o.map((b,p)=>({height:g(b),width:r.availableWidth,lineRange:{start:p,end:p+1},charRange:{start:b.startCharOffset,end:b.endCharOffset}})):
|
|
561
|
-
start:0,end:0},charRange:{start:0,end:0}}];return us(m[m.length-1],()=>f(o.length?o.length-1:0)),{x:e,width:r.availableWidth,units:m,margins:{
|
|
562
|
-
t,e,i,n,r,s,o,a);return l?{type:"text",position:l.position||void 0,offset:l.offset,bounds:n}:null}getUIComponents(t,e,i,n,r,s,o){
|
|
563
|
-
return{block:t.id??"",offset:this.getPlainText(t).length}}getNextCursorPosition(t,e){if(!t.id)return null;
|
|
564
|
-
|
|
565
|
-
i),f=this.getWrappedLines(t,n,g,o),m=this.toVisualOffset(t,this.convertPositionToOffset(
|
|
566
|
-
S,u,h),x=[];let k=i.y;const C=a?b:0;for(let S=C;S<f.length;S++){const w=f[S],
|
|
567
|
-
lineIndex,w=v.line,O=x[S]??i.y,P=p(w);let M=
|
|
568
|
-
measureSegmentDisplayWidth(s,K.text,K.marks))});const I=typeof i.x=="number"?i.x:
|
|
569
|
-
A=bt(
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
0,Math.min(m-w.startCharOffset,K));return{x:F+
|
|
573
|
-
length;K++){const j=w.segments[K],St=et?.[K];if(St&&(X=F+St.startX,j.text===" ")){if(U<=
|
|
574
|
-
|
|
575
|
-
j.text.length;it++){if(U<=0){const pt=Y?.marks?.code?l?.syntaxTheme?.text:void 0;return{
|
|
576
|
-
" "&&(X+=z),U--,Y=j}else if(U<=j.text.length){const it=j.text.slice(0,U),ct=X+
|
|
577
|
-
|
|
578
|
-
return
|
|
579
|
-
t.children[0].text===""}cloneParagraphBlock(t){return{type:"paragraph",children:t.children.map(e=>e.type===
|
|
580
|
-
heading,align:t.align,lineSpacing:t.lineSpacing,spaceBefore:t.spaceBefore,spaceAfter:t.spaceAfter,contextualSpacing:t.
|
|
581
|
-
const r=this.cloneParagraphBlock(t),{index:s,offset:o}=this.offsetToChildPosition(r,i),a=r.children[s];
|
|
582
|
-
...n})}return r}deleteRange(t,e,i){const n=this.cloneParagraphBlock(t),r=this.getPlainText(n),s=r.slice(
|
|
583
|
-
|
|
584
|
-
const i=this.getPlainText(t),n=i.slice(0,e),r=i.slice(e),s={type:"paragraph",id:t.id,children:[{type:"
|
|
585
|
-
let e="";for(const a of t.children)if(a.type==="text"){let l=a.text.replace(/&/g,"&").
|
|
586
|
-
</em>`),a.marks?.underline&&(l=`<u>${l}</u>`),e+=l}const i=t.heading?`h${t.heading}`:"
|
|
587
|
-
n.push(`
|
|
588
|
-
>${e}</${i}>`}toMarkdown(t){let e="";for(const i of t.children)if(i.type==="text"){let n=i.
|
|
589
|
-
${e}`:e}toYjs(t,e){return rt(t)}fromYjs(t){const e={type:"paragraph",id:t.getAttribute(
|
|
590
|
-
|
|
591
|
-
r"]){const y=tt(t,p);if(y==null)continue;const x=parseFloat(y);Number.isFinite(x)&&(e[p]=
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
get(p);if(y instanceof st.XmlText){b=y;break}}return b&&
|
|
596
|
-
attributes),e.children.push(y)}}),e.children.length===0&&(e.children=[{type:"text",text:""}]),e}validate(t){
|
|
597
|
-
|
|
598
|
-
action:"split"}}handleDeleteSelection(t,e,i,n){let r=null;for(let a=0;a<e.length;a++){const l=e.get(a);if(l instanceof
|
|
599
|
-
convertPositionToOffset(t,n);return o>s&&r.delete(s,o-s),r.length,!0}}class fs{constructor(){this.type="
|
|
600
|
-
a=e.diffState;let l="#e5e7eb";a&&o?a==="insert"?l=G(o.diffInsert,q.placeholderTintOpacity):a==="delete"&&(l=G(o.
|
|
601
|
-
relativeToPage?0:s?.yOffset??0,u=i.y-d;let h="#9ca3af";a==="insert"&&o?h=o.diffInsert:a==="delete"&&o&&(h=o.diffDelete),
|
|
602
|
-
height),r?.isSelected&&(t.strokeStyle="#9ca3af",t.lineWidth=2,t.strokeRect(i.x,u,i.width,e.height)),t.fillStyle="#9ca3af",
|
|
603
|
-
"milady",i.x+i.width/2,u+e.height/2),ht(e)&&ut(t,i,u,o),t.restore()}getBounds(t,e,i,n,r,s){return{x:e,width:r.availableWidth,
|
|
604
|
-
0:dt(r,0),bottom:0}}}hitTest(t,e,i,n,r,s,o,a){return e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+t.height?{type:"
|
|
605
|
-
return t.id?{block:t.id,offset:0}:null}getNextCursorPosition(t,e){return null}getPreviousCursorPosition(t,e){
|
|
606
|
-
return{x:l?i.x:i.x+i.width,y:d,fontSize:r.fontSize}}getSelectionRects(t,e,i,n,r,s,o,a){return e!==null||i!==
|
|
607
|
-
const l=n.y+t.height/2;return{offset:0,position:null,beforeChar:i<l}}getCharacterOffset(t,e){return 0}getPositionFromOffset(t,e){}getPlainText(t){
|
|
608
|
-
return!0}canEdit(){return!1}canMergeWith(t,e){return!1}toHTML(t){return`<div style="background-color: #e5e7eb; height: ${t.height}
|
|
609
|
-
px]`}toPlainText(t){return"[Placeholder]"}toYjs(t,e){return rt(t)}fromYjs(t){const e=t.getAttribute("height");return{type:"
|
|
610
|
-
return[]}validate(t){const e=[];return(!t.height||t.height<=0)&&e.push("Placeholder height must be positive"),{valid:e.
|
|
611
|
-
return!0}handleEnterKey(t,e){return{action:"insert-after",newBlock:{type:"paragraph",id:Tt(),children:[
|
|
612
|
-
indicatorInsetXPx,Qi=
|
|
613
|
-
renderCtx,o=i.relativeToPage?0:s?.yOffset??0,a=i.y-o,l=s?.theme,d=e.diffState,u=le(i),h=i.x+
|
|
614
|
-
|
|
615
|
-
h-2,g,16,14)),t.strokeStyle=f,t.lineWidth=1.25,t.lineCap="round",t.lineJoin="round",t.globalAlpha=
|
|
616
|
-
9),t.lineTo(h+6,g+6),t.moveTo(h+3,g+9),t.lineTo(h+6,g+12),t.stroke(),l&&ht(e)&&ut(t,i,a,l),l&&(d===
|
|
617
|
-
n.pageMargin)},a+u,14,l,"Page Break",d),t.restore()}getBounds(t,e,i,n,r,s){return{x:e+ms,width:Qi,
|
|
618
|
-
0:dt(r,0),bottom:0}}}hitTest(t,e,i,n,r,s,o,a){const l=le(n);return e>=n.x&&e<=n.x+n.width&&i>=n.y&&
|
|
619
|
-
return t.id?{block:t.id,offset:0}:null}
|
|
620
|
-
|
|
621
|
-
return 0}getPositionFromOffset(t,e){return t.id?{block:t.id,offset:0}:void 0}getPlainText(t){
|
|
622
|
-
return!1}toHTML(t){return"<page-break />"}toMarkdown(t){return`
|
|
551
|
+
C,0);for(let k=p;k<y;k++){const C=o[k],v=g[k]-x,S=f[k];let w=B.getTabLineWidth(C)??0;C.tabLayout||C.segments.forEach(W=>{W.marks?.latex?w+=B.measureLatexSegment(W.text,l,W.marks):(vt(t,W.marks,n.fontSize,
|
|
552
|
+
n.fontFamily,e,r?.doc),w+=B.measureSegmentDisplayWidth(t,W.text,W.marks))});const O=B.getBlockDirection(e,C),P=Rt(e,k,O,n.indentStepPx),M=bt(i.width,e,k,n.indentStepPx);let I=i.x+P;const A=e.align||(O===
|
|
553
|
+
"rtl"?"right":"left"),T=k===o.length-1,L=A==="justify"&&!T&&!C.tabLayout;A==="center"?I=i.x+P+(M-w)/2:(A==="right"||A==="justify"&&!L&&O==="rtl")&&(I=i.x+P+M-w);const R=L?B.computeJustifyExtraSpacePerGap(
|
|
554
|
+
C,w,M):0,F=B.getLineBidiGeometry(C,s,l,n.fontFamily,e,r?.doc,R);if(I=B.renderLineSegments(t,C,I,(W,$,E)=>{vt(t,W.marks,n.fontSize,n.fontFamily,e,r?.doc);const H=this.renderSegment(t,W,$,v,l,S,e,r,{extraSpacePerGap:R});
|
|
555
|
+
return r?.annotations&&e.id&&B.renderAnnotationUnderlinesForSegment(t,e.id,C.startCharOffset+E,C.startCharOffset+E+W.text.length,$,v,H,W.text,r.annotations),H},{bidiGeometry:F,justify:R>0,rtlTabEntries:C.
|
|
556
|
+
tabLayout?.rtl?B.getRtlTabLineEntries(C,s,l,n.fontFamily,e,r?.doc):void 0,renderTab:(W,$,E,H)=>{vt(t,W,n.fontSize,n.fontFamily,e,r?.doc),B.renderTabLeader(t,$,E,v,H,B.getEffectiveFontSize(l,W),B.getInlineTextColor(
|
|
557
|
+
W,this.getSegmentDiffState(e,W),u,r?.syntaxTheme,B.getTextFill(e,r)))}}),C.hyphenTrailing){const W=C.segments[C.segments.length-1];W&&!W.marks?.latex&&(vt(t,W.marks,n.fontSize,n.fontFamily,e,r?.doc),t.
|
|
558
|
+
fillStyle=B.getInlineTextColor(W.marks,this.getSegmentDiffState(e,W.marks),u,r?.syntaxTheme,B.getTextFill(e,r)),t.fillText("-",I,v))}}}getBounds(t,e,i,n,r,s){const o=this.getWrappedLines(t,n,r,s),a=Ut(
|
|
559
|
+
t),l=kt(t),d=a/l,{top:u,bottom:h}=pi(t,r,a*r.paragraphSpacing),g=b=>B.getWrappedLineHeight(b,l,d),f=b=>{const p=o[b],y=Rt(t,b,B.getBlockDirection(t,p),r.indentStepPx);if(!p)return e+y;const x=B.measureLineRange(
|
|
560
|
+
p,0,p.endCharOffset-p.startCharOffset,n,l,this.getBaseFontFamily(t,r),t,s),k=bt(r.availableWidth,t,b,r.indentStepPx);return B.lineStartX(t.align||(B.getBlockDirection(t,p)==="rtl"?"right":"left"),k,x,
|
|
561
|
+
e+y)+x},m=o.length?o.map((b,p)=>({height:g(b),width:r.availableWidth,baselineOffset:B.getLineMaxTextFontSize(b,l),lineRange:{start:p,end:p+1},charRange:{start:b.startCharOffset,end:b.endCharOffset}})):
|
|
562
|
+
[{height:a,width:r.availableWidth,baselineOffset:l,lineRange:{start:0,end:0},charRange:{start:0,end:0}}];return us(m[m.length-1],()=>f(o.length?o.length-1:0)),{x:e,width:r.availableWidth,units:m,margins:{
|
|
563
|
+
top:u,bottom:h}}}hitTest(t,e,i,n,r,s,o,a){const l=this.getCharacterAtPoint(t,e,i,n,r,s,o,a);return l?{type:"text",position:l.position||void 0,offset:l.offset,bounds:n}:null}getUIComponents(t,e,i,n,r,s,o){
|
|
564
|
+
return[]}getFirstCursorPosition(t){return t.id?{block:t.id,offset:0}:null}getLastCursorPosition(t){return{block:t.id??"",offset:this.getPlainText(t).length}}getNextCursorPosition(t,e){if(!t.id)return null;
|
|
565
|
+
const i=B.getAdjacentCaretOffset(t,e.offset??0,"forward");return i===null?null:{block:t.id,offset:i}}getPreviousCursorPosition(t,e){if(!t.id)return null;const i=B.getAdjacentCaretOffset(t,e.offset??0,
|
|
566
|
+
"backward");return i===null?null:{block:t.id,offset:i}}getCursorScreenPosition(t,e,i,n,r,s,o,a,l){const d=Ut(t),u=kt(t),h=d/u,g=Ft(r,i),f=this.getWrappedLines(t,n,g,o),m=this.toVisualOffset(t,this.convertPositionToOffset(
|
|
567
|
+
t,e)),b=a?.lineRange?.start??0;a?.lineRange?.end??f.length;const p=S=>B.getLineMaxTextFontSize(S,u),y=S=>B.getWrappedLineHeight(S,u,h),x=[];let k=i.y;const C=a?b:0;for(let S=C;S<f.length;S++){const w=f[S],
|
|
568
|
+
O=y(w);x[S]=k,k+=O}const v=zr(f,m,_(t).visibleText)??(f.length>0?{lineIndex:f.length-1,line:f[f.length-1]}:null);if(v){const S=v.lineIndex,w=v.line,O=x[S]??i.y,P=p(w);let M=B.getTabLineWidth(w)??0;w.tabLayout||
|
|
569
|
+
w.segments.forEach(K=>{K.marks?.latex?M+=B.measureLatexSegment(K.text,u,K.marks):(vt(s,K.marks,u,r.fontFamily,t,o),M+=B.measureSegmentDisplayWidth(s,K.text,K.marks))});const I=typeof i.x=="number"?i.x:
|
|
570
|
+
r.pageMargin,A=typeof i.width=="number"&&i.width>0?i.width:r.availableWidth,T=B.getBlockDirection(t,w),L=Rt(t,S,T,r.indentStepPx),R=bt(A,t,S,r.indentStepPx);let F=I+L;const W=t.align||(T==="rtl"?"righ\
|
|
571
|
+
t":"left"),$=S===f.length-1,E=W==="justify"&&!$&&!w.tabLayout,H=B.isRtlLine(w);W==="center"?F=I+L+(R-M)/2:(W==="right"||W==="justify"&&!E&&T==="rtl")&&(F=I+L+R-M);const D=K=>H?F+M-(K-F):K,z=E?B.computeJustifyExtraSpacePerGap(
|
|
572
|
+
w,M,R):0,J=B.getLineBidiGeometry(w,n,u,r.fontFamily,t,o,z);if(J){const K=Math.max(0,w.endCharOffset-w.startCharOffset),j=Math.max(0,Math.min(m-w.startCharOffset,K));return{x:F+Oe(J.slices,j,J.measure,
|
|
573
|
+
e.bidiAffinity),y:O+P,fontSize:P}}if(w.tabLayout?.rtl){const K=Math.max(0,w.endCharOffset-w.startCharOffset),j=Math.max(0,Math.min(m-w.startCharOffset,K));return{x:F+B.getTabLineCaretX(w,j,n,u,r.fontFamily,
|
|
574
|
+
t,o),y:O+P,fontSize:P}}let X=F,U=m-w.startCharOffset,Y=null;const et=w.tabLayout?.segments;for(let K=0;K<w.segments.length;K++){const j=w.segments[K],St=et?.[K];if(St&&(X=F+St.startX,j.text===" ")){if(U<=
|
|
575
|
+
0)return{x:D(X),y:O+P,fontSize:P};X=F+St.endX,U-=1,Y=j;continue}if(j.marks?.latex){const it=B.measureLatexSegment(j.text,u,j.marks);if(U<=0)return{x:D(X),y:O+P,fontSize:P};if(U<j.text.length)return{x:D(
|
|
576
|
+
X+it),y:O+P,fontSize:P};X+=it,U-=j.text.length,Y=j;continue}if(vt(s,j.marks,u,r.fontFamily,t,o),E)for(let it=0;it<j.text.length;it++){if(U<=0){const pt=Y?.marks?.code?l?.syntaxTheme?.text:void 0;return{
|
|
577
|
+
x:D(X),y:O+P,fontSize:P,cursorColor:pt}}const ct=j.text[it],V=B.measureSegmentDisplayWidth(s,ct,j.marks);X+=V,ct===" "&&(X+=z),U--,Y=j}else if(U<=j.text.length){const it=j.text.slice(0,U),ct=X+B.measureSegmentDisplayWidth(
|
|
578
|
+
s,it,j.marks),V=U>0&&j.marks?.code?l?.syntaxTheme?.text:void 0;return{x:D(ct),y:O+P,fontSize:P,cursorColor:V}}else X+=B.measureSegmentDisplayWidth(s,j.text,j.marks),U-=j.text.length,Y=j}const at=Y?.marks?.
|
|
579
|
+
code?l?.syntaxTheme?.text:void 0;return{x:D(X),y:O+P,fontSize:P,cursorColor:at}}return null}getCharacterOffset(t,e){return this.convertPositionToOffset(t,e)}getPositionFromOffset(t,e){return this.convertOffsetToPosition(
|
|
580
|
+
t,e)}isEmpty(t){return t.children.length===0||t.children.length===1&&t.children[0].type==="text"&&t.children[0].text===""}cloneParagraphBlock(t){return{type:"paragraph",children:t.children.map(e=>e.type===
|
|
581
|
+
"text"?{type:"text",text:e.text,marks:e.marks?{...e.marks}:void 0}:{...e}),id:t.id,heading:t.heading,align:t.align,lineSpacing:t.lineSpacing,spaceBefore:t.spaceBefore,spaceAfter:t.spaceAfter,contextualSpacing:t.
|
|
582
|
+
contextualSpacing,leftIndent:t.leftIndent,firstLineIndent:t.firstLineIndent}}insertText(t,e,i,n){const r=this.cloneParagraphBlock(t),{index:s,offset:o}=this.offsetToChildPosition(r,i),a=r.children[s];
|
|
583
|
+
if(a&&a.type==="text"){const l=a.text.slice(0,o)+e+a.text.slice(o);a.text=l,n&&(a.marks={...a.marks,...n})}return r}deleteRange(t,e,i){const n=this.cloneParagraphBlock(t),r=this.getPlainText(n),s=r.slice(
|
|
584
|
+
0,e)+r.slice(i);return n.children=[{type:"text",text:s}],n}canMergeWith(t,e){return t==="paragraph"}mergeWith(t,e,i){if(e.type!=="paragraph")return t;const n=this.cloneParagraphBlock(t);return i==="be\
|
|
585
|
+
fore"?n.children=[...e.children,...n.children]:n.children=[...n.children,...e.children],n}split(t,e){const i=this.getPlainText(t),n=i.slice(0,e),r=i.slice(e),s={type:"paragraph",id:t.id,children:[{type:"\
|
|
586
|
+
text",text:n}]},o={type:"paragraph",id:Z(),children:[{type:"text",text:r}]};return{before:s,after:o}}toHTML(t){let e="";for(const a of t.children)if(a.type==="text"){let l=a.text.replace(/&/g,"&").
|
|
587
|
+
replace(/</g,"<").replace(/>/g,">");a.marks?.bold&&(l=`<strong>${l}</strong>`),a.marks?.italic&&(l=`<em>${l}</em>`),a.marks?.underline&&(l=`<u>${l}</u>`),e+=l}const i=t.heading?`h${t.heading}`:"\
|
|
588
|
+
p",n=[];t.align&&n.push(`text-align: ${t.align}`),typeof t.lineSpacing=="number"&&Number.isFinite(t.lineSpacing)&&n.push(`line-height: ${t.lineSpacing}`);const r=Sn(t);r>0&&n.push(`margin-left: ${r}px`);
|
|
589
|
+
const s=wn(t);s>0&&n.push(`text-indent: ${s}px`);const o=n.length>0?` style="${n.join("; ")}"`:"";return`<${i}${o}>${e}</${i}>`}toMarkdown(t){let e="";for(const i of t.children)if(i.type==="text"){let n=i.
|
|
590
|
+
text;i.marks?.bold&&(n=`**${n}**`),i.marks?.italic&&(n=`*${n}*`),e+=n}return t.heading?`${"#".repeat(t.heading)} ${e}`:e}toYjs(t,e){return rt(t)}fromYjs(t){const e={type:"paragraph",id:t.getAttribute(
|
|
591
|
+
"id")||Z(),children:[]},i=t.getAttribute("heading"),n=i?parseInt(i,10):void 0,r=tt(t,"align"),s=tt(t,"lineSpacing"),o=tt(t,"leftIndent"),a=tt(t,"firstLineIndent");if(n&&n>=1&&n<=6&&(e.heading=n),r&&(e.
|
|
592
|
+
align=r),s){const p=parseFloat(s);Number.isFinite(p)&&(e.lineSpacing=p)}for(const p of["spaceBefore","spaceAfter"]){const y=tt(t,p);if(y==null)continue;const x=parseFloat(y);Number.isFinite(x)&&(e[p]=
|
|
593
|
+
x)}tt(t,"contextualSpacing")==="true"&&(e.contextualSpacing=!0),Tn(e,tt(t,"pagination"));const l=t.getAttribute("styleId");l&&(e.styleId=l);const d=tt(t,"direction");(d==="rtl"||d==="ltr")&&(e.direction=
|
|
594
|
+
d);const u=tt(t,"borders");u&&(e.borders=u);const h=tt(t,"shading");h&&(e.shading=h);const g=tt(t,"tabStops");g&&(e.tabStops=g);const f=t.getAttribute("oxmlAttrs");f&&(e.oxmlAttrs=f);const m=t.getAttribute(
|
|
595
|
+
"oxmlPPr");if(m&&(e.oxmlPPr=m),o){const p=parseFloat(o),y=ti(Number.isNaN(p)?void 0:p,{storedAsUnits:!0});y!==void 0&&(e.leftIndent=y)}if(a){const p=parseFloat(a),y=ti(Number.isNaN(p)?void 0:p,{storedAsUnits:!0,
|
|
596
|
+
firstLine:!0});y!==void 0&&(e.firstLineIndent=y)}let b=null;for(let p=0;p<t.length;p++){const y=t.get(p);if(y instanceof st.XmlText){b=y;break}}return b&&Bt(b).forEach(p=>{if(typeof p.insert=="string"){
|
|
597
|
+
const y={type:"text",text:p.insert};p.attributes&&Object.keys(p.attributes).length>0&&(y.marks=p.attributes),e.children.push(y)}}),e.children.length===0&&(e.children=[{type:"text",text:""}]),e}validate(t){
|
|
598
|
+
const e=[];(!t.children||t.children.length===0)&&e.push("Paragraph must have at least one child node");for(const i of t.children)i.type!=="text"&&e.push(`Invalid child type: ${i.type}`);return{valid:e.
|
|
599
|
+
length===0,errors:e}}shouldDeleteBlock(t,e,i){return this.isEmpty(t)}handleEnterKey(t,e){return{action:"split"}}handleDeleteSelection(t,e,i,n){let r=null;for(let a=0;a<e.length;a++){const l=e.get(a);if(l instanceof
|
|
600
|
+
st.XmlText){r=l;break}}if(!r)return!1;const s=this.convertPositionToOffset(t,i),o=this.convertPositionToOffset(t,n);return o>s&&r.delete(s,o-s),r.length,!0}}class fs{constructor(){this.type="placehold\
|
|
601
|
+
er",this.isTextBased=!1}render(t,e,i,n,r){t.save();const s=r?.renderCtx,o=s?.theme??ot(),a=e.diffState;let l="#e5e7eb";a&&o?a==="insert"?l=G(o.diffInsert,q.placeholderTintOpacity):a==="delete"&&(l=G(o.
|
|
602
|
+
diffDelete,q.placeholderTintOpacity)):r?.isSelected&&(l="#d1d5db"),t.fillStyle=l;const d=i.relativeToPage?0:s?.yOffset??0,u=i.y-d;let h="#9ca3af";a==="insert"&&o?h=o.diffInsert:a==="delete"&&o&&(h=o.diffDelete),
|
|
603
|
+
t.fillRect(i.x,u,i.width,e.height),t.strokeStyle=h,t.strokeRect(i.x,u,i.width,e.height),r?.isSelected&&(t.strokeStyle="#9ca3af",t.lineWidth=2,t.strokeRect(i.x,u,i.width,e.height)),t.fillStyle="#9ca3af",
|
|
604
|
+
t.font="14px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText("milady",i.x+i.width/2,u+e.height/2),ht(e)&&ut(t,i,u,o),t.restore()}getBounds(t,e,i,n,r,s){return{x:e,width:r.availableWidth,
|
|
605
|
+
units:[{height:t.height,width:r.availableWidth}],margins:{top:r.suppressTopSpacingForFirstChild?0:dt(r,0),bottom:0}}}hitTest(t,e,i,n,r,s,o,a){return e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+t.height?{type:"\
|
|
606
|
+
block",bounds:n}:null}getUIComponents(){return[]}getFirstCursorPosition(t){return null}getLastCursorPosition(t){return t.id?{block:t.id,offset:0}:null}getNextCursorPosition(t,e){return null}getPreviousCursorPosition(t,e){
|
|
607
|
+
return null}getCursorScreenPosition(t,e,i,n,r,s,o,a){const l=(e.offset??0)<=0,d=i.y+i.height;return{x:l?i.x:i.x+i.width,y:d,fontSize:r.fontSize}}getSelectionRects(t,e,i,n,r,s,o,a){return e!==null||i!==
|
|
608
|
+
null?[{x:n.x,y:n.y,width:n.width,height:t.height,alpha:.3}]:[]}getCharacterAtPoint(t,e,i,n,r,s,o,a){const l=n.y+t.height/2;return{offset:0,position:null,beforeChar:i<l}}getCharacterOffset(t,e){return 0}getPositionFromOffset(t,e){}getPlainText(t){
|
|
609
|
+
return""}getWordCount(t){return 0}getCharCount(t){return 0}isEmpty(t){return!0}canEdit(){return!1}canMergeWith(t,e){return!1}toHTML(t){return`<div style="background-color: #e5e7eb; height: ${t.height}\
|
|
610
|
+
px; width: 100%;"></div>`}toMarkdown(t){return`[Placeholder: ${t.height}px]`}toPlainText(t){return"[Placeholder]"}toYjs(t,e){return rt(t)}fromYjs(t){const e=t.getAttribute("height");return{type:"place\
|
|
611
|
+
holder",id:t.getAttribute("id")||Z(),height:e?parseInt(e,10):100}}findMatches(t,e){return[]}validate(t){const e=[];return(!t.height||t.height<=0)&&e.push("Placeholder height must be positive"),{valid:e.
|
|
612
|
+
length===0,errors:e}}isAtomic(){return!0}allowsInternalCursor(){return!1}shouldDeleteBlock(t,e,i){return!0}handleEnterKey(t,e){return{action:"insert-after",newBlock:{type:"paragraph",id:Tt(),children:[
|
|
613
|
+
{type:"text",text:""}]}}}getNavigationTarget(t,e){return null}}const _i=At.displayHeightPx,ms=At.indicatorInsetXPx,Qi=At.indicatorWidthPx,ps=At.caretOffsetXPx;function le(c){return Math.min(c.height,_i)}
|
|
614
|
+
class bs{constructor(){this.type="page-break",this.isTextBased=!1}render(t,e,i,n,r){t.save();const s=r?.renderCtx,o=i.relativeToPage?0:s?.yOffset??0,a=i.y-o,l=s?.theme,d=e.diffState,u=le(i),h=i.x+At.iconInsetXPx,
|
|
615
|
+
g=a+Math.max((u-10)/2,At.iconInsetYPx);let f=l?.text??"#6b7280",m=.3;d==="insert"&&l?(f=l.diffInsert,m=q.breakIconOpacity,t.fillStyle=G(l.diffInsert,q.breakTintOpacity),t.fillRect(h-2,g,16,14)):d==="d\
|
|
616
|
+
elete"&&l&&(f=l.diffDelete,m=q.breakIconOpacity,t.fillStyle=G(l.diffDelete,q.breakTintOpacity),t.fillRect(h-2,g,16,14)),t.strokeStyle=f,t.lineWidth=1.25,t.lineCap="round",t.lineJoin="round",t.globalAlpha=
|
|
617
|
+
m,t.beginPath(),t.moveTo(h,g+3),t.lineTo(h+10,g+3),t.lineTo(h+10,g+9),t.lineTo(h+3,g+9),t.moveTo(h+3,g+9),t.lineTo(h+6,g+6),t.moveTo(h+3,g+9),t.lineTo(h+6,g+12),t.stroke(),l&&ht(e)&&ut(t,i,a,l),l&&(d===
|
|
618
|
+
"insert"||d==="delete")&&bi(t,{left:n.pageMarginLeft??n.pageMargin,right:n.pageWidth-(n.pageMarginRight??n.pageMargin)},a+u,14,l,"Page Break",d),t.restore()}getBounds(t,e,i,n,r,s){return{x:e+ms,width:Qi,
|
|
619
|
+
units:[{height:r.pageless?_i:0,width:Qi}],margins:{top:!r.pageless||r.suppressTopSpacingForFirstChild?0:dt(r,0),bottom:0}}}hitTest(t,e,i,n,r,s,o,a){const l=le(n);return e>=n.x&&e<=n.x+n.width&&i>=n.y&&
|
|
620
|
+
i<=n.y+l?{type:"block",bounds:n}:null}getFirstCursorPosition(t){return t.id?{block:t.id,offset:0}:null}getLastCursorPosition(t){return t.id?{block:t.id,offset:0}:null}getNextCursorPosition(t,e){return null}getPreviousCursorPosition(t,e){
|
|
621
|
+
return null}getCursorScreenPosition(t,e,i,n,r,s,o,a){const l=le(i);return{x:i.x+ps+5,y:i.y+l-2,fontSize:r.fontSize}}getSelectionRects(t,e,i,n,r,s,o,a){const l=le(n);return e!==null||i!==null?[{x:n.x,y:n.
|
|
622
|
+
y,width:n.width,height:l,alpha:.15}]:[]}getCharacterAtPoint(t,e,i,n,r,s,o,a){return null}getCharacterOffset(t,e){return 0}getPositionFromOffset(t,e){return t.id?{block:t.id,offset:0}:void 0}getPlainText(t){
|
|
623
|
+
return""}getWordCount(t){return 0}getCharCount(t){return 0}isEmpty(t){return!0}canEdit(){return!1}canMergeWith(t,e){return!1}toHTML(t){return"<page-break />"}toMarkdown(t){return`
|
|
623
624
|
|
|
624
625
|
--- page break ---
|
|
625
626
|
|
|
@@ -651,7 +652,7 @@ for(let v=x;v<k;v++){if(v===0||v===y-1){C+=jt;continue}const S=C+g;if(u.length==
|
|
|
651
652
|
e.align&&e.align!=="justify"?e.align:e.direction==="rtl"?"right":"left",t.fillText(Cs,t.textAlign==="right"?i.x+i.width:t.textAlign==="center"?i.x+i.width/2:i.x,S),C+=h;continue}const w=u[v-1];if(!w){
|
|
652
653
|
C+=h;continue}t.textBaseline="alphabetic",t.font=w.level===1?`500 ${g}px ${f}`:`${g}px ${f}`,t.fillStyle=p;const O=m?.get(w.blockId),P=O===void 0?"":String(O),M=In(e,w,i.x,i.width,P,I=>t.measureText(I).
|
|
653
654
|
width);t.direction="ltr",t.textAlign="left",P&&t.fillText(P,M.numberX,S),t.direction=M.rtl?"rtl":"ltr",t.textAlign=M.align,M.text&&t.fillText(M.text,M.textX,S),P&&M.leaderEnd-M.leaderStart>ii.minimumLeaderWidthPx&&
|
|
654
|
-
|
|
655
|
+
B.renderTabLeader(t,M.leaderStart,M.leaderEnd,S,"dot",g,G(p,.45)),C+=h}l&&ht(e)&&ut(t,i,a,l),t.restore()}getBounds(t,e,i,n,r,s){const o=r.availableWidth,{units:a}=Ss(t,s,o);return{x:e,width:o,units:a,
|
|
655
656
|
margins:{top:r.suppressTopSpacingForFirstChild?0:dt(r,0),bottom:0}}}hitTest(t,e,i,n,r,s,o,a){return e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height?{type:"block",bounds:n}:null}getFirstCursorPosition(t){
|
|
656
657
|
return t.id?{block:t.id,offset:0}:null}getLastCursorPosition(t){return t.id?{block:t.id,offset:1}:null}getNextCursorPosition(t,e){return e.offset===0&&t.id?{block:t.id,offset:1}:null}getPreviousCursorPosition(t,e){
|
|
657
658
|
return e.offset>=1&&t.id?{block:t.id,offset:0}:null}getCursorScreenPosition(t,e,i,n,r,s,o,a){const l=e.offset>=1;return{x:i.x+2,y:l?i.y+i.height-jt:i.y+jt+Xe(t),fontSize:r.fontSize}}atomicEnterBehavior(t,e){
|
|
@@ -680,10 +681,10 @@ round(l*u),1),g=t.align??"left";let f=e;return g==="center"?f=e+Math.max(0,(r.av
|
|
|
680
681
|
top:r.suppressTopSpacingForFirstChild?0:dt(r,12),bottom:0}}}hitTest(t,e,i,n,r,s,o){return e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height?{type:"block",bounds:n}:null}getUIComponents(t,e,i,n,r,s,o){if(o?.
|
|
681
682
|
isReadOnly)return[];const a=()=>{const h=Math.max(8,Math.min(ln,Math.min(e.width,e.height)*.25));return Math.max(6,Math.min(h,Math.min(e.width,e.height)))},l=t.align??"left",d=l==="right",u=d?"nesw-re\
|
|
682
683
|
size":"nwse-resize";return[{id:on,cursor:u,getBounds:()=>{const h=a();return{x:d?e.x:e.x+Math.max(e.width-h,0),y:e.y+Math.max(e.height-h,0),width:h,height:h}},onMouseDown:h=>{const g=h.block,f=g.width||
|
|
683
|
-
Yt,m=g.height||Yt,b=f>0?m/f:1;let p=f,y=m;const x=h.position.x,k=h.position.y,C=h.blockBounds,v=C.x,S=C.y,w=v+f,O=S+m,P=C.x+C.width,M=v+f/2,I=d?x-v:x-w,
|
|
684
|
-
F)),L=
|
|
685
|
-
I,J=Math.max(Yt/2,z-M);E=T(J*2,F)}else{const z=
|
|
686
|
-
|
|
684
|
+
Yt,m=g.height||Yt,b=f>0?m/f:1;let p=f,y=m;const x=h.position.x,k=h.position.y,C=h.blockBounds,v=C.x,S=C.y,w=v+f,O=S+m,P=C.x+C.width,M=v+f/2,I=d?x-v:x-w,A=k-O,T=(R,F)=>Math.max(Yt,Math.min(Math.round(R),
|
|
685
|
+
F)),L=R=>Math.max(Yt,Math.round(R));return{cursor:u,onMouseMove:R=>{const F=R.layout.availableWidth,W=R.position.x,$=R.position.y;let E;if(l==="right"){const z=W-I;E=T(P-z,F)}else if(l==="center"){const z=W-
|
|
686
|
+
I,J=Math.max(Yt/2,z-M);E=T(J*2,F)}else{const z=W-I;E=T(z-v,F)}let H;if(R.modifiers.shiftKey){const z=$-A;H=L(z-S)}else H=L(E*b);if(Math.abs(E-p)<1&&Math.abs(H-y)<1)return;const D={...R.block,width:E,height:H};
|
|
687
|
+
R.api.replaceBlock(D)&&(p=E,y=H)},onMouseUp:R=>{R.api.requestRedraw()},onCancel:()=>{}}}},{id:an,cursor:void 0,getBounds:()=>({x:e.x,y:e.y,width:e.width,height:e.height})}]}getFirstCursorPosition(t){return null}getLastCursorPosition(t){
|
|
687
688
|
return t.id?{block:t.id,offset:0}:{block:"",offset:0}}getNextCursorPosition(t,e){return null}getPreviousCursorPosition(t,e){return null}getCursorScreenPosition(t,e,i,n,r,s,o,a){const l=(e.offset??0)<=
|
|
688
689
|
0,d=i.y+i.height;return{x:l?i.x:i.x+i.width,y:d,fontSize:r.fontSize}}getSelectionRects(t,e,i,n,r,s,o,a){return[]}getCharacterAtPoint(t,e,i,n,r,s,o){return null}getCharacterOffset(t,e){return 0}getPositionFromOffset(t,e){}getPlainText(t){
|
|
689
690
|
return""}getWordCount(t){return 0}getCharCount(t){return 0}isEmpty(t){return!1}canEdit(){return!1}canMergeWith(t){return!1}mergeWith(t,e,i){return t}split(t,e){return{before:t,after:t}}toHTML(t){const e=[
|
|
@@ -696,7 +697,7 @@ getAttribute("originalDataUrl")||void 0,anchorXml:t.getAttribute("anchorXml")||v
|
|
|
696
697
|
width>0)||!(t.height>0))&&e.push("Image block must have positive dimensions"),t.align&&!["left","center","right"].includes(t.align)&&e.push("Image block has invalid alignment"),{valid:e.length===0,errors:e}}isAtomic(){
|
|
697
698
|
return!0}allowsInternalCursor(){return!1}shouldDeleteBlock(t,e,i){return!0}handleEnterKey(t,e){return{action:"insert-after"}}getNavigationTarget(t,e){return null}}function ue(){return Ht.paragraph}const Ms={
|
|
698
699
|
BULLET_MARKER_WIDTH:xt.markerWidthPx,SUBLIST_INDENT_PX:xt.sublistIndentPx},{BULLET_MARKER_WIDTH:Ke,SUBLIST_INDENT_PX:Ls}=Ms,lt=xt.todoCheckboxSizePx,Os=xt.todoCheckboxRadiusPx,qe=xt.todoCheckboxOffsetPx,
|
|
699
|
-
|
|
700
|
+
Rs=xt.maxIndentLevel,Bs=xt.variantIndentPx.todo,As=xt.variantIndentPx.ordered,Ws=xt.variantIndentPx.unordered;function Ge(c,t,e,i,n,r){const s=Math.min(r,i/2,n/2);c.beginPath(),c.moveTo(t+s,e),c.lineTo(
|
|
700
701
|
t+i-s,e),c.quadraticCurveTo(t+i,e,t+i,e+s),c.lineTo(t+i,e+n-s),c.quadraticCurveTo(t+i,e+n,t+i-s,e+n),c.lineTo(t+s,e+n),c.quadraticCurveTo(t,e+n,t,e+n-s),c.lineTo(t,e+s),c.quadraticCurveTo(t,e,t+s,e),c.
|
|
701
702
|
closePath()}class Fs extends Ui{constructor(){super(...arguments),this.type="list",this.markerColumnCache=new Map}shouldRenderActiveSuggestionSegment(t,e,i,n,r){const s=r?.cursorPosition?.block===t.id?
|
|
702
703
|
this.blockOffsetToItem(t,r.cursorPosition.offset??0):null,o=s&&s.itemIndex===e?s.offsetInItem:null,a=i.structuralSuggestionKind==="insert"&&typeof i.structuralSuggestionId=="string"?i.structuralSuggestionId:
|
|
@@ -705,7 +706,7 @@ if(!t.structuralSuggestionKind||t.structuralSuggestionKind==="insert"||t.structu
|
|
|
705
706
|
rge"?i.diffDelete:i.diffInsert,s=t.structuralSuggestionLabel||(t.structuralSuggestionKind==="merge"?"Join":t.structuralSuggestionKind==="split"?"Split":t.structuralSuggestionKind==="change"?"Change":"\
|
|
706
707
|
Insert"),o=18,a=n(s)+7*2,l=Math.max(8,e.x-a-10),d=e.y+Math.max(0,(e.height-o)/2),u=o/2,h=d+o/2,g=t.structuralSuggestionKind==="merge"?i.diffDeleteText:i.diffInsertText;return{label:s,accentColor:r,textColor:g,
|
|
707
708
|
pillX:l,pillY:d,pillWidth:a,pillHeight:o,pillRadius:u,connectorY:h}}isStructuralInsertTarget(t,e){return e?.structuralSuggestionKind==="insert"||!e?.structuralSuggestionKind&&t.structuralSuggestionKind===
|
|
708
|
-
"insert"}isStructuralDeleteTarget(t,e){return e?.structuralSuggestionKind==="delete"||!e?.structuralSuggestionKind&&t.structuralSuggestionKind==="delete"}getSegmentDiffState(t,e,i){return
|
|
709
|
+
"insert"}isStructuralDeleteTarget(t,e){return e?.structuralSuggestionKind==="delete"||!e?.structuralSuggestionKind&&t.structuralSuggestionKind==="delete"}getSegmentDiffState(t,e,i){return B.getDiffState(
|
|
709
710
|
i)||(this.isStructuralInsertTarget(t,e)?"insert":this.isStructuralDeleteTarget(t,e)?"delete":e.structuralSuggestionKind==="change"||!e.structuralSuggestionKind&&t.structuralSuggestionKind==="change"?"\
|
|
710
711
|
format":null)}renderStructuralSuggestionMarker(t,e,i,n){const r=this.getStructuralSuggestionMarkerLayout(e,i,n,s=>{t.save(),t.font="600 10px Arial, sans-serif";const o=t.measureText(s).width;return t.
|
|
711
712
|
restore(),o});r&&(t.save(),t.strokeStyle=G(r.accentColor,.45),t.lineWidth=1.5,t.beginPath(),t.moveTo(r.pillX+r.pillWidth+4,r.connectorY),t.lineTo(i.x+6,r.connectorY),t.stroke(),t.fillStyle=G(r.accentColor,
|
|
@@ -720,8 +721,8 @@ t.children.length;s++){const o=t.children[s],a=this.getPlainTextFromItem(o).leng
|
|
|
720
721
|
return r+(i-n);n+=1,r+=1}}return r}toDocumentOffset(t,e,i,n){const r=t.children.reduce((l,d,u)=>{const h=_(d).visibleText.length;return l+h+(u<t.children.length-1?1:0)},0),s=Math.max(0,Math.min(e,r));
|
|
721
722
|
let o=0,a=0;for(let l=0;l<t.children.length;l++){const d=t.children[l],u=this.getPlainTextFromItem(d).length,h=_(d),g=h.visibleText.length;if(s<=a+g)return o+h.toActualOffset(s-a,n);if(o+=u,a+=g,l<t.children.
|
|
722
723
|
length-1){if(s<=a+1)return o+(s-a);o+=1,a+=1}}return o}getItemDirection(t){return t.direction==="rtl"||t.direction==="ltr"?t.direction:zn(_(t).visibleText)??"ltr"}getListLineBidiGeometry(t,e,i,n,r,s,o){
|
|
723
|
-
return
|
|
724
|
-
t.startCharOffset){const l=zt(t),d=l.trimEnd().length;if(d<l.length&&e>=
|
|
724
|
+
return B.getLineBidiGeometry(t,i,n,r,s,o,0,e)}getRtlTextRightEdge(t,e,i,n){return t+e-i-n}findCharacterInLine(t,e,i,n,r,s,o){const a=B.findCharacterAtXWithFormatting(t,e,i,n,r,s,o);if(a.offset===t.endCharOffset-
|
|
725
|
+
t.startCharOffset){const l=zt(t),d=l.trimEnd().length;if(d<l.length&&e>=B.measureLineRange(t,0,l.length,i,n,r,s,o))return{offset:d,beforeChar:!1}}return a}getOffsetWithinItem(t,e){const i=t.children.findIndex(
|
|
725
726
|
d=>d.id===e.block);if(i!==-1){const d=t.children[i],u=this.getPlainTextFromItem(d).length,h=Math.max(0,Math.min(u,e.offset));let g=h,f=0,m=0;for(let b=0;b<d.children.length;b++){const p=d.children[b];
|
|
726
727
|
if(p.type==="text"){if(g<=p.text.length){f=b,m=g;break}g-=p.text.length,f=b,m=p.text.length}}return{itemIndex:i,offsetInItem:h,childIndex:f,offsetInChild:m}}const{itemIndex:n,offsetInItem:r}=this.blockOffsetToItem(
|
|
727
728
|
t,e.offset??0);let s=r,o=0,a=0;const l=t.children[n];if(!l)return{itemIndex:n,offsetInItem:r,childIndex:0,offsetInChild:0};for(let d=0;d<l.children.length;d++){const u=l.children[d];if(u.type==="text"){
|
|
@@ -729,22 +730,22 @@ if(s<=u.text.length){o=d,a=s;break}s-=u.text.length,o=d,a=u.text.length}}return{
|
|
|
729
730
|
i).length,s=Math.max(0,Math.min(r,n));let o=0;for(let a=0;a<e;a++)o+=this.getPlainTextFromItem(t.children[a]).length,o+=1;return{block:t.id??"",offset:o+s}}getWrappedLines(t,e,i,n){const r=[];let s=0;
|
|
730
731
|
return t.children.forEach((o,a)=>{a>0&&(s+=1),this.wrapListItem(o,e,i.availableWidth,ue(),this.getBaseFontFamily(t,i),t,n).forEach(l=>{r.push({...l,startCharOffset:l.startCharOffset+s,endCharOffset:l.
|
|
731
732
|
endCharOffset+s})}),s+=_(o).visibleText.length}),r}wrapListItem(t,e,i,n,r,s,o){const a=Math.max(0,i-this.getMarkerColumnPx(s,e,n,r)-this.getItemIndentOffset(t)),l=Ni(_(t).visibleChildren,e,{getAvailableWidth:()=>a,
|
|
732
|
-
setFont:h=>
|
|
733
|
+
setFont:h=>B.setMeasurementFont(e,n,r,h,void 0,s,o),measureLatex:(h,g)=>B.measureLatexSegment(h,n,g),retainWrapSpace:!0}),d=l.length>0?l:[{segments:[{text:""}],startCharOffset:0,endCharOffset:0}],u=h=>h!==
|
|
733
734
|
void 0&&Number.isFinite(h)&&h>=0?h:void 0;return d.map((h,g)=>({...h,...t.lineSpacing!==void 0&&Number.isFinite(t.lineSpacing)&&t.lineSpacing>0?{lineSpacingOverride:t.lineSpacing}:{},...g===0&&u(t.spaceBefore)!==
|
|
734
735
|
void 0?{spaceBefore:t.spaceBefore}:{},...g===d.length-1&&u(t.spaceAfter)!==void 0?{spaceAfter:t.spaceAfter}:{}}))}convertOffsetToPosition(t,e){const i=Math.max(0,Math.min(e,this.getBlockLength(t)));return t.
|
|
735
736
|
id?{block:t.id,offset:i}:{block:"",offset:i}}convertPositionToOffset(t,e){const i=this.getBlockLength(t);return Math.max(0,Math.min(e.offset??0,i))}normalizeItemPosition(t,e){return this.getOffsetWithinItem(
|
|
736
737
|
t,e)}getSelectionRects(t,e,i,n,r,s,o,a){const l=n.width||s.availableWidth,d=this.getFontSize(t),u=this.getLineHeight(t),h=this.getBaseFontFamily(t,s),g=[],f=[];let m=0;if(t.children.forEach((x,k)=>{k>
|
|
737
738
|
0&&(m+=1);const C=this.wrapListItem(x,r,l,d,h,t,o),v=this.getMarkerColumnPx(t,r,d,h),S=this.getItemIndentOffset(x),w=n.x+v+S,O=this.getItemDirection(x),P=this.getRtlTextRightEdge(n.x,l,v,S);C.forEach(
|
|
738
|
-
M=>{let I=w;if(O==="rtl"){const
|
|
739
|
+
M=>{let I=w;if(O==="rtl"){const A=zt(M).length,T=B.measureLineRange(M,0,A,r,d,h,t,o);I=P-T}f[g.length]=I,g.push({...M,startCharOffset:M.startCharOffset+m,endCharOffset:M.endCharOffset+m})}),m+=_(x).visibleText.
|
|
739
740
|
length}),g.length===0)return[];const b=x=>{const{itemIndex:k,offsetInItem:C}=this.normalizeItemPosition(t,x);let v=0;for(let S=0;S<k&&S<t.children.length;S++)v+=this.getPlainTextFromItem(t.children[S]).
|
|
740
|
-
length+1;return this.toVisualOffset(t,v+C)},p=e?b(e):0,y=i?b(i):this.toVisualOffset(t,this.getBlockLength(t));return
|
|
741
|
-
end,t,o,f)}getListIndentPx(t){switch(t.variant){case"todo":return
|
|
741
|
+
length+1;return this.toVisualOffset(t,v+C)},p=e?b(e):0,y=i?b(i):this.toVisualOffset(t,this.getBlockLength(t));return B.calculateSelectionRectsForLines(g,p,y,n.x,n.y,u,r,d,h,a?.lineRange?.start,a?.lineRange?.
|
|
742
|
+
end,t,o,f)}getListIndentPx(t){switch(t.variant){case"todo":return Bs;case"ordered":return As;case"unordered":default:return Ws}}getMarkerColumnPx(t,e,i,n){const r=this.getListIndentPx(t);if(t.variant!==
|
|
742
743
|
"ordered"||!t.numberingFormat||!e)return r;const s=`${i??16}px ${n??"Arial, sans-serif"}`,o=[t.id,t.numberingFormat,t.startNumber??1,t.children.map(u=>u.indentLevel??0).join(","),s].join("|"),a=this.markerColumnCache.
|
|
743
744
|
get(o);if(a!==void 0)return a;let l=0;try{e.setFont(s);const u=jn(t,ai(t));for(const h of u)l=Math.max(l,e.measureText(h).width)}catch{}const d=Math.min(Math.max(r,Math.ceil(l)+10),240);return this.markerColumnCache.
|
|
744
745
|
size>200&&this.markerColumnCache.clear(),this.markerColumnCache.set(o,d),d}getItemIndentLevel(t){const e=t.indentLevel??0;if(!Number.isFinite(e))return 0;const i=Math.floor(e);return Math.max(0,Math.min(
|
|
745
|
-
|
|
746
|
+
Rs,i))}getItemIndentOffset(t){return this.getItemIndentLevel(t)*Ls}renderListMarker(t,e,i,n,r,s,o,a,l,d,u){const h=(b,p=0)=>u?2*n-b-p:b,g=n-Ke,f=r+s/2,m=this.isStructuralInsertTarget(e,a)?o?.diffInsertText||
|
|
746
747
|
o?.text||"#000000":o?.text||"#000000";switch(t.save(),t.fillStyle=m,t.font=t.font,e.variant){case"unordered":{const I=a?this.getItemIndentLevel(a):0;if(I===0)t.beginPath(),t.arc(h(g+8),f,2.5,0,Math.PI*
|
|
747
|
-
2),t.fill();else if(I===1)t.beginPath(),t.arc(h(g+8),f,2.5,0,Math.PI*2),t.lineWidth=1.5,t.strokeStyle=m,t.stroke();else{t.lineWidth=1.5,t.strokeStyle=m;const
|
|
748
|
+
2),t.fill();else if(I===1)t.beginPath(),t.arc(h(g+8),f,2.5,0,Math.PI*2),t.lineWidth=1.5,t.strokeStyle=m,t.stroke();else{t.lineWidth=1.5,t.strokeStyle=m;const A=5;t.strokeRect(h(g+5,A*2),f-A+1,A*2,A*2)}}
|
|
748
749
|
break;case"ordered":const b=(e.startNumber||1)+i,p=d||`${b}.`;t.textAlign=u?"left":"right",t.textBaseline="middle",t.fillText(p,u?n+6:n-6,f),t.textAlign="left",t.textBaseline="alphabetic";break;case"t\
|
|
749
750
|
odo":const y=h(g-qe,lt),x=f-lt/2,k=o?.todoCheckboxChecked||"#46b35e",C=this.isStructuralInsertTarget(e,a)?m:o?.todoCheckboxBorder||o?.text||"#0f172a",v=a?.checked?k:C,S=o?.todoCheckboxBackground||"#ff\
|
|
750
751
|
ffff",w=!!l?.hovered,O=!!l?.active,P=G(k,.12);let M=S;a?.checked?M=G(k,.18):O?M=G(k,.18):w&&(M=P),Ge(t,y,x,lt,lt,Os),t.fillStyle=M,t.fill(),t.lineWidth=1.5,t.strokeStyle=w||O?k:v,t.stroke(),a?.checked&&
|
|
@@ -752,45 +753,46 @@ ffff",w=!!l?.hovered,O=!!l?.active,P=G(k,.12);let M=S;a?.checked?M=G(k,.18):O?M=
|
|
|
752
753
|
break}t.restore()}render(t,e,i,n,r){const s=r?.theme??ot(),o=r?.syntaxTheme,a=Ee(t),l=r?.doc,d=this.getBaseFontFamily(e,n),u=r?.fragment?.unitRange?.start??0,h=r?.fragment?.unitRange?.end??Number.POSITIVE_INFINITY;
|
|
753
754
|
let g=i.y,f=0;const m=e.variant==="ordered"?(l?Xn(l).get(e.id):void 0)??ai(e):void 0,b=m?{...m.counters}:{level0:0,level1:0,level2:0},p=m?.start??1,y=ue(),x=pe(e),k={...r??{},theme:s,syntaxTheme:o};t:
|
|
754
755
|
for(let C=0;C<e.children.length;C++){const v=e.children[C],S=y,w=this.getItemIndentLevel(v),O=this.getItemIndentOffset(v),P=this.getMarkerColumnPx(e,a,S,d);vt(t,{},S,d,void 0,l);const M=this.wrapListItem(
|
|
755
|
-
v,a,n.availableWidth,S,d,e,l),I=(()=>{const E=de(e,`checkbox-${C}`);return{hovered:r?.hoveredUIComponentKey===E,active:r?.activeUIComponentKey===E}})(),
|
|
756
|
-
void 0;let T=!1;const L=this.getItemDirection(v),
|
|
756
|
+
v,a,n.availableWidth,S,d,e,l),I=(()=>{const E=de(e,`checkbox-${C}`);return{hovered:r?.hoveredUIComponentKey===E,active:r?.activeUIComponentKey===E}})(),A=e.variant==="ordered"?li(b,p,w,ci(e.numberingFormat)):
|
|
757
|
+
void 0;let T=!1;const L=this.getItemDirection(v),R=L==="rtl",F=i.x+P+O,W=this.getRtlTextRightEdge(i.x,n.availableWidth,P,O),$=R?W:F;for(let E=0;E<M.length;E++){const H=f>=u&&f<h,D=M[E],z=B.getWrappedLineHeight(
|
|
757
758
|
D,y,x);if(H){if(g+=D.spaceBefore??0,!T&&E===0){const at=v.structuralSuggestionKind?v:C===0&&e.structuralSuggestionKind?e:null;at&&this.renderStructuralSuggestionMarker(t,at,{x:F,y:g,height:z},s),this.
|
|
758
|
-
renderListMarker(t,e,C,$,g,z,s,v,I,
|
|
759
|
+
renderListMarker(t,e,C,$,g,z,s,v,I,A,R),T=!0}const J=g+B.getLineMaxTextFontSize(D,y),X=e.variant==="todo"&&v.checked,U=(at,K,j,St)=>{const it=this.getSegmentDiffState(e,v,K);vt(t,K,S,d,void 0,l);const ct=this.
|
|
759
760
|
renderSegment(t,{text:at,marks:K},j,J,S,z,e,k,{diffState:it,suggestionContainer:v,renderActiveSuggestionBackground:it?this.shouldRenderActiveSuggestionSegment(e,C,v,K,r):!1,textColor:!it&&X?s?.todoCheckedText:
|
|
760
761
|
void 0});if(X&&!(it==="delete"&&!Ne(K?.suggestionId))){const V=!it&&s?.todoCheckedText||String(t.fillStyle);t.save(),t.beginPath(),t.moveTo(j,J-S*.3),t.lineTo(j+ct,J-S*.3),t.strokeStyle=V,t.lineWidth=
|
|
761
|
-
1,t.stroke(),t.restore()}if(r?.annotations&&v.id){const V=D.startCharOffset+St,pt=V+at.length;
|
|
762
|
-
D,L,a,S,d,e,l),et=Y&&
|
|
762
|
+
1,t.stroke(),t.restore()}if(r?.annotations&&v.id){const V=D.startCharOffset+St,pt=V+at.length;B.renderAnnotationUnderlinesForSegment(t,v.id,V,pt,j,J,ct,at,r.annotations)}return ct},Y=this.getListLineBidiGeometry(
|
|
763
|
+
D,L,a,S,d,e,l),et=Y&&R?W-Y.measure(0,Y.lineText.length):F;B.renderLineSegments(t,D,et,(at,K,j)=>U(at.text,at.marks,K,j),{bidiGeometry:Y}),g+=z+(D.spaceAfter??0)}if(f+=1,f>=h)break t}}}getBounds(t,e,i,n,r,s){
|
|
763
764
|
const o=ue(),a=pe(t),l=o*a,{top:d,bottom:u}=pi(t,r,l*r.paragraphSpacing),h=[];let g=0,f=0;return t.children.forEach((m,b)=>{b>0&&(f+=1);const p=this.getItemIndentOffset(m),y=this.wrapListItem(m,n,r.availableWidth,
|
|
764
|
-
Ht.paragraph,this.getBaseFontFamily(t,r),t,s);y.length===0?(h.push({height:l,width:r.availableWidth,lineRange:{start:g,end:g+1},charRange:{start:f,end:f},data:{type:"line",itemIndex:b,
|
|
765
|
-
indentOffset:p,empty:!0}}),g+=1):y.forEach((x,k)=>{const C=
|
|
766
|
-
start:f+x.startCharOffset,end:f+x.endCharOffset},data:{type:"line",itemIndex:b,lineIndexInItem:k,indentOffset:p}}),
|
|
767
|
-
lineRange:{start:0,end:0},charRange:{start:0,end:0},data:{type:"line",itemIndex:0,lineIndexInItem:0,indentOffset:0,
|
|
768
|
-
const s=t.children[e];return s?this.wrapListItem(s,i,n.availableWidth,Ht.paragraph,this.getBaseFontFamily(
|
|
769
|
-
return null;const l=this.getFontSize(t),d=this.getLineHeight(t)/l,u=this.getBaseFontFamily(t,s),h=a?.unitRange?.
|
|
770
|
-
length;b++){const p=t.children[b],y=this.getItemIndentOffset(p),x=this.wrapListItem(p,r,s.availableWidth,l,
|
|
771
|
-
0)+(C.spaceAfter??0);if(m>=h&&m<g){const S=f,w=f+v;if(i>=S&&i<w){const O=this.getMarkerColumnPx(t,r,l,u),
|
|
772
|
-
measure(0,M.lineText.length),
|
|
773
|
-
u,t,o)}const
|
|
774
|
-
offset;return{type:"text",position:L,offset:
|
|
775
|
-
u=ue(),h=pe(t),g=u*h;let f=e.y,m=0;t:for(let b=0;b<t.children.length;b++){const p=t.children[b],y=this.wrapListItem(
|
|
776
|
-
p),k=f+(y[0]?.spaceBefore??0),C=y.length>0?
|
|
777
|
-
getItemDirection(p)==="rtl"?e.x+n.availableWidth-this.getListIndentPx(t)-x+Ke+qe-lt:e.x+this.getListIndentPx(
|
|
778
|
-
x:P,y:k+C/2-lt/2,width:lt,height:lt}),onMouseDown:M=>{const I=!(p.checked??!1),
|
|
779
|
-
(f+=w+(S.spaceBefore??0)+(S.spaceAfter??0)),m+=1,m>=d)break t}}return a}findMatches(t,e){const i=[];let n=0;for(const r of t.
|
|
780
|
-
s,e)){const a=n+o.startOffset,l=n+o.endOffset;i.push({text:o.text,startOffset:a,endOffset:l,startPosition:{block:t.id??"",
|
|
781
|
-
return t.children.length===0?null:t.id?{block:t.id,offset:0}:null}getLastCursorPosition(t){const e=this.
|
|
782
|
-
if(!t.id)return null;const{itemIndex:i,offsetInItem:n}=this.getOffsetWithinItem(t,e);if(i>=t.children.
|
|
783
|
-
resolveOffsetWithinItem(t,i,r,s);if(i<t.children.length-1){const o=t.children[i+1];return this.
|
|
784
|
-
itemIndex:i,offsetInItem:n}=this.getOffsetWithinItem(t,e),r=t.children[i];if(!r)return null;const s=
|
|
785
|
-
0){const o=t.children[i-1],a=_(o).visibleText.length;return this.resolveOffsetWithinItem(t,i-1,o,_(
|
|
786
|
-
itemIndex:d,offsetInItem:u}=this.normalizeItemPosition(t,e);if(d>=t.children.length)return null;
|
|
787
|
-
p=this.getBaseFontFamily(t,r),y=this.getMarkerColumnPx(t,n,m,p),x=i.x+y+f,k=b/m,C=this.getItemDirection(
|
|
788
|
-
unitRange?.end??Number.MAX_SAFE_INTEGER;let P=0,M=0;for(let L=0;L<d;L++){const
|
|
789
|
-
B,m,k)),P++}const I=this.wrapListItem(h,n,r.availableWidth,m,p,t,o),
|
|
790
|
-
I.length-1?I[L+1]:null;if(T===
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
765
|
+
Ht.paragraph,this.getBaseFontFamily(t,r),t,s);y.length===0?(h.push({height:l,width:r.availableWidth,baselineOffset:o,lineRange:{start:g,end:g+1},charRange:{start:f,end:f},data:{type:"line",itemIndex:b,
|
|
766
|
+
lineIndexInItem:0,indentOffset:p,empty:!0}}),g+=1):y.forEach((x,k)=>{const C=B.getWrappedLineHeight(x,o,a);h.push({height:C+(x.spaceBefore??0)+(x.spaceAfter??0),width:r.availableWidth,baselineOffset:(x.
|
|
767
|
+
spaceBefore??0)+B.getLineMaxTextFontSize(x,o),lineRange:{start:g,end:g+1},charRange:{start:f+x.startCharOffset,end:f+x.endCharOffset},data:{type:"line",itemIndex:b,lineIndexInItem:k,indentOffset:p}}),
|
|
768
|
+
g+=1}),f+=_(m).visibleText.length}),h.length===0&&h.push({height:l,width:r.availableWidth,lineRange:{start:0,end:0},charRange:{start:0,end:0},data:{type:"line",itemIndex:0,lineIndexInItem:0,indentOffset:0,
|
|
769
|
+
empty:!0}}),{x:e,width:r.availableWidth,units:h,margins:{top:d,bottom:u}}}getWrappedLinesForItem(t,e,i,n,r){const s=t.children[e];return s?this.wrapListItem(s,i,n.availableWidth,Ht.paragraph,this.getBaseFontFamily(
|
|
770
|
+
t,n),t,r):[]}hitTest(t,e,i,n,r,s,o,a){if(s=Ft(s,n),e<n.x||e>n.x+n.width,i<n.y||i>n.y+n.height)return null;const l=this.getFontSize(t),d=this.getLineHeight(t)/l,u=this.getBaseFontFamily(t,s),h=a?.unitRange?.
|
|
771
|
+
start??0,g=a?.unitRange?.end??Number.POSITIVE_INFINITY;let f=n.y,m=0;for(let b=0;b<t.children.length;b++){const p=t.children[b],y=this.getItemIndentOffset(p),x=this.wrapListItem(p,r,s.availableWidth,l,
|
|
772
|
+
u,t,o);for(let k=0;k<x.length;k++){const C=x[k],v=B.getWrappedLineHeight(C,l,d)+(C.spaceBefore??0)+(C.spaceAfter??0);if(m>=h&&m<g){const S=f,w=f+v;if(i>=S&&i<w){const O=this.getMarkerColumnPx(t,r,l,u),
|
|
773
|
+
P=this.getItemDirection(p),M=this.getListLineBidiGeometry(C,P,r,l,u,t,o);let I;if(M){const F=M.measure(0,M.lineText.length),W=P==="rtl"?this.getRtlTextRightEdge(n.x,s.availableWidth,O,y)-F:n.x+O+y;I=Re(
|
|
774
|
+
M.slices,e-W,M.lineText,M.measure)}else{const F=e-n.x-O-y;I=this.findCharacterInLine(C,F,r,l,u,t,o)}const A=C.startCharOffset+I.offset,T=_(p).toActualOffset(A,I.beforeChar?"backward":"forward"),L=this.
|
|
775
|
+
resolveOffsetWithinItem(t,b,p,T);L.bidiAffinity=I.beforeChar?"leading":"trailing";const R=L.offset;return{type:"text",position:L,offset:R,bounds:n}}f+=v}m++}if(m>=g)break}return null}getUIComponents(t,e,i,n,r,s,o){
|
|
776
|
+
n=Ft(n,e);const a=[],l=s?.unitRange?.start??0,d=s?.unitRange?.end??Number.POSITIVE_INFINITY,u=ue(),h=pe(t),g=u*h;let f=e.y,m=0;t:for(let b=0;b<t.children.length;b++){const p=t.children[b],y=this.wrapListItem(
|
|
777
|
+
p,i,n.availableWidth,Ht.paragraph,this.getBaseFontFamily(t,n),t,r),x=this.getItemIndentOffset(p),k=f+(y[0]?.spaceBefore??0),C=y.length>0?B.getWrappedLineHeight(y[0],u,h):g;for(let v=0;v<y.length;v++){
|
|
778
|
+
const S=y[v],w=B.getWrappedLineHeight(S,u,h),O=m>=l&&m<d;if(v===0&&O&&t.variant==="todo"){const P=this.getItemDirection(p)==="rtl"?e.x+n.availableWidth-this.getListIndentPx(t)-x+Ke+qe-lt:e.x+this.getListIndentPx(
|
|
779
|
+
t)+x-Ke-qe;a.push({id:`checkbox-${b}`,cursor:"pointer",interceptsSelection:!0,getBounds:()=>({x:P,y:k+C/2-lt/2,width:lt,height:lt}),onMouseDown:M=>{const I=!(p.checked??!1),A={...t};A.children=[...t.children],
|
|
780
|
+
A.children[b]={...p,checked:I},M.api.replaceBlock(A)&&M.api.requestRedraw()}})}if(O&&(f+=w+(S.spaceBefore??0)+(S.spaceAfter??0)),m+=1,m>=d)break t}}return a}findMatches(t,e){const i=[];let n=0;for(const r of t.
|
|
781
|
+
children){const s=this.getPlainTextFromItem(r);for(const o of B.findTextMatches(s,e)){const a=n+o.startOffset,l=n+o.endOffset;i.push({text:o.text,startOffset:a,endOffset:l,startPosition:{block:t.id??"",
|
|
782
|
+
offset:a},endPosition:{block:t.id??"",offset:l}})}n+=s.length+1}return i}getFirstCursorPosition(t){return t.children.length===0?null:t.id?{block:t.id,offset:0}:null}getLastCursorPosition(t){const e=this.
|
|
783
|
+
getBlockLength(t);return t.id?{block:t.id,offset:e}:{block:"",offset:e}}getNextCursorPosition(t,e){if(!t.id)return null;const{itemIndex:i,offsetInItem:n}=this.getOffsetWithinItem(t,e);if(i>=t.children.
|
|
784
|
+
length)return null;const r=t.children[i],s=B.getAdjacentCaretOffset(r,n,"forward");if(s!==null)return this.resolveOffsetWithinItem(t,i,r,s);if(i<t.children.length-1){const o=t.children[i+1];return this.
|
|
785
|
+
resolveOffsetWithinItem(t,i+1,o,0)}return null}getPreviousCursorPosition(t,e){if(!t.id)return null;const{itemIndex:i,offsetInItem:n}=this.getOffsetWithinItem(t,e),r=t.children[i];if(!r)return null;const s=B.
|
|
786
|
+
getAdjacentCaretOffset(r,n,"backward");if(s!==null)return this.resolveOffsetWithinItem(t,i,r,s);if(i>0){const o=t.children[i-1],a=_(o).visibleText.length;return this.resolveOffsetWithinItem(t,i-1,o,_(
|
|
787
|
+
o).toActualOffset(a,"backward"))}return null}getCursorScreenPosition(t,e,i,n,r,s,o,a,l){r=Ft(r,i);const{itemIndex:d,offsetInItem:u}=this.normalizeItemPosition(t,e);if(d>=t.children.length)return null;
|
|
788
|
+
const h=t.children[d],g=_(h),f=this.getItemIndentOffset(h),m=this.getFontSize(t),b=this.getLineHeight(t),p=this.getBaseFontFamily(t,r),y=this.getMarkerColumnPx(t,n,m,p),x=i.x+y+f,k=b/m,C=this.getItemDirection(
|
|
789
|
+
h),v=C==="rtl",S=this.getRtlTextRightEdge(i.x,r.availableWidth,y,f),w=a?.unitRange?.start??0,O=a?.unitRange?.end??Number.MAX_SAFE_INTEGER;let P=0,M=0;for(let L=0;L<d;L++){const R=t.children[L],F=this.
|
|
790
|
+
wrapListItem(R,n,r.availableWidth,m,p,t,o);for(const W of F)P>=w&&P<O&&(M+=B.getWrappedLineBoxHeight(W,m,k)),P++}const I=this.wrapListItem(h,n,r.availableWidth,m,p,t,o),A=g.visibleText,T=g.toVisibleOffset(
|
|
791
|
+
u);for(let L=0;L<I.length;L++){const R=I[L];if(T>=R.startCharOffset&&T<=R.endCharOffset){const F=L<I.length-1?I[L+1]:null;if(T===R.endCharOffset&&F&&F.startCharOffset<=T){const Y=F.startCharOffset-1,et=Y>=
|
|
792
|
+
0?A[Y]:void 0;if(et===`
|
|
793
|
+
`||et===" ")continue}const W=P+L;if(W<w||W>=O)return null;for(let Y=0;Y<L;Y++){const et=P+Y;et>=w&&et<O&&(M+=B.getWrappedLineBoxHeight(I[Y],m,k))}const $=B.getLineMaxTextFontSize(R,m),E=i.y+M+(R.spaceBefore??
|
|
794
|
+
0)+$,H=T-R.startCharOffset;let D;const z=this.getListLineBidiGeometry(R,C,n,m,p,t,o);if(z){const Y=z.measure(0,z.lineText.length);D=(v?S-Y:x)+Oe(z.slices,H,z.measure,e.bidiAffinity)}else v?D=S:D=x+B.measureLineRange(
|
|
795
|
+
R,0,H,n,m,p,t,o);let J,X=m,U=0;for(const Y of R.segments){const et=Y.text.length;if(H<=U+et){H>U&&Y.marks?.code&&(J=l?.syntaxTheme?.text),Y.marks?.fontSize&&(X=Y.marks.fontSize);break}U+=et}return{x:D,
|
|
794
796
|
y:E,fontSize:X,cursorColor:J}}}return null}getCharacterOffset(t,e){return this.convertPositionToOffset(t,e)}getPositionFromOffset(t,e){return this.convertOffsetToPosition(t,e)}isEmpty(t){return t.children.
|
|
795
797
|
length===0||t.children.every(e=>this.getPlainTextFromItem(e).length===0)}canMergeWith(t,e){return t==="paragraph"}shouldDeleteBlock(t,e,i){return this.isEmpty(t)}handleEnterKey(t,e){if(!e)return{action:"\
|
|
796
798
|
none"};const{itemIndex:i}=this.blockOffsetToItem(t,e.offset??0),n=t.children[i];return n?this.getPlainTextFromItem(n).replace(`
|
|
@@ -799,11 +801,11 @@ n.offset??0);if(r<0||s<0||r>=t.children.length||s>=t.children.length)return!1;co
|
|
|
799
801
|
index:l})}const a=l=>{for(let d=0;d<l.length;d++){const u=l.get(d);if(u instanceof st.XmlText)return u}return null};if(r===s){const l=o[r];if(!l)return!1;const d=a(l.element);if(!d)return!1;const u=t.
|
|
800
802
|
children[r];if(!u||u.type!=="list-item")return!1;const{offsetInItem:h}=this.blockOffsetToItem(t,i.offset??0),{offsetInItem:g}=this.blockOffsetToItem(t,n.offset??0),f=this.pathPositionToListYTextOffset(
|
|
801
803
|
u,[],h),m=this.pathPositionToListYTextOffset(u,[],g);return m>f&&d.delete(f,m-f),!0}else{const l=o[r];if(l){const h=a(l.element),g=t.children[r];if(h&&g){const{offsetInItem:f}=this.blockOffsetToItem(t,
|
|
802
|
-
i.offset??0),m=this.pathPositionToListYTextOffset(g,[],f);if(m<h.length){const b=
|
|
803
|
-
{};break}y+=k}if(h.delete(m,h.length-m),Object.keys(p).length>0&&h.length>0){const x=
|
|
804
|
+
i.offset??0),m=this.pathPositionToListYTextOffset(g,[],f);if(m<h.length){const b=Bt(h);let p={},y=0;for(const x of b)if(typeof x.insert=="string"){const k=x.insert.length;if(y<=m&&m<y+k){p=x.attributes||
|
|
805
|
+
{};break}y+=k}if(h.delete(m,h.length-m),Object.keys(p).length>0&&h.length>0){const x=Bt(h),k=x[x.length-1];k&&k.attributes&&Object.keys(k.attributes).length>0}}}}let d=s;if(s>r+1){const h=s-r-1,g=o[r+
|
|
804
806
|
1]?.index;g!==void 0&&e.delete(g,h),d=r+1,o.length=0;for(let f=0;f<e.length;f++){const m=e.get(f);m instanceof st.XmlElement&&m.nodeName==="list-item"&&o.push({element:m,index:f})}}const u=o[d];if(u){
|
|
805
807
|
const h=a(u.element),g=t.children[s];if(h&&g){const{offsetInItem:f}=this.blockOffsetToItem(t,n.offset??0),m=this.pathPositionToListYTextOffset(g,[],f);if(m<h.length){const b=o[r];if(b){const p=a(b.element);
|
|
806
|
-
if(p){let y=p.length,x={};if(y>0){const v=
|
|
808
|
+
if(p){let y=p.length,x={};if(y>0){const v=Bt(p);let S=0;for(const w of v)if(typeof w.insert=="string"){const O=S+w.insert.length;O===y?x=w.attributes||{}:S<y&&y<O&&(x=w.attributes||{}),S=O}}const k=Bt(
|
|
807
809
|
h);let C=0;k.forEach(v=>{if(typeof v.insert=="string"){const S=v.insert.length;if(C+S<=m){C+=S;return}if(C<m){const w=m-C,O=v.insert.substring(w);if(O.length>0){const P=v.attributes||{};JSON.stringify(
|
|
808
810
|
P)!==JSON.stringify(x)||Object.keys(P).length>0?qt(p,y,O,P):qt(p,y,O),y+=O.length}}else{const w=v.attributes||{};Object.keys(w).length>0?qt(p,y,v.insert,w):qt(p,y,v.insert,{}),y+=v.insert.length}C+=S}})}}}
|
|
809
811
|
e.delete(u.index,1)}}return!0}}pathPositionToListYTextOffset(t,e,i){return Math.max(0,Math.min(i,this.getPlainTextFromItem(t).length))}buildListHTMLRecursive(t,e,i){const n=t.variant==="ordered"?"ol":
|
|
@@ -815,7 +817,7 @@ children[o])>i){const h=this.buildListHTMLRecursive(t,o,i+1);u+=h.html,o=h.nextI
|
|
|
815
817
|
return t.children.forEach(n=>{const r=this.getItemIndentLevel(n),s=" ".repeat(r),o=this.getPlainTextFromItem(n);if(t.variant==="ordered"){const a=li(i,t.startNumber??1,r,ci(t.numberingFormat));e.push(
|
|
816
818
|
`${s}${a} ${o}`.trimEnd())}else if(t.variant==="todo"){const a=n.checked?"[x]":"[ ]";e.push(`${s}- ${a} ${o}`.trimEnd())}else e.push(`${s}- ${o}`.trimEnd())}),e.join(`
|
|
817
819
|
`)}toYjs(t,e){return rt(t)}fromYjs(t){const e=[];for(let a=0;a<t.length;a++){const l=t.get(a);if(!(l instanceof st.XmlElement)||l.nodeName!=="list-item")continue;const d=[];for(let g=0;g<l.length;g++){
|
|
818
|
-
const f=l.get(g);if(f instanceof st.XmlText){
|
|
820
|
+
const f=l.get(g);if(f instanceof st.XmlText){Bt(f).forEach(m=>{if(typeof m.insert=="string"){const b={type:"text",text:m.insert};m.attributes&&Object.keys(m.attributes).length>0&&(b.marks=m.attributes),
|
|
819
821
|
d.push(b)}});break}}d.length===0&&d.push({type:"text",text:""});const u=l.getAttribute("checked"),h=l.getAttribute("indentLevel");e.push({type:"list-item",id:l.getAttribute("id")||Z(),checked:u==="tru\
|
|
820
822
|
e"?!0:u==="false"?!1:void 0,indentLevel:h?parseInt(h,10):void 0,...Object.fromEntries(Pn.flatMap(g=>{const f=tt(l,g),m=Number(f);return f!=null&&Number.isFinite(m)&&m>=0?[[g,m]]:[]})),children:d})}const i=t.
|
|
821
823
|
getAttribute("startNumber"),n=t.getAttribute("numberingChainId"),r=tt(t,"lineSpacing"),s={type:"list",id:t.getAttribute("id")||Z(),variant:t.getAttribute("variant")||"unordered",startNumber:i?parseInt(
|
|
@@ -898,7 +900,7 @@ forEach(r=>{if(n){const s=n.toYjs(r,e);i.push([s])}}),i}fromYjs(t){const e=[],i=
|
|
|
898
900
|
i&&e.push(i.fromYjs(r))}return{type:"table-row",id:t.getAttribute("id")||Z(),children:e,diffState:t.getAttribute("diffState")==="insert"||t.getAttribute("diffState")==="delete"||t.getAttribute("diffSt\
|
|
899
901
|
ate")==="equal"?t.getAttribute("diffState"):void 0,suggestionId:t.getAttribute("suggestionId")||void 0}}findMatches(t,e){const i=[],n=this.getCellHandler();for(const r of t.children)n&&i.push(...n.findMatches(
|
|
900
902
|
r,e));return i}validate(t){const e=[];t.id||e.push("Table row must have an ID"),t.children.length===0&&e.push("Table row must have at least one cell");const i=this.getCellHandler();for(const n of t.children)
|
|
901
|
-
if(i){const r=i.validate(n);!r.valid&&r.errors&&e.push(...r.errors)}return{valid:e.length===0,errors:e}}}const Es=
|
|
903
|
+
if(i){const r=i.validate(n);!r.valid&&r.errors&&e.push(...r.errors)}return{valid:e.length===0,errors:e}}}const Es=Wt.borderColor,$s=Wt.borderWidthPx,Ns=Wt.cellPaddingPx,Kt=8,mn=5,js=100;class Xs{constructor(){
|
|
902
904
|
this.type="table",this.isTextBased=!1,this.rowHandler=new Hs}getRowHandler(){return this.rowHandler}getTableCellPadding(t){const e=t.cellPadding;return Number.isFinite(e)?Math.max(0,Math.round(e)):Ns}render(t,e,i,n,r){}getBounds(t,e,i,n,r,s){
|
|
903
905
|
const o=t.tableWidth??r.availableWidth;let a=e;if(o<r.availableWidth){const u=t.align??"left";u==="center"?a=e+Math.max(0,(r.availableWidth-o)/2):u==="right"&&(a=e+Math.max(0,r.availableWidth-o))}const l=this.
|
|
904
906
|
computeGridGeometry(t,r,n,s),d=l.geometry.totalHeight;return{x:a,width:o,units:[{height:d,width:o,data:l}],margins:{top:r.suppressTopSpacingForFirstChild?0:dt(r,12),bottom:0}}}normalizeColumnWidths(t){
|
|
@@ -938,7 +940,7 @@ e.push("Table must have at least one row");const i=be(t);for(let r=0;r<i.rows;r+
|
|
|
938
940
|
grid columns`);const a=i.cells.filter(l=>l.row===r).length;a!==s.children.length&&e.push(`Row ${r+1} has ${s.children.length} cells but only ${a} fit the grid`)}t.columnWidths.length>0&&t.columnWidths.
|
|
939
941
|
length!==i.cols&&e.push(`Column widths array has ${t.columnWidths.length} entries, expected ${i.cols}`);const n=this.getRowHandler();for(const r of t.children){const s=n.validate(r);!s.valid&&s.errors&&
|
|
940
942
|
e.push(...s.errors)}return{valid:e.length===0,errors:e}}isAtomic(){return!1}allowsInternalCursor(){return!0}shouldDeleteBlock(t,e,i){return this.isEmpty(t)}handleEnterKey(t,e){return{action:"none"}}handleDeleteBackward(t,e){
|
|
941
|
-
return{handled:!1}}handleDeleteForward(t,e){return{handled:!1}}}const pn=
|
|
943
|
+
return{handled:!1}}handleDeleteForward(t,e){return{handled:!1}}}const pn=Wt.cellPaddingPx,Ys=Wt.borderColor,Ks=Wt.borderWidthPx;class qs{constructor(){this.type="table-cell",this.isTextBased=!1}getRegistry(){
|
|
942
944
|
return Q.getInstance()}getChildHandler(t){return this.getRegistry().getHandlerForBlock(t)}getResolvedCellPadding(t){const e=t.tableCellPadding;return Number.isFinite(e)?Math.max(0,Math.round(e)):pn}getResolvedCellPaddingSides(t,e){
|
|
943
945
|
return qn(this.getResolvedCellPadding(e),t.padding)}getResolvedBorderStyle(t){const e=t?.fragment?.data,i=e?.tableBorderColor||t?.theme?.pageBorder||Ys,n=e?.tableBorderWidth,r=Number.isFinite(n)?Math.
|
|
944
946
|
max(0,Number(n)):Ks;return{borderColor:i,borderWidth:r}}render(t,e,i,n,r){t.save();const s=r?.renderCtx,o=i.relativeToPage?0:s?.yOffset??0,a=i.y-o,l=r?.fragment?.data;e.backgroundColor?(t.fillStyle=e.
|
|
@@ -947,7 +949,7 @@ nsert"||v==="delete",u=d(e.diffState),h=d(l?.rowDiffState),g=d(l?.tableDiffState
|
|
|
947
949
|
r.theme.diffDelete,w=g&&!h&&!u?q.tableTintOpacity:q.tableRowTintOpacity;t.fillStyle=G(S,v?w.insert:w.delete),t.fillRect(i.x,a,i.width,i.height),(u||l?.isLeftCol)&&(t.fillStyle=G(S,q.tableRowRailOpacity),
|
|
948
950
|
t.fillRect(i.x,a,Math.min(i.width,q.tableCellRailWidthPx),i.height))}const{borderColor:m,borderWidth:b}=this.getResolvedBorderStyle(r),p=Gn(l?.tableBorders),y=Un(e.borders),x=(()=>{if(r?.isReadOnly)return null;
|
|
949
951
|
const v=l?.parentTableId;if(!v)return null;const S=r?.activeUIComponentKey??r?.hoveredUIComponentKey;if(!S)return null;const w=`${v}:`;if(!S.startsWith(w))return null;const O=S.slice(w.length);if(O===
|
|
950
|
-
"table-width-resize")return l?.isRightCol===!0?"right":null;const P=/^col-resize-(\d+)$/.exec(O);if(!P)return null;const M=Number(P[1]),I=l?.gridCol??0,
|
|
952
|
+
"table-width-resize")return l?.isRightCol===!0?"right":null;const P=/^col-resize-(\d+)$/.exec(O);if(!P)return null;const M=Number(P[1]),I=l?.gridCol??0,A=l?.colSpan??1;return I+A-1===M?"right":I===M+1?
|
|
951
953
|
"left":null})(),k=v=>{const S=v==="left"?i.x:i.x+i.width;Et(t,{style:"single",width:1,color:r?.theme?.pageBorder||"#cccccc"},S,a,S,a+i.height)};if(p||y){const v=Vn({tableBorders:p,cellBorders:y,flags:{
|
|
952
954
|
isTopRow:l?.isTopRow===!0,isBottomRow:l?.isBottomRow===!0,isLeftCol:l?.isLeftCol===!0,isRightCol:l?.isRightCol===!0},fallback:{style:"single",width:b,color:m}}),S=i.x,w=a,O=i.width,P=i.height;if(Et(t,
|
|
953
955
|
v.top,S,w,S+O,w),Et(t,v.bottom,S,w+P,S+O,w+P),Et(t,v.left,S,w,S,w+P),Et(t,v.right,S+O,w,S+O,w+P),x){const M=v[x];(M.style==="none"||M.width<=0)&&k(x)}}else b>0?(t.strokeStyle=m,t.lineWidth=b,t.strokeRect(
|
|
@@ -1010,12 +1012,12 @@ beginPath(),Lt(t,i.x,d,i.width,f,4),t.fill();const b=i.x+this.padding,p=d+this.p
|
|
|
1010
1012
|
t.fillStyle=y;for(let C=0;C<h.length;C++){const v=h[C],S=p+C*this.lineHeight;t.fillText(v.text,b,S)}x&&oi(x)}}}this.renderDiagramSection(t,e,i,m,r),this.drawDiagramToggle(t,e,i,m,o),t.restore(),ht(e)&&
|
|
1011
1013
|
ut(t,i,n,r)}render(t,e,i,n,r){const s=r?.theme??ot(),o=r?.syntaxTheme,a=r?.renderCtx,l=i.relativeToPage?0:a?.yOffset??0,d=i.y-l;if(this.isDiagramEnabled(e)){this.renderDiagramMode(t,e,i,d,s,o,r);return}
|
|
1012
1014
|
t.save();const u=o?.background||s?.codeBackground||"#f5f5f5",h=o?.text||s?.codeText||"#333333",g=r?.fragment,f=i.width-this.padding*2,m={measureText:L=>t.measureText(L),setFont:L=>{t.font=L}};let b,p=null;
|
|
1013
|
-
if(e.lineDiffs&&e.lineDiffs.length>0){t.font=`${this.fontSize}px ${this.fontFamily}`;const L=t.measureText("- ").width;p=this.wrapLineDiffs(e.lineDiffs,m,f,L),b=p.map((
|
|
1014
|
-
endCharOffset:0,sourceLineIndex:F,isWrappedContinuation:
|
|
1015
|
+
if(e.lineDiffs&&e.lineDiffs.length>0){t.font=`${this.fontSize}px ${this.fontFamily}`;const L=t.measureText("- ").width;p=this.wrapLineDiffs(e.lineDiffs,m,f,L),b=p.map((R,F)=>({text:R.text,startCharOffset:0,
|
|
1016
|
+
endCharOffset:0,sourceLineIndex:F,isWrappedContinuation:R.isWrappedContinuation}))}else t.font=`${this.fontSize}px ${this.fontFamily}`,b=this.wrapCode(e,m,f);const y=Math.max(1,b.length),x=Math.max(0,
|
|
1015
1017
|
Math.min(g?.lineRange?.start??0,y)),k=Math.max(x,Math.min(g?.lineRange?.end??y,y)),C=x===0,v=k>=y;let S=(k-x)*this.lineHeight;C&&(S+=this.padding),v&&(S+=this.padding),t.fillStyle=u,t.beginPath();const w=4,
|
|
1016
1018
|
O=C?w:0,P=v?w:0;Lt(t,i.x,d,i.width,S,[O,O,P,P]),t.fill(),t.beginPath(),t.rect(i.x,d,i.width,S),t.clip(),t.font=`${this.fontSize}px ${this.fontFamily}`,t.textBaseline="top";const M=i.x+this.padding,I=d+
|
|
1017
|
-
(C?this.padding:0)+this.textVerticalOffset;if(p){this.renderWithLineDiffs(t,p,i,M,I,d,h,s,o,x,k),t.restore(),ht(e)&&ut(t,i,d,s);return}const
|
|
1018
|
-
renderWithHighlighting(t,T,M,I,h,f,b,x,k);else{t.fillStyle=h;for(let L=x;L<k;L++){const
|
|
1019
|
+
(C?this.padding:0)+this.textVerticalOffset;if(p){this.renderWithLineDiffs(t,p,i,M,I,d,h,s,o,x,k),t.restore(),ht(e)&&ut(t,i,d,s);return}const A=e.language,T=A?si(e.content,A,r?.syntaxTheme):null;if(T)this.
|
|
1020
|
+
renderWithHighlighting(t,T,M,I,h,f,b,x,k);else{t.fillStyle=h;for(let L=x;L<k;L++){const R=b[L],F=L-x,W=I+F*this.lineHeight;t.fillText(R.text,M,W)}A&&oi(A)}t.restore(),ht(e)&&ut(t,i,d,s)}renderWithLineDiffs(t,e,i,n,r,s,o,a,l,d=0,u){
|
|
1019
1021
|
const h=t.measureText("- ").width,g=n+h,f=l?.default||o,m=l?.background||"#f5f5f5",b=this.isColorDark(m),p=b?"rgba(34, 197, 94, 0.25)":"rgba(34, 197, 94, 0.15)",y=b?"rgba(239, 68, 68, 0.25)":"rgba(239\
|
|
1020
1022
|
, 68, 68, 0.15)",x=b?"#4ade80":"#16a34a",k=b?"#f87171":"#dc2626",C=u??e.length;let v=r;for(let S=d;S<C;S++){const w=e[S];(w.type==="insert"||w.type==="delete")&&(t.fillStyle=w.type==="insert"?p:y,t.fillRect(
|
|
1021
1023
|
i.x,v-this.textVerticalOffset,i.width,this.lineHeight)),w.isWrappedContinuation?(t.fillStyle=w.type==="insert"?x:w.type==="delete"?k:f,t.fillText(" ",n,v)):w.type==="insert"?(t.fillStyle=x,t.fillText(
|
|
@@ -1053,8 +1055,8 @@ if(p+k/2>f)break;p+=k,b=x+1}const y=m.startCharOffset+b;return{block:t.id,offset
|
|
|
1053
1055
|
const d=n.x+this.padding,u=n.width-this.padding*2,h=e?this.getCharacterOffset(t,e):0,g=i?this.getCharacterOffset(t,i):t.content.length;if(h===g)return l;const f=this.wrapCode(t,r,u),m=a?.lineRange?.start??
|
|
1054
1056
|
0,b=a?.lineRange?.end??f.length,p=m===0,y=n.y+(p?this.padding:0);r.setFont(`${this.fontSize}px ${this.fontFamily}`);let x=0,k=f.length-1;for(let S=0;S<f.length;S++){const w=f[S];if(h>=w.startCharOffset&&
|
|
1055
1057
|
h<=w.endCharOffset&&(x=S),g>=w.startCharOffset&&g<=w.endCharOffset){k=S;break}}const C=Math.max(x,m),v=Math.min(k,b-1);if(C>v)return l;for(let S=C;S<=v;S++){const w=f[S],O=S-m,P=y+O*this.lineHeight;let M=0,
|
|
1056
|
-
I=w.text.length;S===x&&(M=Math.max(0,h-w.startCharOffset)),S===k&&(I=Math.min(w.text.length,g-w.startCharOffset));const
|
|
1057
|
-
T).width||4;l.push({x:L,y:P,width:
|
|
1058
|
+
I=w.text.length;S===x&&(M=Math.max(0,h-w.startCharOffset)),S===k&&(I=Math.min(w.text.length,g-w.startCharOffset));const A=w.text.substring(0,M),T=w.text.substring(M,I),L=d+r.measureText(A).width,R=r.measureText(
|
|
1059
|
+
T).width||4;l.push({x:L,y:P,width:R,height:this.lineHeight})}return l}getWordCount(t){const e=t.content.trim();return e?e.split(/\s+/).length:0}getCharCount(t){return t.content.length}isEmpty(t){return!t.
|
|
1058
1060
|
content||t.content.length===0}canEdit(){return!0}insertText(t,e,i){const n=this.getCharacterOffset(t,i),r=t.content.slice(0,n)+e+t.content.slice(n);return{...t,content:r}}deleteRange(t,e,i){const n=t.
|
|
1059
1061
|
content.slice(0,e)+t.content.slice(i);return{...t,content:n}}canMergeWith(t,e){return!1}toHTML(t){const e=t.content.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return`<pre><code${t.
|
|
1060
1062
|
language?` class="language-${t.language}"`:""}>${e}</code></pre>`}toMarkdown(t){return`\`\`\`${t.language||""}
|
|
@@ -1090,5 +1092,5 @@ if(typeof e=="string"){let r=0;for(;(r=n.indexOf(e,r))!==-1;)i.push({text:e,star
|
|
|
1090
1092
|
n))!==null;)i.push({text:s[0],startOffset:s.index,endOffset:s.index+s[0].length})}return i}validate(t){const e=[];return t.id||e.push("Math block missing id"),(t.content===void 0||t.content===null)&&e.
|
|
1091
1093
|
push("Math block missing content"),{valid:e.length===0,errors:e}}}const _s=c=>{const t=new Set(c.getRegisteredTypes()),e=[new gs,new fs,new bs,new vs,new ws,new Ps,new Fs,new _e,new zs,new Ds,new Xs,new qs,
|
|
1092
1094
|
new xn,new Js,new tr];for(const i of e)t.has(i.type)||c.register(i)};Q.setInitializer(_s);function Qs(){Q.getInstance()}Qs();function Zs(){return Q.getInstance()}export{fi as $,gn as A,xi as B,ve as C,
|
|
1093
|
-
nt as D,Er as E,$r as F,$i as G,bn as H,Fe as I,Fi as J,
|
|
1095
|
+
nt as D,Er as E,$r as F,$i as G,bn as H,Fe as I,Fi as J,Be as K,We as L,gi as M,ui as N,Mr as O,ye as P,xe as Q,dt as R,ie as S,di as T,Ve as U,_n as V,hi as W,_ as X,ke as Y,mi as Z,ar as _,Pi as a,or as a0,
|
|
1094
1096
|
Qn as b,Ee as c,ft as d,wi as e,gt as f,Dr as g,ki as h,Pe as i,Zt as j,Ci as k,Si as l,Zs as m,te as n,Ti as o,Se as p,vi as q,Li as r,Te as s,yi as t,we as u,Ii as v,ze as w,Hr as x,Nr as y,un as z};
|