Add tables, to-dos, callouts and the rest of editor parity

The editor gains the blocks and formatting it lacked next to AFFiNE:

- Tables with a header row, resizable columns, a toolbar to add, delete,
  merge and split, and rows that move by a drag grip, toolbar buttons or
  Ctrl+Alt+Up/Down.
- To-do lists (also from "[] "), callouts with an emoji and colour, and
  headings down to level 6 (Ctrl+Shift+0-6 for text and headings).
- Text colour and highlights from a fixed palette that follows the theme,
  and left, centre and right alignment.
- Optional line numbers on code blocks, with a default hosts can set.
- PDF attachments show their pages inline; pdf.js loads only then, and
  the mobile bundle leaves it out.
- The selection toolbar adds underline, colour, align, inline math, make a
  linked page and copy block link. A grip beside each block drags it and
  opens a menu: turn into, move, duplicate, copy, copy link, delete.
- The slash menu adds Today, Tomorrow, Yesterday, Now and New page.

The web app translates the new words and makes linked pages as children
of the open page. The mobile bridge gets underline, to-do, callout and
table commands, so its protocol moves to version 2 and the bundle is
rebuilt.

docwell-server's converters learn the new nodes: Markdown writes task
lists, GitHub alerts and tables and reads them back; HTML keeps colours
and alignment and reads its own output back; PDF draws tables, to-dos,
callouts and coloured text; Word import keeps tables, alignment, H4-H6
and colours; Notion import turns databases into tables and keeps
callouts and to-dos. Imported tables and H4-H6 headings no longer
collapse into paragraphs and H3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-11-14 12:20:08 +01:00
1 parent 3c7403ddf9
commit d28f1e02db
44 files changed
+4318 -338

No files matched your search

+69 -55
View File
@@ -16,21 +16,21 @@
`),slice:t}}function oo(e,t,n,r,i){let a=i.parent.type.spec.code,o,c;if(!n&&!t)return null;let l=!!t&&(r||a||!n);if(l){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return c=new p(s.from(e.state.schema.text(t.replace(/\r\n?/g,`
`))),0,0),e.someProp(`transformPasted`,t=>{c=t(c,e,!0)}),c;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)c=n;else{let n=i.marks(),{schema:r}=e.state,a=Qe.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=yo(n),_i&&bo(o);let u=o&&o.querySelector(`[data-pm-slice]`),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute(`data-pm-slice`)||``);if(d&&d[3])for(let e=+d[3];e>0;e--){let e=o.firstChild;for(;e&&!O(e);)e=e.nextSibling;if(!e)break;o=e}if(c||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Re.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!so.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)c=xo(mo(c,+d[1],+d[2]),d[4]);else if(c=p.maxOpen(co(c.content,i),!0),c.openStart||c.openEnd){let e=0,t=0;for(let t=c.content.firstChild;e<c.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=c.content.lastChild;t<c.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);c=mo(c,e,t)}return e.someProp(`transformPasted`,t=>{c=t(c,e,l)}),c}var so=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function co(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&uo(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=fo(a[a.length-1],i.length));let n=lo(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return s.from(a)}return e}function lo(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,s.from(e));return e}function uo(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=uo(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(s.from(lo(n,e,i+1))))}}function fo(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,fo(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(r))}function po(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,c=o.content;return e.childCount>1&&(a=0),i<r-1&&(c=po(c,t,n,r,i+1,a)),i>=n&&(c=t<0?o.contentMatchAt(0).fillBefore(c,a<=i).append(c):c.append(o.contentMatchAt(o.childCount).fillBefore(s.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(c))}function mo(e,t,n){return t<e.openStart&&(e=new p(po(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new p(po(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var ho={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]};function go(){return document.implementation.createHTMLDocument(`title`)}var _o=null;function vo(e){let t=window.trustedTypes;if(!t)return e;if(!_o){if(_o=t.defaultPolicy)try{return _o.createHTML(e)}catch{}_o=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return _o.createHTML(e)}function yo(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=go(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&ho[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=vo(e),a)for(let e=0;e<a.length;e++)r=r.querySelector(a[e])||r;for(let e=0;e<n.styleSheets.length;e++){let t=n.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=r.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return r}function bo(e){let t=e.querySelectorAll(ui?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function xo(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;try{i=s.from(t.create(r[e+1],i))}catch{break}a++,o++}return new p(i,a,o)}var So={},Co={},wo={touchstart:!0,touchmove:!0},To=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariCompoLine truncated
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function qu(e,t){return Ku(e,{from:0,to:e.content.size},t)}function Ju(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Yu(e,t){let n=il(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function Xu(e,t){let n=nu(typeof t==`string`?t:t.name,e.schema);return n===`node`?Yu(e,t):n===`mark`?mu(e,t):{}}function Zu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Qu(e){let t=Zu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function $u(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Qu(r)}function ed(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=_l(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var td=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},nd=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function rd(e,t){return t.nodes[e]||t.marks[e]||null}function id(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var ad=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function od(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?vl(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>ml(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>ml(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function sd(e,t,n={}){if(!t)return Zl(e,null,n)||od(e,null,n);let r=nu(t,e.schema);return r===`node`?Zl(e,t,n):r===`mark`&&od(e,t,n)}var cd=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=yu(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},ld=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function ud(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function dd(e,t){let{nodeExtensions:n}=Au(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=Nu(k(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function fd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(fd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function pd(e){return e instanceof T}function md(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function hd(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!md(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var gd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function _d(e,t){let n=t.mapping.mapResult(e.position);return{position:new gd(n.pos),mapResult:n}}function Line truncated
`,textSerializers:o={}}=n||{},s=``;return e.nodesBetween(r,i,(e,n,c,l)=>{e.isBlock&&n>r&&(s+=a);let u=o?.[e.type.name];if(u)return c&&(s+=u({node:e,pos:n,parent:c,index:l,range:t})),!1;if(e.isText){var d;s+=e==null||(d=e.text)==null?void 0:d.slice(Math.max(r,n)-n,i-n)}}),s}function qu(e,t){return Ku(e,{from:0,to:e.content.size},t)}function Ju(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Yu(e,t){let n=il(t,e.schema),{from:r,to:i}=e.selection,a=[];e.doc.nodesBetween(r,i,e=>{a.push(e)});let o=a.reverse().find(e=>e.type.name===n.name);return o?{...o.attrs}:{}}function Xu(e,t){let n=nu(typeof t==`string`?t:t.name,e.schema);return n===`node`?Yu(e,t):n===`mark`?mu(e,t):{}}function Zu(e,t=JSON.stringify){let n={};return e.filter(e=>{let r=t(e);return Object.prototype.hasOwnProperty.call(n,r)?!1:n[r]=!0})}function Qu(e){let t=Zu(e);return t.length===1?t:t.filter((e,n)=>!t.filter((e,t)=>t!==n).some(t=>e.oldRange.from>=t.oldRange.from&&e.oldRange.to<=t.oldRange.to&&e.newRange.from>=t.newRange.from&&e.newRange.to<=t.newRange.to))}function $u(e){let{mapping:t,steps:n}=e,r=[],i=t.invert();return t.maps.forEach((e,a)=>{let o=[];if(e.ranges.length)e.forEach((e,t)=>{o.push({from:e,to:t})});else{let{from:e,to:t}=n[a];if(e===void 0||t===void 0)return;o.push({from:e,to:t})}let s=t.slice(a);o.forEach(({from:e,to:t})=>{let n=s.map(e,-1),a=s.map(t),o=i.map(n,-1),c=i.map(a);r.push({oldRange:{from:o,to:c},newRange:{from:n,to:a}})})}),Qu(r)}function ed(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=_l(n.resolve(e),t.type);i&&r.push({mark:t,...i})}):n.nodesBetween(e,t,(e,t)=>{e&&e?.nodeSize!==void 0&&r.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),r}var td=(e,t,n,r=20)=>{let i=e.doc.resolve(n),a=r,o=null;for(;a>0&&o===null;){let e=i.node(a);e?.type.name===t?o=e:--a}return[o,a]},nd=e=>{let t=e.depth-1;if(t<0)return null;let n=e.index(t);return n===0?null:e.node(t).child(n-1)};function rd(e,t){return t.nodes[e]||t.marks[e]||null}function id(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let r=e.find(e=>e.type===t&&e.name===n);return r?r.attribute.keepOnSplit:!1}))}var ad=(e,t=500)=>{let n=``,r=e.parentOffset;return e.parent.nodesBetween(Math.max(0,r-t),r,(e,t,i,a)=>{var o;let s=(o=e.type.spec).toText?.call(o,{node:e,pos:t,parent:i,index:a})||e.textContent||`%leaf%`;n+=e.isAtom&&!e.isText?s:s.slice(0,Math.max(0,r-t))}),n};function od(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?vl(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>ml(e.attrs,n,{strict:!1}));let o=0,s=[];if(i.forEach(({$from:t,$to:n})=>{let r=t.pos,i=n.pos;e.doc.nodesBetween(r,i,(e,t)=>{if(a&&e.inlineContent&&!e.type.allowsMarkType(a))return!1;if(!e.isText&&!e.marks.length)return;let n=Math.max(r,t),c=Math.min(i,t+e.nodeSize),l=c-n;o+=l,s.push(...e.marks.map(e=>({mark:e,from:n,to:c})))})}),o===0)return!1;let c=s.filter(e=>!a||a.name===e.mark.type.name).filter(e=>ml(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),l=s.filter(e=>!a||e.mark.type!==a&&e.mark.type.excludes(a)).reduce((e,t)=>e+t.to-t.from,0);return(c>0?c+l:c)>=o}function sd(e,t,n={}){if(!t)return Zl(e,null,n)||od(e,null,n);let r=nu(t,e.schema);return r===`node`?Zl(e,t,n):r===`mark`&&od(e,t,n)}var cd=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=yu(e=>e.type.name===t)(e.selection);if(!n)return!1;let r=e.doc.resolve(n.pos+1);return i.pos+1===r.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},ld=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function ud(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function dd(e,t){let{nodeExtensions:n}=Au(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=Nu(k(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function fd(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){if(n){if(e.type.name===`hardBreak`)return!0;if(e.isText)return!/\S/.test(e.text??``)}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(e.content.childCount===0)return!0;if(t){let r=!0;return e.content.forEach(e=>{r!==!1&&(fd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function pd(e){return e instanceof T}function md(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.apply==`function`&&typeof t.getMap==`function`&&typeof t.invert==`function`&&typeof t.map==`function`&&typeof t.merge==`function`&&typeof t.toJSON==`function`}function hd(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!md(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var gd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function _d(e,t){let n=t.mapping.mapResult(e.position);return{position:new gd(n.pos),mapResult:n}}function Line truncated
`);return`:::${l}${i}\n\n${o}\n\n:::`}}}function Xf(e){let t={};return Gf(e,`shortcode`).forEach(e=>{e.type===`keyValue`&&(t[e.name]=e.value)}),t}function Zf(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function Qf(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=Xf,serializeAttributes:a=Zf,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=u(e.attrs||{}),i=a(n),o=i?` ${i}`:``;return s?`[${l}${o}]`:`[${l}${o}]${t}[/${l}]`}}}function $f(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function ep(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function tp(e,t,n){let r=t.split(`
`),i=n.isParagraphContinuation??(e=>ep(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(`
`);return`:::${l}${i}\n\n${o}\n\n:::`}}}function Zf(e){let t={};return Kf(e,`shortcode`).forEach(e=>{e.type===`keyValue`&&(t[e.name]=e.value)}),t}function Qf(e){return Object.entries(e).filter(([,e])=>e!=null).map(([e,t])=>`${e}="${t}"`).join(` `)}function $f(e){let{nodeName:t,name:n,getContent:r,parseAttributes:i=Zf,serializeAttributes:a=Qf,defaultAttributes:o={},selfClosing:s=!1,allowedAttributes:c}=e,l=n||t,u=e=>{if(!c)return e;let t={};return c.forEach(n=>{let r=typeof n==`string`?n:n.name,i=typeof n==`string`?void 0:n.skipIfDefault;if(r in e){let n=e[r];if(i!==void 0&&n===i)return;t[r]=n}}),t},d=l.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return{parseMarkdown:(e,n)=>{let i={...o,...e.attributes};if(s)return n.createNode(t,i);let a=r?r(e):e.content||``;return a?n.createNode(t,i,[n.createTextNode(a)]):n.createNode(t,i,[])},markdownTokenizer:{name:t,level:`inline`,start(e){let t=RegExp(s?`\\[${d}\\s*[^\\]]*\\]`:`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),n=e.match(t)?.index;return n===void 0?-1:n},tokenize(e,n,r){let a=RegExp(s?`^\\[${d}\\s*([^\\]]*)\\]`:`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),o=e.match(a);if(!o)return;let c=``,l=``;if(s){let[,e]=o;l=e}else{let[,e,t]=o;l=e,c=t||``}let u=i(l.trim());return{type:t,raw:o[0],content:c.trim(),attributes:u}}},renderMarkdown:e=>{let t=``;r?t=r(e):e.content&&e.content.length>0&&(t=e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``));let n=u(e.attrs||{}),i=a(n),o=i?` ${i}`:``;return s?`[${l}${o}]`:`[${l}${o}]${t}[/${l}]`}}}function ep(e,t){return e.replace(/^[ \t]*/,e=>{let n=0;for(let t of e)n+=t===` `?4-n%4:1;return` `.repeat(Math.max(0,n-t))})}function tp(e,t){let n=`text\n${e}\n`,r=t(n)[0];return(r?.type===`paragraph`||r?.type===`text`)&&r.raw===n}function np(e,t,n){let r=t.split(`
`),i=n.isParagraphContinuation??(e=>tp(e,n.blockTokens)),a=0;for(let e of r){if(!e.trim()||!i(e))break;a+=1}return{mainContent:[e,...r.slice(0,a).map(e=>e.trimStart())].join(`
`),nestedContent:r.slice(a).join(`
`)}}function np(e,t,n){let r=e.split(`
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],u=e.match(t.itemPattern);if(!u){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;o<r.length;){var c;let e=r[o];if(e.trim()===``){var l;let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=tp(p,g.map(e=>$f(e,f+s)).join(`
`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var rp=4;function ip(e){let t=0;for(let n of e)t=n===` `?t+rp-t%rp:t+1;return t}function ap(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(`
`)}}function rp(e,t,n){let r=e.split(`
`),i=[],a=``,o=0,s=t.baseIndentSize||2;for(;o<r.length;){let e=r[o],u=e.match(t.itemPattern);if(!u){if(i.length>0)break;if(e.trim()===``){o+=1,a=`${a}${e}\n`;continue}return}let d=t.extractItemData(u),{indentLevel:f,mainContent:p}=d;a=`${a}${e}\n`;let m=[p];for(o+=1;o<r.length;){var c;let e=r[o];if(e.trim()===``){var l;let t=r.slice(o+1).findIndex(e=>e.trim()!==``);if(t===-1)break;if((((l=r[o+1+t].match(/^(\s*)/))==null||(l=l[1])==null?void 0:l.length)||0)>f){m.push(e),a=`${a}${e}\n`,o+=1;continue}break}if((((c=e.match(/^(\s*)/))==null||(c=c[1])==null?void 0:c.length)||0)>f)m.push(e),a=`${a}${e}\n`,o+=1;else break}let h,g=m.slice(1);if(g.length>0){let e=np(p,g.map(e=>ep(e,f+s)).join(`
`),n);d.mainContent=e.mainContent;let r=e.nestedContent;r.trim()&&(h=t.customNestedParser?t.customNestedParser(r):n.blockTokens(r))}let _=t.createToken(d,h);i.push(_)}if(i.length!==0)return{items:i,raw:a.slice(0,e.length)}}var ip=4;function ap(e){let t=0;for(let n of e)t=n===` `?t+ip-t%ip:t+1;return t}function op(e,t,n,r,i){if(!e||!Array.isArray(e.content))return``;let a=typeof n==`function`?n(r):n,[o,...s]=e.content,c=t.renderChildren([o]),l=`${a}${i?.indentMainContent?c.split(`
`).map((e,n)=>n===0?e:t.indent(e)).join(`
`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=ip(a);return(ip(n)>=r?n:` `.repeat(r))+e},o=r.split(`
`):c}`;return s&&s.length>0&&s.forEach((e,n)=>{let r=t.renderChild?.call(t,e,n+1)??t.renderChildren([e]);if(r!=null){let n=e=>{if(!i?.alignNestedToPrefix)return t.indent(e);let n=t.indent(``),r=ap(a);return(ap(n)>=r?n:` `.repeat(r))+e},o=r.split(`
`).map(e=>n(e||``)).join(`
`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function op(e,t){let n={...e};return Mf(e)&&Mf(t)&&Object.keys(t).forEach(r=>{Mf(t[r])&&Mf(e[r])?n[r]=op(e[r],t[r]):n[r]=t[r]}),n}function sp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var cp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},lp=(e,t)=>{if(pl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function up(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:Bn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function dp(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=up({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Yc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Xc({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Vc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function fp(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function pp(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=ad(l)+i;for(let e of a){let a=lp(u,e.find);if(a&&fp(l,a,i)&&dp({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function mp(e){let{editor:t,rules:n}=e,r=new E({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let c=e.getMeta(`applyInputRules`);return c&&setTimeout(()=>{let{text:e}=c;e=typeof e==`string`?e:xu(s.from(e),a.schema);let{from:i}=c,o=i+e.length;pp({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return pp({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&pp({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?pp({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var hp=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Nu(k(this,`addOptions`,{name:this.name}))}}get storage(){return{...Nu(k(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>op(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},gp=class e extends hp{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},_p=class{constructor(e){this.find=e.find,this.handler=e.handler}},vp=(e,t,n)=>{if(pl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function yp(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Xc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||vp(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var bp=null,xp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Sp(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c;try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}let l=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let s=e.tr,l=Yc({state:e,transaction:s});if(yp({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:c})&&s.steps.length){try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s}};return t.on(`destroy`,()=>{bp===t&&(bp=null)}),n.map(e=>new E({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(bp=t)},i=()=>{bp&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,c=t,!a){let e=bp;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let c=t[0],u=c.getMeta(`uiEvent`)===`paste`&&!i,d=c.getMeta(`uiEvent`)===`drop`&&!a,f=c.getMeta(`applyPasteRules`),p=!!f;if(!u&&!d&&!p)return;if(p){let{text:t}=f;t=typeof t==`string`?t:xu(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=xp(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let m=n.doc.content.findDiffStart(r.doc.content),h=n.doc.content.findDiffEnd(r.doc.content);if(Af(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var Cp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Gu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Uu(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=k(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:rd(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Wu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:rd(t.name,this.schema)},r=[],i=k(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&k(t,`exitable`,n)&&(a.ArrowRight=()=>gp.handleExit({editor:e,mark:t})),i){Line truncated
`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function sp(e,t){let n={...e};return Nf(e)&&Nf(t)&&Object.keys(t).forEach(r=>{Nf(t[r])&&Nf(e[r])?n[r]=sp(e[r],t[r]):n[r]=t[r]}),n}function cp(e,t,n={}){let{state:r}=t,{doc:i,tr:a}=r,o=e;i.descendants((t,r)=>{let i=a.mapping.map(r),s=a.mapping.map(r)+t.nodeSize,c=null;if(t.marks.forEach(e=>{if(e!==o)return!1;c=e}),!c)return;let l=!1;if(Object.keys(n).forEach(e=>{n[e]!==c.attrs[e]&&(l=!0)}),l){let t=e.type.create({...e.attrs,...n});a.removeMark(i,s,e.type),a.addMark(i,s,t)}}),a.docChanged&&t.view.dispatch(a)}var lp=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},up=(e,t)=>{if(pl(t))return t.exec(e);let n=t(e);if(!n)return null;let r=[n.text];return r.index=n.index,r.input=e,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn(`[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".`),r.push(n.replaceWith)),r};function dp(e){let{editor:t,from:n,to:r,text:i,insertText:a}=e;if(!a)return{inputTransaction:null,tr:t.view.state.tr};let o=t.view.state.tr.insertText(i,n,r);return{inputTransaction:o,tr:Bn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function fp(e){let{editor:t,from:n,to:r,text:i,rule:a,match:o,plugin:s,insertText:c}=e,{view:l}=t,{inputTransaction:u,tr:d}=dp({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Yc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Xc({editor:t,state:p});return a.handler({state:p,range:m,match:o,commands:h,chain:g,can:_})===null||!d.steps.length?!1:(u&&(l.dispatch(u),!l.state.doc.eq(u.doc))||(Vc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function pp(e,t,n){let r=t[0].length-n.length;if(r<=0)return!0;let i=e.parentOffset-r;return i>=0&&e.parent.textBetween(i,e.parentOffset)===t[0].slice(0,r)}function mp(e){let{editor:t,from:n,to:r,text:i,rules:a,plugin:o,insertText:s}=e,{view:c}=t;if(c.composing)return!1;let l=c.state.doc.resolve(n);if(l.parent.type.spec.code||(l.nodeBefore||l.nodeAfter)?.marks.find(e=>e.type.spec.code))return!1;let u=ad(l)+i;for(let e of a){let a=up(u,e.find);if(a&&pp(l,a,i)&&fp({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function hp(e){let{editor:t,rules:n}=e,r=new E({state:{init(){return null},apply(e,i,a){let o=e.getMeta(r);if(o)return o;let c=e.getMeta(`applyInputRules`);return c&&setTimeout(()=>{let{text:e}=c;e=typeof e==`string`?e:xu(s.from(e),a.schema);let{from:i}=c,o=i+e.length;mp({editor:t,from:i,to:o,text:e,rules:n,plugin:r})}),e.selectionSet||e.docChanged?null:i}},props:{handleTextInput(e,i,a,o){return mp({editor:t,from:i,to:a,text:o,rules:n,plugin:r,insertText:!0})},handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:i}=e.state.selection;i&&mp({editor:t,from:i.pos,to:i.pos,text:``,rules:n,plugin:r})}),!1)},handleKeyDown(e,i){if(i.key!==`Enter`)return!1;let{$cursor:a}=e.state.selection;return a?mp({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var gp=class{constructor(e={}){this.type=`extendable`,this.parent=null,this.child=null,this.name=``,this.config={name:this.name},this.config={...this.config,...e},this.name=this.config.name}get options(){return{...Nu(k(this,`addOptions`,{name:this.name}))}}get storage(){return{...Nu(k(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>sp(this.options,e)});return t.name=this.name,t.parent=this.parent,this.child=null,t}extend(e={}){let t=new this.constructor({...this.config,...e});return t.parent=this,this.child=t,t.name=`name`in e?e.name:t.parent.name,t}},_p=class e extends gp{constructor(...e){super(...e),this.type=`mark`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,r=e.state.selection.$from;if(r.pos===r.end()){let i=r.marks();if(!i.find(e=>e?.type.name===t.name))return!1;let a=i.find(e=>e?.type.name===t.name);return a&&n.removeStoredMark(a),n.insertText(` `,r.pos),e.view.dispatch(n),!0}return!1}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}},vp=class{constructor(e){this.find=e.find,this.handler=e.handler}},yp=(e,t,n)=>{if(pl(t))return[...e.matchAll(t)];let r=t(e,n);return r?r.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn(`[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".`),n.push(t.replaceWith)),n}):[]};function bp(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Xc({editor:t,state:n}),d=[];return n.doc.nodesBetween(r,i,(e,t)=>{var f;if((f=e.type)!=null&&(f=f.spec)!=null&&f.code||!(e.isText||e.isTextblock||e.isInline))return;let p=e.content?.size??e.nodeSize??0,m=Math.max(r,t),h=Math.min(i,t+p);m>=h||yp(e.isText?e.text||``:e.textBetween(m-t,h-t,void 0,``),a.find,o).forEach(e=>{if(e.index===void 0)return;let t=m+e.index+1,r=t+e[0].length,i={from:n.tr.mapping.map(t),to:n.tr.mapping.map(r)},f=a.handler({state:n,range:i,match:e,commands:c,chain:l,can:u,pasteEvent:o,dropEvent:s});d.push(f)})}),d.every(e=>e!==null)}var xp=null,Sp=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Cp(e){let{editor:t,rules:n}=e,r=null,i=!1,a=!1,o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,c;try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}let l=({state:e,from:n,to:r,rule:i,pasteEvt:a})=>{let s=e.tr,l=Yc({state:e,transaction:s});if(bp({editor:t,state:l,from:Math.max(n-1,0),to:r.b-1,rule:i,pasteEvent:a,dropEvent:c})&&s.steps.length){try{c=typeof DragEvent<`u`?new DragEvent(`drop`):null}catch{c=null}return o=typeof ClipboardEvent<`u`?new ClipboardEvent(`paste`):null,s}};return t.on(`destroy`,()=>{xp===t&&(xp=null)}),n.map(e=>new E({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(xp=t)},i=()=>{xp&&=null};return window.addEventListener(`dragstart`,n),window.addEventListener(`dragend`,i),{destroy(){window.removeEventListener(`dragstart`,n),window.removeEventListener(`dragend`,i)}}},props:{handleDOMEvents:{drop:(e,t)=>{if(a=r===e.dom.parentElement,c=t,!a){let e=xp;e?.isEditable&&setTimeout(()=>{if(e.isDestroyed)return;let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{let n=t.clipboardData?.getData(`text/html`);return o=t,i=!!n?.includes(`data-pm-slice`),!1}}},appendTransaction:(t,n,r)=>{let c=t[0],u=c.getMeta(`uiEvent`)===`paste`&&!i,d=c.getMeta(`uiEvent`)===`drop`&&!a,f=c.getMeta(`applyPasteRules`),p=!!f;if(!u&&!d&&!p)return;if(p){let{text:t}=f;t=typeof t==`string`?t:xu(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=Sp(t);return l({rule:e,state:r,from:n,to:{b:i},pasteEvt:a})}let m=n.doc.content.findDiffStart(r.doc.content),h=n.doc.content.findDiffEnd(r.doc.content);if(jf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var wp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Gu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Uu(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=k(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:rd(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Wu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:rd(t.name,this.schema)},r=[],i=k(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&k(t,`exitable`,n)&&(a.ArrowRight=()=>_p.handleExit({editor:e,mark:t})),i){Line truncated
`)}}})]}}),Ep=wp.create({name:`commands`,addCommands(){return{...tf}}}),Dp=wp.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=hu(e.before,[e,...t]);$u(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof St){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),Op=wp.create({name:`drop`,addProseMirrorPlugins(){return[new E({key:new D(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),kp=wp.create({name:`editable`,addProseMirrorPlugins(){return[new E({key:new D(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),Ap=new D(`focusEvents`),jp=wp.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new E({key:Ap,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),Mp=wp.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:C.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Tl()||Jl()?i:r},addProseMirrorPlugins(){return[new E({key:new D(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=C.atStart(t.doc).from,l=C.atEnd(t.doc).to;if(a||o!==c||s!==l||!fd(n.doc))return;let u=n.tr,d=Yc({state:n,transaction:u}),{commands:f}=new Xc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),Np=wp.create({name:`paste`,addProseMirrorPlugins(){return[new E({key:new D(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Pp=wp.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new E({key:new D(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Fp=wp.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Au(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new E({key:new D(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Ip=!1;function Lp(e){if(Ip)return;Ip=!0;let t;try{let n=Dt.fromJSON(e,Line truncated
`)}}})]}}),Dp=Tp.create({name:`commands`,addCommands(){return{...tf}}}),Op=Tp.create({name:`delete`,onUpdate({transaction:e,appendedTransactions:t}){var n;let r=()=>{var n,r;if(((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null||(r=n.filterTransaction)==null?void 0:r.call(n,e))??e.getMeta(`y-sync$`))return;let i=hu(e.before,[e,...t]);$u(i).forEach(t=>{i.mapping.mapResult(t.oldRange.from).deletedAfter&&i.mapping.mapResult(t.oldRange.to).deletedBefore&&i.before.nodesBetween(t.oldRange.from,t.oldRange.to,(n,r)=>{let a=r+n.nodeSize-2,o=t.oldRange.from<=r&&a<=t.oldRange.to;this.editor.emit(`delete`,{type:`node`,node:n,from:r,to:a,newFrom:i.mapping.map(r),newTo:i.mapping.map(a),deletedRange:t.oldRange,newRange:t.newRange,partial:!o,editor:this.editor,transaction:e,combinedTransform:i})})});let a=i.mapping;i.steps.forEach((t,n)=>{if(t instanceof St){let r=a.slice(n).map(t.from,-1),o=a.slice(n).map(t.to),s=a.invert().map(r,-1),c=a.invert().map(o),l=r>0&&i.doc.nodeAt(r-1)?.marks.some(e=>e.eq(t.mark)),u=i.doc.nodeAt(o)?.marks.some(e=>e.eq(t.mark));this.editor.emit(`delete`,{type:`mark`,mark:t.mark,from:t.from,to:t.to,deletedRange:{from:s,to:c},newRange:{from:r,to:o},partial:!!(u||l),editor:this.editor,transaction:e,combinedTransform:i})}})};((n=this.editor.options.coreExtensionOptions)==null||(n=n.delete)==null?void 0:n.async)??!0?setTimeout(r,0):r()}}),kp=Tp.create({name:`drop`,addProseMirrorPlugins(){return[new E({key:new D(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),Ap=Tp.create({name:`editable`,addProseMirrorPlugins(){return[new E({key:new D(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),jp=new D(`focusEvents`),Mp=Tp.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new E({key:jp,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let r=e.state.tr.setMeta(`focus`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1},blur:(t,n)=>{e.isFocused=!1;let r=e.state.tr.setMeta(`blur`,{event:n}).setMeta(`addToHistory`,!1);return t.dispatch(r),!1}}}})]}}),Np=Tp.create({name:`keymap`,addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:r}=t,{empty:i,$anchor:a}=n,{pos:o,parent:s}=a,c=a.parent.isTextblock&&o>0?t.doc.resolve(o-1):a,l=c.parent.type.spec.isolating,u=a.pos-a.parentOffset,d=l&&c.parent.childCount===1?u===a.pos:C.atStart(r).from===o;return!i||!s.type.isTextblock||s.textContent.length||!d||d&&a.parent.type.name===`paragraph`?!1:e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},i={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Tl()||Jl()?i:r},addProseMirrorPlugins(){return[new E({key:new D(`clearDocument`),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta(`composition`)))return;let r=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),i=e.some(e=>e.getMeta(`preventClearDocument`));if(!r||i)return;let{empty:a,from:o,to:s}=t.selection,c=C.atStart(t.doc).from,l=C.atEnd(t.doc).to;if(a||o!==c||s!==l||!fd(n.doc))return;let u=n.tr,d=Yc({state:n,transaction:u}),{commands:f}=new Xc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),Pp=Tp.create({name:`paste`,addProseMirrorPlugins(){return[new E({key:new D(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Fp=Tp.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new E({key:new D(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Ip=Tp.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Au(this.extensions);return[{types:e.filter(e=>e.name!==`text`).map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{let t=e.getAttribute(`dir`);return t&&(t===`ltr`||t===`rtl`||t===`auto`)?t:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new E({key:new D(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),Lp=!1;function Rp(e){if(Lp)return;Lp=!0;let t;try{let n=Dt.fromJSON(e,Line truncated
position: relative;
}
@@ -100,21 +100,21 @@ img.ProseMirror-separator {
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`,Bp=class extends of{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:_d,createMappablePosition:vd},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=Cl(t,this.options.autofocus);this.editorState=Bn.create({doc:t,schema:this.schema,selection:e||void 0})}Lp(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Xc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Xc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=Of(zp,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return sf&&!this.hasWarnedStaleDecorationRead&&af(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Mu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
}`,Vp=class extends of{constructor(e={}){super(),this.css=null,this.className=`tiptap`,this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.hasWarnedStaleDecorationRead=!1,this.options={element:typeof document<`u`?document.createElement(`div`):null,content:``,injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:_d,createMappablePosition:vd},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on(`beforeCreate`,this.options.onBeforeCreate),this.emit(`beforeCreate`,{editor:this}),this.on(`mount`,this.options.onMount),this.on(`unmount`,this.options.onUnmount),this.on(`contentError`,this.options.onContentError),this.on(`create`,this.options.onCreate),this.on(`update`,this.options.onUpdate),this.on(`selectionUpdate`,this.options.onSelectionUpdate),this.on(`transaction`,this.options.onTransaction),this.on(`focus`,this.options.onFocus),this.on(`blur`,this.options.onBlur),this.on(`destroy`,this.options.onDestroy),this.on(`drop`,({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on(`paste`,({event:e,slice:t})=>this.options.onPaste(e,t)),this.on(`delete`,this.options.onDelete);let t=this.createDoc();if(!this.editorState){let e=Cl(t,this.options.autofocus);this.editorState=Bn.create({doc:t,schema:this.schema,selection:e||void 0})}Rp(this.schema),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>`u`)throw Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);this.createView(e),this.emit(`mount`,{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit(`create`,{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){this.editorState=this.editorView.state;let e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove==`function`?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn(`Failed to remove CSS element:`,e)}this.css=null,this.emit(`unmount`,{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager?this.commandManager.chain():Xc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Xc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=Of(Bp,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},this.editorView&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps({...this.options.editorProps,attributes:this.getEditorViewAttributes()}),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit(`update`,{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,t)=>{if(this.editorView)return this.editorView[t];if(t===`state`)return this.editorState;if(t in e)return Reflect.get(e,t);throw Error(`[tiptap error]: The editor view is not available. Cannot access view['${t}']. The editor may not be mounted yet.`)}})}get state(){return sf&&!this.hasWarnedStaleDecorationRead&&af(this)&&(this.hasWarnedStaleDecorationRead=!0,console.warn("[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.")),this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,t){let n=Mu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
`,textSerializers:n={}}=e||{};return qu(this.state.doc,{blockSeparator:t,textSerializers:{...Ju(this.schema),...n}})}get isEmpty(){return fd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new Rp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Vp(e){return new cp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(ed(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Hp(e){return new cp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function Up(e){return new cp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=Nu(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Wp(e){return new cp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=Nu(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&It(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&Jt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Gp=e=>`touches`in e,Kp=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resLine truncated
`)}},kg=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ih]?Lh(e,t):sm(e)?im(e,e=>am(t,t=>kg(e,t))):Rh(e)?Wh(e,(e,n)=>kg(e,t[n])):!1,Ag=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),kg(t,n)}equals(e){return this.constructor===e.constructor&&Zh(this.shape,e.shape)}[Dg](){return!0}[Ih](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ih()}get nullable(){return l_(this,w_)}get optional(){return new Vg(this)}cast(e){return O_(e,this),e}expect(e){return O_(e,this),e}},jg=class extends Ag{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Mg=(e,t=null)=>new jg(e,t);Mg(jg);var Ng=class extends Ag{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Pg=e=>new Ng(e);Mg(Ng);var Fg=class extends Ag{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Ig=(...e)=>new Fg(e),Lg=Mg(Fg),Rg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),zg=e=>{if(y_.check(e))return[Rg(e)];if(Lg.check(e))return e.shape.map(e=>e+``);if(v_.check(e))return[`[+-]?\\d+.?\\d*`];if(b_.check(e))return[`.*`];if(u_.check(e))return e.shape.map(zg).flat(1);ah()};Mg(class extends Ag{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(zg).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Bg=Symbol(`optional`),Vg=class extends Ag{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Bg](){return!0}},Hg=Mg(Vg),Ug=class extends Ag{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Ug,Mg(Ug);var Wg=class e extends Ag{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Wh(this.shape,(n,r)=>{let i=this._isPartial&&!Gh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Gg=e=>new Wg(e),Kg=Mg(Wg),qg=Pg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Jg=class extends Ag{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Wh(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Yg=(e,t)=>new Jg(e,t),Xg=Mg(Jg),Zg=class extends Ag{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Wh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Qg=(...e)=>new Zg(e);Mg(Zg);var $g=class extends Ag{constructor(e){super(),this.shape=e.length===1?e[0]:new c_(e)}check(e,t){let n=sm(e)&&im(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},e_=(...e)=>new $g(e),t_=Mg($g),n_=Pg(e=>sm(e)),r_=class extends Ag{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},i_=(e,t=null)=>new r_(e,t);Mg(r_);var a_=i_(Ag),o_=Mg(class extends Ag{constructor(e){super(),this.len=e.length-1,this.args=Qg(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),s_=Pg(e=>typeof e==`function`);Mg(class extends Ag{constructor(e){super(),this.shape=e}check(e,t){let n=im(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var c_=class extends Ag{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=am(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},l_=(...e)=>e.findIndex(e=>u_.check(e))>=0?l_(...e.map(e=>D_(e)).map(e=>u_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new c_(e),u_=Mg(c_),d_=()=>!0,f_=Pg(d_),p_=Mg(Ng,e=>e.shape===d_),m_=Pg(e=>typeof e==`bigint`),h_=Pg(e=>e===m_),g_=Pg(e=>typeof e==`symbol`);Pg(e=>e===g_);var __=Pg(e=>typeof e==`number`),v_=Pg(e=>e===__),y_=Pg(e=>typeof e==`string`),b_=Pg(e=>e===y_),x_=Pg(e=>typeof e==`boolean`),S_=Pg(e=>e===x_),C_=Ig(void 0);Mg(Fg,e=>e.shape.length===1&&e.shape[0]===void 0),Ig(void 0);var w_=Ig(null),T_=Mg(Fg,e=>e.shape.length===1&&e.shape[0]===null);Mg(Uint8Array),Mg(jg,e=>e.shape===Uint8Array);var E_=l_(__,y_,w_,C_,m_,x_,g_);(()=>{let e=e_(f_),t=Yg(y_,f_),n=l_(__,y_,w_,x_,e,t);return e.shape=n,t.shape.values=n,n})();var D_=e=>{if(a_.check(e))return e;ifLine truncated
`;n.right=new Jx(N(o,by(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new jx(i)),n.right.integrate(e,0),n.forward()}Hb(e,t,n,s)},Jb=(e,t,n,r,i)=>{let a=t,o=Yp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===wx){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case wx:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Ub(i,n);break}}}t=t.right}return s},Yb=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===wx){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Xb=e=>{let t=0;return Iy(e.doc,n=>{let r=e._start,i=e._start,a=Yp(),o=Xp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case wx:Ub(o,i.content);break;default:t+=Jb(n,r,i,a,o),a=Xp(o),r=i}i=i.right}}),t},Zb=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Oy(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===wx&&e.constructor!==mx&&t.add(e.parent)})}Iy(n,n=>{sv(e,e.deleteSet,e=>{if(e instanceof mx||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===wx?t.add(r):Yb(n,e)});for(let e of t)Xb(e)})},Qb=(e,t,n)=>{let r=n,i=Xp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Vx:case Sx:case jx:n<t.right.length&&Ty(e,N(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Jb(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&ub(o._searchMarker,t.index,-r+n),t},$b=class extends eb{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];Iy(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},Uh(o)||(e.attributes=zh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Vx:case Sx:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case jx:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case wx:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Rb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Rb(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Rb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Rb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Ub(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},ex=class e extends fb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??nb(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new $b(this,e,t);db(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??nb();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===jx&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Iy(this.doc,n=>{let r=new zb(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Kb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&Qb(n,r,a.delete):qb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??nb();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(gy(s,e)||t!==void 0&&gy(s,t))switch(s.content.constructor){case jx:{let r=i.get(`ychange`);e!==void 0&&!gy(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!gy(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Vx:case Sx:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case wx:gy(s,e)&&(c(),Ub(i,s.content))}s=s.right}c()};return e||t?Iy(a,n=>{e&&_y(n,e),t&&_y(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Iy(r,r=>{let i=Vb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Kb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Iy(r,r=>{let i=Vb(r,this,e,!n);Kb(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Iy(n,n=>{Qb(n,Vb(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Iy(r,r=>{let i=Vb(r,this,e,!1);i.right!==null&&qb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Iy(this.doc,t=>{Tb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Iy(this.doc,n=>{Eb(n,this,e,t)})}getAttribute(e){return Db(this,e)}getAttributes(){return Ob(this)}_write(e){e.writeTypeRef(Ix)}},tx=e=>new ex,nx=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??nb()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ax||t.constructor===rx)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},rx=class e extends fb{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof fb?e.clone():e)),t}get length(){return this.doc??nb(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new nx(this,e)}querySelector(e){e=e.toUpperCase();let t=new nx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),rm(new nx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){db(this,e,new sx(this,t,e))}toString(){return _b(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),gb(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Iy(this.doc,n=>{Sb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Iy(this.doc,n=>{let r=e&&e instanceof fb?e._item:e;bb(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw rh(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Iy(this.doc,n=>{wb(n,this,e,t)})}toArray(){return mb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return yb(this,e)}slice(e=0,t=this.length){return pb(this,e,t)}forEach(e){gb(this,e)}_write(e){e.writeTypeRef(Rx)}},ix=e=>new rx,ax=class e extends rx{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Vh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>eLine truncated
`,textSerializers:n={}}=e||{};return qu(this.state.doc,{blockSeparator:t,textSerializers:{...Ju(this.schema),...n}})}get isEmpty(){return fd(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit(`destroy`),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){return this.editorView?.isDestroyed??!0}$node(e,t){return this.$doc?.querySelector(e,t)||null}$nodes(e,t){return this.$doc?.querySelectorAll(e,t)||null}$pos(e){let t=this.state.doc.resolve(e),n=e>0&&t.nodeAfter&&!t.nodeAfter.isText&&t.nodeAfter.isAtom?t.nodeAfter:null;return new zp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function Hp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r);if(i===!1||i===null)return null;let{tr:a}=t,o=r[r.length-1],s=r[0];if(o){let r=s.search(/\S/),c=n.from+s.indexOf(o),l=c+o.length;if(ed(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>c).length)return null;l<n.to&&a.delete(l,n.to),c>n.from&&a.delete(n.from+r,c);let u=n.from+r+o.length;a.addMark(n.from+r,u,e.type.create(i||{})),a.removeStoredMark(e.type)}},undoable:e.undoable})}function Up(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=Nu(e.getAttributes,void 0,r)||{},{tr:a}=t,o=n.from,s=n.to,c=e.type.create(i);if(r[1]){let e=o+r[0].lastIndexOf(r[1]);e>s?e=s:s=e+r[1].length;let t=r[0][r[0].length-1];a.insertText(t,o+r[0].length-1),a.replaceWith(e,s,c)}else if(r[0]){let t=e.type.isInline?o:o-1;a.insert(t,e.type.create(i)).delete(a.mapping.map(o),a.mapping.map(s))}a.scrollIntoView()},undoable:e.undoable})}function Wp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=Nu(e.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,a)},undoable:e.undoable})}function Gp(e){return new lp({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=Nu(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&It(s,e.type,a);if(!c)return null;if(o.wrap(s,c),e.keepMarks&&e.editor){let{selection:n,storedMarks:r}=t,{splittableMarks:i}=e.editor.extensionManager,a=r||n.$to.parentOffset&&n.$from.marks();if(a){let e=a.filter(e=>i.includes(e.type.name));o.ensureMarks(e)}}if(e.keepAttributes){let t=e.type.name===`bulletList`||e.type.name===`orderedList`?`listItem`:`taskList`;i().updateAttributes(t,a).run()}let l=o.doc.resolve(n.from-1).nodeBefore;l&&l.type===e.type&&Jt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Kp=e=>`touches`in e,qp=class{constructor(e){var t;this.directions=[`bottom-left`,`bottom-right`,`top-left`,`top-right`],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:``,wrapper:``,handle:``,resizing:``},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.clientX-this.startX,n=e.clientY-this.startY;this.handleResize(t,n)},this.handleTouchMove=e=>{if(!this.isResizing||!this.activeHandle)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this.startX,r=t.clientY-this.startY;this.handleResize(n,r)},this.handleMouseUp=()=>{if(!this.isResizing)return;let e=this.element.offsetWidth,t=this.element.offsetHeight;this.onCommit(e,t),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState=`false`,this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener(`mousemove`,this.handleMouseMove),document.removeEventListener(`mouseup`,this.handleMouseUp),document.removeEventListener(`keydown`,this.handleKeyDown),document.removeEventListener(`keyup`,this.handleKeyUp)},this.handleKeyDown=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=e=>{e.key===`Shift`&&(this.isShiftKeyPressed=!1)},this.node=e.node,this.editor=e.editor,this.element=e.element,this.element.draggable=!1,this.contentElement=e.contentElement,this.getPos=e.getPos,this.onResize=e.onResize,this.onCommit=e.onCommit,this.onUpdate=e.onUpdate,e.options?.min&&(this.minSize={...this.minSize,...e.options.min}),e.options?.max&&(this.maxSize=e.options.max),e!=null&&(t=e.options)!=null&&t.directions&&(this.directions=e.options.directions),e.options?.preserveAspectRatio&&(this.preserveAspectRatio=e.options.preserveAspectRatio),e.options?.className&&(this.classNames={container:e.options.className.container||``,wrapper:e.options.className.wrapper||``,handle:e.options.className.handle||``,resizing:e.options.className.resLine truncated
`)}},Ag=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Lh]?Rh(e,t):cm(e)?am(e,e=>om(t,t=>Ag(e,t))):zh(e)?Gh(e,(e,n)=>Ag(e,t[n])):!1,jg=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Ag(t,n)}equals(e){return this.constructor===e.constructor&&Qh(this.shape,e.shape)}[Og](){return!0}[Lh](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){ah()}get nullable(){return u_(this,T_)}get optional(){return new Hg(this)}cast(e){return k_(e,this),e}expect(e){return k_(e,this),e}},Mg=class extends jg{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},Ng=(e,t=null)=>new Mg(e,t);Ng(Mg);var Pg=class extends jg{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},Fg=e=>new Pg(e);Ng(Pg);var Ig=class extends jg{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},Lg=(...e)=>new Ig(e),Rg=Ng(Ig),zg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Bg=e=>{if(b_.check(e))return[zg(e)];if(Rg.check(e))return e.shape.map(e=>e+``);if(y_.check(e))return[`[+-]?\\d+.?\\d*`];if(x_.check(e))return[`.*`];if(d_.check(e))return e.shape.map(Bg).flat(1);oh()};Ng(class extends jg{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Bg).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Vg=Symbol(`optional`),Hg=class extends jg{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Vg](){return!0}},Ug=Ng(Hg),Wg=class extends jg{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Wg,Ng(Wg);var Gg=class e extends jg{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Gh(this.shape,(n,r)=>{let i=this._isPartial&&!Kh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Kg=e=>new Gg(e),qg=Ng(Gg),Jg=Fg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Yg=class extends jg{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Gh(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Xg=(e,t)=>new Yg(e,t),Zg=Ng(Yg),Qg=class extends jg{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Gh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},$g=(...e)=>new Qg(e);Ng(Qg);var e_=class extends jg{constructor(e){super(),this.shape=e.length===1?e[0]:new l_(e)}check(e,t){let n=cm(e)&&am(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},t_=(...e)=>new e_(e),n_=Ng(e_),r_=Fg(e=>cm(e)),i_=class extends jg{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},a_=(e,t=null)=>new i_(e,t);Ng(i_);var o_=a_(jg),s_=Ng(class extends jg{constructor(e){super(),this.len=e.length-1,this.args=$g(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),c_=Fg(e=>typeof e==`function`);Ng(class extends jg{constructor(e){super(),this.shape=e}check(e,t){let n=am(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var l_=class extends jg{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=om(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},u_=(...e)=>e.findIndex(e=>d_.check(e))>=0?u_(...e.map(e=>O_(e)).map(e=>d_.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new l_(e),d_=Ng(l_),f_=()=>!0,p_=Fg(f_),m_=Ng(Pg,e=>e.shape===f_),h_=Fg(e=>typeof e==`bigint`),g_=Fg(e=>e===h_),__=Fg(e=>typeof e==`symbol`);Fg(e=>e===__);var v_=Fg(e=>typeof e==`number`),y_=Fg(e=>e===v_),b_=Fg(e=>typeof e==`string`),x_=Fg(e=>e===b_),S_=Fg(e=>typeof e==`boolean`),C_=Fg(e=>e===S_),w_=Lg(void 0);Ng(Ig,e=>e.shape.length===1&&e.shape[0]===void 0),Lg(void 0);var T_=Lg(null),E_=Ng(Ig,e=>e.shape.length===1&&e.shape[0]===null);Ng(Uint8Array),Ng(Mg,e=>e.shape===Uint8Array);var D_=u_(v_,b_,T_,w_,h_,S_,__);(()=>{let e=t_(p_),t=Xg(b_,p_),n=u_(v_,b_,T_,S_,e,t);return e.shape=n,t.shape.values=n,n})();var O_=e=>{if(o_.check(e))return e;ifLine truncated
`;n.right=new Yx(N(o,xy(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Mx(i)),n.right.integrate(e,0),n.forward()}Ub(e,t,n,s)},Yb=(e,t,n,r,i)=>{let a=t,o=Xp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Tx){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case Tx:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Wb(i,n);break}}}t=t.right}return s},Xb=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Tx){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Zb=e=>{let t=0;return Ly(e.doc,n=>{let r=e._start,i=e._start,a=Xp(),o=Zp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Tx:Wb(o,i.content);break;default:t+=Yb(n,r,i,a,o),a=Zp(o),r=i}i=i.right}}),t},Qb=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&ky(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Tx&&e.constructor!==hx&&t.add(e.parent)})}Ly(n,n=>{cv(e,e.deleteSet,e=>{if(e instanceof hx||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Tx?t.add(r):Xb(n,e)});for(let e of t)Zb(e)})},$b=(e,t,n)=>{let r=n,i=Zp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Hx:case Cx:case Mx:n<t.right.length&&Ey(e,N(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&Yb(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&db(o._searchMarker,t.index,-r+n),t},ex=class extends tb{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){let e=this.target.doc,t=[];Ly(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},Wh(o)||(e.attributes=Bh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Hx:case Cx:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case Mx:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case Tx:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(zb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),zb(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;zb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(zb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Wb(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},tx=class e extends pb{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??rb(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch(e){console.error(e)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new ex(this,e,t);fb(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??rb();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Mx&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Ly(this.doc,n=>{let r=new Bb(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&qb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&$b(n,r,a.delete):Jb(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??rb();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(_y(s,e)||t!==void 0&&_y(s,t))switch(s.content.constructor){case Mx:{let r=i.get(`ychange`);e!==void 0&&!_y(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!_y(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Hx:case Cx:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Tx:_y(s,e)&&(c(),Wb(i,s.content))}s=s.right}c()};return e||t?Ly(a,n=>{e&&vy(n,e),t&&vy(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Ly(r,r=>{let i=Hb(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),qb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Ly(r,r=>{let i=Hb(r,this,e,!n);qb(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Ly(n,n=>{$b(n,Hb(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Ly(r,r=>{let i=Hb(r,this,e,!1);i.right!==null&&Jb(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Ly(this.doc,t=>{Eb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Ly(this.doc,n=>{Db(n,this,e,t)})}getAttribute(e){return Ob(this,e)}getAttributes(){return kb(this)}_write(e){e.writeTypeRef(Lx)}},nx=e=>new tx,rx=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??rb()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===ox||t.constructor===ix)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}e=e.parent===this._root?null:e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}},ix=class e extends pb{constructor(){super(),this._prelimContent=[]}get firstChild(){let e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof pb?e.clone():e)),t}get length(){return this.doc??rb(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new rx(this,e)}querySelector(e){e=e.toUpperCase();let t=new rx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),im(new rx(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){fb(this,e,new cx(this,t,e))}toString(){return vb(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),_b(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Ly(this.doc,n=>{Cb(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Ly(this.doc,n=>{let r=e&&e instanceof pb?e._item:e;xb(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw ih(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Ly(this.doc,n=>{Tb(n,this,e,t)})}toArray(){return hb(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return bb(this,e)}slice(e=0,t=this.length){return mb(this,e,t)}forEach(e){_b(this,e)}_write(e){e.writeTypeRef(zx)}},ax=e=>new ix,ox=class e extends ix{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Hh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>eLine truncated
`).map(e=>e.trim()===``?`>`:`> ${e}`);n.push(i.join(`
`))}),n.join(`
>
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>CT(this.editor,this.type)}},addInputRules(){return[Wp({find:wT,type:this.type})]}}),ET=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,DT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,OT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,kT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,AT=gp.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return ST(`strong`,{...A(this.options.HTMLAttributes,e),children:ST(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Vp({find:ET,type:this.type}),Vp({find:OT,type:this.type})]},addPasteRules(){return[Jp({find:DT,type:this.type}),Jp({find:kT,type:this.type})]}}),jT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},MT=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function NT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var PT=gp.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(NT(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Vp({find:jT,type:this.type})]},addPasteRules(){return[Jp({find:MT,type:this.type})]}}),FT=4,IT=/^```([a-z]+)?[\s\n]$/,LT=/^~~~([a-z]+)?[\s\n]$/,RT=qp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:FT,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,A(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??FT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
`)},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>wT(this.editor,this.type)}},addInputRules(){return[Gp({find:TT,type:this.type})]}}),DT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,OT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,kT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,AT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,jT=_p.create({name:`bold`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!==`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name===this.name},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return CT(`strong`,{...A(this.options.HTMLAttributes,e),children:CT(`slot`,{})})},markdownTokenName:`strong`,parseMarkdown:(e,t)=>t.applyMark(`bold`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<strong>`,close:`</strong>`}},renderMarkdown:(e,t)=>`**${t.renderChildren(e)}**`,addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Hp({find:DT,type:this.type}),Hp({find:kT,type:this.type})]},addPasteRules(){return[Yp({find:OT,type:this.type}),Yp({find:AT,type:this.type})]}}),MT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},NT=e=>{let t=/`([^`]+)`(?!`)/g,n=[],r;for(;(r=t.exec(e))!==null;)r.index>0&&e[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n};function PT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var FT=_p.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`codespan`,parseMarkdown:(e,t)=>t.applyMark(`code`,[{type:`text`,text:e.text||``}]),renderMarkdown:(e,t,n)=>{var r;if(!e.content)return``;let i=typeof(n==null||(r=n.meta)==null?void 0:r.markText)==`string`?n.meta.markText:``,a="`".repeat(PT(i)),o=i.startsWith("`")||i.endsWith("`")?` `:``;return`${a}${o}${t.renderChildren(e.content)}${o}${a}`},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Hp({find:MT,type:this.type})]},addPasteRules(){return[Yp({find:NT,type:this.type})]}}),IT=4,LT=/^```([a-z]+)?[\s\n]$/,RT=/^~~~([a-z]+)?[\s\n]$/,zT=Jp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:IT,HTMLAttributes:{}}},content:`text*`,marks:``,group:`block`,code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{let{languageClassPrefix:t}=this.options;return t&&[...e.firstElementChild?.classList||[]].filter(e=>e.startsWith(t)).map(e=>e.replace(t,``))[0]||null},rendered:!1}}},parseHTML(){return[{tag:`pre`,preserveWhitespace:`full`}]},renderHTML({node:e,HTMLAttributes:t}){return[`pre`,A(this.options.HTMLAttributes,t),[`code`,{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},markdownTokenName:`code`,parseMarkdown:(e,t)=>e.raw?.startsWith("```")===!1&&e.raw?.startsWith(`~~~`)===!1&&e.codeBlockStyle!==`indented`?[]:t.createNode(`codeBlock`,{language:e.lang||null},e.text?[t.createTextNode(e.text)]:[]),renderMarkdown:(e,t)=>{let n=``,r=e.attrs?.language||``;return n=e.content?[`\`\`\`${r}`,t.renderChildren(e.content),"```"].join(`
`):`\`\`\`${r}\n\n\`\`\``,n},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,`paragraph`,e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=t.pos===1;return!e||t.parent.type.name!==this.name?!1:n||!t.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??IT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;if(i.parent.type!==this.type)return!1;let o=` `.repeat(t);return a?e.commands.insertContent(o):e.commands.command(({tr:e})=>{let{from:t,to:i}=r,a=n.doc.textBetween(t,i,`
`,`
`).split(`
`).map(e=>o+e).join(`
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??FT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
`);return e.replaceWith(t,i,n.schema.text(a)),!0})},"Shift-Tab":({editor:e})=>{if(!this.options.enableTabIndentation)return!1;let t=this.options.tabSize??IT,{state:n}=e,{selection:r}=n,{$from:i,empty:a}=r;return i.parent.type===this.type?a?e.commands.command(({tr:e})=>{let{pos:r}=i,a=i.start(),o=i.end(),s=n.doc.textBetween(a,o,`
`,`
`).split(`
`),c=0,l=0,u=r-a;for(let e=0;e<s.length;e+=1){if(l+s[e].length>=u){c=e;break}l+=s[e].length+1}let d=s[c].match(/^ */)?.[0]||``,f=Math.min(d.length,t);if(f===0)return!0;let p=a;for(let e=0;e<c;e+=1)p+=s[e].length+1;return e.delete(p,p+f),r-p<=f&&e.setSelection(w.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
@@ -123,29 +123,43 @@ img.ProseMirror-separator {
`).map(e=>{let n=e.match(/^ */)?.[0]||``,r=Math.min(n.length,t);return e.slice(r)}).join(`
`);return e.replaceWith(i,a,n.schema.text(o)),!0}):!1},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;let a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(C.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Up({find:IT,type:this.type,getAttributes:e=>({language:e[1]})}),Up({find:LT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new E({key:new D(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(w.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),zT=qp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`);return!a||!o?!1:e.chain().command(({tr:e})=>(e.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:e})=>{if(!this.options.exitOnArrowUp)return!1;let{state:t}=e,{selection:n}=t,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;let a=r.before();return a>0?!1:e.commands.insertDefaultBlock({pos:a})},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:r}=t,{$from:i,empty:a}=n;if(!a||i.parent.type!==this.type||i.parentOffset!==i.parent.nodeSize-2)return!1;let o=i.after();return o===void 0?!1:r.nodeAt(o)?e.commands.command(({tr:e})=>(e.setSelection(C.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[Wp({find:LT,type:this.type,getAttributes:e=>({language:e[1]})}),Wp({find:RT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new E({key:new D(`codeBlockVSCodeHandler`),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData(`text/plain`),r=t.clipboardData.getData(`vscode-editor-data`),i=(r?JSON.parse(r):void 0)?.mode;if(!n||!i)return!1;let{tr:a,schema:o}=e.state,s=o.text(n.replace(/\r\n?/g,`
`));return a.replaceSelectionWith(this.type.create({language:i},s)),a.selection.$from.parent.type!==this.type&&a.setSelection(w.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),BT=zT,VT=Jp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``}),BT=qp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,A(this.options.HTMLAttributes,e)]},renderText(){return`
`):``}),HT=Jp.create({name:`hardBreak`,markdownTokenName:`br`,addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:`inline`,selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:`br`}]},renderHTML({HTMLAttributes:e}){return[`br`,A(this.options.HTMLAttributes,e)]},renderText(){return`
`},renderMarkdown:()=>`
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),VT=qp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Up({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),HT=qp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,A(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Df(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(w.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(T.create(t.doc,n.pos)):t.setSelection(w.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(w.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Hp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),UT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,WT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,GT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,KT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,qT=gp.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Vp({find:UT,type:this.type}),Vp({find:GT,type:this.type})]},addPasteRules(){return[Jp({find:WT,type:this.type}),Jp({find:KT,type:this.type})]}}),JT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,xD=`️`,SD=`‍`,CD=``,wD=null,TD=null;function ED(e=[]){let t={};lE.groups=t;let n=new lE;wD??=AD(JT),TD??=AD(YT),F(n,`'`,VE),F(n,`{`,wE),F(n,`}`,TE),F(n,`[`,EE),F(n,`]`,DE),F(n,`(`,OE),F(n,`)`,kE),F(n,`<`,AE),F(n,`>`,jE),F(n,`(`,ME),F(n,`)`,NE),F(n,`「`,PE),F(n,`」`,FE),F(n,`『`,IE),F(n,`』`,LE),F(n,`<`,RE),F(n,`>`,zE),F(n,`&`,BE),F(n,`*`,HE),F(n,`@`,UE),F(n,"`",GE),F(n,`^`,KE),F(n,`:`,qE),F(n,`,`,JE),F(n,`$`,YE),F(n,`.`,XE),F(n,`=`,ZE),F(n,`!`,QE),F(n,`-`,$E),F(n,`%`,eD),F(n,`|`,tD),F(n,`+`,nD),F(n,`#`,rD),F(n,`?`,iD),F(n,`"`,aD),F(n,`/`,cD),F(n,`;`,sD),F(n,`~`,lD),F(n,`_`,uD),F(n,`\\`,WE),F(n,`・`,oD);let r=uE(n,_D,xE,{[XT]:!0});uE(r,_D,r);let i=uE(r,mD,mE,{[$T]:!0}),a=uE(r,hD,hE,{[eE]:!0}),o=uE(n,mD,fE,{[ZT]:!0});uE(o,_D,i),uE(o,mD,o),uE(i,_D,i),uE(i,mD,i);let s=uE(n,hD,pE,{[QT]:!0});uE(s,mD),uE(s,_D,a),uE(s,hD,s),uE(a,_D,a),uE(a,mD),uE(a,hD,a);let c=F(n,bD,CE,{[aE]:!0}),l=F(n,yD,SE,{[aE]:!0}),u=uE(n,vD,SE,{[aE]:!0});F(n,CD,u),F(l,bD,c),F(l,CD,u),uE(l,vD,u),F(u,yD),F(u,bD),uE(u,vD,u),F(u,CD,u);let d=uE(n,gD,dD,{[nE]:!0});F(d,`#`),uE(d,gD,d),F(d,xD,d);let f=F(d,SD);F(f,`#`),uE(f,gD,d);let p=[[mD,o],[_D,i]],m=[[mD,null],[hD,s],[_D,a]];for(let e=0;e<wD.length;e++)kD(n,wD[e],_E,fE,p);for(let e=0;e<TD.length;e++)kD(n,TD[e],vE,pE,m);sE(_E,{tld:!0,ascii:!0},t),sE(vE,{utld:!0,alpha:!0},t),kD(n,`file`,yE,fE,p),kD(n,`mailto`,yE,fE,p),kD(n,`http`,bE,fE,p),kD(n,`https`,bE,fE,p),kD(n,`ftp`,bE,fE,p),kD(n,`ftps`,bE,fE,p),sE(yE,{scheme:!0,ascii:!0},t),sE(bE,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[rE]:!0}:{[iE]:!0};r.indexOf(`-`)>=0?i[tE]=!0:mD.test(r)?_D.test(r)?i[$T]=!0:i[ZT]=!0:i[XT]=!0,dE(n,r,r,i)}return dE(n,`localhost`,gE,{ascii:!0}),n.jd=new lE(fD),{start:n,tokens:Object.assign({groups:t},pD)}}function DD(e,t){let n=OD(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function OD(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function kD(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new lE(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new lE(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function AD(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var jD={defaultProtocol:`http`,events:null,format:ND,formatHref:ND,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function MD(e,t=null){let n=Object.assign({},jD);e&&(n=Object.assign(n,e instanceof MD?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i,this.ignoreClasses=n.ignoreClasses.slice()}MD.prototype={o:jD,ignoreTags:[],ignoreClasses:[],isIgnoredClass(e){if(typeof e!=`string`||this.ignoreClasses.length===0)return!1;let t=e.split(/\s+/);for(let e=0;e<t.length;e++)if(this.ignoreClasses.indexOf(t[e])>=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:jD[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function ND(e){return e}function PD(e,t){this.t=`token`,this.v=e,this.tk=t}PD.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=jD.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);reLine truncated
`,parseMarkdown:()=>({type:`hardBreak`}),addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:r})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:i}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:a}=this.options,{splittableMarks:o}=r.extensionManager,s=i||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&s&&a){let t=s.filter(e=>o.includes(e.type.name));e.ensureMarks(t)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),UT=Jp.create({name:`heading`,addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:`inline*`,group:`block`,defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){return[`h${this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0]}`,A(this.options.HTMLAttributes,t),0]},parseMarkdown(e,t){let n=e.depth||1;return this.options.levels.includes(n)?t.createNode(`heading`,{level:n},t.parseInline(e.tokens||[])):t.createNode(`paragraph`,void 0,t.parseInline(e.tokens||[]))},renderMarkdown:(e,t)=>{let n=e.attrs?.level?parseInt(e.attrs.level,10):1,r=`#`.repeat(n);return e.content?`${r} ${t.renderChildren(e.content)}`:``},addCommands(){return{setHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.setNode(this.name,e):!1,toggleHeading:e=>({commands:t})=>this.options.levels.includes(e.level)?t.toggleNode(this.name,`paragraph`,e):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>Wp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),WT=Jp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,A(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Df(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return pd(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:e,tr:t,dispatch:n})=>{if(n){let{$to:n}=t.selection,r=n.end();if(n.nodeAfter)n.nodeAfter.isTextblock?t.setSelection(w.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(T.create(t.doc,n.pos)):t.setSelection(w.create(t.doc,n.pos));else{let i=(e.schema.nodes[this.options.nextNodeType]||n.parent.type.contentMatch.defaultType)?.create();i&&(t.insert(r,i),t.setSelection(w.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Up({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),GT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,KT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,qT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,JT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,YT=_p.create({name:`italic`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`em`},{tag:`i`,getAttrs:e=>e.style.fontStyle!==`normal`&&null},{style:`font-style=normal`,clearMark:e=>e.type.name===this.name},{style:`font-style=italic`}]},renderHTML({HTMLAttributes:e}){return[`em`,A(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},markdownTokenName:`em`,parseMarkdown:(e,t)=>t.applyMark(`italic`,t.parseInline(e.tokens||[])),markdownOptions:{htmlReopen:{open:`<em>`,close:`</em>`}},renderMarkdown:(e,t)=>`*${t.renderChildren(e)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Hp({find:GT,type:this.type}),Hp({find:qT,type:this.type})]},addPasteRules(){return[Yp({find:KT,type:this.type}),Yp({find:JT,type:this.type})]}}),XT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,CD=`️`,wD=`‍`,TD=``,ED=null,DD=null;function OD(e=[]){let t={};dE.groups=t;let n=new dE;ED??=MD(XT),DD??=MD(ZT),F(n,`'`,UE),F(n,`{`,EE),F(n,`}`,DE),F(n,`[`,OE),F(n,`]`,kE),F(n,`(`,AE),F(n,`)`,jE),F(n,`<`,ME),F(n,`>`,NE),F(n,`(`,PE),F(n,`)`,FE),F(n,`「`,IE),F(n,`」`,LE),F(n,`『`,RE),F(n,`』`,zE),F(n,`<`,BE),F(n,`>`,VE),F(n,`&`,HE),F(n,`*`,WE),F(n,`@`,GE),F(n,"`",qE),F(n,`^`,JE),F(n,`:`,YE),F(n,`,`,XE),F(n,`$`,ZE),F(n,`.`,QE),F(n,`=`,$E),F(n,`!`,eD),F(n,`-`,tD),F(n,`%`,nD),F(n,`|`,rD),F(n,`+`,iD),F(n,`#`,aD),F(n,`?`,oD),F(n,`"`,sD),F(n,`/`,uD),F(n,`;`,lD),F(n,`~`,dD),F(n,`_`,fD),F(n,`\\`,KE),F(n,`・`,cD);let r=fE(n,yD,CE,{[QT]:!0});fE(r,yD,r);let i=fE(r,gD,gE,{[tE]:!0}),a=fE(r,_D,_E,{[nE]:!0}),o=fE(n,gD,mE,{[$T]:!0});fE(o,yD,i),fE(o,gD,o),fE(i,yD,i),fE(i,gD,i);let s=fE(n,_D,hE,{[eE]:!0});fE(s,gD),fE(s,yD,a),fE(s,_D,s),fE(a,yD,a),fE(a,gD),fE(a,_D,a);let c=F(n,SD,TE,{[sE]:!0}),l=F(n,xD,wE,{[sE]:!0}),u=fE(n,bD,wE,{[sE]:!0});F(n,TD,u),F(l,SD,c),F(l,TD,u),fE(l,bD,u),F(u,xD),F(u,SD),fE(u,bD,u),F(u,TD,u);let d=fE(n,vD,pD,{[iE]:!0});F(d,`#`),fE(d,vD,d),F(d,CD,d);let f=F(d,wD);F(f,`#`),fE(f,vD,d);let p=[[gD,o],[yD,i]],m=[[gD,null],[_D,s],[yD,a]];for(let e=0;e<ED.length;e++)jD(n,ED[e],yE,mE,p);for(let e=0;e<DD.length;e++)jD(n,DD[e],bE,hE,m);lE(yE,{tld:!0,ascii:!0},t),lE(bE,{utld:!0,alpha:!0},t),jD(n,`file`,xE,mE,p),jD(n,`mailto`,xE,mE,p),jD(n,`http`,SE,mE,p),jD(n,`https`,SE,mE,p),jD(n,`ftp`,SE,mE,p),jD(n,`ftps`,SE,mE,p),lE(xE,{scheme:!0,ascii:!0},t),lE(SE,{slashscheme:!0,ascii:!0},t),e=e.sort((e,t)=>e[0]>t[0]?1:-1);for(let t=0;t<e.length;t++){let r=e[t][0],i=e[t][1]?{[aE]:!0}:{[oE]:!0};r.indexOf(`-`)>=0?i[rE]=!0:gD.test(r)?yD.test(r)?i[tE]=!0:i[$T]=!0:i[QT]=!0,pE(n,r,r,i)}return pE(n,`localhost`,vE,{ascii:!0}),n.jd=new dE(mD),{start:n,tokens:Object.assign({groups:t},hD)}}function kD(e,t){let n=AD(t.replace(/[A-Z]/g,e=>e.toLowerCase())),r=n.length,i=[],a=0,o=0;for(;o<r;){let s=e,c=null,l=0,u=null,d=-1,f=-1;for(;o<r&&(c=s.go(n[o]));)s=c,s.accepts()?(d=0,f=0,u=s):d>=0&&(d+=n[o].length,f++),l+=n[o].length,a+=n[o].length,o++;a-=d,o-=f,l-=d,i.push({t:u.t,v:t.slice(a-l,a),s:a-l,e:a})}return i}function AD(e){let t=[],n=e.length,r=0;for(;r<n;){let i=e.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=e.charCodeAt(r+1))<56320||a>57343?e[r]:e.slice(r,r+2);t.push(o),r+=o.length}return t}function jD(e,t,n,r,i){let a,o=t.length;for(let n=0;n<o-1;n++){let o=t[n];e.j[o]?a=e.j[o]:(a=new dE(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new dE(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function MD(e){let t=[],n=[],r=0;for(;r<e.length;){let i=0;for(;`0123456789`.indexOf(e[r+i])>=0;)i++;if(i>0){t.push(n.join(``));for(let t=parseInt(e.substring(r,r+i),10);t>0;t--)n.pop();r+=i}else n.push(e[r]),r++}return t}var ND={defaultProtocol:`http`,events:null,format:FD,formatHref:FD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function PD(e,t=null){let n=Object.assign({},ND);e&&(n=Object.assign(n,e instanceof PD?e.o:e));let r=n.ignoreTags,i=[];for(let e=0;e<r.length;e++)i.push(r[e].toUpperCase());this.o=n,t&&(this.defaultRender=t),this.ignoreTags=i,this.ignoreClasses=n.ignoreClasses.slice()}PD.prototype={o:ND,ignoreTags:[],ignoreClasses:[],isIgnoredClass(e){if(typeof e!=`string`||this.ignoreClasses.length===0)return!1;let t=e.split(/\s+/);for(let e=0;e<t.length;e++)if(this.ignoreClasses.indexOf(t[e])>=0)return!0;return!1},defaultRender(e){return e},check(e){return this.get(`validate`,e.toString(),e)},get(e,t,n){let r=t!=null,i=this.o[e];return i&&(typeof i==`object`?(i=n.t in i?i[n.t]:ND[e],typeof i==`function`&&r&&(i=i(t,n))):typeof i==`function`&&r&&(i=i(t,n.t,n)),i)},getObj(e,t,n){let r=this.o[e];return typeof r==`function`&&t!=null&&(r=r(t,n.t,n)),r},render(e){let t=e.render(this);return(this.get(`render`,null,e)||this.defaultRender)(t,e.t,e)}};function FD(e){return e}function ID(e,t){this.t=`token`,this.v=e,this.tk=t}ID.prototype={isLink:!1,toString(){return this.v},toHref(e){return this.toString()},toFormattedString(e){let t=this.toString(),n=e.get(`truncate`,t,this),r=e.get(`format`,t,this);return n&&r.length>n?r.substring(0,n)+`…`:r},toFormattedHref(e){return e.get(`formatHref`,this.toHref(e.get(`defaultProtocol`)),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(e=ND.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(e),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(e){return{type:this.t,value:this.toFormattedString(e),isLink:this.isLink,href:this.toFormattedHref(e),start:this.startIndex(),end:this.endIndex()}},validate(e){return e.get(`validate`,this.toString(),this)},render(e){let t=this,n=this.toHref(e.get(`defaultProtocol`)),r=e.get(`formatHref`,n,this),i=e.get(`tagName`,n,t),a=this.toFormattedString(e),o={},s=e.get(`className`,n,t),c=e.get(`target`,n,t),l=e.get(`rel`,n,t),u=e.getObj(`attributes`,n,t),d=e.getObj(`events`,n,t);reLine truncated
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);KD.customSchemes.push([e,t])}function YD(){KD.scanner=ED(KD.customSchemes);for(let e=0;e<KD.tokenQueue.length;e++)KD.tokenQueue[e][1]({scanner:KD.scanner});KD.parser=VD(KD.scanner.tokens);for(let e=0;e<KD.pluginQueue.length;e++)KD.pluginQueue[e][1]({scanner:KD.scanner,parser:KD.parser});return KD.initialized=!0,KD}function XD(e){return KD.initialized||YD(),HD(KD.parser.start,e,DD(KD.scanner.start,e))}XD.scan=DD;function ZD(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new MD(n),i=XD(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var QD=`[\0- \xA0 ᠎ -\u2029  ]`,$D=new RegExp(QD),eO=RegExp(`${QD}$`),tO=RegExp(`${QD}+$`),nO=new RegExp(QD,`g`);function rO(e,t,n){let r=e.doc.resolve(t.to);if(!r.nodeBefore?.isText)return;let i=e.doc.textBetween(t.from,t.to,``,``).match(tO)?.[0];if(!i)return;let a=t.to-i.length,o=ed(a,t.to,e.doc).filter(e=>e.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function iO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function aO(e){return new E({key:new D(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=hu(n.doc,[...t]);if(!t.some(Jc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof Dt)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);i<a&&t.push({from:i,to:a})}),t.sort((e,t)=>t.to-e.to),t.forEach(t=>rO(o,t,e.type))}if($u(s).forEach(({newRange:t})=>{let n=_u(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!eO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split($D).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=XD(n).map(t=>t.toObject(e.defaultProtocol));if(!iO(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{ed(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function oO(e){return new E({key:new D(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Xu(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var sO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,cO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function lO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function uO(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&lO(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function dO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||lO(e,t.index??0)||uO(e,t.index??0)?!1:!!r.trim()&&n(i)}function fO(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function pO(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function mO(e){return{href:e.data?.href,title:e.data?.title??null}}function hO(e){let t=Vp({find:t=>{let n=sO.exec(t);return!n||!dO(t,n,e.isAllowedHref)?null:fO(n)},type:e.type,getAttributes:mO});return new cp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function gO(e){let t=Jp({find:t=>{let n=[];for(let r of t.matchAll(cO))dO(t,r,e.isAllowedHref)&&n.push(fO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>pO(t,e)));return[...n,...r]},type:e.type,getAttributes:mO});return new _p({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function _O(e){return new E({key:new D(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=ZD(c,Line truncated
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(bO,this.editor.getAttributes(xO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Wp({find:SO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Wp({find:SO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(xO),editor:this.editor})),[e]}}),wO=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},TO=(e,t,n,r)=>{let i=wO(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:c,insertPos:l,items:u}=i,d=e.tr;d.delete(c,c+o.nodeSize);let f=d.mapping.map(l);return d.insert(f,s.from(u)),d.setSelection(a.map(d.doc,d.mapping)),t&&t(d),!0},EO=(e,t,n)=>TO(e.state,e.view.dispatch,t,n),DO=(e,t)=>wp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>EO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),OO=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],kO=`abcdefghijklmnopqrstuvwxyz`,AO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function jO(e){let t=e,n=``;for(let[e,r]of OO)for(;t>=e;)n+=r,t-=e;return n}function MO(e){return jO(e).toUpperCase()}function NO(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of OO)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function PO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=NO(e);return t<=0?!1:(e===e.toLowerCase()?jO(t):MO(t))===e}function FO(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function IO(e){if(e<=26)return kO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?kO[n]:kO[t]+kO[n]}function LO(e){if(e&&!/^\d+$/.test(e)){if(PO(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function RO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=LO(e);if(t===`i`||t===`I`)return NO(e);if(t===`a`||t===`A`){let t=FO(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function zO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return IO(t);case`A`:return IO(t).toUpperCase();case`i`:return jO(t);case`I`:return MO(t);default:return String(t)}}function BO(e){if(e.length===0)return!1;let t=LO(e[0])??`numeric`,n=RO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=zO(t,n+r);if(e[r]!==i)return!1}return!0}function VO(e){return{type:LO(e),start:RO(e)}}function HO(e){let{type:t,start:n}=VO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function UO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${IO(r)}${n}`;case`A`:return`${IO(r).toUpperCase()}${n}`;case`i`:return`${jO(r)}${n}`;case`I`:return`${MO(r)}${n}`;default:return`${r}${n}`}}function WO(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function GO(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var KO=`&nbsp;`,qO=1,JO=e=>(e?.level??qO)>qO;function YO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function XO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var ZO=qp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(YO(e))return{type:`listItem`,content:[{type:`paragraph`,content:XO(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]}Line truncated
3. "-" cannot repeat`);JD.customSchemes.push([e,t])}function ZD(){JD.scanner=OD(JD.customSchemes);for(let e=0;e<JD.tokenQueue.length;e++)JD.tokenQueue[e][1]({scanner:JD.scanner});JD.parser=UD(JD.scanner.tokens);for(let e=0;e<JD.pluginQueue.length;e++)JD.pluginQueue[e][1]({scanner:JD.scanner,parser:JD.parser});return JD.initialized=!0,JD}function QD(e){return JD.initialized||ZD(),WD(JD.parser.start,e,kD(JD.scanner.start,e))}QD.scan=kD;function $D(e,t=null,n=null){if(t&&typeof t==`object`){if(n)throw Error(`linkifyjs: Invalid link type ${t}; must be a string`);n=t,t=null}let r=new PD(n),i=QD(e),a=[];for(let e=0;e<i.length;e++){let n=i[e];n.isLink&&(!t||n.t===t)&&r.check(n)&&a.push(n.toFormattedObject(r))}return a}var eO=`[\0- \xA0 ᠎ -\u2029  ]`,tO=new RegExp(eO),nO=RegExp(`${eO}$`),rO=RegExp(`${eO}+$`),iO=new RegExp(eO,`g`);function aO(e,t,n){let r=e.doc.resolve(t.to);if(!r.nodeBefore?.isText)return;let i=e.doc.textBetween(t.from,t.to,``,``).match(rO)?.[0];if(!i)return;let a=t.to-i.length,o=ed(a,t.to,e.doc).filter(e=>e.mark.type===n);if(!o.length)return;let{nodeAfter:s}=r;if(s&&o.some(e=>e.mark.isInSet(s.marks)))return;let c=e.storedMarks;e.removeMark(a,t.to,n),e.setStoredMarks(c),e.selection.empty&&e.selection.from===t.to&&e.removeStoredMark(n)}function oO(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function sO(e){return new E({key:new D(`autolink`),appendTransaction:(t,n,r)=>{let i=t.some(e=>e.docChanged)&&!n.doc.eq(r.doc),a=t.some(e=>e.getMeta(`preventAutolink`));if(!i||a)return;let{tr:o}=r,s=hu(n.doc,[...t]);if(!t.some(Jc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof Dt)||!e.slice.size)return;let r=s.mapping.slice(n+1),i=r.map(e.from,1),a=r.map(e.from+e.slice.size,-1);i<a&&t.push({from:i,to:a})}),t.sort((e,t)=>t.to-e.to),t.forEach(t=>aO(o,t,e.type))}if($u(s).forEach(({newRange:t})=>{let n=_u(r.doc,t,e=>e.isTextblock),i,a;if(n.length>1)i=n[0],a=r.doc.textBetween(i.pos,i.pos+i.node.nodeSize,void 0,` `);else if(n.length){let e=r.doc.textBetween(t.from,t.to,` `,` `);if(!nO.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(tO).filter(Boolean);if(t.length<=0)return!1;let n=t[t.length-1],s=i.pos+a.lastIndexOf(n);if(!n)return!1;let c=QD(n).map(t=>t.toObject(e.defaultProtocol));if(!oO(c))return!1;c.filter(e=>e.isLink).map(e=>({...e,from:s+e.start+1,to:s+e.end+1})).filter(e=>!r.schema.marks.code||!r.doc.rangeHasMark(e.from,e.to,r.schema.marks.code)).filter(t=>e.validate(t.value)).filter(t=>e.shouldAutoLink(t.value)).forEach(t=>{ed(t.from,t.to,r.doc).some(t=>t.mark.type===e.type)||o.addMark(t.from,t.to,e.type.create({href:t.href}))})}}),o.steps.length)return o}})}function cO(e){return new E({key:new D(`handleClickLink`),props:{handleClick:(t,n,r)=>{if(r.button!==0||!t.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let t=r.target;if(!t)return!1;let n=e.editor.view.dom;i=t.closest(`a`),i&&!n.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(e.enableClickSelection&&(a=e.editor.commands.extendMarkRange(e.type.name)),e.openOnClick){let n=Xu(t.state,e.type.name),r=i.href??n.href,o=i.target??n.target;r&&(window.open(r,o),a=!0)}return a}}})}var lO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,uO=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function dO(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function fO(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&dO(e,r)){r+=1;continue}let i=0;for(;r<t&&e[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function pO(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||dO(e,t.index??0)||fO(e,t.index??0)?!1:!!r.trim()&&n(i)}function mO(e){let[t,n,r,,i,a,o]=e,s=i??a??o;return{index:e.index??0,text:t,replaceWith:n,data:{href:r,title:s||null,markdown:!0}}}function hO(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function gO(e){return{href:e.data?.href,title:e.data?.title??null}}function _O(e){let t=Hp({find:t=>{let n=lO.exec(t);return!n||!pO(t,n,e.isAllowedHref)?null:mO(n)},type:e.type,getAttributes:gO});return new lp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function vO(e){let t=Yp({find:t=>{let n=[];for(let r of t.matchAll(uO))pO(t,r,e.isAllowedHref)&&n.push(mO(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>hO(t,e)));return[...n,...r]},type:e.type,getAttributes:gO});return new vp({find:t.find,handler:e=>{let n=t.handler(e);return n!==null&&e.state.tr.steps.length&&e.match.data?.markdown&&e.state.tr.setMeta(`preventAutolink`,!0),n}})}function yO(e){return new E({key:new D(`handlePasteLink`),props:{handlePaste:(t,n,r)=>{let{shouldAutoLink:i}=e,{state:a}=t,{selection:o}=a,{empty:s}=o;if(s)return!1;let c=``;r.content.forEach(e=>{c+=e.textContent});let l=$D(c,Line truncated
`):``,markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(SO,this.editor.getAttributes(CO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Gp({find:wO,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Gp({find:wO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(CO),editor:this.editor})),[e]}}),EO=(e,t,n)=>{let{selection:r}=e;if(!r.empty)return null;let{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let a=-1;for(let e=i.depth;e>0;--e)if(i.node(e).type.name===t){a=e;break}if(a<0)return null;let o=i.node(a),s=i.index(a);if(s+1>=o.childCount)return null;let c=o.child(s+1);if(!n.includes(c.type.name))return null;let l=e.schema.nodes[t],u=!1;if(c.forEach(e=>{e.type===l&&e.childCount>1&&(u=!0)}),!u)return null;let d=e.doc.resolve(i.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;let f=[];return d.forEach(e=>{f.push(e)}),f.length===0?null:{listItemDepth:a,nestedList:d,nestedListPos:i.after(),insertPos:i.after(a),items:f}},DO=(e,t,n,r)=>{let i=EO(e,n,r);if(!i)return!1;let{selection:a}=e,{nestedList:o,nestedListPos:c,insertPos:l,items:u}=i,d=e.tr;d.delete(c,c+o.nodeSize);let f=d.mapping.map(l);return d.insert(f,s.from(u)),d.setSelection(a.map(d.doc,d.mapping)),t&&t(d),!0},OO=(e,t,n)=>DO(e.state,e.view.dispatch,t,n),kO=(e,t)=>Tp.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>OO(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),AO=[[1e3,`m`],[900,`cm`],[500,`d`],[400,`cd`],[100,`c`],[90,`xc`],[50,`l`],[40,`xl`],[10,`x`],[9,`ix`],[5,`v`],[4,`iv`],[1,`i`]],jO=`abcdefghijklmnopqrstuvwxyz`,MO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function NO(e){let t=e,n=``;for(let[e,r]of AO)for(;t>=e;)n+=r,t-=e;return n}function PO(e){return NO(e).toUpperCase()}function FO(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of AO)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function IO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=FO(e);return t<=0?!1:(e===e.toLowerCase()?NO(t):PO(t))===e}function LO(e){let t=e.toLowerCase();if(t.length===1)return t.charCodeAt(0)-97+1;if(t.length===2){let e=t.charCodeAt(0)-97,n=t.charCodeAt(1)-97;return(e+1)*26+n+1}return 0}function RO(e){if(e<=26)return jO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?jO[n]:jO[t]+jO[n]}function zO(e){if(e&&!/^\d+$/.test(e)){if(IO(e))return e===e.toLowerCase()?`i`:`I`;if(/^[a-z]{1,2}$/.test(e))return`a`;if(/^[A-Z]{1,2}$/.test(e))return`A`}}function BO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=zO(e);if(t===`i`||t===`I`)return FO(e);if(t===`a`||t===`A`){let t=LO(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function VO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return RO(t);case`A`:return RO(t).toUpperCase();case`i`:return NO(t);case`I`:return PO(t);default:return String(t)}}function HO(e){if(e.length===0)return!1;let t=zO(e[0])??`numeric`,n=BO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=VO(t,n+r);if(e[r]!==i)return!1}return!0}function UO(e){return{type:zO(e),start:BO(e)}}function WO(e){let{type:t,start:n}=UO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function GO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${RO(r)}${n}`;case`A`:return`${RO(r).toUpperCase()}${n}`;case`i`:return`${NO(r)}${n}`;case`I`:return`${PO(r)}${n}`;default:return`${r}${n}`}}function KO(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function qO(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var JO=`&nbsp;`,YO=1,XO=e=>(e?.level??YO)>YO;function ZO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function QO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var $O=Jp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`list_item`,parseMarkdown:(e,t)=>{if(e.type!==`list_item`)return[];let n=t.parseBlockChildren??t.parseChildren,r=[];if(e.tokens&&e.tokens.length>0){if(ZO(e))return{type:`listItem`,content:[{type:`paragraph`,content:QO(e.text||``,t)}]};let[i,...a]=e.tokens;if(i.type===`heading`)return{type:`listItem`,content:[{type:`paragraph`,content:t.parseInline(i.tokens??[])},...a.length>0?n(a):[]]}Line truncated
`).trim(),contentLines:m,raw:g.join(`
`)}),r=h,n=h}return[t,r]}var hk=RegExp(`^(${AO})([.)])\\s+(.+)$`);function gk(e){let t=e.split(`
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(hk);if(!t)return null;n.push({marker:t[1],content:t[3]})}return BO(n.map(e=>e.marker))?{type:`orderedList`,attrs:HO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function _k(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=pk(a.contentLines),c=o.join(`
`)}),r=h,n=h}return[t,r]}var _k=RegExp(`^(${MO})([.)])\\s+(.+)$`);function vk(e){let t=e.split(`
`).filter(e=>e.trim().length>0);if(t.length===0)return null;let n=[];for(let e of t){let t=e.trim().match(_k);if(!t)return null;n.push({marker:t[1],content:t[3]})}return HO(n.map(e=>e.marker))?{type:`orderedList`,attrs:WO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function yk(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=hk(a.contentLines),c=o.join(`
`).trim(),l=[];c&&l.push({type:`paragraph`,raw:c,tokens:n.inlineTokens(c)});let u=s.join(`
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=_k(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function vk(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var yk=64;function bk(e,t){let n=[],r=0;for(;n.length<t;){let t=e.indexOf(`
`,r);if(t===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,t)),r=t+1}return n}function xk(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!sk.test(n))return[[],0,[]];let r=yk,i=bk(e,r),a=mk(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=bk(e,r),a=mk(i);return[a[0],a[1],i]}var Sk=`listItem`,Ck=`textStyle`,wk=/^(\d+)\.\s$/;function Tk(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var Ek=qp.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Tk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Tk(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=A(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?vk(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=xk(e);if(r.length===0)return;let o=_k(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Sk,this.editor.getAttributes(Ck)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new E({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=gk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Wp({find:wk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Wp({find:wk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Ck)}),joinPredicate:e,editor:this.editor})),[t]}}),Dk=/^\s*(\[([( |x])?\])\s$/,Ok=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,kk=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},Ak=qp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,A(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>ap(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[DO(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=Ok;let l=e=>{let t=kk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Lu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Wp({find:Dk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),jk=qp.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`uLine truncated
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=np(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=np(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});wp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(CO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(ZO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ok.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ek.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Ak.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(jk.configure(this.options.taskList)),e}});var Mk=`&nbsp;`,Nk=`\xA0`,Pk=qp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,A(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Mk||n[0].text===Mk||n[0].raw===Nk||n[0].text===Nk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Mk||r[0].text===Nk)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?Mk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Fk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Ik=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Lk=gp.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Vp({find:Fk,type:this.type})]},addPasteRules(){return[Jp({find:Ik,type:this.type})]}}),Rk=qp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),zk=gp.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,A(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`<u>${t.renderChildren(e)}</u>`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(`<u>`)},tokenize(e,t,n){if(!/^<u>/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleLine truncated
`).length+1)));let r=document.createElement(`div`);r.className=`dw-source__actions`;let i=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`dw-source__btn ${t}`,r.textContent=e,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,n),r};e.onRemove&&r.append(i(e.labels.remove,`dw-source__btn--danger`,()=>{u(!0),e.onRemove()}));let a=document.createElement(`span`);a.style.flex=`1`,r.append(a,i(e.labels.cancel,``,()=>u()),i(e.labels.done,`dw-source__btn--primary`,()=>o())),t.append(n,r),document.body.append(t);let o=()=>{let t=n.value;u(!0),e.onSave(t)};n.addEventListener(`input`,()=>e.onInput?.(n.value)),n.addEventListener(`keydown`,t=>{let n=t;n.key===`Escape`?(n.preventDefault(),u()):n.key===`Enter`&&(n.ctrlKey||n.metaKey||!e.multiline)&&(n.preventDefault(),o()),n.stopPropagation()});let s=n=>{!t.contains(n.target)&&!e.anchor.contains(n.target)&&u()};setTimeout(()=>document.addEventListener(`mousedown`,s),0);let c=Wj(e.anchor,t,()=>{Jj(e.anchor,t,{placement:`bottom-start`,middleware:[Gj(6),qj(),Kj({padding:8})]}).then(({x:e,y:n})=>Object.assign(t.style,{left:`${e}px`,top:`${n}px`}))}),l=!1;function u(n=!1){l||(l=!0,c(),document.removeEventListener(`mousedown`,s),t.remove(),Yj===d&&(Yj=null),n||e.onCancel?.())}let d=()=>u();return Yj=d,n.focus(),e.multiline||n.select(),d}var Zj=[{pattern:/^https:\/\/(?:www\.|m\.)?youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/|live\/)([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/youtu\.be\/([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?vimeo\.com\/(?:video\/)?(\d+)/,src:e=>`https://player.vimeo.com/video/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-f]{32})/,src:e=>`https://www.loom.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[\w-]+/,src:(e,t)=>`https://www.figma.com/embed?embed_host=docwell&url=${encodeURIComponent(t.href)}`},{pattern:/^https:\/\/codepen\.io\/([\w-]+)\/(?:pen|embed)\/([\w-]+)/,src:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{pattern:/^https:\/\/open\.spotify\.com\/(?:embed\/)?(track|album|playlist|episode|show)\/(\w+)/,src:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`,ratio:`audio`},{pattern:/^https:\/\/docs\.google\.com\/(document|spreadsheets|presentation)\/d\/([\w-]+)/,src:e=>`https://docs.google.com/${e[1]}/d/${e[2]}/preview`,ratio:`tall`},{pattern:/^https:\/\/(?:www\.)?google\.com\/maps\/embed\?/,src:(e,t)=>t.href}];function Qj(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of Zj){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function $j(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var eM=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function tM(e,t,n){let{node:r}=e.view.domAtPos(e.state.selection.from),i=r instanceof HTMLElement?r:r.parentElement??e.view.dom;return new Promise(e=>{let r=t.blocks;Xj({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e($j(t)),onCancel:()=>e(``)})})}async function nM(e,t,n,r){let i=await tM(e,t,t.blocks.embedUrl);i&&(Qj(i)?e.chain().focus().insertEmbed(i).run():await iM(e,i,n,r))}async function rM(e,t,n,r){let i=await tM(e,t,t.blocks.linkUrl);i&&await iM(e,i,n,r)}async function iM(e,t,n,r){let i={url:t};if(n)try{i={...await n.preview(t),url:t}}catch(e){r?.(e)}e.chain().focus().insertLinkCard(i).run()}var aM=qp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=$j(String(e.attrs.url));return[`div`,A(t,{"data-type":`embed`}),[`a`,{href:n},n]]},addCommands(){return{insertEmbed:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e}})}},addNodeView(){return({node:e})=>{let t=this.options.labels.blocks,n=document.createElement(`figure`);n.className=`dw-embed`,n.setAttribute(`data-type`,`embed`),n.contentEditable=`false`;let r=e=>{let r=$j(e),i=Qj(r);if(n.replaceChildren(),!i){let e=document.createElement(`a`);e.href=r,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=r||t.embedInvalid,n.append(e);return}n.dataset.ratio=i.ratio;let a=document.createElement(`iframe`);a.className=`dw-embed__frame`,a.src=i.src,a.title=`${t.embed}: ${eM(r)}`,a.loading=`lazy`,a.allow=`fullscreen; picture-in-picture; encrypted-media; clipboard-write`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`);let o=document.createElement(`figcaption`);o.className=`dw-embed__caption`;let s=document.createElement(`a`);s.href=r,s.targeLine truncated
`).trim();if(u){let e=n.blockTokens(u);l.push(...e)}let d=i+1,f=[];for(;d<e.length&&e[d].indent>t;)f.push(e[d]),d+=1;if(f.length>0){let e=yk(f,Math.min(...f.map(e=>e.indent)),n);l.push({type:`list`,ordered:!0,start:f[0].number,typeMarker:f[0].type,items:e,raw:f.map(e=>e.raw).join(`
`)})}r.push({type:`list_item`,raw:a.raw,tokens:l}),i=d}else i+=1}return r}function bk(e,t){return e.map(e=>{if(e.type!==`list_item`)return t.parseChildren([e])[0];let n=[];return e.tokens&&e.tokens.length>0&&e.tokens.forEach(e=>{if(e.type===`paragraph`||e.type===`list`||e.type===`blockquote`||e.type===`code`)n.push(...t.parseChildren([e]));else if(e.type===`text`&&e.tokens){let r=t.parseChildren([e]);n.push({type:`paragraph`,content:r})}else{let r=t.parseChildren([e]);r.length>0&&n.push(...r)}}),{type:`listItem`,content:n}})}var xk=64;function Sk(e,t){let n=[],r=0;for(;n.length<t;){let t=e.indexOf(`
`,r);if(t===-1)return n.push(e.slice(r)),n;n.push(e.slice(r,t)),r=t+1}return n}function Ck(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!lk.test(n))return[[],0,[]];let r=xk,i=Sk(e,r),a=gk(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=Sk(e,r),a=gk(i);return[a[0],a[1],i]}var wk=`listItem`,Tk=`textStyle`,Ek=/^(\d+)\.\s$/;function Dk(e){let t=e.match(/list-style-type\s*:\s*([^;]+)/i);if(!t)return null;switch(t[1].trim().toLowerCase()){case`upper-roman`:return`I`;case`lower-roman`:return`i`;case`upper-alpha`:case`upper-latin`:return`A`;case`lower-alpha`:case`lower-latin`:return`a`;default:return null}}var Ok=Jp.create({name:`orderedList`,addOptions(){return{itemTypeName:`listItem`,HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:`block list`,content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:e=>e.hasAttribute(`start`)?parseInt(e.getAttribute(`start`)||``,10):1},type:{default:null,parseHTML:e=>{let t=e.getAttribute(`type`);if(t)return t;let n=e.getAttribute(`style`);if(n){let e=Dk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=Dk(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=A(this.options.HTMLAttributes,r);return t!==1&&(i.start=t),n&&n!==`1`&&(i.type=n),[`ol`,i,0]},markdownTokenName:`list`,parseMarkdown:(e,t)=>{if(e.type!==`list`||!e.ordered)return[];let n=e.start||1,r=e.typeMarker,i=e.items?bk(e.items,t):[],a={};return n!==1&&(a.start=n),r&&(a.type=r),Object.keys(a).length>0?{type:`orderedList`,attrs:a,content:i}:{type:`orderedList`,content:i}},renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``,markdownTokenizer:{name:`orderedList`,level:`block`,start:()=>-1,tokenize:(e,t,n)=>{let[r,i,a]=Ck(e);if(r.length===0)return;let o=yk(r,r[0].indent,n);if(o.length!==0)return{type:`list`,ordered:!0,start:r[0]?.number||1,typeMarker:r[0]?.type,items:o,raw:a.slice(0,i).join(`
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(wk,this.editor.getAttributes(Tk)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new E({props:{handlePaste:(e,t)=>{if((t.clipboardData?.getData(`text/html`))?.trim())return!1;let n=t.clipboardData?.getData(`text/plain`);if(!n)return!1;let r=vk(n);if(!r)return!1;try{let t=e.state.schema.nodeFromJSON(r),n=e.state.tr.replaceSelectionWith(t);return e.dispatch(n),!0}catch{return!1}}}})]},addInputRules(){let e=(e,t)=>(!t.attrs.type||t.attrs.type===`1`)&&t.childCount+t.attrs.start===+e[1],t=Gp({find:Ek,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gp({find:Ek,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Tk)}),joinPredicate:e,editor:this.editor})),[t]}}),kk=/^\s*(\[([( |x])?\])\s$/,Ak=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,jk=(e,t,n)=>{var r;return(n==null||(r=n.checkboxLabel)==null?void 0:r.call(n,e,t))||`Task item checkbox for ${e.textContent||`empty task item`}`},Mk=Jp.create({name:`taskItem`,addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:`taskList`,a11y:void 0}},content(){return this.options.nested?`paragraph block*`:`paragraph+`},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:e=>{let t=e.getAttribute(`data-checked`);return t===``||t===`true`},renderHTML:e=>({"data-checked":e.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51,contentElement:e=>e.querySelector(`div`)??e}]},renderHTML({node:e,HTMLAttributes:t}){return[`li`,A(this.options.HTMLAttributes,t,{"data-type":this.name}),[`label`,[`input`,{type:`checkbox`,checked:e.attrs.checked?`checked`:null}],[`span`]],[`div`,0]]},parseMarkdown:(e,t)=>{let n=[];if(e.tokens&&e.tokens.length>0?n.push(t.createNode(`paragraph`,{},t.parseInline(e.tokens))):e.text?n.push(t.createNode(`paragraph`,{},[t.createNode(`text`,{text:e.text})])):n.push(t.createNode(`paragraph`,{},[])),e.nestedTokens&&e.nestedTokens.length>0){let r=t.parseChildren(e.nestedTokens);n.push(...r)}return t.createNode(`taskItem`,{checked:e.checked||!1},n)},renderMarkdown:(e,t)=>op(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[kO(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){let e={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...e,Tab:()=>this.editor.commands.sinkListItem(this.name)}:e},addNodeView(){return({node:e,HTMLAttributes:t,getPos:n,editor:r})=>{let i=document.createElement(`li`),a=document.createElement(`label`),o=document.createElement(`span`),s=document.createElement(`input`),c=document.createElement(`div`);o.style.cssText=Ak;let l=e=>{let t=jk(e,e.attrs.checked,this.options.a11y);s.setAttribute(`aria-label`,t),o.textContent=t};l(e),a.contentEditable=`false`,s.type=`checkbox`,s.addEventListener(`mousedown`,e=>e.preventDefault()),s.addEventListener(`change`,t=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){s.checked=!s.checked;return}let{checked:i}=t.target;r.isEditable&&typeof n==`function`&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:e})=>{let t=n();if(typeof t!=`number`)return!1;let r=e.doc.nodeAt(t);return e.setNodeMarkup(t,void 0,{...r?.attrs,checked:i}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(e,i)||(s.checked=!s.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([e,t])=>{i.setAttribute(e,t)}),i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,a.append(s,o),i.append(a,c),Object.entries(t).forEach(([e,t])=>{i.setAttribute(e,t)});let u=new Set(Object.keys(t));return{dom:i,contentDOM:c,update:e=>{if(e.type!==this.type)return!1;i.dataset.checked=e.attrs.checked,s.checked=e.attrs.checked,l(e);let t=r.extensionManager.attributes,n=Lu(e,t),a=new Set(Object.keys(n)),o=this.options.HTMLAttributes;return u.forEach(e=>{a.has(e)||(e in o?i.setAttribute(e,o[e]):i.removeAttribute(e))}),Object.entries(n).forEach(([e,t])=>{t==null?e in o?i.setAttribute(e,o[e]):i.removeAttribute(e):i.setAttribute(e,t)}),u=a,!0}}}},addInputRules(){return[Gp({find:kk,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),Nk=Jp.create({name:`taskList`,addOptions(){return{itemTypeName:`taskItem`,HTMLAttributes:{}}},group:`block list`,content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`uLine truncated
`):``,markdownTokenizer:{name:`taskList`,level:`block`,start(e){let t=e.match(/^\s*[-+*]\s+\[([ xX])\]\s+/)?.index;return t===void 0?-1:t},tokenize(e,t,n){let r=e=>{let t=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(t){let r={type:`taskList`,raw:t.raw,items:t.items},i=e.slice(t.raw.length);return i.trim()?[r,...n.blockTokens(i)]:[r]}return n.blockTokens(e)},i=rp(e,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:e=>({indentLevel:e[1].length,mainContent:e[4],checked:e[3].toLowerCase()===`x`}),createToken:(e,t)=>({type:`taskItem`,raw:``,mainContent:e.mainContent,indentLevel:e.indentLevel,checked:e.checked,text:e.mainContent,tokens:n.inlineTokens(e.mainContent),nestedTokens:t}),customNestedParser:r},n);if(i)return{type:`taskList`,raw:i.raw,items:i.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:e})=>e.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});Tp.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(TO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push($O.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(ck.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(Ok.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(Mk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(Nk.configure(this.options.taskList)),e}});var Pk=`&nbsp;`,Fk=`\xA0`,Ik=Jp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,A(this.options.HTMLAttributes,e),0]},parseMarkdown:(e,t)=>{let n=e.tokens||[];if(n.length===1&&n[0].type===`image`)return t.parseChildren([n[0]]);let r=t.parseInline(n);return n.length===1&&n[0].type===`text`&&(n[0].raw===Pk||n[0].text===Pk||n[0].raw===Fk||n[0].text===Fk)&&r.length===1&&r[0].type===`text`&&(r[0].text===Pk||r[0].text===Fk)?t.createNode(`paragraph`,void 0,[]):t.createNode(`paragraph`,void 0,r)},renderMarkdown:(e,t,n)=>{if(!e)return``;let r=Array.isArray(e.content)?e.content:[];if(r.length===0){var i,a;let e=Array.isArray(n==null||(i=n.previousNode)==null?void 0:i.content)?n.previousNode.content:[];return(n==null||(a=n.previousNode)==null?void 0:a.type)===`paragraph`&&e.length===0?Pk:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Lk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Rk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,zk=_p.create({name:`strike`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`s`},{tag:`del`},{tag:`strike`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`line-through`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`s`,A(this.options.HTMLAttributes,e),0]},markdownTokenName:`del`,parseMarkdown:(e,t)=>t.applyMark(`strike`,t.parseInline(e.tokens||[])),renderMarkdown:(e,t)=>`~~${t.renderChildren(e)}~~`,addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Hp({find:Lk,type:this.type})]},addPasteRules(){return[Yp({find:Rk,type:this.type})]}}),Bk=Jp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),Vk=_p.create({name:`underline`,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:`u`},{style:`text-decoration`,consuming:!1,getAttrs:e=>e.includes(`underline`)?{}:!1}]},renderHTML({HTMLAttributes:e}){return[`u`,A(this.options.HTMLAttributes,e),0]},parseMarkdown(e,t){return t.applyMark(this.name||`underline`,t.parseInline(e.tokens||[]))},renderMarkdown(e,t){return`<u>${t.renderChildren(e)}</u>`},markdownTokenizer:{name:`underline`,level:`inline`,start(e){return e.toLowerCase().indexOf(`<u>`)},tokenize(e,t,n){if(!/^<u>/i.test(e))return;let r=/\\[\s\S]|`+|<\/u>/gi;r.lastIndex=3;let i=r.exec(e);for(;i;){if(i[0].startsWith("`")){let t=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/.exec(e.slice(i.index));t&&(r.lastIndex=i.index+t[0].length)}else if(!i[0].startsWith(`\\`)){let t=e.slice(3,i.index);return t?{type:`underline`,raw:e.slice(0,r.lastIndex),text:t,tokens:n.inlineTokens(t)}:void 0}i=r.exec(e)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleLine truncated
`).length:0;c!==o&&(o=c,i.textContent=Array.from({length:c},(e,t)=>t+1).join(`
`))};return s(n),{dom:r,contentDOM:a,update:e=>e.type===n.type&&(s(e),!0),ignoreMutation:e=>i.contains(e.target)}}}}),jj=(e,t)=>e===`application/pdf`||typeof t==`string`&&/\.pdf$/i.test(t);function Mj(e,t,n,r){let i=!1,a=null,o=null,s=document.createElement(`div`);return s.className=`dw-pdf__status`,s.textContent=r.blocks.pdfLoading,e.replaceChildren(s),(async()=>{try{let c=await n();if(i)return;o=c.getDocument({url:t});let l=await o.promise;if(i)return;s.remove();let u=Math.max(e.clientWidth-2,200),d=window.devicePixelRatio||1;a=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;let e=t.target;a?.unobserve(e),p(e,Number(e.dataset.page))}},{root:e,rootMargin:`400px 0px`});let f=(await l.getPage(1)).getViewport({scale:1});for(let t=1;t<=l.numPages;t++){let n=document.createElement(`div`);n.className=`dw-pdf__page`,n.dataset.page=String(t),n.style.aspectRatio=`${f.width} / ${f.height}`,n.setAttribute(`aria-label`,r.blocks.pdfPage.replace(`{n}`,String(t))),e.append(n),a.observe(n)}async function p(e,t){let n=await l.getPage(t);if(i)return;let r=u/n.getViewport({scale:1}).width,a=n.getViewport({scale:r*d}),o=document.createElement(`canvas`);o.width=Math.floor(a.width),o.height=Math.floor(a.height),e.style.aspectRatio=`${a.width} / ${a.height}`,e.append(o),await n.render({canvas:o,viewport:a}).promise}}catch{i||(s.textContent=r.blocks.loadFailed)}})(),()=>{i=!0,a?.disconnect(),o?.destroy()}}var Nj={page:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`,`M9 12h6`,`M9 16h6`],"chevron-right":[`M10 6l6 6-6 6`],"chevron-down":[`M6 10l6 6 6-6`],"chevron-up":[`M6 14l6-6 6 6`],plus:[`M12 5v14`,`M5 12h14`],search:[`M11 4a7 7 0 1 0 0 14a7 7 0 1 0 0-14z`,`M16.5 16.5L20 20`],more:[`M6 12h.01`,`M12 12h.01`,`M18 12h.01`],drop:[`M12 4h7v7a7 7 0 1 1-7-7z`],info:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 11v5`,`M12 8h.01`],check:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8 12.5l2.5 2.5L16 9.5`],alert:[`M12 4l9 16H3z`,`M12 10v4`,`M12 17h.01`],error:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M9 9l6 6`,`M15 9l-6 6`],text:[`M5 6h14`,`M12 6v13`],heading:[`M6 5v14`,`M18 5v14`,`M6 12h12`],list:[`M9 6h11`,`M9 12h11`,`M9 18h11`,`M4.5 6h.01`,`M4.5 12h.01`,`M4.5 18h.01`],todo:[`M4 4h7v7H4z`,`M5.5 7.5l1.5 1.5 2.5-2.5`,`M14 7h6`,`M4 14h7v7H4z`,`M14 17h6`],code:[`M9 7l-5 5 5 5`,`M15 7l5 5-5 5`],quote:[`M6 6v12`,`M10 8h9`,`M10 12h9`,`M10 16h6`],image:[`M4 5h16v14H4z`,`M4 16l5-5 4 4 2-2 5 5`,`M15.5 8.5h.01`],table:[`M4 5h16v14H4z`,`M4 10h16`,`M4 15h16`,`M10 5v14`],lock:[`M6 11h12v9H6z`,`M8.5 11V8a3.5 3.5 0 0 1 7 0v3`],trash:[`M4 7h16`,`M10 4h4`,`M6 7l1 13h10l1-13`,`M10 11v6`,`M14 11v6`],settings:[`M4 7h9`,`M17 7h3`,`M15 5v4`,`M4 17h3`,`M11 17h9`,`M9 15v4`],menu:[`M4 7h16`,`M4 12h16`,`M4 17h16`],close:[`M6 6l12 12`,`M18 6L6 18`],open:[`M8 16L16 8`,`M9 8h7v7`],restore:[`M4.5 13a7.5 7.5 0 1 0 2.2-6.3`,`M5 4v4h4`],"sign-out":[`M14 4h5v16h-5`,`M10 8l-4 4 4 4`,`M6 12h9`],sidebar:[`M4 5h16v14H4z`,`M9.5 5v14`],home:[`M4 11l8-7 8 7`,`M6 9.5V20h12V9.5`,`M10 20v-5h4v5`],sun:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M12 3v1.5`,`M12 19.5V21`,`M3 12h1.5`,`M19.5 12H21`,`M5.6 5.6l1.1 1.1`,`M17.3 17.3l1.1 1.1`,`M5.6 18.4l1.1-1.1`,`M17.3 6.7l1.1-1.1`],moon:[`M19.5 14.5A8 8 0 0 1 9.5 4.5a8 8 0 1 0 10 10z`],monitor:[`M4 5h16v11H4z`,`M9 20h6`,`M12 16v4`],selector:[`M8 9l4-4 4 4`,`M8 15l4 4 4-4`],star:[`M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.9l-4.9 2.6.9-5.6-4-3.9 5.5-.8z`],clock:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M12 7v5l3 2`],calendar:[`M5 5h14a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z`,`M4 10h16`,`M8 3v4`,`M16 3v4`],share:[`M12 4v11`,`M8 8l4-4 4 4`,`M6 13v7h12v-7`],link:[`M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1`,`M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1`],upload:[`M12 16V4`,`M7 9l5-5 5 5`,`M4 20h16`],download:[`M12 4v12`,`M7 11l5 5 5-5`,`M4 20h16`],file:[`M6 3h8l4 4v14H6z`,`M14 3v4h4`],paperclip:[`M18 11.5l-6.4 6.4a4.2 4.2 0 0 1-6-6l7-7a2.8 2.8 0 0 1 4 4l-7 7a1.4 1.4 0 0 1-2-2l6.4-6.4`],comment:[`M5 5h14v10H9l-4 4z`],at:[`M12 8a4 4 0 1 0 0 8a4 4 0 1 0 0-8z`,`M16 12v1.5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.5 7.1`],bold:[`M7 5h6a3.5 3.5 0 0 1 0 7H7z`,`M7 12h7a3.5 3.5 0 0 1 0 7H7z`],italic:[`M10 5h8`,`M6 19h8`,`M14 5l-4 14`],strike:[`M5 12h14`,`M16 7.5A3.5 3 0 0 0 12.5 5h-1A3.5 3 0 0 0 8 8c0 4 8 3 8 7.5a3.5 3.5 0 0 1-3.5 3.5h-1A3.5 3 0 0 1 8 16.5`],underline:[`M7 4v7a5 5 0 0 0 10 0V4`,`M5 20h14`],"list-ordered":[`M10 6h10`,`M10 12h10`,`M10 18h10`,`M4 5l1.5-1v5`,`M4 15.5a1.5 1.5 0 0 1 3 .5L4 19h3`],divider:[`M4 12h16`],globe:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M3 12h18`,`M12 3c2.5 2.5 3.5 5.5 3.5 9s-1 6.5-3.5 9`,`M12 3C9.5 5.5 8.5 8.5 8.5 12s1 6.5 3.5 9`],bell:[`M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15z`,`M10 20a2 2 0 0 0 4 0`],"bell-off":[`M6 16V11a6 6 0 0 1 9.5-4.9`,`M18 11v5l1.5 2H8`,`M10 20a2 2 0 0 0 4 0`,`M4 4l16 16`],smile:[`M12 3a9 9 0 1 0 0 18a9 9 0 1 0 0-18z`,`M8.5 14a4 4 0 0 0 7 0`,`M9 9.5h.01`,`M15 9.5h.01`],reply:[`M9 7L4 12l5 5`,`M4 12h10a6 6 0 0 1 6 6v1`],pencil:[`M15 5l4 4L8 20H4v-4z`],sigma:[`M18 6V4H6l6 8lLine truncated
`).map(e=>!e.includes(`|`)||!e.includes("`")?e:aP(e)).join(`
`)}function sP(e){return(e||``).replaceAll(``,` `).replace(/\s+/g,` `).trim()}function cP(e,t){return t?e.split(t).join(`
`):e}function lP(e){return e.replace(/\\.|\|/g,e=>e===`|`?`\\|`:e)}function uP(e,t,n={}){if(!e||!e.content||e.content.length===0)return``;let r=[];e.content.forEach(e=>{let i=[];e.content&&e.content.forEach(e=>{let r=``;r=e.content&&Array.isArray(e.content)&&e.content.length>1?e.content.map(e=>cP(t.renderChildren(e),n.cellLineSeparator)).join(`
`):cP(e.content?t.renderChildren(e.content):``,n.cellLineSeparator);let a=lP(sP(r.replace(/[ \t]*\r?\n[ \t]*/g,`<br>`))),o=e.type===`tableHeader`,s=RN(e.attrs);i.push({text:a,isHeader:o,align:s})}),r.push(i)});let i=r.reduce((e,t)=>Math.max(e,t.length),0);if(i===0)return``;let a=Array.from({length:i}).fill(0);r.forEach(e=>{for(let t=0;t<i;t+=1){let n=(e[t]?.text||``).length;n>a[t]&&(a[t]=n),a[t]<3&&(a[t]=3)}});let o=(e,t)=>e+` `.repeat(Math.max(0,t-e.length)),s=r[0],c=s.some(e=>e.isHeader),l=Array.from({length:i}).fill(null);r.forEach(e=>{for(let t=0;t<i;t+=1)!l[t]&&e[t]?.align&&(l[t]=e[t].align)});let u=`
`,d=Array.from({length:i}).map((e,t)=>c&&s[t]&&s[t].text||``);return u+=`| ${d.map((e,t)=>o(e,a[t])).join(` | `)} |\n`,u+=`| ${a.map((e,t)=>{let n=Math.max(3,e),r=l[t];return r===`left`?`:${`-`.repeat(n)}`:r===`right`?`${`-`.repeat(n)}:`:r===`center`?`:${`-`.repeat(n)}:`:`-`.repeat(n)}).join(` | `)} |\n`,(c?r.slice(1):r).forEach(e=>{u+=`| ${Array.from({length:i}).fill(0).map((t,n)=>o(e[n]&&e[n].text||``,a[n])).join(` | `)} |\n`}),u}var dP=new D(`preserveCellSelectionOnContextMenu`);function fP(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});if(n)return n.pos;if(!(t.target instanceof Node))return null;try{return e.posAtDOM(t.target,0)}catch{return null}}function pP(e,t){let n=!1;return e.forEachCell((e,r)=>{t>=r&&t<r+e.nodeSize&&(n=!0)}),n}function mP(){return new E({key:dP,props:{handleDOMEvents:{mousedown(e,t){if(t.button!==2)return!1;let{selection:n}=e.state;if(!nP(n)||n.ranges.length<2)return!1;let r=fP(e,t);return r==null||!pP(n,r)?!1:(t.preventDefault(),!0)}}}})}var hP=Jp.create({name:`table`,addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:ZN,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:`tableRow+`,tableRole:`table`,isolating:!0,group:`block`,parseHTML(){return[{tag:`table`}]},renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:r,tableMinWidth:i}=QN(e,this.options.cellMinWidth),a=t.style;function o(){return a||(r?`width: ${r}`:`min-width: ${i}`)}let s=[`table`,A(this.options.HTMLAttributes,t,{style:o()}),n,[`tbody`,0]];return this.options.renderWrapper?[`div`,{class:`tableWrapper`},s]:s},parseMarkdown:(e,t)=>{let n=[],r=Array.isArray(e.align)?e.align:[];if(e.header){let i=[];e.header.forEach((e,n)=>{let a=IN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableHeader`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}return e.rows&&e.rows.forEach(e=>{let i=[];e.forEach((e,n)=>{let a=IN(r[n]??e.align),o=a?{align:a}:{};i.push(t.createNode(`tableCell`,o,[{type:`paragraph`,content:t.parseInline(e.tokens)}]))}),n.push(t.createNode(`tableRow`,{},i))}),t.createNode(`table`,void 0,n)},renderMarkdown:(e,t)=>uP(e,t),markdownTokenizer:{name:`table`,level:`block`,start:e=>{let t=e.split(`
`);if(t.length<2)return-1;let n=t[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes(`|`)?-1:t[0].includes(`|`)?0:-1},tokenize(e,t,n){let r=e.indexOf(`
`),i=r>=0?e.slice(0,r):e,a=i.split(`
`);if(a.length<2)return;let o=a[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes(`|`))return;let s=oP(i);if(s===i)return;let c=n.blockTokens(s)[0];if(c?.type!==`table`||!c.raw)return;let l=c.raw.split(`
`).length,u=e.split(`
`).slice(0,l).join(`
`);return{...c,raw:u}}},addCommands(){return{insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:a})=>{let o=tP(a.schema,e,t,n);if(i){let e=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(w.near(r.doc.resolve(e)))}return!0},addColumnBefore:()=>({state:e,dispatch:t})=>AM(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>jM(e,t),deleteColumn:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return NM(e,t&&(e=>{n&&iP(e,n.pos),t(e)}))},addRowBefore:()=>({state:e,dispatch:t})=>IM(e,t),addRowAfter:()=>({state:e,dispatch:t})=>LM(e,t),deleteRow:()=>({state:e,dispatch:t})=>{let n=vu(e.selection.$from,e=>e.type.name===`table`);return zM(e,t&&(e=>{n&&iP(e,n.pos),t(e)}))},deleteTable:()=>({state:e,dispatch:t})=>QM(e,t),mergeCells:()=>({state:e,dispatch:t})=>HM(e,t),splitCell:()=>({state:e,dispatch:t})=>UM(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>JM(`column`)(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>JM(`row`)(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>YM(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>HM(e,t)?!0:UM(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:r})=>GM(e,t)(n,r),goToNextCell:()=>({state:e,dispatch:t})=>ZM(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>ZM(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&EM(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=vM.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:rP,"Mod-Backspace":rP,Delete:rP,"Mod-Delete":rP}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[xN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:null,lastColumnResizable:this.options.lastColumnResizable})]:[],FN({allowTableNodeSelection:this.options.allowTableNodeSelection}),mP()]},addNodeView(){let e=this.options.View;return e?({node:t,view:n,HTMLAttributes:r})=>{let i=A(this.options.HTMLAttributes,r);return new e(t,this.options.cellMinWidth,n,i)}:null},extendNodeSchema(e){return{tableRole:Nu(k(e,`tableRole`,{name:e.name,options:e.options,storage:e.storage}))}}}),gP=Tp.create({name:`tableKit`,addExtensions(){let e=[];return this.options.table!==!1&&e.push(hP.configure(this.options.table)),this.options.tableCell!==!1&&e.push(KN.configure(this.options.tableCell)),this.options.tableHeader!==!1&&e.push(qN.configure(this.options.tableHeader)),this.options.tableRow!==!1&&e.push(JN.configure(this.options.tableRow)),e}}),_P=Tp.create({name:`textAlign`,addOptions(){return{types:[],alignments:[`left`,`center`,`right`,`justify`],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>{let t=e.style.textAlign;return this.options.alignments.includes(t)?t:this.options.defaultAlignment},renderHTML:e=>!Pf(e.textAlign)||!this.options.alignments.includes(e.textAlign)?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.map(n=>t.updateAttributes(n,{textAlign:e})).some(e=>e):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.map(t=>e.resetAttributes(t,`textAlign`)).some(e=>e),toggleTextAlign:e=>({editor:t,commands:n})=>this.options.alignments.includes(e)?t.isActive({textAlign:e})?n.unsetTextAlign():n.setTextAlign(e):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign(`left`),"Mod-Shift-e":()=>this.editor.commands.setTextAlign(`center`),"Mod-Shift-r":()=>this.editor.commands.setTextAlign(`right`),"Mod-Shift-j":()=>this.editor.commands.setTextAlign(`justify`)}}});function vP(){return[Nk.configure({HTMLAttributes:{class:`dw-tasks`}}),Mk.configure({nested:!0})]}function yP(){return[gP.configure({table:{resizable:!0,cellMinWidth:60,HTMLAttributes:{class:`dw-table`}}})]}var bP=_P.configure({types:[`heading`,`paragraph`],alignments:[`left`,`center`,`right`]}),xP=Tp.create({name:`headingShortcuts`,addKeyboardShortcuts(){let e={"Mod-Shift-0":()=>this.editor.commands.setParagraph()};for(let t of[1,2,3,4,5,6])e[`Mod-Shift-${t}`]=()=>this.editor.commands.toggleHeading({level:t});return e}}),SP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,CP=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,wP=_p.create({name:`highlight`,addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute(`data-color`)||Af(e,`background-color`)||e.style.backgroundColor,renderHTML:e=>Pf(e.color)?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:`mark`}]},renderHTML({HTMLAttributes:e}){retuLine truncated
`).length+1)));let r=document.createElement(`div`);r.className=`dw-source__actions`;let i=(e,t,n)=>{let r=document.createElement(`button`);return r.type=`button`,r.className=`dw-source__btn ${t}`,r.textContent=e,r.addEventListener(`mousedown`,e=>e.preventDefault()),r.addEventListener(`click`,n),r};e.onRemove&&r.append(i(e.labels.remove,`dw-source__btn--danger`,()=>{u(!0),e.onRemove()}));let a=document.createElement(`span`);a.style.flex=`1`,r.append(a,i(e.labels.cancel,``,()=>u()),i(e.labels.done,`dw-source__btn--primary`,()=>o())),t.append(n,r),document.body.append(t);let o=()=>{let t=n.value;u(!0),e.onSave(t)};n.addEventListener(`input`,()=>e.onInput?.(n.value)),n.addEventListener(`keydown`,t=>{let n=t;n.key===`Escape`?(n.preventDefault(),u()):n.key===`Enter`&&(n.ctrlKey||n.metaKey||!e.multiline)&&(n.preventDefault(),o()),n.stopPropagation()});let s=n=>{!t.contains(n.target)&&!e.anchor.contains(n.target)&&u()};setTimeout(()=>document.addEventListener(`mousedown`,s),0);let c=wj(e.anchor,t,()=>{Oj(e.anchor,t,{placement:`bottom-start`,middleware:[Tj(6),Dj(),Ej({padding:8})]}).then(({x:e,y:n})=>Object.assign(t.style,{left:`${e}px`,top:`${n}px`}))}),l=!1;function u(n=!1){l||(l=!0,c(),document.removeEventListener(`mousedown`,s),t.remove(),sF===d&&(sF=null),n||e.onCancel?.())}let d=()=>u();return sF=d,n.focus(),e.multiline||n.select(),d}var lF=[{pattern:/^https:\/\/(?:www\.|m\.)?youtube\.com\/(?:watch\?(?:.*&)?v=|shorts\/|embed\/|live\/)([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/youtu\.be\/([\w-]{11})/,src:e=>`https://www.youtube-nocookie.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?vimeo\.com\/(?:video\/)?(\d+)/,src:e=>`https://player.vimeo.com/video/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/([\da-f]{32})/,src:e=>`https://www.loom.com/embed/${e[1]}`},{pattern:/^https:\/\/(?:www\.)?figma\.com\/(?:file|design|proto|board|slides)\/[\w-]+/,src:(e,t)=>`https://www.figma.com/embed?embed_host=docwell&url=${encodeURIComponent(t.href)}`},{pattern:/^https:\/\/codepen\.io\/([\w-]+)\/(?:pen|embed)\/([\w-]+)/,src:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{pattern:/^https:\/\/open\.spotify\.com\/(?:embed\/)?(track|album|playlist|episode|show)\/(\w+)/,src:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`,ratio:`audio`},{pattern:/^https:\/\/docs\.google\.com\/(document|spreadsheets|presentation)\/d\/([\w-]+)/,src:e=>`https://docs.google.com/${e[1]}/d/${e[2]}/preview`,ratio:`tall`},{pattern:/^https:\/\/(?:www\.)?google\.com\/maps\/embed\?/,src:(e,t)=>t.href}];function uF(e){let t;try{t=new URL(e.trim())}catch{return null}for(let e of lF){let n=e.pattern.exec(t.href);if(n)return{src:e.src(n,t),ratio:e.ratio??`video`}}return null}function dF(e){try{let t=new URL(e.trim());return t.protocol===`https:`||t.protocol===`http:`?t.href:``}catch{return``}}var fF=e=>{try{return new URL(e).hostname.replace(/^www\./,``)}catch{return e}};function pF(e,t,n){let{node:r}=e.view.domAtPos(e.state.selection.from),i=r instanceof HTMLElement?r:r.parentElement??e.view.dom;return new Promise(e=>{let r=t.blocks;cF({anchor:i,value:`https://`,label:n,labels:{done:r.done,cancel:r.cancel,remove:r.remove},onSave:t=>e(dF(t)),onCancel:()=>e(``)})})}async function mF(e,t,n,r){let i=await pF(e,t,t.blocks.embedUrl);i&&(uF(i)?e.chain().focus().insertEmbed(i).run():await gF(e,i,n,r))}async function hF(e,t,n,r){let i=await pF(e,t,t.blocks.linkUrl);i&&await gF(e,i,n,r)}async function gF(e,t,n,r){let i={url:t};if(n)try{i={...await n.preview(t),url:t}}catch(e){r?.(e)}e.chain().focus().insertLinkCard(i).run()}var _F=Jp.create({name:`embed`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null}},addAttributes(){return{url:{default:``,parseHTML:e=>e.getAttribute(`data-url`)??``,renderHTML:e=>({"data-url":e.url})}}},parseHTML(){return[{tag:`div[data-type='embed']`}]},renderHTML({node:e,HTMLAttributes:t}){let n=dF(String(e.attrs.url));return[`div`,A(t,{"data-type":`embed`}),[`a`,{href:n},n]]},addCommands(){return{insertEmbed:e=>({commands:t})=>t.insertContent({type:this.name,attrs:{url:e}})}},addNodeView(){return({node:e})=>{let t=this.options.labels.blocks,n=document.createElement(`figure`);n.className=`dw-embed`,n.setAttribute(`data-type`,`embed`),n.contentEditable=`false`;let r=e=>{let r=dF(e),i=uF(r);if(n.replaceChildren(),!i){let e=document.createElement(`a`);e.href=r,e.target=`_blank`,e.rel=`noopener noreferrer`,e.textContent=r||t.embedInvalid,n.append(e);return}n.dataset.ratio=i.ratio;let a=document.createElement(`iframe`);a.className=`dw-embed__frame`,a.src=i.src,a.title=`${t.embed}: ${fF(r)}`,a.loading=`lazy`,a.allow=`fullscreen; picture-in-picture; encrypted-media; clipboard-write`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-popups allow-presentation`);let o=document.createElement(`figcaption`);o.className=`dw-embed__caption`;let s=document.createElement(`a`);s.href=r,s.targeLine truncated
c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
@@ -156,7 +170,7 @@ c5.3,-9.3,12,-14,20,-14
H400000v`+(40+e)+`H845.2724
s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},$M=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
M`+(834+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},_I=function(e,t){return`M263,`+(601+e+t)+`c0.7,0,18,39.7,52,119
c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
c340,-704.7,510.7,-1060.3,512,-1067
l`+e/2.084+` -`+e+`
@@ -166,7 +180,7 @@ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,
c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},eN=function(e,t){return`M983 `+(10+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},vI=function(e,t){return`M983 `+(10+e+t)+`
l`+e/3.13+` -`+e+`
c4,-6.7,10,-10,18,-10 H400000v`+(40+e)+`
H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
@@ -175,7 +189,7 @@ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
c53.7,-170.3,84.5,-266.8,92.5,-289.5z
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},tN=function(e,t){return`M424,`+(2398+e+t)+`
M`+(1001+e)+` `+t+`h400000v`+(40+e)+`h-400000z`},yI=function(e,t){return`M424,`+(2398+e+t)+`
c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
@@ -185,18 +199,18 @@ v`+(40+e)+`H1014.6
s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
c-2,6,-10,9,-24,9
c-8,0,-12,-0.7,-12,-2z M`+(1001+e)+` `+t+`
h400000v`+(40+e)+`h-400000z`},nN=function(e,t){return`M473,`+(2713+e+t)+`
h400000v`+(40+e)+`h-400000z`},bI=function(e,t){return`M473,`+(2713+e+t)+`
c339.3,-1799.3,509.3,-2700,510,-2702 l`+e/5.298+` -`+e+`
c3.3,-7.3,9.3,-11,18,-11 H400000v`+(40+e)+`H1017.7
s-90.5,478,-276.2,1466c-185.7,988,-279.5,1483,-281.5,1485c-2,6,-10,9,-24,9
c-8,0,-12,-0.7,-12,-2c0,-1.3,-5.3,-32,-16,-92c-50.7,-293.3,-119.7,-693.3,-207,-1200
c0,-1.3,-5.3,8.7,-16,30c-10.7,21.3,-21.3,42.7,-32,64s-16,33,-16,33s-26,-26,-26,-26
s76,-153,76,-153s77,-151,77,-151c0.7,0.7,35.7,202,105,604c67.3,400.7,102,602.7,104,
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},rN=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},iN=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
606zM`+(1001+e)+` `+t+`h400000v`+(40+e)+`H1017.7z`},xI=function(e){var t=e/2;return`M400000 `+e+` H0 L`+t+` 0 l65 45 L145 `+(e-80)+` H400000z`},SI=function(e,t,n){var r=n-54-t-e;return`M702 `+(e+t)+`H400000`+(40+e)+`
H742v`+r+`l-4 4-4 4c-.667.7 -2 1.5-4 2.5s-4.167 1.833-6.5 2.5-5.5 1-9.5 1
h-12l-28-84c-16.667-52-96.667 -294.333-240-727l-212 -643 -85 170
c-4-3.333-8.333-7.667-13 -13l-13-13l77-155 77-156c66 199.333 139 419.667
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},aN=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=QM(t,ZM);break;case`sqrtSize1`:r=$M(t,ZM);break;case`sqrtSize2`:r=eN(t,ZM);break;case`sqrtSize3`:r=tN(t,ZM);break;case`sqrtSize4`:r=nN(t,ZM);break;case`sqrtTall`:r=iN(t,ZM,n)}return r},oN=function(e,t){switch(e){case`⎜`:return XM(`M291 0 H417 V`+t+` H291z`);case`∣`:return XM(`M145 0 H188 V`+t+` H145z`);case`∥`:return XM(`M145 0 H188 V`+t+` H145z`)+XM(`M367 0 H410 V`+t+` H367z`);case`⎟`:return XM(`M457 0 H583 V`+t+` H457z`);case`⎢`:return XM(`M319 0 H403 V`+t+` H319z`);case`⎥`:return XM(`M263 0 H347 V`+t+` H263z`);case`⎪`:return XM(`M384 0 H504 V`+t+` H384z`);case`⏐`:return XM(`M312 0 H355 V`+t+` H312z`);case`‖`:return XM(`M257 0 H300 V`+t+` H257z`)+XM(`M478 0 H521 V`+t+` H478z`);default:return``}},sN={doubleleftarrow:`M262 157
219 661 l218 661zM702 `+t+`H400000v`+(40+e)+`H742z`},CI=function(e,t,n){t=1e3*t;var r=``;switch(e){case`sqrtMain`:r=gI(t,hI);break;case`sqrtSize1`:r=_I(t,hI);break;case`sqrtSize2`:r=vI(t,hI);break;case`sqrtSize3`:r=yI(t,hI);break;case`sqrtSize4`:r=bI(t,hI);break;case`sqrtTall`:r=SI(t,hI,n)}return r},wI=function(e,t){switch(e){case`⎜`:return mI(`M291 0 H417 V`+t+` H291z`);case`∣`:return mI(`M145 0 H188 V`+t+` H145z`);case`∥`:return mI(`M145 0 H188 V`+t+` H145z`)+mI(`M367 0 H410 V`+t+` H367z`);case`⎟`:return mI(`M457 0 H583 V`+t+` H457z`);case`⎢`:return mI(`M319 0 H403 V`+t+` H319z`);case`⎥`:return mI(`M263 0 H347 V`+t+` H263z`);case`⎪`:return mI(`M384 0 H504 V`+t+` H384z`);case`⏐`:return mI(`M312 0 H355 V`+t+` H312z`);case`‖`:return mI(`M257 0 H300 V`+t+` H257z`)+mI(`M478 0 H521 V`+t+` H478z`);default:return``}},TI={doubleleftarrow:`M262 157
l10-10c34-36 62.7-77 86-123 3.3-8 5-13.3 5-16 0-5.3-6.7-8-20-8-7.3
0-12.2.5-14.5 1.5-2.3 1-4.8 4.5-7.5 10.5-49.3 97.3-121.7 169.3-217 216-28
14-57.3 25-88 33-6.7 2-11 3.8-13 5.5-2 1.7-3 4.2-3 7.5s1 5.8 3 7.5
@@ -242,10 +256,10 @@ m0 0v40h400000v-40z`,leftharpoondown:`M7 241c-4 4-6.333 8.667-7 14 0 5.333.667 9
v40h399900v-40zM0 241v40h399900v-40zm0 0v40h399900v-40z`,lefthook:`M400000 281 H103s-33-11.2-61-33.5S0 197.3 0 164s14.2-61.2 42.5
-83.5C70.8 58.2 104 47 142 47 c16.7 0 25 6.7 25 20 0 12-8.7 18.7-26 20-40 3.3
-68.7 15.7-86 37-10 12-15 25.3-15 40 0 22.7 9.8 40.7 29.5 54 19.7 13.3 43.5 21
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:XM(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:XM(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:XM(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:XM(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
71.5 23h399859zM103 281v-40h399897v40z`,leftlinesegment:mI(`M40 281 V428 H0 V94 H40 V241 H400000 v40z`),leftbracketunder:mI(`M0 0 h120 V290 H399995 v120 H0z`),leftbracketover:mI(`M0 440 h120 V150 H399995 v-120 H0z`),leftmapsto:mI(`M40 281 V448H0V74H40V241H400000v40z`),leftToFrom:`M0 147h400000v40H0zm0 214c68 40 115.7 95.7 143 167h22c15.3 0 23
-.3 23-1 0-1.3-5.3-13.7-16-37-18-35.3-41.3-69-70-101l-7-8h399905v-40H95l7-8
c28.7-32 52-65.7 70-101 10.7-23.3 16-35.7 16-37 0-.7-7.7-1-23-1h-22C115.7 265.3
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:XM(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
68 321 0 361zm0-174v-40h399900v40zm100 154v40h399900v-40z`,longequal:mI(`M0 50 h400000 v40H0z m0 194h40000v40H0z`),midbrace:`M200428 334
c-100.7-8.3-195.3-44-280-108-55.3-42-101.7-93-139-153l-9-14c-2.7 4-5.7 8.7-9 14
-53.3 86.7-123.7 153-211 199-66.7 36-137.3 56.3-212 62H0V214h199568c178.3-11.7
311.7-78.3 403-201 6-8 9.7-12 11-12 .7-.7 6.7-1 18-1s17.3.3 18 1c1.3 0 5 4 11
@@ -294,7 +308,7 @@ m0 0v40h399900v-40z m100 194v40h399900v-40zm0 0v40h399900v-40z`,rightharpoondown
m0-194v40h400000v-40zm0 0v40h400000v-40z`,righthook:`M399859 241c-764 0 0 0 0 0 40-3.3 68.7-15.7 86-37 10-12 15-25.3
15-40 0-22.7-9.8-40.7-29.5-54-19.7-13.3-43.5-21-71.5-23-17.3-1.3-26-8-26-20 0
-13.3 8.7-20 26-20 38 0 71 11.2 99 33.5 0 0 7 5.6 21 16.7 14 11.2 21 33.5 21
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:XM(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:XM(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:XM(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
66.8s-14 61.2-42 83.5c-28 22.3-61 33.5-99 33.5L0 241z M0 281v-40h399859v40z`,rightlinesegment:mI(`M399960 241 V94 h40 V428 h-40 V281 H0 v-40z`),rightbracketunder:mI(`M399995 0 h-120 V290 H0 v120 H400000z`),rightbracketover:mI(`M399995 440 h-120 V150 H0 v-120 H399995z`),rightToFrom:`M400000 167c-70.7-42-118-97.7-142-167h-23c-15.3 0-23 .3-23
1 0 1.3 5.3 13.7 16 37 18 35.3 41.3 69 70 101l7 8H0v40h399905l-7 8c-28.7 32
-52 65.7-70 101-10.7 23.3-16 35.7-16 37 0 .7 7.7 1 23 1h23c24-69.3 71.3-125 142
-167z M100 147v40h399900v-40zM0 341v40h399900v-40z`,twoheadleftarrow:`M0 167c68 40
@@ -367,7 +381,7 @@ M93 435 v40 H400000 v-40z M500 241 v40 H400000 v-40z M500 241 v40 H400000 v-40z`
c4.7,-4.7,7,-9.3,7,-14c0,-9.3,-3.7,-15.3,-11,-18c-92.7,-56.7,-159,-133.7,-199,
-231c-3.3,-9.3,-6,-14.7,-8,-16c-2,-1.3,-7,-2,-15,-2c-10.7,0,-16.7,2,-18,6
c-2,2.7,-1,9.7,3,21c15.3,42,36.7,81.8,64,119.5c27.3,37.7,58,69.2,92,94.5z
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},cN=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
M500 241 v40 H399408 v-40z M500 435 v40 H400000 v-40z`},EI=function(e,t){switch(e){case`lbrack`:return`M403 1759 V84 H666 V0 H319 V1759 v`+t+` v1759 v84 h347 v-84
H403z M403 1759 V0 H319 V1759 v`+t+` v1759 v84 h84z`;case`rbrack`:return`M347 1759 V0 H0 V84 H263 V1759 v`+t+` v1759 H0 v84 H347z
M347 1759 V0 H263 V1759 v`+t+` v1759 h84z`;case`vert`:return`M145 15 v585 v`+t+` v585 c2.667,10,9.667,15,21,15
c10,0,16.667,-5,20,-15 v-585 v`+-t+` v-585 c-2.667,-10,-9.667,-15,-21,-15
@@ -395,18 +409,18 @@ c-55.7,194.7,-131.8,370.3,-228.5,527c-20.7,34.7,-41.7,66.3,-63,95c-2,3.3,-4,7,-6
c0,7.3,5.7,11,17,11c0,0,11,0,11,0c9.3,0,14.3,-0.3,15,-1c5.3,-5.3,10.3,-11,15,-17
c242.7,-294.7,395.3,-681.7,458,-1161c21.3,-164.7,33.3,-350.7,36,-558
l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function lN(e){return`toText`in e}var uN=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(lN(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},dN={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},fN={ex:!0,em:!0,mu:!0},pN=function(e){return typeof e!=`string`&&(e=e.unit),e in dN||e in fN||e===`ex`},mN=function(e,t){var n;if(e.unit in dN)n=dN[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new I(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},R=function(e){return+e.toFixed(4)+`em`},hN=function(e){return e.filter(e=>e).join(` `)},gN=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=_M(n)+`:`+r+`;`)}return t},_N=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},vN=function(e){var t=document.createElement(e);t.className=hN(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},yN=/[\s"'>/=\x00-\x1f]/,bN=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+bM(hN(this.classes))+`"`);var n=gN(this.style);n&&(t+=` style="`+bM(n)+`"`);for(var r of Object.keys(this.attributes)){if(yN.test(r))throw new I(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+bM(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},xN=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,_N.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return vN.call(this,`span`)}toMarkup(){return bN.call(this,`span`)}},SN=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,_N.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return vN.call(this,`a`)}toMarkup(){return bN.call(this,`a`)}},CN=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+bM(this.src)+`"`+(` alt="`+bM(this.alt)+`"`),t=gN(this.style);return t&&(e+=` style="`+bM(t)+`"`),e+=`'/>`,e}},wN={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},TN=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=qM(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=wN[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=R(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=hN(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=bM(hN(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new EN([new DN(d[v])],{width:`400em`,height:R(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=NP([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=R(m),l.push(b)}return{span:Y([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=R(o),a>0&&(i.style.minWidth=R(a)),i},HF=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=Y([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new ON({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new ON({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=NP([],[new EN(c,{width:`100%`,height:R(o)})],i)}return a.height=o,a.style.height=R(o),a},UF=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],WF=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],GF=new Set(UF),KF=new Set(WF);function qF(e){return GF.has(e)}function Q(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function JF(e){var t=YF(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function YF(e){return e.type===`atom`||KF.has(e.type)?e:null}function XF(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new I(t,e);return r}var ZF=e=>{if(e instanceof TN)return e;if(jN(e)&&e.children.length===1)return ZF(e.children[0])},QF=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Q(e.base,`accent`),n=r.base,e.base=n,i=AN(fF(e,t)),e.base=r):(r=Q(e,`accent`),n=r.base);var a=fF(n,t.havingCrampedStyle()),o=r.isShifty&&CM(n),s=0;o&&(s=ZF(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=VF(r,t),u=zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+R(2*s)+`)`,marginLeft:R(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=WP(`vec`,t),f=UP.vec[1]):(d=kP({type:`textord`,mode:r.mode,text:r.label},t),d=kN(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=Y([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=R(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=zP({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=Y([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},$F=(e,t)=>{var n=e.isStretchy?RF(e.label):new Z(`mo`,[bF(e.label,e.mode)]),r=new Z(`mover`,[DF(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},eI=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));X({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=eF(t[0]),r=!eI.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:QF,mathmlBuilder:$F}),X({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),X({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=fF(e.base,t),r=VF(e,t),i=e.label===`\\utilde`?.12:0;return Y([`mord`,`accentunder`],[zP({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=RF(e.label),r=new Z(`munder`,[DF(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var tI=e=>{var t=new Z(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};X({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrightarLine truncated
]`,KL=`\\\\[a-zA-Z@]+`,qL=`\\\\[^\ud800-\udfff]`,JL=`(`+KL+`)`+GL+`*`,YL=`\\\\(
-470,-1265c-4.7,-6,-9.7,-11.7,-15,-17c-0.7,-0.7,-6.7,-1,-18,-1z`;default:throw Error(`Unknown stretchy delimiter.`)}};function DI(e){return`toText`in e}var OI=class{constructor(e){this.children=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.children=e,this.classes=[],this.height=0,this.depth=0,this.maxFontSize=0,this.style={}}hasClass(e){return this.classes.includes(e)}toNode(){for(var e=document.createDocumentFragment(),t=0;t<this.children.length;t++)e.appendChild(this.children[t].toNode());return e}toMarkup(){for(var e=``,t=0;t<this.children.length;t++)e+=this.children[t].toMarkup();return e}toText(){return this.children.map(e=>{if(DI(e))return e.toText();throw Error(`Expected MathDomNode with toText, got `+e.constructor.name)}).join(``)}},kI={pt:1,mm:7227/2540,cm:7227/254,in:72.27,bp:803/800,pc:12,dd:1238/1157,cc:14856/1157,nd:685/642,nc:1370/107,sp:1/65536,px:803/800},AI={ex:!0,em:!0,mu:!0},jI=function(e){return typeof e!=`string`&&(e=e.unit),e in kI||e in AI||e===`ex`},MI=function(e,t){var n;if(e.unit in kI)n=kI[e.unit]/t.fontMetrics().ptPerEm/t.sizeMultiplier;else if(e.unit===`mu`)n=t.fontMetrics().cssEmPerMu;else{var r=t.style.isTight()?t.havingStyle(t.style.text()):t;if(e.unit===`ex`)n=r.fontMetrics().xHeight;else if(e.unit===`em`)n=r.fontMetrics().quad;else throw new I(`Invalid unit: '`+e.unit+`'`);r!==t&&(n*=r.sizeMultiplier/t.sizeMultiplier)}return Math.min(e.number*n,t.maxSize)},R=function(e){return+e.toFixed(4)+`em`},NI=function(e){return e.filter(e=>e).join(` `)},PI=function(e){var t=``;for(var n of Object.keys(e)){var r=e[n];r!==void 0&&(t+=FF(n)+`:`+r+`;`)}return t},FI=function(e,t,n){if(this.classes=e||[],this.attributes={},this.height=0,this.depth=0,this.maxFontSize=0,this.style=n||{},t){t.style.isTight()&&this.classes.push(`mtight`);var r=t.getColor();r&&(this.style.color=r)}},II=function(e){var t=document.createElement(e);t.className=NI(this.classes),Object.assign(t.style,this.style);for(var n of Object.keys(this.attributes))t.setAttribute(n,this.attributes[n]);for(var r=0;r<this.children.length;r++)t.appendChild(this.children[r].toNode());return t},LI=/[\s"'>/=\x00-\x1f]/,RI=function(e){var t=`<`+e;this.classes.length&&(t+=` class="`+RF(NI(this.classes))+`"`);var n=PI(this.style);n&&(t+=` style="`+RF(n)+`"`);for(var r of Object.keys(this.attributes)){if(LI.test(r))throw new I(`Invalid attribute name '`+r+`'`);t+=` `+r+`="`+RF(this.attributes[r])+`"`}t+=`>`;for(var i=0;i<this.children.length;i++)t+=this.children[i].toMarkup();return t+=`</`+e+`>`,t},zI=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.width=void 0,this.maxFontSize=void 0,this.style=void 0,this.italic=void 0,FI.call(this,e,n,r),this.children=t||[]}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return II.call(this,`span`)}toMarkup(){return RI.call(this,`span`)}},BI=class{constructor(e,t,n,r){this.children=void 0,this.attributes=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,FI.call(this,t,r),this.children=n||[],this.setAttribute(`href`,e)}setAttribute(e,t){this.attributes[e]=t}hasClass(e){return this.classes.includes(e)}toNode(){return II.call(this,`a`)}toMarkup(){return RI.call(this,`a`)}},VI=class{constructor(e,t,n){this.src=void 0,this.alt=void 0,this.classes=void 0,this.height=void 0,this.depth=void 0,this.maxFontSize=void 0,this.style=void 0,this.alt=t,this.src=e,this.classes=[`mord`],this.height=0,this.depth=0,this.maxFontSize=0,this.style=n}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createElement(`img`);return e.src=this.src,e.alt=this.alt,e.className=`mord`,Object.assign(e.style,this.style),e}toMarkup(){var e=`<img src="`+RF(this.src)+`"`+(` alt="`+RF(this.alt)+`"`),t=PI(this.style);return t&&(e+=` style="`+RF(t)+`"`),e+=`'/>`,e}},HI={î:`ı̂`,ï:`ı̈`,í:`ı́`,ì:`ı̀`},UI=class{constructor(e,t,n,r,i,a,o,s){this.text=void 0,this.height=void 0,this.depth=void 0,this.italic=void 0,this.skew=void 0,this.width=void 0,this.maxFontSize=void 0,this.classes=void 0,this.style=void 0,this.text=e,this.height=t||0,this.depth=n||0,this.italic=r||0,this.skew=i||0,this.width=a||0,this.classes=o||[],this.style=s||{},this.maxFontSize=0;var c=dI(this.text.charCodeAt(0));c&&this.classes.push(c+`_fallback`),/[îïíì]/.test(this.text)&&(this.text=HI[this.text])}hasClass(e){return this.classes.includes(e)}toNode(){var e=document.createTextNode(this.text),t=null;return this.italic>0&&(t=document.createElement(`span`),t.style.marginRight=R(this.italic)),this.classes.length>0&&(t||=document.createElement(`span`),t.className=NI(this.classes)),Object.keys(this.style).length>0&&(t||=document.createElement(`span`),Object.assign(t.style,this.style)),t?(t.appendChild(e),t):e}toMarkup(){var e=!1,t=`<span`;this.classes.length&&(e=!0,t+=` class="`,t+=RF(NI(this.classes)Line truncated
`+h+` children.`);for(var v=0;v<h;v++){var y=new WI([new GI(d[v])],{width:`400em`,height:R(m),viewBox:`0 0 `+n+` `+p,preserveAspectRatio:_[v]+` slice`}),b=ZL([g[v]],[y],t);if(h===1)return{span:b,minWidth:f,height:m};b.style.height=R(m),l.push(b)}return{span:Y([`katex-stretchy`],l,t),minWidth:f,height:m}}var r=n(),i=r.span,a=r.minWidth,o=r.height;return i.height=o,i.style.height=R(o),a>0&&(i.style.minWidth=R(a)),i},oz=function(e,t,n,r,i){var a,o=e.height+e.depth+n+r;if(/fbox|color|angl/.test(t)){if(a=Y([`katex-stretchy`,t],[],i),t===`fbox`){var s=i.color&&i.getColor();s&&(a.style.borderColor=s)}}else{var c=[];/^[bx]cancel$/.test(t)&&c.push(new KI({x1:`0`,y1:`0`,x2:`100%`,y2:`100%`,"stroke-width":`0.046em`})),/^x?cancel$/.test(t)&&c.push(new KI({x1:`0`,y1:`100%`,x2:`100%`,y2:`0`,"stroke-width":`0.046em`})),a=ZL([],[new WI(c,{width:`100%`,height:R(o)})],i)}return a.height=o,a.style.height=R(o),a},sz=[`bin`,`close`,`inner`,`open`,`punct`,`rel`],cz=[`accent-token`,`mathord`,`op-token`,`spacing`,`textord`],lz=new Set(sz),uz=new Set(cz);function dz(e){return lz.has(e)}function Q(e,t){if(!e||e.type!==t)throw Error(`Expected node of type `+t+`, but got `+(e?`node of type `+e.type:String(e)));return e}function fz(e){var t=pz(e);if(!t)throw Error(`Expected node of symbol group type, but got `+(e?`node of type `+e.type:String(e)));return t}function pz(e){return e.type===`atom`||uz.has(e.type)?e:null}function mz(e,t,n){var r=``;for(var i of e.body)if(i.type===`textord`)r+=i.text;else if(n&&i.type===`spacing`&&i.text===` `)r+=` `;else throw new I(t,e);return r}var hz=e=>{if(e instanceof UI)return e;if(YI(e)&&e.children.length===1)return hz(e.children[0])},gz=(e,t)=>{var n,r,i;e&&e.type===`supsub`?(r=Q(e.base,`accent`),n=r.base,e.base=n,i=JI(AR(e,t)),e.base=r):(r=Q(e,`accent`),n=r.base);var a=AR(n,t.havingCrampedStyle()),o=r.isShifty&&VF(n),s=0;o&&(s=hz(a)?.skew??0);var c=r.label===`\\c`,l=c?a.height+a.depth:Math.min(a.height,t.fontMetrics().xHeight),u;if(r.isStretchy)u=az(r,t),u=rR({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`elem`,elem:u,wrapperClasses:[`svg-align`],wrapperStyle:s>0?{width:`calc(100% - `+R(2*s)+`)`,marginLeft:R(2*s)}:void 0}]});else{var d,f;r.label===`\\vec`?(d=cR(`vec`,t),f=sR.vec[1]):(d=qL({type:`textord`,mode:r.mode,text:r.label},t),d=qI(d),d.italic=0,f=d.width,c&&(l+=d.depth)),u=Y([`accent-body`],[d]);var p=r.label===`\\textcircled`;p&&(u.classes.push(`accent-full`),l=a.height);var m=s;p||(m-=f/2),u.style.left=R(m),r.label===`\\textcircled`&&(u.style.top=`.2em`),u=rR({positionType:`firstBaseline`,children:[{type:`elem`,elem:a},{type:`kern`,size:-l},{type:`elem`,elem:u}]})}var h=Y([`mord`,`katex-accent`],[u],t);return i?(i.children[0]=h,i.height=Math.max(h.height,i.height),i.classes[0]=`mord`,i):h},_z=(e,t)=>{var n=e.isStretchy?nz(e.label):new Z(`mo`,[RR(e.label,e.mode)]),r=new Z(`mover`,[GR(e.base,t),n]);return r.setAttribute(`accent`,`true`),r},vz=new RegExp([`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`].map(e=>`\\`+e).join(`|`));X({type:`accent`,names:[`\\acute`,`\\grave`,`\\ddot`,`\\tilde`,`\\bar`,`\\breve`,`\\check`,`\\hat`,`\\vec`,`\\dot`,`\\mathring`,`\\widecheck`,`\\widehat`,`\\widetilde`,`\\overrightarrow`,`\\overleftarrow`,`\\Overrightarrow`,`\\overleftrightarrow`,`\\overgroup`,`\\overlinesegment`,`\\overleftharpoon`,`\\overrightharpoon`],numArgs:1,handler:(e,t)=>{var n=vR(t[0]),r=!vz.test(e.funcName),i=!r||e.funcName===`\\widehat`||e.funcName===`\\widetilde`||e.funcName===`\\widecheck`;return{type:`accent`,mode:e.parser.mode,label:e.funcName,isStretchy:r,isShifty:i,base:n}},htmlBuilder:gz,mathmlBuilder:_z}),X({type:`accent`,names:[`\\'`,"\\`",`\\^`,`\\~`,`\\=`,`\\u`,`\\.`,`\\"`,`\\c`,`\\r`,`\\H`,`\\v`,`\\textcircled`],numArgs:1,allowedInText:!0,allowedInMath:!0,argTypes:[`primitive`],handler:(e,t)=>{var n=t[0],r=e.parser.mode;return r===`math`&&(e.parser.settings.reportNonstrict(`mathVsTextAccents`,`LaTeX's accent `+e.funcName+` works only in text mode`),r=`text`),{type:`accent`,mode:r,label:e.funcName,isStretchy:!1,isShifty:!0,base:n}}}),X({type:`accentUnder`,names:[`\\underleftarrow`,`\\underrightarrow`,`\\underleftrightarrow`,`\\undergroup`,`\\underlinesegment`,`\\utilde`],numArgs:1,handler:(e,t)=>{var n=e.parser,r=e.funcName,i=t[0];return{type:`accentUnder`,mode:n.mode,label:r,base:i}},htmlBuilder:(e,t)=>{var n=AR(e.base,t),r=az(e,t),i=e.label===`\\utilde`?.12:0;return Y([`mord`,`accentunder`],[rR({positionType:`top`,positionData:n.height,children:[{type:`elem`,elem:r,wrapperClasses:[`svg-align`]},{type:`kern`,size:i},{type:`elem`,elem:n}]})],t)},mathmlBuilder:(e,t)=>{var n=nz(e.label),r=new Z(`munder`,[GR(e.base,t),n]);return r.setAttribute(`accentunder`,`true`),r}});var yz=e=>{var t=new Z(`mpadded`,e?[e]:[]);return t.setAttribute(`width`,`+0.6em`),t.setAttribute(`lspace`,`0.3em`),t};X({type:`xArrow`,names:[`\\xleftarrow`,`\\xrightarrow`,`\\xLeftarrow`,`\\xRightarrow`,`\\xleftrightarLine truncated
]`,uV=`\\\\[a-zA-Z@]+`,dV=`\\\\[^\ud800-\udfff]`,fV=`(`+uV+`)`+lV+`*`,pV=`\\\\(
|[ \r ]+
?)[ \r ]*`,XL=`[̀-ͯ]`,ZL=RegExp(XL+`+$`),QL=`(`+GL+`+)|`+(YL+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(XL+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(XL+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+JL)+(`|`+qL+`)`),$L=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(QL,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new $I(`EOF`,new QI(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new I(`Unexpected character: '`+e[t]+`'`,new $I(e[t],new QI(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new $I(r,new QI(this,t,this.tokenRegex.lastIndex))}},eR=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new I(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},tR=ZI;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var nR={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new I("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=nR[t.text],r==null||r>=n)throw new I(`Invalid base-`+n+` digit `+t.text);for(var i;(i=nR[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var rR=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new I(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new I(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new I(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new I(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>rR(e,!1,!0,!1)),$(`\\renewcommand`,e=>rR(e,!0,!1,!1)),$(`\\providecommand`,e=>rR(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),WL[n],zN.math[n],zN.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathreLine truncated
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(mR,t[0])&&!zN[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=mR[t[0]]+t.slice(1));var i=ZL.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(zN[this.mode][t]){this.settings.strict&&this.mode===`math`&&sP.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=zN[this.mode][t].group,s=QI.range(e);a=qF(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(YM(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:QI.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!pR[l])throw new I(`Unknown accent ' `+l+`'`,e);var u=pR[l][this.mode]||pR[l].text;if(!u)throw new I(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:QI.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};hR.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var gR=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new hR(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new I(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new $I(`\\df@tag`)])}]}return r},_R=function(e,t,n){t.textContent=``;var r=xR(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),_R=function(){throw new I(`KaTeX doesn't work in quirks mode.`)});var vR=function(e,t){return xR(e,t).toMarkup()},yR=function(e,t){return gR(e,new kM(t))},bR=function(e,t,n){if(n.throwOnError||!(e instanceof I))throw e;var r=Y([`katex-error`],[new TN(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},xR=function(e,t){var n=new kM(t);try{return FF(gR(e,n),e,n)}catch(t){return bR(t,e,n)}},SR={version:`0.18.10`,render:_R,renderToString:vR,ParseError:I,SETTINGS_SCHEMA:TM,__parse:yR,__renderToDomTree:xR,__renderToHTMLTree:function(e,t){var n=new kM(t);try{return IF(gR(e,n),e,n)}catch(t){return bR(t,e,n)}},__setFontMetrics:FN,__defineSymbol:z,__defineFunction:X,__defineMacro:$,__domTree:{Span:xN,Anchor:SN,SymbolNode:TN,SvgNode:EN,PathNode:DN,LineNode:ON}},CR=qp.create({name:`blockMath`,group:`block`,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertBlockMath:e=>({commands:t,editor:n})=>{let{latex:r,pos:i}=e;return r?t.insertContentAt(i??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateBlockMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r??a.attrs.latex}),!0)}}},parseHTML(){return[{tag:`div[data-type="block-math"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`block-math`})]},parseMarkdown:e=>({type:`blockMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>[`$$`,e.attrs?.latex||``,`$$`].join(`
`),markdownTokenizer:{name:`blockMath`,level:`block`,start:e=>e.indexOf(`$$`),tokenize:e=>{let t=e.match(/^\$\$([^$]+)\$\$/);if(!t)return;let[n,r]=t;return{type:`blockMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new cp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{SR.render(t.attrs.latex,i,e),r.classList.remove(`block-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`block-math-error`)}}let o=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,o),a(),{dom:r,destroy(){r.removeEventListener(`click`,o)}}}}}),wR=e=>{let t=/\$\$([^$\n]+?)\$\$(?!\$)/g,n=t.exec(e);for(;n!==null;){if(n.index===0||e[n.index-1]!==`$`)return{index:n.index,text:n[0],data:{latex:n[1]}};t.lastIndex=n.index+1,n=t.exec(e)}return null},TR=qp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new cp({find:wR,handler:({state:e,range:t,match:n})=>{let r=n.data?.latex;if(typeof r!=`string`)return null;let{tr:i}=e,a=t.from,o=t.to;i.replaceWith(a,o,this.type.create({latex:r}))}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`span`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),r.dataset.type=`inline-math`,r.setAttribute(`data-latex`,t.attrs.latex);function i(){try{SR.render(t.attrs.latex,r,e),r.classList.remove(`inline-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`inline-math-error`)}}let a=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,a),i(),{dom:r,destroy(){r.removeEventListener(`click`,a)}}}}}),ER=wp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[CR.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),TR.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function DR(e,t){let n=n=>(r,i)=>{let a=t();if(!a?.isEditable)return;let o=a.view.nodeDOM(i);if(!(o instanceof HTMLElement))return;let s=e.blocks;Xj({anchor:o,value:String(r.attrs.latex??``),label:s.latex,multiline:n===`block`,monospace:!0,labels:{done:s.done,cancel:s.cancel,remove:s.remove},onSave:e=>{let t=a.chain().setNodeSelection(i);e.trim()?(n===`inline`?t.updateInlineMath({latex:e,pos:i}):t.updateBlockMath({latex:e,pos:i})).focus().run():(n===`inline`?t.deleteInlineMath({pos:i}):t.deleteBlockMath({pos:i})).focus().run()},onRemove:()=>{let e=a.chain();(n===`inline`?e.deleteInlineMath({pos:i}):e.deleteBlockMath({pos:i})).focus().run()}})};return ER.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function OR(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=kf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegELine truncated
`);return/\s/.test(n)}):!1}function AR(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function jR(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:AR(e)}function MR({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!kR(r)}function NR({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function PR({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),xs.create(a.doc,[vs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function FR({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function IR({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function LR({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Gj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(qj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function RR(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function zR({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&RR(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=Wj(c,o,()=>{Jj(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function BR({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=IR({editor:e,items:n}),v=LR({placLine truncated
Idea --> Draft --> Review --> Published`,ez=null;function tz(e){return ez??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),ez}var nz=0;async function rz(e,t,n,r){if(e.classList.remove(`dw-mermaid__body--error`),!t.trim())e.textContent=``;else if(r)try{let{svg:n}=await(await tz(r)).render(`dw-mermaid-${++nz}`,t);e.innerHTML=n}catch(t){e.classList.add(`dw-mermaid__body--error`),e.textContent=`${n.blocks.mermaidError} ${t instanceof Error?t.message:String(t)}`}else{let n=document.createElement(`pre`);n.className=`dw-mermaid__source`,n.textContent=t,e.replaceChildren(n)}}var iz=qp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=$R)=>({commands:t})=>t.insertContent({type:this.name,attrs:{code:e}})}},addNodeView(){return({node:e,editor:t,getPos:n})=>{let r=this.options.labels,i=this.options.load,a=document.createElement(`div`);a.className=`dw-mermaid`,a.setAttribute(`data-type`,`mermaid`);let o=document.createElement(`div`);o.className=`dw-mermaid__body`,a.append(o);let s=String(e.attrs.code);return rz(o,s,r,i),a.addEventListener(`click`,()=>{if(!t.isEditable)return;let e=typeof n==`function`?n():void 0;if(e===void 0)return;let c=r.blocks;Xj({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void rz(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),rz(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void rz(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),rz(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}),az=e=>`/p/${encodeURIComponent(e)}`,oz=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function sz(e){return oz.exec(e)?.[1]??``}function cz(e,t,n,r=`Untitled`){let i=`${n.icon?`${n.icon} `:``}${n.title||r}`;e.chain().focus().deleteRange(t).insertContent([{type:`text`,text:i,marks:[{type:`link`,attrs:{href:az(n.id)}}]},{type:`text`,text:` `}]).run()}var lz=wp.create({name:`pageLinks`,addOptions(){return{host:void 0,labels:null,onNavigate:void 0}},addProseMirrorPlugins(){let{host:e,onNavigate:t}=this.options,n=this.options.labels,r=[];return e&&r.push(UR({editor:this.editor,pluginKey:new D(`pageLinks`),char:`[[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:ZR({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>cz(e.editor,e.range,t)})})),t&&r.push(new E({key:new D(`pageLinkClicks`),props:{handleClick:(e,n,r)=>{let i=(r.target?.closest?.(`a[href]`))?.getAttribute(`href`)??``;return!sz(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function uz(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.multiple=!0,n.onchange=()=>t([...n.files??[]]),n.click()})}function dz(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`quote`,`quote`,[`blockquote`,`>`],(e,t)=>e.chain().focus().deleteRange(t).toggleBlockquote().run()),o(`code`,`code`,[`codeblock`,"```",`snippet`],(e,t)=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()),o(`toggle`,`chevron-right`,[`details`,`collapse`,`expand`,`fold`,`>`],(e,t)=>e.chain().focus().deleteRange(t).setDetails().run()),o(`divider`,`divider`,[`hr`,`rule`,`line`,`---`],(e,t)=>e.chain().focus().deleteRange(t).setHorizontalRule().run()),o(`toc`,`list`,[`contents`,`outline`,`headings`,`index`],(e,t)=>e.chain().focus().deleteRange(t).insertTableOfContents().run()),o(`math`,`sigma`,[`latex`,`formula`,`equation`,`katex`,`$$`],(e,t)=>e.chain().focus().deleteLine truncated
?)[ \r ]*`,mV=`[̀-ͯ]`,hV=RegExp(mV+`+$`),gV=`(`+lV+`+)|`+(pV+`|`)+`([!-\\[\\]-‧‪-퟿豈-￿]`+(mV+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(mV+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+fV)+(`|`+dV+`)`),_V=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(gV,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new _B(`EOF`,new gB(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new I(`Unexpected character: '`+e[t]+`'`,new _B(e[t],new gB(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new _B(r,new gB(this,t,this.tokenRegex.lastIndex))}},vV=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new I(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){if(Object.prototype.hasOwnProperty.call(this.current,e))return this.current[e];if(Object.prototype.hasOwnProperty.call(this.builtins,e))return this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:void 0)}t==null?delete this.current[e]:this.current[e]=t}},yV=hB;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var bV={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`"){if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new I("\\char` missing argument");else r=t.text.charCodeAt(0)}else n=10;if(n){if(r=bV[t.text],r==null||r>=n)throw new I(`Invalid base-`+n+` digit `+t.text);for(var i;(i=bV[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var xV=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new I(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new I(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new I(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new I(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>xV(e,!1,!0,!1)),$(`\\renewcommand`,e=>xV(e,!0,!1,!1)),$(`\\providecommand`,e=>xV(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),cV[n],rL.math[n],rL.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathreLine truncated
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(MV,t[0])&&!rL[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=MV[t[0]]+t.slice(1));var i=hV.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(rL[this.mode][t]){this.settings.strict&&this.mode===`math`&&TL.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=rL[this.mode][t].group,s=gB.range(e);a=dz(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(pI(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:gB.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!jV[l])throw new I(`Unknown accent ' `+l+`'`,e);var u=jV[l][this.mode]||jV[l].text;if(!u)throw new I(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:gB.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};NV.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var PV=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new NV(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new I(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new _B(`\\df@tag`)])}]}return r},FV=function(e,t,n){t.textContent=``;var r=zV(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),FV=function(){throw new I(`KaTeX doesn't work in quirks mode.`)});var IV=function(e,t){return zV(e,t).toMarkup()},LV=function(e,t){return PV(e,new qF(t))},RV=function(e,t,n){if(n.throwOnError||!(e instanceof I))throw e;var r=Y([`katex-error`],[new UI(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},zV=function(e,t){var n=new qF(t);try{return $R(PV(e,n),e,n)}catch(t){return RV(t,e,n)}},BV={version:`0.18.10`,render:FV,renderToString:IV,ParseError:I,SETTINGS_SCHEMA:UF,__parse:LV,__renderToDomTree:zV,__renderToHTMLTree:function(e,t){var n=new qF(t);try{return ez(PV(e,n),e,n)}catch(t){return RV(t,e,n)}},__setFontMetrics:$I,__defineSymbol:z,__defineFunction:X,__defineMacro:$,__domTree:{Span:zI,Anchor:BI,SymbolNode:UI,SvgNode:WI,PathNode:GI,LineNode:KI}},VV=Jp.create({name:`blockMath`,group:`block`,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertBlockMath:e=>({commands:t,editor:n})=>{let{latex:r,pos:i}=e;return r?t.insertContentAt(i??n.state.selection.from,{type:this.name,attrs:{latex:r}}):!1},deleteBlockMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateBlockMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r??a.attrs.latex}),!0)}}},parseHTML(){return[{tag:`div[data-type="block-math"]`}]},renderHTML({HTMLAttributes:e}){return[`div`,A(e,{"data-type":`block-math`})]},parseMarkdown:e=>({type:`blockMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>[`$$`,e.attrs?.latex||``,`$$`].join(`
`),markdownTokenizer:{name:`blockMath`,level:`block`,start:e=>e.indexOf(`$$`),tokenize:e=>{let t=e.match(/^\$\$([^$]+)\$\$/);if(!t)return;let[n,r]=t;return{type:`blockMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:/^\$\$\$([^$]+)\$\$\$$/,handler:({state:e,range:t,match:n})=>{let[,r]=n,{tr:i}=e,a=e.doc.resolve(t.from),o=this.type.create({latex:r}),s=a.depth>0&&a.parent.isTextblock&&t.from===a.start()&&t.to===a.end()&&a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),this.type)?{from:a.before(),to:a.after()}:t;i.replaceWith(s.from,s.to,o)}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`div`),i=document.createElement(`div`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),i.className=`block-math-inner`,r.dataset.type=`block-math`,r.setAttribute(`data-latex`,t.attrs.latex),r.appendChild(i);function a(){try{BV.render(t.attrs.latex,i,e),r.classList.remove(`block-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`block-math-error`)}}let o=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,o),a(),{dom:r,destroy(){r.removeEventListener(`click`,o)}}}}}),HV=e=>{let t=/\$\$([^$\n]+?)\$\$(?!\$)/g,n=t.exec(e);for(;n!==null;){if(n.index===0||e[n.index-1]!==`$`)return{index:n.index,text:n[0],data:{latex:n[1]}};t.lastIndex=n.index+1,n=t.exec(e)}return null},UV=Jp.create({name:`inlineMath`,group:`inline`,inline:!0,atom:!0,addOptions(){return{onClick:void 0,katexOptions:void 0}},addAttributes(){return{latex:{default:``,parseHTML:e=>e.getAttribute(`data-latex`),renderHTML:e=>({"data-latex":e.latex})}}},addCommands(){return{insertInlineMath:e=>({editor:t,tr:n})=>{let r=e.latex,i=e?.pos??t.state.selection.from;return r?(n.replaceWith(i,i,this.type.create({latex:r})),!0):!1},deleteInlineMath:e=>({editor:t,tr:n})=>{let r=e?.pos??t.state.selection.$from.pos,i=t.state.doc.nodeAt(r);return!i||i.type.name!==this.name?!1:(n.delete(r,r+i.nodeSize),!0)},updateInlineMath:e=>({editor:t,tr:n})=>{let r=e?.latex,i=e?.pos;i===void 0&&(i=t.state.selection.$from.pos);let a=t.state.doc.nodeAt(i);return!a||a.type.name!==this.name?!1:(n.setNodeMarkup(i,this.type,{...a.attrs,latex:r}),!0)}}},parseHTML(){return[{tag:`span[data-type="inline-math"]`}]},renderHTML({HTMLAttributes:e}){return[`span`,A(e,{"data-type":`inline-math`})]},parseMarkdown:e=>({type:`inlineMath`,attrs:{latex:e.latex}}),renderMarkdown:e=>`$${e.attrs?.latex||``}$`,markdownTokenizer:{name:`inlineMath`,level:`inline`,start:e=>e.indexOf(`$`),tokenize:e=>{let t=e.match(/^\$([^$]+)\$(?!\$)/);if(!t)return;let[n,r]=t;return{type:`inlineMath`,raw:n,latex:r.trim()}}},addInputRules(){return[new lp({find:HV,handler:({state:e,range:t,match:n})=>{let r=n.data?.latex;if(typeof r!=`string`)return null;let{tr:i}=e,a=t.from,o=t.to;i.replaceWith(a,o,this.type.create({latex:r}))}})]},addNodeView(){let{katexOptions:e}=this.options;return({node:t,getPos:n})=>{let r=document.createElement(`span`);r.className=`tiptap-mathematics-render`,this.editor.isEditable&&r.classList.add(`tiptap-mathematics-render--editable`),r.dataset.type=`inline-math`,r.setAttribute(`data-latex`,t.attrs.latex);function i(){try{BV.render(t.attrs.latex,r,e),r.classList.remove(`inline-math-error`)}catch{r.textContent=t.attrs.latex,r.classList.add(`inline-math-error`)}}let a=e=>{e.preventDefault(),e.stopPropagation();let r=n();r!=null&&this.options.onClick&&this.options.onClick(t,r)};return this.options.onClick&&r.addEventListener(`click`,a),i(),{dom:r,destroy(){r.removeEventListener(`click`,a)}}}}}),WV=Tp.create({name:`Mathematics`,addOptions(){return{inlineOptions:void 0,blockOptions:void 0,katexOptions:void 0}},addExtensions(){return[VV.configure({...this.options.blockOptions,katexOptions:this.options.katexOptions}),UV.configure({...this.options.inlineOptions,katexOptions:this.options.katexOptions})]}});function GV(e,t){let n=n=>(r,i)=>{let a=t();if(!a?.isEditable)return;let o=a.view.nodeDOM(i);if(!(o instanceof HTMLElement))return;let s=e.blocks;cF({anchor:o,value:String(r.attrs.latex??``),label:s.latex,multiline:n===`block`,monospace:!0,labels:{done:s.done,cancel:s.cancel,remove:s.remove},onSave:e=>{let t=a.chain().setNodeSelection(i);e.trim()?(n===`inline`?t.updateInlineMath({latex:e,pos:i}):t.updateBlockMath({latex:e,pos:i})).focus().run():(n===`inline`?t.deleteInlineMath({pos:i}):t.deleteBlockMath({pos:i})).focus().run()},onRemove:()=>{let e=a.chain();(n===`inline`?e.deleteInlineMath({pos:i}):e.deleteBlockMath({pos:i})).focus().run()}})};return WV.configure({katexOptions:{throwOnError:!1,strict:!1,trust:!1},inlineOptions:{onClick:n(`inline`)},blockOptions:{onClick:n(`block`)}})}function KV(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=kf(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegELine truncated
`);return/\s/.test(n)}):!1}function JV(e){return()=>{let t=e.state.selection.$anchor.pos,{top:n,right:r,bottom:i,left:a}=e.view.coordsAtPos(t);try{return new DOMRect(a,n,r-a,i-n)}catch{return null}}}function YV(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:JV(e)}function XV({match:e,dismissedRange:t,state:n,transaction:r,editor:i,shouldResetDismissed:a,effectiveAllowSpaces:o}){return a?.({editor:i,state:n,range:t,match:e,transaction:r,allowSpaces:o})?!1:o?e.range.from===t.from:e.range.from===t.from&&!qV(r)}function ZV({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function QV({pluginKey:e,decorationTag:t,decorationClass:n,decorationContent:r,decorationEmptyClass:i,renderer:a,dispatchExit:o}){return{handleKeyDown(t,n){var r;let i=e.getState(t.state);if(!i.active)return!1;if(n.key===`Escape`||n.key===`Esc`){var s;return a==null||(s=a.onKeyDown)==null||s.call(a,{view:t,event:n,range:i.range}),o(t),!0}return(a==null||(r=a.onKeyDown)==null?void 0:r.call(a,{view:t,event:n,range:i.range}))||!1},decorations(a){let{active:o,range:s,decorationId:c,query:l}=e.getState(a);if(!o)return null;let u=!l?.length,d=[n];return u&&d.push(i),xs.create(a.doc,[vs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function $V({editor:e,char:t,effectiveAllowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,findSuggestionMatch:o,allow:s,shouldShow:c,shouldKeepDismissed:l,pluginKey:u}){return{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(d,f,p,m){let{isEditable:h}=e,{composing:g}=e.view,{selection:_}=d,{empty:v,from:y}=_,b={...f},x=d.getMeta(u);if(x&&x.exit)return b.active=!1,b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null,b.dismissedRange=f.active?{...f.range}:f.dismissedRange,b;if(b.composing=g,d.docChanged&&b.dismissedRange!==null&&(b.dismissedRange={from:d.mapping.map(b.dismissedRange.from),to:d.mapping.map(b.dismissedRange.to)}),h&&(v||e.view.composing)){(y<f.range.from||y>f.range.to)&&!g&&!f.composing&&(b.active=!1);let u=o({char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:_.$from}),p=`id_${Math.floor(Math.random()*4294967295)}`;u&&s({editor:e,state:m,range:u.range,isActive:f.active})&&(!c||c({editor:e,range:u.range,query:u.query,text:u.text,transaction:d}))?(b.dismissedRange!==null&&!l({match:u,dismissedRange:b.dismissedRange,state:m,transaction:d})&&(b.dismissedRange=null),b.dismissedRange===null?(b.active=!0,b.decorationId=f.decorationId||p,b.range=u.range,b.query=u.query,b.text=u.text):b.active=!1):(u||(b.dismissedRange=null),b.active=!1)}else b.active=!1;return b.active||(b.decorationId=null,b.range={from:0,to:0},b.query=null,b.text=null),b}}}function eH({editor:e,items:t}){let n=null,r=null,i=null,a=()=>{r!==null&&(clearTimeout(r),r=null),i?.(),i=null},o=e=>new Promise(t=>{i=t,r=setTimeout(()=>{r=null;let e=i;i=null,e?.()},e)}),s=()=>{n?.abort(),a(),n=null};return{abort:s,fetch:async(r,i)=>{s(),n=new AbortController;let a=n;if(i>0&&await o(i),n!==a||a.signal.aborted)return{status:`aborted`};try{let i=await t({editor:e,query:r,signal:a.signal});return n!==a||a.signal.aborted?{status:`aborted`}:{status:`resolved`,items:i}}catch{return n!==a||a.signal.aborted?{status:`aborted`}:{status:`error`}}}}}function tH({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[Tj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(Dj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function nH(e){if(e instanceof HTMLElement)return e;if(typeof e==`string`)try{let t=document.querySelector(e);if(t)return t}catch{return document.body}return document.body}function rH({getReferenceRect:e,contextElement:t,config:n,container:r,dismissOnOutsideClick:i,dismiss:a}){return(o,s={})=>{let c={getBoundingClientRect:()=>e()??new DOMRect,contextElement:t},l=!1,u=!o.isConnected;u&&nH(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=wj(c,o,()=>{Oj(c,o,{placement:n.placement,strategy:n.strategy,middleware:n.middleware}).then(({x:e,y:t,placement:n,strategy:r})=>{s.onPosition?s.onPosition({x:e,y:t,placement:n,strategy:r}):(Object.assign(o.style,{position:r,left:`${e}px`,top:`${t}px`}),l||(l=!0,o.style.visibility=``))})},s.autoUpdate),f;return i&&(f=e=>{let n=e.target;!(n instanceof Node)||o.contains(n)||t.contains(n)||a()},document.addEventListener(`pointerdown`,f,!0)),()=>{d(),f&&document.removeEventListener(`pointerdown`,f,!0),u&&o.remove()}}}function iH({editor:e,pluginKey:t,items:n,renderer:r,minQueryLength:i,debounce:a,initialItems:o,placement:s,offset:c,container:l,flip:u,floatingUi:d,dismissOnOutsideClick:f,command:p,clientRectFor:m,dispatchExit:h}){let g,_=eH({editor:e,items:n}),v=tH({placLine truncated
Idea --> Draft --> Review --> Published`,mH=null;function hH(e){return mH??=e().then(e=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:document.documentElement.classList.contains(`dark`)?`dark`:`neutral`,fontFamily:`inherit`}),e)),mH}var gH=0;async function _H(e,t,n,r){if(e.classList.remove(`dw-mermaid__body--error`),!t.trim())e.textContent=``;else if(r)try{let{svg:n}=await(await hH(r)).render(`dw-mermaid-${++gH}`,t);e.innerHTML=n}catch(t){e.classList.add(`dw-mermaid__body--error`),e.textContent=`${n.blocks.mermaidError} ${t instanceof Error?t.message:String(t)}`}else{let n=document.createElement(`pre`);n.className=`dw-mermaid__source`,n.textContent=t,e.replaceChildren(n)}}var vH=Jp.create({name:`mermaid`,group:`block`,atom:!0,draggable:!0,addOptions(){return{labels:null,load:void 0}},addAttributes(){return{code:{default:``,parseHTML:e=>e.getAttribute(`data-code`)??e.textContent??``,renderHTML:e=>({"data-code":e.code})}}},parseHTML(){return[{tag:`div[data-type='mermaid']`},{tag:`pre.mermaid`}]},renderHTML({node:e,HTMLAttributes:t}){return[`div`,A(t,{"data-type":`mermaid`}),[`pre`,{},String(e.attrs.code)]]},addCommands(){return{insertMermaid:(e=pH)=>({commands:t})=>t.insertContent({type:this.name,attrs:{code:e}})}},addNodeView(){return({node:e,editor:t,getPos:n})=>{let r=this.options.labels,i=this.options.load,a=document.createElement(`div`);a.className=`dw-mermaid`,a.setAttribute(`data-type`,`mermaid`);let o=document.createElement(`div`);o.className=`dw-mermaid__body`,a.append(o);let s=String(e.attrs.code);return _H(o,s,r,i),a.addEventListener(`click`,()=>{if(!t.isEditable)return;let e=typeof n==`function`?n():void 0;if(e===void 0)return;let c=r.blocks;cF({anchor:a,value:s,label:c.mermaid,multiline:!0,monospace:!0,labels:{done:c.done,cancel:c.cancel,remove:c.remove},onInput:e=>void _H(o,e,r,i),onSave:n=>{t.chain().setNodeSelection(e).updateAttributes(`mermaid`,{code:n}).run(),_H(o,n,r,i)},onRemove:()=>t.chain().setNodeSelection(e).deleteSelection().focus().run(),onCancel:()=>void _H(o,s,r,i)})}),{dom:a,update:e=>e.type.name===`mermaid`&&(e.attrs.code!==s&&(s=String(e.attrs.code),_H(o,s,r,i)),!0),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}),yH=e=>`/p/${encodeURIComponent(e)}`,bH=/^\/p\/([A-Za-z0-9_-]+)\/?(?:[?#].*)?$/;function xH(e){return bH.exec(e)?.[1]??``}function SH(e,t,n,r=`Untitled`){let i=`${n.icon?`${n.icon} `:``}${n.title||r}`;e.chain().focus().deleteRange(t).insertContent([{type:`text`,text:i,marks:[{type:`link`,attrs:{href:yH(n.id)}}]},{type:`text`,text:` `}]).run()}async function CH(e,t,n){if(!t.create)return;let{from:r,to:i,empty:a}=e.state.selection,o=a?``:e.state.doc.textBetween(r,i,` `).trim().slice(0,200),s=await t.create(o);a||!o?SH(e,{from:r,to:r},s,n):e.chain().focus().setTextSelection({from:r,to:i}).setLink({href:yH(s.id)}).run()}var wH=Tp.create({name:`pageLinks`,addOptions(){return{host:void 0,labels:null,onNavigate:void 0}},addProseMirrorPlugins(){let{host:e,onNavigate:t}=this.options,n=this.options.labels,r=[];return e&&r.push(sH({editor:this.editor,pluginKey:new D(`pageLinks`),char:`[[`,allowSpaces:!0,allow:({state:e,range:t})=>!e.doc.resolve(t.from).parent.type.spec.code,items:async({query:t})=>(await e.search(t).catch(()=>[])).slice(0,8),render:Ij({label:n.pageLinks,empty:n.noPages,toItem:e=>({label:`${e.icon?`${e.icon} `:``}${e.title||`…`}`,description:e.hint,icon:`page`}),pick:(e,t)=>SH(e.editor,e.range,t)})})),t&&r.push(new E({key:new D(`pageLinkClicks`),props:{handleClick:(e,n,r)=>{let i=(r.target?.closest?.(`a[href]`))?.getAttribute(`href`)??``;return!xH(i)||e.editable&&!(r.ctrlKey||r.metaKey)?!1:(r.preventDefault(),t(i),!0)}}})),r}});function TH(e){return new Promise(t=>{let n=document.createElement(`input`);n.type=`file`,n.accept=e,n.multiple=!0,n.onchange=()=>t([...n.files??[]]),n.click()})}function EH(e,t,n,r,i=!1,a){let o=(t,n,r,i)=>({id:t,icon:n,keywords:r,label:e.slash[t]?.label??t,description:e.slash[t]?.description??``,run:i}),s=[o(`text`,`text`,[`paragraph`,`p`],(e,t)=>e.chain().focus().deleteRange(t).setParagraph().run()),o(`h1`,`heading`,[`heading`,`title`,`#`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:1}).run()),o(`h2`,`heading`,[`heading`,`subtitle`,`##`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:2}).run()),o(`h3`,`heading`,[`heading`,`###`],(e,t)=>e.chain().focus().deleteRange(t).setHeading({level:3}).run()),...[4,5,6].map(e=>o(`h${e}`,`heading`,[`heading`,`other headings`,`#`.repeat(e)],(t,n)=>t.chain().focus().deleteRange(n).setHeading({level:e}).run())),o(`bullet`,`list`,[`list`,`ul`,`-`],(e,t)=>e.chain().focus().deleteRange(t).toggleBulletList().run()),o(`ordered`,`list-ordered`,[`list`,`ol`,`1.`],(e,t)=>e.chain().focus().deleteRange(t).toggleOrderedList().run()),o(`todo`,`todo`,[`task`,`checkbox`,`checklist`,`[]`],(e,t)=>e.chain().focus().deleteRange(t).toggleTaskList().run()),o(`callout`,`callout`,[`note`,`info`,`tip`,`warning`,`aside`,`box`],(e,t)=>e.chain().focus().deleteRange(t).setCallout().run()),o(`taLine truncated
<style rel="stylesheet" crossorigin>/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--font-serif:"Source Serif 4 Variable", "Source Serif 4", "Iowan Old Style", Georgia, serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--dw-surface);--color-surface-sunken:var(--dw-surface-sunken);--color-surface-raised:var(--dw-surface-raised);--color-surface-hover:var(--dw-surface-hover);--color-line:var(--dw-line);--color-line-strong:var(--dw-line-strong);--color-ink:var(--dw-ink);--color-ink-muted:var(--dw-ink-muted);--color-ink-faint:var(--dw-ink-faint);--color-primary:var(--dw-primary);--color-primary-hover:var(--dw-primary-hover);--color-on-primary:var(--dw-on-primary);--color-accent:var(--dw-accent);--color-accent-soft:var(--dw-accent-soft);--color-selection:var(--dw-selection);--color-focus-ring:var(--dw-focus-ring);--color-success:var(--dw-success);--color-success-soft:var(--dw-success-soft);--color-warning:var(--dw-warning);--color-warning-soft:var(--dw-warning-soft);--color-danger:var(--dw-danger);--color-danger-soft:var(--dw-danger-soft);--color-on-danger:var(--dw-on-danger);--color-info:var(--dw-info);--color-info-soft:var(--dw-info-soft);--color-code-bg:var(--dw-code-bg);--text-ui-xs:12px;--text-ui-xs--line-height:16px;--text-ui-xs--letter-spacing:.01em;--text-ui-xs--font-weight:500;--text-ui-sm:13px;--text-ui-sm--line-height:18px;--text-ui-md:14px;--text-ui-md--line-height:20px;--text-doc-h1:30px;--text-doc-h1--line-height:38px;--text-doc-h2:24px;--text-doc-h2--line-height:32px;--text-doc-h3:18px;--text-doc-h3--line-height:28px;--text-doc-body:16px;--text-doc-body--line-height:27px;--text-code:14px;--text-code--line-height:22px;--spacing-control-sm:28px;--spacing-control-md:34px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-cLine truncated
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial}}}@layer theme{:root,:host{--font-sans:"Inter Variable", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;--font-serif:"Source Serif 4 Variable", "Source Serif 4", "Iowan Old Style", Georgia, serif;--font-mono:"JetBrains Mono Variable", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--ease-in:cubic-bezier(.4, 0, 1, 1);--ease-out:cubic-bezier(0, 0, .2, 1);--ease-in-out:cubic-bezier(.4, 0, .2, 1);--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-surface:var(--dw-surface);--color-surface-sunken:var(--dw-surface-sunken);--color-surface-raised:var(--dw-surface-raised);--color-surface-hover:var(--dw-surface-hover);--color-line:var(--dw-line);--color-line-strong:var(--dw-line-strong);--color-ink:var(--dw-ink);--color-ink-muted:var(--dw-ink-muted);--color-ink-faint:var(--dw-ink-faint);--color-primary:var(--dw-primary);--color-primary-hover:var(--dw-primary-hover);--color-on-primary:var(--dw-on-primary);--color-accent:var(--dw-accent);--color-accent-soft:var(--dw-accent-soft);--color-selection:var(--dw-selection);--color-focus-ring:var(--dw-focus-ring);--color-success:var(--dw-success);--color-success-soft:var(--dw-success-soft);--color-warning:var(--dw-warning);--color-warning-soft:var(--dw-warning-soft);--color-danger:var(--dw-danger);--color-danger-soft:var(--dw-danger-soft);--color-on-danger:var(--dw-on-danger);--color-info:var(--dw-info);--color-info-soft:var(--dw-info-soft);--color-code-bg:var(--dw-code-bg);--text-ui-xs:12px;--text-ui-xs--line-height:16px;--text-ui-xs--letter-spacing:.01em;--text-ui-xs--font-weight:500;--text-ui-sm:13px;--text-ui-sm--line-height:18px;--text-ui-md:14px;--text-ui-md--line-height:20px;--text-doc-h1:30px;--text-doc-h1--line-height:38px;--text-doc-h2:24px;--text-doc-h2--line-height:32px;--text-doc-h3:18px;--text-doc-h3--line-height:28px;--text-doc-body:16px;--text-doc-body--line-height:27px;--text-code:14px;--text-code--line-height:22px;--shadow-menu:var(--dw-shadow-menu);--container-doc:720px;--container-doc-wide:1040px;--spacing-control-sm:28px;--spacing-control-md:34px}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-Line truncated
/*$vite$:1*/</style>
</head>
<body>
+18
View File
@@ -47,6 +47,24 @@ describe("EditorBridge", () => {
expect(state?.type === "state" && state.state.canUndo).toBe(true);
});
it("makes to-do lists, callouts and tables from the toolbar", () => {
const { bridge, sent } = setup();
bridge.receive({ type: "setContent", content: doc });
bridge.receive({ type: "command", command: "taskList" });
expect(bridge.content.content?.[0]?.type).toBe("taskList");
const state = sent.filter((m) => m.type === "state").at(-1);
expect(state?.type === "state" && state.state.active).toContain("taskList");
bridge.receive({ type: "setContent", content: doc });
bridge.receive({ type: "command", command: "callout" });
expect(bridge.content.content?.[0]?.type).toBe("callout");
bridge.receive({ type: "command", command: "callout" });
expect(bridge.content.content?.[0]?.type).toBe("paragraph");
bridge.receive({ type: "command", command: "table" });
expect(bridge.content.content?.some((n) => n.type === "table")).toBe(true);
});
it("applies the page's width and font to the document", () => {
const { bridge, sent } = setup();
const root = document.documentElement.classList;
+10
View File
@@ -17,6 +17,12 @@ const commands: Record<Command, (e: Editor) => boolean> = {
orderedList: (e) => e.chain().focus().toggleOrderedList().run(),
blockquote: (e) => e.chain().focus().toggleBlockquote().run(),
codeBlock: (e) => e.chain().focus().toggleCodeBlock().run(),
underline: (e) => e.chain().focus().toggleUnderline().run(),
taskList: (e) => e.chain().focus().toggleTaskList().run(),
// A callout around the selection, or the selection taken out of one.
callout: (e) =>
e.isActive("callout") ? e.chain().focus().unsetCallout().run() : e.chain().focus().setCallout().run(),
table: (e) => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
undo: (e) => e.chain().focus().undo().run(),
redo: (e) => e.chain().focus().redo().run(),
};
@@ -34,6 +40,10 @@ const activeChecks: [Command, (e: Editor) => boolean][] = [
["orderedList", (e) => e.isActive("orderedList")],
["blockquote", (e) => e.isActive("blockquote")],
["codeBlock", (e) => e.isActive("codeBlock")],
["underline", (e) => e.isActive("underline")],
["taskList", (e) => e.isActive("taskList")],
["callout", (e) => e.isActive("callout")],
["table", (e) => e.isActive("table")],
];
/**
+5 -1
View File
@@ -18,6 +18,10 @@ export type Command =
| "orderedList"
| "blockquote"
| "codeBlock"
| "underline"
| "taskList"
| "callout"
| "table"
| "undo"
| "redo";
@@ -62,4 +66,4 @@ export type EditorMessage =
| { type: "error"; message: string };
/** Bumped when a message changes shape, so the app can refuse a stale bundle. */
export const PROTOCOL_VERSION = 1;
export const PROTOCOL_VERSION = 2;
+6
View File
@@ -20,12 +20,17 @@
"@floating-ui/dom": "^1.8.0",
"@tiptap/core": "^3.32.2",
"@tiptap/extension-bubble-menu": "^3.32.2",
"@tiptap/extension-code-block": "^3.32.2",
"@tiptap/extension-collaboration": "^3.32.2",
"@tiptap/extension-collaboration-caret": "^3.32.2",
"@tiptap/extension-details": "^3.32.2",
"@tiptap/extension-highlight": "^3.32.2",
"@tiptap/extension-image": "^3.32.2",
"@tiptap/extension-list": "^3.32.2",
"@tiptap/extension-mathematics": "^3.32.2",
"@tiptap/extension-mention": "^3.32.2",
"@tiptap/extension-table": "^3.32.2",
"@tiptap/extension-text-align": "^3.32.2",
"@tiptap/extensions": "^3.32.2",
"@tiptap/pm": "^3.32.2",
"@tiptap/starter-kit": "^3.32.2",
@@ -35,6 +40,7 @@
"katex": "^0.18.10",
"lib0": "^0.2.119",
"mermaid": "^12.2.0",
"pdfjs-dist": "^5.4.149",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"y-protocols": "^1.0.7",
+233 -21
View File
@@ -3,15 +3,18 @@
import type { Editor, JSONContent } from "@tiptap/core";
import { EditorContent, useEditor } from "@tiptap/vue-3";
import { BubbleMenu } from "@tiptap/vue-3/menus";
import { CellSelection } from "@tiptap/pm/tables";
import { DwIcon, type IconName } from "@docwell/ui";
import { computed, nextTick, onBeforeUnmount, ref, watch } from "vue";
import { blockHash, ensureBlockId } from "./blocklinks";
import { palette, type PaletteColor } from "./colors";
import { docwellExtensions, type CollabUser } from "./extensions";
import { findKey } from "./find";
import type { LinkHost } from "./embeds";
import type { FileHost } from "./files";
import { englishLabels, type EditorLabels } from "./labels";
import type { MentionHost } from "./mention";
import type { PageHost } from "./pagelinks";
import { createLinkedPage, type PageHost } from "./pagelinks";
import type { CollabProvider } from "./provider";
const props = withDefaults(
@@ -35,6 +38,8 @@ const props = withDefaults(
labels?: EditorLabels;
/** Shows the Comment button on selections, also when the editor is read-only. */
canComment?: boolean;
/** Whether code blocks show line numbers unless one was switched on or off itself. */
codeLineNumbers?: boolean;
}>(),
{ editable: true },
);
@@ -70,6 +75,8 @@ const editor = useEditor({
// The heavy editors load on first use; the mobile bridge leaves them out.
loadMermaid: () => import("mermaid").then((m) => m.default),
loadExcalidraw: () => import("./excalidraw"),
loadPdf: () => import("./pdfjs").then((m) => m.pdf),
codeLineNumbers: props.codeLineNumbers,
onNavigate: (path) => emit("navigate", path),
labels: props.labels,
onCommentSelect: (id) => emit("comment-select", id),
@@ -82,6 +89,9 @@ const editor = useEditor({
found.value = { current: f?.current ?? -1, total: f?.matches.length ?? 0 };
},
onBlur: () => emit("blur"),
onSelectionUpdate: ({ editor }) => {
if (editor.state.selection.empty) panel.value = null;
},
});
watch(
@@ -93,22 +103,58 @@ onBeforeUnmount(() => editor.value?.destroy());
// The selection toolbar: formatting for editors, Comment for anyone allowed.
type Tool = { id: string; icon: IconName; label: string; active: () => boolean; run: () => void };
/** The colour or alignment choices open under the toolbar, if any. */
const panel = ref<"color" | "align" | null>(null);
const togglePanel = (p: "color" | "align") => (panel.value = panel.value === p ? null : p);
const alignment = (e: Editor) =>
String(e.getAttributes("paragraph").textAlign ?? e.getAttributes("heading").textAlign ?? "left");
const alignIcons: Record<string, IconName> = { left: "align-left", center: "align-center", right: "align-right" };
const alignLabel = (a: string) =>
labels.value.format[a === "center" ? "alignCenter" : a === "right" ? "alignRight" : "alignLeft"];
const tools = computed<Tool[]>(() => {
const e = editor.value;
if (!e) return [];
const f = labels.value.format;
const mark = (id: "bold" | "italic" | "strike" | "code", icon: IconName, label: string): Tool => ({
const mark = (id: "bold" | "italic" | "underline" | "strike" | "code", icon: IconName, label: string): Tool => ({
id,
icon,
label,
active: () => e.isActive(id),
run: () => e.chain().focus().toggleMark(id).run(),
});
return [
const list: Tool[] = [
mark("bold", "bold", f.bold),
mark("italic", "italic", f.italic),
mark("underline", "underline", f.underline),
mark("strike", "strike", f.strike),
mark("code", "code", f.code),
{
id: "color",
icon: "palette",
label: f.color,
active: () => panel.value === "color" || e.isActive("textColor") || e.isActive("highlight"),
run: () => togglePanel("color"),
},
{
id: "align",
icon: alignIcons[alignment(e)] ?? "align-left",
label: f.align,
active: () => panel.value === "align",
run: () => togglePanel("align"),
},
{
id: "math",
icon: "sigma",
label: f.math,
active: () => false,
run: () => {
const { from, to } = e.state.selection;
const latex = e.state.doc.textBetween(from, to, " ").trim() || "x";
e.chain().focus().deleteSelection().insertInlineMath({ latex }).run();
},
},
{
id: "link",
icon: "link",
@@ -123,8 +169,85 @@ const tools = computed<Tool[]>(() => {
},
},
];
const pages = props.pages;
if (pages?.create) {
list.push({
id: "linkedPage",
icon: "page-plus",
label: f.linkedPage,
active: () => false,
run: () => void createLinkedPage(e, pages, "").catch((err) => emit("error", err)),
});
}
const blockLink = props.blockLink;
if (blockLink) {
list.push({
id: "blockLink",
icon: "share",
label: labels.value.blocks.copyBlockLink,
active: () => false,
run: () => {
const $from = e.state.selection.$from;
const id = $from.depth >= 1 ? ensureBlockId(e.view, $from.before(1)) : null;
if (!id) return;
const url = blockLink(blockHash(id));
navigator.clipboard.writeText(url).then(
() => emit("block-link-copied", url),
() => window.prompt("", url),
);
},
});
}
return list;
});
function setColor(kind: "text" | "highlight", color: PaletteColor | null) {
const c = editor.value?.chain().focus();
if (!c) return;
if (kind === "text") (color ? c.setTextColor(color) : c.unsetTextColor()).run();
else (color ? c.setHighlight({ color }) : c.unsetHighlight()).run();
}
function setAlign(a: "left" | "center" | "right") {
editor.value?.chain().focus().setTextAlign(a).run();
panel.value = null;
}
// The table toolbar sits above the table the cursor is in.
type TableTool = {
id: Exclude<keyof EditorLabels["table"], "toolbar" | "dragRow">;
run: (e: Editor) => boolean;
danger?: boolean;
};
const tableTools: TableTool[] = [
{ id: "addRowBefore", run: (e) => e.chain().focus().addRowBefore().run() },
{ id: "addRowAfter", run: (e) => e.chain().focus().addRowAfter().run() },
{ id: "addColumnBefore", run: (e) => e.chain().focus().addColumnBefore().run() },
{ id: "addColumnAfter", run: (e) => e.chain().focus().addColumnAfter().run() },
{ id: "moveRowUp", run: (e) => e.chain().focus().moveTableRow(-1).run() },
{ id: "moveRowDown", run: (e) => e.chain().focus().moveTableRow(1).run() },
{ id: "deleteRow", run: (e) => e.chain().focus().deleteRow().run() },
{ id: "deleteColumn", run: (e) => e.chain().focus().deleteColumn().run() },
{ id: "toggleHeaderRow", run: (e) => e.chain().focus().toggleHeaderRow().run() },
{ id: "mergeCells", run: (e) => e.chain().focus().mergeCells().run() },
{ id: "splitCell", run: (e) => e.chain().focus().splitCell().run() },
{ id: "deleteTable", run: (e) => e.chain().focus().deleteTable().run(), danger: true },
];
function showTableMenu({ editor: e }: { editor: Editor }) {
if (!e.isEditable || !e.isActive("table")) return false;
return e.state.selection.empty || e.state.selection instanceof CellSelection;
}
/** The table around the selection, which the table toolbar is placed against. */
function tableElement() {
const e = editor.value;
if (!e) return null;
const { node } = e.view.domAtPos(e.state.selection.from);
const el = (node instanceof HTMLElement ? node : node.parentElement)?.closest("table");
return el ? { getBoundingClientRect: () => el.getBoundingClientRect() } : null;
}
function comment() {
const e = editor.value;
if (!e) return;
@@ -147,7 +270,7 @@ function shouldShow({ editor: e, from, to }: { editor: Editor; from: number; to:
"embed",
"linkCard",
];
if (from === to || blocks.some((b) => e.isActive(b))) return false;
if (from === to || blocks.some((b) => e.isActive(b)) || e.state.selection instanceof CellSelection) return false;
return e.isEditable || props.canComment;
}
@@ -308,35 +431,124 @@ defineExpose({ editor, openFind });
v-if="editor"
:editor="editor"
:should-show="shouldShow"
class="flex items-center gap-0.5 rounded-md border border-line bg-surface-raised p-1 shadow-menu"
class="flex flex-col gap-1 rounded-md border border-line bg-surface-raised p-1 shadow-menu"
data-testid="bubble-menu"
>
<template v-if="editor.isEditable">
<div class="flex items-center gap-0.5">
<template v-if="editor.isEditable">
<button
v-for="t in tools"
:key="t.id"
type="button"
class="grid size-7 cursor-pointer place-items-center rounded-sm text-ink-muted hover:bg-surface-hover hover:text-ink"
:class="{ 'bg-surface-hover text-ink': t.active() }"
:aria-label="t.label"
:title="t.label"
:aria-pressed="t.active()"
@mousedown.prevent
@click="t.run()"
>
<DwIcon :name="t.icon" :size="16" />
</button>
</template>
<button
v-for="t in tools"
:key="t.id"
v-if="canComment"
type="button"
class="flex h-7 cursor-pointer items-center gap-1 rounded-sm px-2 text-ui-sm font-semibold text-ink-muted hover:bg-surface-hover hover:text-ink"
:class="{ 'ml-0.5 border-l border-line pl-2': editor.isEditable }"
data-testid="comment-selection"
@mousedown.prevent
@click="comment"
>
<DwIcon name="comment" :size="16" />{{ labels.format.comment }}
</button>
</div>
<div
v-if="editor.isEditable && panel === 'color'"
class="flex flex-col gap-1 border-t border-line px-1 pt-1.5 pb-0.5"
data-testid="color-panel"
>
<div
v-for="kind in ['text', 'highlight'] as const"
:key="kind"
class="flex items-center gap-1"
role="group"
:aria-label="kind === 'text' ? labels.format.textColor : labels.format.highlight"
>
<span class="w-20 shrink-0 text-ui-xs text-ink-muted">{{
kind === "text" ? labels.format.textColor : labels.format.highlight
}}</span>
<button
type="button"
class="dw-swatch"
:class="kind === 'text' ? 'dw-swatch--text' : 'dw-swatch--none'"
:aria-label="labels.format.noColor"
:title="labels.format.noColor"
@mousedown.prevent
@click="setColor(kind, null)"
>
{{ kind === "text" ? "A" : "" }}
</button>
<button
v-for="c in palette"
:key="c"
type="button"
class="dw-swatch"
:class="kind === 'text' ? 'dw-swatch--text' : 'dw-swatch--fill'"
:data-color="c"
:aria-label="labels.colors[c] ?? c"
:title="labels.colors[c] ?? c"
:aria-pressed="editor.isActive(kind === 'text' ? 'textColor' : 'highlight', { color: c })"
@mousedown.prevent
@click="setColor(kind, c)"
>
{{ kind === "text" ? "A" : "" }}
</button>
</div>
</div>
<div
v-if="editor.isEditable && panel === 'align'"
class="flex items-center gap-0.5 border-t border-line px-1 pt-1"
data-testid="align-panel"
>
<button
v-for="a in ['left', 'center', 'right'] as const"
:key="a"
type="button"
class="grid size-7 cursor-pointer place-items-center rounded-sm text-ink-muted hover:bg-surface-hover hover:text-ink"
:class="{ 'bg-surface-hover text-ink': t.active() }"
:aria-label="t.label"
:title="t.label"
:aria-pressed="t.active()"
:class="{ 'bg-surface-hover text-ink': alignment(editor) === a }"
:aria-label="alignLabel(a)"
:title="alignLabel(a)"
:aria-pressed="alignment(editor) === a"
@mousedown.prevent
@click="t.run()"
@click="setAlign(a)"
>
<DwIcon :name="t.icon" :size="16" />
<DwIcon :name="alignIcons[a] ?? 'align-left'" :size="16" />
</button>
</template>
</div>
</BubbleMenu>
<BubbleMenu
v-if="editor"
:editor="editor"
plugin-key="tableMenu"
:should-show="showTableMenu"
:get-referenced-virtual-element="tableElement"
:options="{ placement: 'top-start', offset: 6 }"
class="flex max-w-[calc(100vw-16px)] flex-wrap items-center gap-0.5 rounded-md border border-line bg-surface-raised p-1 shadow-menu"
role="toolbar"
:aria-label="labels.table.toolbar"
data-testid="table-menu"
>
<button
v-if="canComment"
v-for="t in tableTools"
:key="t.id"
type="button"
class="flex h-7 cursor-pointer items-center gap-1 rounded-sm px-2 text-ui-sm font-semibold text-ink-muted hover:bg-surface-hover hover:text-ink"
:class="{ 'ml-0.5 border-l border-line pl-2': editor.isEditable }"
data-testid="comment-selection"
class="h-7 cursor-pointer rounded-sm px-2 text-ui-xs font-semibold text-ink-muted hover:bg-surface-hover hover:text-ink"
:class="{ 'text-danger hover:text-danger': t.danger }"
@mousedown.prevent
@click="comment"
@click="t.run(editor)"
>
<DwIcon name="comment" :size="16" />{{ labels.format.comment }}
{{ labels.table[t.id] }}
</button>
</BubbleMenu>
<EditorContent :editor="editor" />
+120 -40
View File
@@ -2,8 +2,9 @@
import { Extension, type Editor } from "@tiptap/core";
import type { Node as PMNode } from "@tiptap/pm/model";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import { NodeSelection, Plugin, PluginKey } from "@tiptap/pm/state";
import type { EditorView } from "@tiptap/pm/view";
import { blockActions, openBlockMenu } from "./blockmenu";
import type { EditorLabels } from "./labels";
/** Blocks a link can point at. */
@@ -14,6 +15,9 @@ const linkable = [
"codeBlock",
"bulletList",
"orderedList",
"taskList",
"callout",
"table",
"details",
"image",
"embed",
@@ -41,6 +45,21 @@ function newBlockId(): string {
return [...bytes].map((b) => (b % 36).toString(36)).join("");
}
/**
* The id of the block at pos, giving it one first when the view can be
* edited; null when it has none and cannot get one.
*/
export function ensureBlockId(view: EditorView, pos: number): string | null {
const node = view.state.doc.nodeAt(pos);
if (!node) return null;
const id = node.attrs.blockId as string | null;
if (id) return id;
if (!view.editable || !linkable.includes(node.type.name)) return null;
const fresh = newBlockId();
view.dispatch(view.state.tr.setNodeAttribute(pos, "blockId", fresh));
return fresh;
}
function findBlock(doc: PMNode, id: string): number {
let found = -1;
doc.descendants((node, pos) => {
@@ -79,9 +98,10 @@ export interface BlockLinkOptions {
}
/**
* Links to single blocks. A block gets a short id the first time someone
* copies a link to it, from the button beside it in the margin. Readers can
* copy links to blocks that already have one.
* Links to single blocks, and the handle beside each block. A block gets a
* short id the first time someone copies a link to it. Readers can copy
* links to blocks that already have one. Editors also get a grip that drags
* the block and opens its actions menu (see blockmenu.ts).
*/
export const BlockLinks = Extension.create<BlockLinkOptions>({
name: "blockLinks",
@@ -113,67 +133,96 @@ export const BlockLinks = Extension.create<BlockLinkOptions>({
addProseMirrorPlugins() {
const { link, onCopied } = this.options;
const labels = this.options.labels!;
if (!link) return [];
const editor = this.editor;
return [
new Plugin({
key: new PluginKey("blockLinks"),
view: (view) => new BlockHandle(view, labels.blocks.copyBlockLink, link, onCopied),
view: (view) => new BlockHandle(view, editor, labels, link, onCopied),
}),
];
},
});
/** The "copy link" button that follows the pointer from block to block. */
// The editor package draws its handles itself, without the icon set's layout.
const linkGlyph =
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.5 1.5"/><path d="M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.5-1.5"/></svg>';
const gripGlyph =
'<svg viewBox="0 0 24 24" width="14" height="14" fill="currentColor" aria-hidden="true"><circle cx="9" cy="6" r="1.6"/><circle cx="15" cy="6" r="1.6"/><circle cx="9" cy="12" r="1.6"/><circle cx="15" cy="12" r="1.6"/><circle cx="9" cy="18" r="1.6"/><circle cx="15" cy="18" r="1.6"/></svg>';
/** The buttons that follow the pointer from block to block: copy link, and the grip. */
class BlockHandle {
private button = document.createElement("button");
private gutter = document.createElement("div");
private linkButton = document.createElement("button");
private grip = document.createElement("button");
private pos = -1;
private closeMenu: (() => void) | null = null;
constructor(
private view: EditorView,
label: string,
private link: (hash: string) => string,
private editor: Editor,
private labels: EditorLabels,
private link?: (hash: string) => string,
private onCopied?: (url: string) => void,
) {
const b = this.button;
const g = this.gutter;
g.className = "dw-block-gutter";
g.contentEditable = "false";
g.hidden = true;
g.addEventListener("mouseleave", this.leave);
const b = this.linkButton;
b.type = "button";
b.className = "dw-block-handle";
b.setAttribute("aria-label", label);
b.title = label;
b.contentEditable = "false";
// A chain-link glyph; the editor package draws no icons of its own.
b.innerHTML =
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M10 13a5 5 0 0 0 7.07 0l3-3a5 5 0 0 0-7.07-7.07l-1.5 1.5"/><path d="M14 11a5 5 0 0 0-7.07 0l-3 3a5 5 0 0 0 7.07 7.07l1.5-1.5"/></svg>';
b.hidden = true;
b.setAttribute("aria-label", labels.blocks.copyBlockLink);
b.title = labels.blocks.copyBlockLink;
b.innerHTML = linkGlyph;
b.addEventListener("mousedown", (e) => e.preventDefault());
b.addEventListener("click", () => void this.copy());
b.addEventListener("mouseleave", this.leave);
const grip = this.grip;
grip.type = "button";
grip.className = "dw-block-handle dw-block-grip";
grip.setAttribute("aria-label", labels.blockMenu.open);
grip.setAttribute("aria-haspopup", "menu");
grip.setAttribute("aria-expanded", "false");
grip.title = labels.blockMenu.open;
grip.innerHTML = gripGlyph;
grip.draggable = true;
grip.addEventListener("click", this.openMenu);
grip.addEventListener("dragstart", this.dragStart);
grip.addEventListener("dragend", () => this.hide());
if (link) g.append(b);
g.append(grip);
view.dom.addEventListener("mousemove", this.move);
view.dom.addEventListener("mouseleave", this.leave);
}
/** The element around the editor, which the button sits in. Hosts may move the editor after creating it. */
/** The element around the editor, which the buttons sit in. Hosts may move the editor after creating it. */
private get host(): HTMLElement | null {
const host = this.view.dom.parentElement;
if (host && this.button.parentElement !== host) {
if (host && this.gutter.parentElement !== host) {
host.classList.add("dw-block-host");
host.append(this.button);
host.append(this.gutter);
}
return host;
}
private hide = () => {
this.button.hidden = true;
if (this.closeMenu) return;
this.gutter.hidden = true;
this.pos = -1;
};
// Moving from the text onto the button keeps it.
// Moving from the text onto the buttons keeps them.
private leave = (e: MouseEvent) => {
const to = e.relatedTarget as Node | null;
if (to && (this.button.contains(to) || this.view.dom.contains(to))) return;
if (to && (this.gutter.contains(to) || this.view.dom.contains(to))) return;
this.hide();
};
private move = (e: MouseEvent) => {
if (this.closeMenu) return;
// The top-level block under the pointer.
let el = e.target as HTMLElement | null;
while (el && el.parentElement !== this.view.dom) el = el.parentElement;
@@ -188,26 +237,56 @@ class BlockHandle {
const $pos = this.view.state.doc.resolve(Math.min(pos, this.view.state.doc.content.size));
const start = $pos.depth >= 1 ? $pos.before(1) : pos;
const node = this.view.state.doc.nodeAt(start);
if (!node) return this.hide();
// Readers can only copy links that exist; only editors can add an id.
if (!node || !linkable.includes(node.type.name) || (!node.attrs.blockId && !this.view.editable)) {
return this.hide();
}
const canLink = !!this.link && linkable.includes(node.type.name) && (!!node.attrs.blockId || this.view.editable);
const canEdit = this.view.editable;
if (!canLink && !canEdit) return this.hide();
this.linkButton.hidden = !canLink;
this.grip.hidden = !canEdit;
this.pos = start;
const box = el.getBoundingClientRect();
const hostBox = host.getBoundingClientRect();
this.button.style.top = `${box.top - hostBox.top + Math.min(box.height / 2, 14) - 11}px`;
this.button.hidden = false;
this.gutter.style.top = `${box.top - hostBox.top + Math.min(box.height / 2, 14) - 11}px`;
this.gutter.hidden = false;
};
private async copy() {
const node = this.pos >= 0 ? this.view.state.doc.nodeAt(this.pos) : null;
if (!node) return;
let id = node.attrs.blockId as string | null;
if (!id) {
if (!this.view.editable) return;
id = newBlockId();
this.view.dispatch(this.view.state.tr.setNodeAttribute(this.pos, "blockId", id));
private openMenu = () => {
if (this.closeMenu) {
this.closeMenu();
return;
}
const pos = this.pos;
if (pos < 0 || !this.view.editable) return;
const node = this.view.state.doc.nodeAt(pos);
const canLink = !!this.link && !!node && linkable.includes(node.type.name);
const actions = blockActions(this.editor, pos, this.labels, canLink ? () => void this.copy(pos) : undefined);
this.grip.setAttribute("aria-expanded", "true");
this.closeMenu = openBlockMenu(this.grip, actions, this.labels.blockMenu.open, () => {
this.closeMenu = null;
this.grip.setAttribute("aria-expanded", "false");
this.hide();
});
};
/** Drags the whole block, the way ProseMirror drags a selected node. */
private dragStart = (e: DragEvent) => {
const pos = this.pos;
if (pos < 0 || !e.dataTransfer) return;
this.closeMenu?.();
const sel = NodeSelection.create(this.view.state.doc, pos);
this.view.dispatch(this.view.state.tr.setSelection(sel));
e.dataTransfer.effectAllowed = "copyMove";
e.dataTransfer.setData("text/plain", sel.node.textContent);
const dom = this.view.nodeDOM(pos);
if (dom instanceof HTMLElement) e.dataTransfer.setDragImage(dom, 0, 0);
this.view.dragging = { slice: sel.content(), move: true };
};
private async copy(at = this.pos) {
if (at < 0 || !this.link) return;
const id = ensureBlockId(this.view, at);
if (!id) return;
const url = this.link(blockHash(id));
try {
await navigator.clipboard.writeText(url);
@@ -223,8 +302,9 @@ class BlockHandle {
}
destroy() {
this.button.parentElement?.classList.remove("dw-block-host");
this.button.remove();
this.closeMenu?.();
this.gutter.parentElement?.classList.remove("dw-block-host");
this.gutter.remove();
this.view.dom.removeEventListener("mousemove", this.move);
this.view.dom.removeEventListener("mouseleave", this.leave);
}
+285
View File
@@ -0,0 +1,285 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
import type { ChainedCommands, Editor, JSONContent } from "@tiptap/core";
import { Fragment } from "@tiptap/pm/model";
import { Selection } from "@tiptap/pm/state";
import type { IconName } from "@docwell/ui/icons";
import { showsLineNumbers } from "./codeblock";
import type { EditorLabels } from "./labels";
import { isPdf } from "./pdf";
import { svgIcon } from "./suggestion";
/** One row of the block menu; a row with children opens a list of them instead. */
export interface BlockAction {
id: string;
label: string;
icon: IconName;
run?: () => void;
children?: BlockAction[];
danger?: boolean;
}
/** What a block's text can turn into, as slash-menu ids with the commands that make them. */
const conversions: [string, IconName, (c: ChainedCommands) => ChainedCommands][] = [
["text", "text", (c) => c],
["h1", "heading", (c) => c.setNode("heading", { level: 1 })],
["h2", "heading", (c) => c.setNode("heading", { level: 2 })],
["h3", "heading", (c) => c.setNode("heading", { level: 3 })],
["bullet", "list", (c) => c.toggleBulletList()],
["ordered", "list-ordered", (c) => c.toggleOrderedList()],
["todo", "todo", (c) => c.toggleTaskList()],
["quote", "quote", (c) => c.setBlockquote()],
["code", "code", (c) => c.setCodeBlock()],
["callout", "callout", (c) => c.setCallout()],
];
/** Blocks whose text the menu can turn into another kind of block. */
const convertible = [
"paragraph",
"heading",
"codeBlock",
"blockquote",
"bulletList",
"orderedList",
"taskList",
"callout",
];
/** A block's JSON without block ids, so a copy does not share links with the original. */
function withoutIds(json: JSONContent): JSONContent {
const out: JSONContent = { ...json };
if (out.attrs && "blockId" in out.attrs) out.attrs = { ...out.attrs, blockId: null };
if (out.content) out.content = out.content.map(withoutIds);
return out;
}
/**
* The actions for the top-level block at pos: turn into, move, duplicate,
* copy, delete, plus block-specific ones (line numbers, PDF pages).
*/
export function blockActions(editor: Editor, pos: number, labels: EditorLabels, copyLink?: () => void): BlockAction[] {
const node = editor.state.doc.nodeAt(pos);
if (!node) return [];
const m = labels.blockMenu;
const end = pos + node.nodeSize;
const index = editor.state.doc.resolve(pos).index(0);
const out: BlockAction[] = [];
if (convertible.includes(node.type.name)) {
out.push({
id: "turnInto",
label: m.turnInto,
icon: "text",
children: conversions.map(([id, icon, make]) => ({
id,
icon,
label: labels.slash[id]?.label ?? id,
run: () => {
if (id === "callout") {
// A callout holds any block, so the block goes in as it is (a
// heading stays a heading); a quote gives it its contents.
if (node.type.name === "callout") return;
const inner = node.type.name === "blockquote" ? node.content : Fragment.from(node);
const callout = editor.schema.nodes.callout!.create(null, inner);
const tr = editor.state.tr.replaceWith(pos, end, callout);
editor.view.dispatch(tr.setSelection(Selection.near(tr.doc.resolve(pos + 1))).scrollIntoView());
editor.commands.focus();
return;
}
// Select the block's text from its first to its last line (lists and
// callouts hold it deeper down), then make plain paragraphs of it, so
// every kind starts from the same place.
const doc = editor.state.doc;
const from = Selection.findFrom(doc.resolve(pos), 1, true)?.from ?? pos + 1;
const to = Selection.findFrom(doc.resolve(end), -1, true)?.to ?? end - 1;
const chain = editor.chain().focus().setTextSelection({ from, to }).clearNodes();
make(chain).run();
},
})),
});
}
if (node.type.name === "codeBlock") {
const byDefault = !!editor.extensionManager.extensions.find((e) => e.name === "codeBlock")?.options.lineNumbers;
const on = showsLineNumbers(node.attrs.lineNumbers, byDefault);
out.push({
id: "lineNumbers",
label: on ? m.hideLineNumbers : m.showLineNumbers,
icon: "list-ordered",
run: () => editor.view.dispatch(editor.state.tr.setNodeAttribute(pos, "lineNumbers", !on)),
});
}
if (node.type.name === "fileAttachment" && isPdf(node.attrs.mime, node.attrs.name)) {
const preview = node.attrs.view === "preview";
out.push({
id: "pdfView",
label: preview ? m.showAsFile : m.showPages,
icon: preview ? "paperclip" : "file",
run: () => editor.view.dispatch(editor.state.tr.setNodeAttribute(pos, "view", preview ? "card" : "preview")),
});
}
if (index > 0) {
out.push({
id: "moveUp",
label: m.moveUp,
icon: "arrow-up",
run: () => {
const prev = editor.state.doc.child(index - 1);
const tr = editor.state.tr.delete(pos, end).insert(pos - prev.nodeSize, node);
editor.view.dispatch(tr.scrollIntoView());
},
});
}
if (index < editor.state.doc.childCount - 1) {
out.push({
id: "moveDown",
label: m.moveDown,
icon: "arrow-down",
run: () => {
const next = editor.state.doc.child(index + 1);
const tr = editor.state.tr.delete(pos, end).insert(pos + next.nodeSize, node);
editor.view.dispatch(tr.scrollIntoView());
},
});
}
out.push(
{
id: "duplicate",
label: m.duplicate,
icon: "plus",
run: () => {
const copy = editor.schema.nodeFromJSON(withoutIds(node.toJSON() as JSONContent));
editor.view.dispatch(editor.state.tr.insert(end, copy).scrollIntoView());
},
},
{
id: "copy",
label: m.copy,
icon: "copy",
run: () => {
// The browser's own copy keeps the block's formatting for pasting elsewhere.
editor.chain().focus().setNodeSelection(pos).run();
document.execCommand("copy");
},
},
);
if (copyLink) out.push({ id: "copyLink", label: labels.blocks.copyBlockLink, icon: "link", run: copyLink });
out.push({
id: "delete",
label: m.delete,
icon: "trash",
danger: true,
run: () => {
editor.view.dispatch(editor.state.tr.delete(pos, end));
editor.commands.focus();
},
});
return out;
}
/**
* Shows actions in a menu next to anchor. Arrows move, Enter picks, Escape
* or a click elsewhere closes it. Returns a function that closes it.
*/
export function openBlockMenu(anchor: HTMLElement, actions: BlockAction[], label: string, onClose?: () => void) {
const box = document.createElement("div");
box.className = "dw-suggest dw-block-menu";
box.setAttribute("role", "menu");
box.setAttribute("aria-label", label);
let list = actions;
let active = 0;
let stack: BlockAction[][] = [];
const draw = () => {
box.replaceChildren();
list.forEach((a, i) => {
const row = document.createElement("button");
row.type = "button";
row.className = `dw-suggest__item${i === active ? " is-active" : ""}${a.danger ? " is-danger" : ""}`;
row.setAttribute("role", "menuitem");
row.tabIndex = -1;
if (a.children) row.setAttribute("aria-haspopup", "menu");
const glyph = document.createElement("span");
glyph.className = "dw-suggest__icon";
glyph.append(svgIcon(a.icon));
const text = document.createElement("span");
text.className = "dw-suggest__label";
text.textContent = a.label;
row.append(glyph, text);
if (a.children) {
const more = svgIcon("chevron-right", 14);
more.classList.add("dw-block-menu__more");
row.append(more);
}
row.addEventListener("mousedown", (e) => e.preventDefault());
row.addEventListener("click", () => pick(i));
row.addEventListener("mouseenter", () => {
active = i;
for (const [j, r] of [...box.children].entries()) r.classList.toggle("is-active", j === i);
});
box.append(row);
});
(box.children[active] as HTMLElement | undefined)?.focus();
};
const pick = (i: number) => {
const a = list[i];
if (!a) return;
if (a.children) {
stack.push(list);
list = a.children;
active = 0;
draw();
return;
}
close();
a.run?.();
};
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape" || (e.key === "ArrowLeft" && stack.length)) {
e.preventDefault();
e.stopPropagation();
if (stack.length) {
list = stack.pop()!;
active = 0;
draw();
} else close();
return;
}
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
e.preventDefault();
active = (active + (e.key === "ArrowDown" ? 1 : -1) + list.length) % list.length;
draw();
} else if (e.key === "Enter" || e.key === " " || e.key === "ArrowRight") {
e.preventDefault();
if (e.key !== "ArrowRight" || list[active]?.children) pick(active);
}
};
const onDown = (e: MouseEvent) => {
if (!box.contains(e.target as Node) && !anchor.contains(e.target as Node)) close();
};
document.body.append(box);
const stop = autoUpdate(anchor, box, () => {
void computePosition(anchor, box, {
placement: "bottom-start",
strategy: "fixed",
middleware: [offset(4), flip(), shift({ padding: 8 })],
}).then(({ x, y }) => Object.assign(box.style, { left: `${x}px`, top: `${y}px` }));
});
box.addEventListener("keydown", onKey);
document.addEventListener("mousedown", onDown, true);
let closed = false;
function close() {
if (closed) return;
closed = true;
stop();
box.remove();
document.removeEventListener("mousedown", onDown, true);
stack = [];
onClose?.();
}
draw();
return close;
}
+173
View File
@@ -0,0 +1,173 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Editor, type JSONContent } from "@tiptap/core";
import { afterEach, describe, expect, it } from "vitest";
import { blockActions } from "./blockmenu";
import { showsLineNumbers } from "./codeblock";
import { docwellExtensions } from "./extensions";
import { englishLabels } from "./labels";
import { filterCommands, slashCommands } from "./slash";
let editor: Editor | undefined;
afterEach(() => editor?.destroy());
function setup(content: string | JSONContent, opts: Parameters<typeof docwellExtensions>[0] = {}) {
editor = new Editor({ extensions: docwellExtensions(opts), content });
return editor;
}
const types = (e: Editor) => (e.getJSON().content ?? []).map((n) => n.type);
const action = (e: Editor, pos: number, id: string) => {
const all = blockActions(e, pos, englishLabels);
return all.find((a) => a.id === id) ?? all.flatMap((a) => a.children ?? []).find((a) => a.id === id);
};
describe("new blocks", () => {
it("reads callouts, to-dos and tables back from their HTML", () => {
const e = setup(
'<aside data-type="callout" data-emoji="🔥" data-color="red"><p>Hot</p></aside>' +
'<ul data-type="taskList"><li data-type="taskItem" data-checked="true"><p>Done</p></li></ul>' +
"<table><tr><th><p>A</p></th><th><p>B</p></th></tr><tr><td><p>1</p></td><td><p>2</p></td></tr></table>",
);
const [callout, tasks, table] = e.getJSON().content as JSONContent[];
expect(callout).toMatchObject({ type: "callout", attrs: { emoji: "🔥", color: "red" } });
expect(tasks?.content?.[0]).toMatchObject({ type: "taskItem", attrs: { checked: true } });
expect(table?.content?.[0]?.content?.[0]?.type).toBe("tableHeader");
expect(table?.content?.[1]?.content?.[1]?.type).toBe("tableCell");
});
it("reads a callout from the server's HTML export without its emoji in the text", () => {
const e = setup(
'<aside data-type="callout" data-emoji="🔥" data-color="red"><span class="callout-emoji">🔥</span>' +
'<div class="callout-body"><p>Careful</p></div></aside>',
);
expect(e.getJSON().content![0]).toEqual({
type: "callout",
attrs: { emoji: "🔥", color: "red", blockId: null },
content: [
{ type: "paragraph", attrs: { textAlign: null, blockId: null }, content: [{ type: "text", text: "Careful" }] },
],
});
});
it("keeps only palette colours on text and highlights", () => {
const e = setup('<p><span data-color="green">ok</span><span data-color="#f00">no</span><mark>hi</mark></p>');
const runs = e.getJSON().content![0]!.content!;
expect(runs[0]).toMatchObject({ text: "ok", marks: [{ type: "textColor", attrs: { color: "green" } }] });
expect(runs[1]).toEqual({ type: "text", text: "no" });
expect(runs[2]?.marks?.[0]?.type).toBe("highlight");
});
it("has headings down to level 6 and aligns text", () => {
const e = setup("<h5>Small</h5>");
expect(e.getJSON().content![0]).toMatchObject({ type: "heading", attrs: { level: 5 } });
e.chain().setTextSelection(1).setTextAlign("center").run();
expect(e.getJSON().content![0]!.attrs!.textAlign).toBe("center");
});
it("turns '[] ' at the start of a line into a to-do list", () => {
const e = setup("<p></p>");
e.commands.focus();
// Input rules run on typed text; the space is "typed", the brackets inserted.
e.commands.insertContent("[]");
e.view.someProp("handleTextInput", (f) => f(e.view, 3, 3, " ", () => e.state.tr));
expect(types(e)).toContain("taskList");
});
it("follows the default for line numbers until a block picks", () => {
expect(showsLineNumbers(null, true)).toBe(true);
expect(showsLineNumbers(false, true)).toBe(false);
const e = setup("<pre><code>a\nb</code></pre>", { codeLineNumbers: true });
e.chain().setTextSelection(1).toggleCodeLineNumbers().run();
expect(e.getJSON().content![0]!.attrs!.lineNumbers).toBe(false);
});
it("offers the new blocks and date shortcuts in the slash menu", () => {
const ids = filterCommands(slashCommands(englishLabels), "").map((c) => c.id);
for (const id of ["h4", "h5", "h6", "todo", "callout", "table", "today", "tomorrow", "yesterday", "now"]) {
expect(ids).toContain(id);
}
expect(filterCommands(slashCommands(englishLabels), "other").map((c) => c.id)).toEqual(["h4", "h5", "h6"]);
expect(ids).not.toContain("newPage");
const withPages = slashCommands(englishLabels, undefined, undefined, {
search: async () => [],
create: async () => ({ id: "x", title: "" }),
});
expect(withPages.map((c) => c.id)).toContain("newPage");
});
});
describe("blockActions", () => {
const doc = "<p>one</p><p>two</p><p>three</p>";
it("moves blocks up and down", () => {
const e = setup(doc);
const second = e.state.doc.child(0).nodeSize;
action(e, second, "moveUp")!.run!();
expect(e.getText({ blockSeparator: "|" })).toBe("two|one|three");
action(e, 0, "moveDown")!.run!();
expect(e.getText({ blockSeparator: "|" })).toBe("one|two|three");
});
it("has no move up for the first block and no move down for the last", () => {
const e = setup(doc);
expect(action(e, 0, "moveUp")).toBeUndefined();
const last = e.state.doc.content.size - e.state.doc.lastChild!.nodeSize;
expect(action(e, last, "moveDown")).toBeUndefined();
});
it("duplicates a block without its link id", () => {
const e = setup({
type: "doc",
content: [{ type: "paragraph", attrs: { blockId: "abcdef12" }, content: [{ type: "text", text: "x" }] }],
});
action(e, 0, "duplicate")!.run!();
const [a, b] = e.getJSON().content!;
expect(a!.attrs!.blockId).toBe("abcdef12");
expect(b!.attrs!.blockId).toBeNull();
expect(b!.content).toEqual(a!.content);
});
it("turns a paragraph into other blocks and back", () => {
const e = setup(doc);
action(e, 0, "todo")!.run!();
expect(types(e)[0]).toBe("taskList");
action(e, 0, "callout")!.run!();
expect(types(e)[0]).toBe("callout");
action(e, 0, "h2")!.run!();
expect(e.getJSON().content![0]).toMatchObject({ type: "heading", attrs: { level: 2 } });
action(e, 0, "text")!.run!();
expect(types(e)).toEqual(["paragraph", "paragraph", "paragraph"]);
});
it("keeps a heading, list or code block as it is inside a new callout", () => {
const e = setup("<h2>Title</h2><ul><li><p>a</p></li></ul><blockquote><p>q</p></blockquote>");
action(e, 0, "callout")!.run!();
expect(e.getJSON().content![0]).toMatchObject({
type: "callout",
content: [{ type: "heading", attrs: { level: 2 }, content: [{ type: "text", text: "Title" }] }],
});
const list = e.state.doc.child(0).nodeSize;
action(e, list, "callout")!.run!();
expect(e.getJSON().content![1]!.content![0]!.type).toBe("bulletList");
// A quote gives the callout its contents rather than sitting inside it.
const quote = list + e.state.doc.child(1).nodeSize;
action(e, quote, "callout")!.run!();
expect(e.getJSON().content![2]!.content!.map((n) => n.type)).toEqual(["paragraph"]);
});
it("deletes a block", () => {
const e = setup(doc);
action(e, 0, "delete")!.run!();
expect(e.getText({ blockSeparator: "|" })).toBe("two|three");
});
it("switches a PDF between its pages and a card", () => {
const e = setup({
type: "doc",
content: [{ type: "fileAttachment", attrs: { url: "/f", name: "a.pdf", mime: "application/pdf" } }],
});
action(e, 0, "pdfView")!.run!();
expect(e.getJSON().content![0]!.attrs!.view).toBe("preview");
});
});
+47
View File
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Extension, type AnyExtension } from "@tiptap/core";
import { TaskItem, TaskList } from "@tiptap/extension-list";
import { TableKit } from "@tiptap/extension-table";
import TextAlign from "@tiptap/extension-text-align";
/**
* To-do lists. Typing "[] " or "[x] " at the start of a line starts one; items
* nest with Tab like other lists.
*/
export function docwellTasks(): AnyExtension[] {
return [TaskList.configure({ HTMLAttributes: { class: "dw-tasks" } }), TaskItem.configure({ nested: true })];
}
/**
* Simple tables: a header row, resizable columns, cells that hold blocks.
* Tab moves between cells and adds a row at the end.
*/
export function docwellTables(): AnyExtension[] {
return [
TableKit.configure({
table: { resizable: true, cellMinWidth: 60, HTMLAttributes: { class: "dw-table" } },
}),
];
}
/** Left, centre and right alignment of text blocks (Ctrl+Shift+L / E / R). */
export const docwellAlign = TextAlign.configure({
types: ["heading", "paragraph"],
alignments: ["left", "center", "right"],
});
/**
* AFFiNE-style shortcuts on top of Tiptap's own: Ctrl+Shift+0 for text and
* Ctrl+Shift+1–6 for headings. Code blocks keep Tiptap's Ctrl+Alt+C.
*/
export const HeadingShortcuts = Extension.create({
name: "headingShortcuts",
addKeyboardShortcuts() {
const out: Record<string, () => boolean> = { "Mod-Shift-0": () => this.editor.commands.setParagraph() };
for (const level of [1, 2, 3, 4, 5, 6] as const) {
out[`Mod-Shift-${level}`] = () => this.editor.commands.toggleHeading({ level });
}
return out;
},
});
+168
View File
@@ -0,0 +1,168 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { mergeAttributes, Node } from "@tiptap/core";
import { isPaletteColor, palette, type PaletteColor } from "./colors";
import type { EditorLabels } from "./labels";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
callout: {
/** Wraps the selected blocks in a callout. */
setCallout: (attrs?: { emoji?: string; color?: PaletteColor }) => ReturnType;
/** Turns the callout around the selection back into plain blocks. */
unsetCallout: () => ReturnType;
};
}
}
const defaultEmoji = "💡";
/** One emoji or a short symbol; anything longer is not an icon. */
function cleanEmoji(s: string): string {
const t = s.trim();
return t && [...t].length <= 4 ? t : "";
}
/**
* A box set apart by an emoji and a background colour. It holds ordinary
* blocks. Clicking the emoji changes it; the dot next to it steps through
* the colours.
*/
export const Callout = Node.create<{ labels: EditorLabels | null }>({
name: "callout",
group: "block",
content: "block+",
defining: true,
draggable: true,
addOptions() {
return { labels: null };
},
addAttributes() {
return {
emoji: {
default: defaultEmoji,
parseHTML: (el) => cleanEmoji(el.getAttribute("data-emoji") ?? "") || defaultEmoji,
renderHTML: (attrs) => ({ "data-emoji": attrs.emoji }),
},
color: {
default: "blue",
parseHTML: (el) => {
const c = el.getAttribute("data-color");
return isPaletteColor(c) ? c : "blue";
},
renderHTML: (attrs) => ({ "data-color": attrs.color }),
},
};
},
parseHTML() {
return [
{
tag: "aside[data-type=callout]",
// docwell-server's HTML export shows the emoji beside a .callout-body.
contentElement: (el) => el.querySelector<HTMLElement>(":scope > .callout-body") ?? el,
},
];
},
renderHTML({ HTMLAttributes }) {
return ["aside", mergeAttributes(HTMLAttributes, { "data-type": "callout", class: "dw-callout" }), 0];
},
addCommands() {
return {
setCallout:
(attrs) =>
({ commands }) =>
commands.wrapIn(this.name, attrs),
unsetCallout:
() =>
({ commands }) =>
commands.lift(this.name),
};
},
addKeyboardShortcuts() {
return {
// Backspace at the very start of a callout unwraps it, like a quote.
Backspace: ({ editor }) => {
const { $from, empty } = editor.state.selection;
if (!empty || $from.parentOffset > 0) return false;
for (let d = $from.depth - 1; d > 0; d--) {
if ($from.node(d).type.name === this.name) {
if ($from.index(d) !== 0 || $from.start(d + 1) !== $from.start()) return false;
return editor.commands.lift(this.name);
}
if ($from.index(d) !== 0) return false;
}
return false;
},
};
},
addNodeView() {
return ({ node, getPos, editor }) => {
const labels = this.options.labels;
const dom = document.createElement("aside");
dom.className = "dw-callout";
dom.setAttribute("data-type", "callout");
const side = document.createElement("div");
side.className = "dw-callout__side";
side.contentEditable = "false";
const emoji = document.createElement("button");
emoji.type = "button";
emoji.className = "dw-callout__emoji";
const dot = document.createElement("button");
dot.type = "button";
dot.className = "dw-callout__color";
side.append(emoji, dot);
const content = document.createElement("div");
content.className = "dw-callout__body";
dom.append(side, content);
let current = node;
const set = (patch: Record<string, string>) => {
const pos = getPos();
if (typeof pos !== "number" || !editor.isEditable) return;
editor.view.dispatch(editor.state.tr.setNodeMarkup(pos, undefined, { ...current.attrs, ...patch }));
};
emoji.addEventListener("mousedown", (e) => e.preventDefault());
emoji.addEventListener("click", () => {
if (!editor.isEditable) return;
const next = cleanEmoji(window.prompt(labels?.blocks.calloutEmoji ?? "Emoji", current.attrs.emoji) ?? "");
if (next) set({ emoji: next });
});
dot.addEventListener("mousedown", (e) => e.preventDefault());
dot.addEventListener("click", () => {
const i = palette.indexOf(current.attrs.color as PaletteColor);
set({ color: palette[(i + 1) % palette.length]! });
});
const draw = () => {
dom.setAttribute("data-color", String(current.attrs.color));
emoji.textContent = String(current.attrs.emoji);
const label = labels?.blocks.calloutEmoji ?? "Emoji";
emoji.setAttribute("aria-label", label);
emoji.title = label;
const colorLabel = labels?.blocks.calloutColor ?? "Colour";
dot.setAttribute("aria-label", colorLabel);
dot.title = colorLabel;
};
draw();
return {
dom,
contentDOM: content,
update: (n) => {
if (n.type !== node.type) return false;
current = n;
draw();
return true;
},
// Clicks on the emoji and colour buttons are not edits of the text.
stopEvent: (e) => side.contains(e.target as globalThis.Node),
ignoreMutation: (m) => side.contains(m.target),
};
};
},
});
+93
View File
@@ -0,0 +1,93 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import CodeBlock, { type CodeBlockOptions } from "@tiptap/extension-code-block";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
codeLineNumbers: {
/** Shows or hides line numbers on the code block at the selection. */
toggleCodeLineNumbers: () => ReturnType;
};
}
}
/** Whether a code block shows line numbers: its own choice, else the editor's default. */
export function showsLineNumbers(attr: unknown, byDefault: boolean): boolean {
return typeof attr === "boolean" ? attr : byDefault;
}
/**
* Code blocks with optional line numbers. lineNumbers is null until someone
* picks for that block, so it follows the default (lineNumbers option, e.g.
* from a workspace setting) until then.
*/
export const DocwellCodeBlock = CodeBlock.extend<CodeBlockOptions & { lineNumbers: boolean }>({
addOptions() {
return { ...this.parent!(), lineNumbers: false };
},
addAttributes() {
return {
...this.parent?.(),
lineNumbers: {
default: null,
parseHTML: (el) => {
const v = el.getAttribute("data-line-numbers");
return v === "true" ? true : v === "false" ? false : null;
},
renderHTML: (attrs) =>
typeof attrs.lineNumbers === "boolean" ? { "data-line-numbers": String(attrs.lineNumbers) } : {},
},
};
},
addCommands() {
return {
...this.parent?.(),
toggleCodeLineNumbers:
() =>
({ editor, commands }) => {
if (!editor.isActive(this.name)) return false;
const now = showsLineNumbers(editor.getAttributes(this.name).lineNumbers, this.options.lineNumbers);
return commands.updateAttributes(this.name, { lineNumbers: !now });
},
};
},
addNodeView() {
const byDefault = this.options.lineNumbers;
const prefix = this.options.languageClassPrefix ?? "language-";
return ({ node }) => {
const pre = document.createElement("pre");
pre.className = "dw-code";
const gutter = document.createElement("div");
gutter.className = "dw-code__gutter";
gutter.contentEditable = "false";
gutter.setAttribute("aria-hidden", "true");
const code = document.createElement("code");
pre.append(gutter, code);
let lines = -1;
const draw = (n: typeof node) => {
const on = showsLineNumbers(n.attrs.lineNumbers, byDefault);
pre.classList.toggle("dw-code--numbered", on);
code.className = n.attrs.language ? `${prefix}${String(n.attrs.language)}` : "";
const count = on ? n.textContent.split("\n").length : 0;
if (count !== lines) {
lines = count;
gutter.textContent = Array.from({ length: count }, (_, i) => i + 1).join("\n");
}
};
draw(node);
return {
dom: pre,
contentDOM: code,
update: (n) => {
if (n.type !== node.type) return false;
draw(n);
return true;
},
ignoreMutation: (m) => gutter.contains(m.target),
};
};
},
});
+90
View File
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Mark, mergeAttributes } from "@tiptap/core";
import Highlight from "@tiptap/extension-highlight";
/**
* The colours text, highlights and callouts can have. Documents store the
* name, not a value, so the colours follow the theme (editor.css has a light
* and a dark shade of each) and stay readable in exports.
*/
export const palette = ["gray", "red", "orange", "yellow", "green", "teal", "blue", "purple", "pink"] as const;
export type PaletteColor = (typeof palette)[number];
export const isPaletteColor = (c: unknown): c is PaletteColor =>
typeof c === "string" && (palette as readonly string[]).includes(c);
declare module "@tiptap/core" {
interface Commands<ReturnType> {
textColor: {
setTextColor: (color: PaletteColor) => ReturnType;
unsetTextColor: () => ReturnType;
};
}
}
/** Coloured text: `<span data-color="red">`. */
export const TextColor = Mark.create({
name: "textColor",
addAttributes() {
return {
color: {
default: null,
parseHTML: (el) => {
const c = el.getAttribute("data-color");
return isPaletteColor(c) ? c : null;
},
renderHTML: (attrs) => (attrs.color ? { "data-color": attrs.color } : {}),
},
};
},
parseHTML() {
return [
{ tag: "span[data-color]", getAttrs: (el) => (isPaletteColor(el.getAttribute("data-color")) ? {} : false) },
];
},
renderHTML({ HTMLAttributes }) {
return ["span", mergeAttributes(HTMLAttributes, { class: "dw-text-color" }), 0];
},
addCommands() {
return {
setTextColor:
(color) =>
({ commands }) =>
commands.setMark(this.name, { color }),
unsetTextColor:
() =>
({ commands }) =>
commands.unsetMark(this.name),
};
},
});
/**
* Highlighted text, ==like this== or from the toolbar, with a palette colour
* ("yellow" when none was picked). Stored as the colour name like TextColor.
*/
export const DocwellHighlight = Highlight.extend({
addOptions() {
return { ...this.parent!(), multicolor: true };
},
addAttributes() {
return {
color: {
default: null,
parseHTML: (el) => {
const c = el.getAttribute("data-color");
return isPaletteColor(c) ? c : null;
},
renderHTML: (attrs) => ({ "data-color": isPaletteColor(attrs.color) ? attrs.color : "yellow" }),
},
};
},
renderHTML({ HTMLAttributes }) {
return ["mark", mergeAttributes(HTMLAttributes, { class: "dw-highlight" }), 0];
},
});
+429 -7
View File
@@ -20,7 +20,7 @@
.dw-prose > * + * {
margin-top: 8px;
}
.dw-prose > :is(h1, h2, h3) {
.dw-prose > :is(h1, h2, h3, h4, h5, h6) {
margin-top: 20px;
}
.dw-prose h1 {
@@ -102,7 +102,7 @@
border-radius: var(--radius-md);
}
.dw-prose img.ProseMirror-selectednode,
.dw-prose .dw-file.ProseMirror-selectednode,
.dw-prose .dw-file-block.ProseMirror-selectednode .dw-file,
.dw-prose .ProseMirror-selectednode:is(.dw-mermaid, .dw-diagram, .dw-toc, .tiptap-mathematics-render) {
outline: 2px solid var(--color-focus-ring);
outline-offset: 2px;
@@ -609,9 +609,17 @@
.dw-block-host {
position: relative;
}
.dw-block-handle {
.dw-block-gutter {
position: absolute;
left: -30px;
right: calc(100% + 6px);
display: flex;
gap: 2px;
}
.dw-block-gutter[hidden],
.dw-block-handle[hidden] {
display: none;
}
.dw-block-handle {
display: grid;
place-items: center;
width: 22px;
@@ -628,7 +636,7 @@
}
/* Phones have no margin to spare and no hover. */
@media (max-width: 640px), (hover: none) {
.dw-block-handle {
.dw-block-gutter {
display: none;
}
}
@@ -706,10 +714,424 @@
/* The page's body font, chosen per page; headings follow it too. */
.dw-font-serif .dw-prose,
.dw-font-serif .dw-prose :is(h1, h2, h3) {
.dw-font-serif .dw-prose :is(h1, h2, h3, h4, h5, h6) {
font-family: var(--font-serif);
}
.dw-font-mono .dw-prose,
.dw-font-mono .dw-prose :is(h1, h2, h3) {
.dw-font-mono .dw-prose :is(h1, h2, h3, h4, h5, h6) {
font-family: var(--font-mono);
}
/* ---- Headings 4–6 ("Other headings") ---- */
.dw-prose h4 {
font-size: var(--text-doc-body);
line-height: var(--text-doc-body--line-height);
font-weight: 600;
}
.dw-prose h5 {
font-size: var(--text-ui-md);
font-weight: 600;
}
.dw-prose h6 {
font-size: var(--text-ui-sm);
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.04em;
color: var(--color-ink-muted);
}
/* ---- Palette colours (colors.ts): text, highlight and callout shades ---- */
:root {
--dw-c-gray: #6b6f6d;
--dw-c-red: #c0392b;
--dw-c-orange: #c2571a;
--dw-c-yellow: #9a7400;
--dw-c-green: #3d7a1f;
--dw-c-teal: #1f7f79;
--dw-c-blue: #2f6fbf;
--dw-c-purple: #7c5cc4;
--dw-c-pink: #b8327a;
--dw-bg-gray: #ecece9;
--dw-bg-red: #fbe3df;
--dw-bg-orange: #fbe7d7;
--dw-bg-yellow: #fbf1c7;
--dw-bg-green: #e4f1d8;
--dw-bg-teal: #d9efec;
--dw-bg-blue: #dfe9f7;
--dw-bg-purple: #ebe4f7;
--dw-bg-pink: #f8e0ec;
}
.dark {
--dw-c-gray: #a3a8a5;
--dw-c-red: #f08a7e;
--dw-c-orange: #f0a26a;
--dw-c-yellow: #e5c454;
--dw-c-green: #93c96b;
--dw-c-teal: #6cc9bf;
--dw-c-blue: #86b2ec;
--dw-c-purple: #b9a2ec;
--dw-c-pink: #eb8fc0;
--dw-bg-gray: #34383a;
--dw-bg-red: #4a2723;
--dw-bg-orange: #4a3020;
--dw-bg-yellow: #45391a;
--dw-bg-green: #2c3f22;
--dw-bg-teal: #1e3d3a;
--dw-bg-blue: #22334d;
--dw-bg-purple: #352b4d;
--dw-bg-pink: #47263a;
}
[data-color="gray"] {
--dw-c: var(--dw-c-gray);
--dw-bg: var(--dw-bg-gray);
}
[data-color="red"] {
--dw-c: var(--dw-c-red);
--dw-bg: var(--dw-bg-red);
}
[data-color="orange"] {
--dw-c: var(--dw-c-orange);
--dw-bg: var(--dw-bg-orange);
}
[data-color="yellow"] {
--dw-c: var(--dw-c-yellow);
--dw-bg: var(--dw-bg-yellow);
}
[data-color="green"] {
--dw-c: var(--dw-c-green);
--dw-bg: var(--dw-bg-green);
}
[data-color="teal"] {
--dw-c: var(--dw-c-teal);
--dw-bg: var(--dw-bg-teal);
}
[data-color="blue"] {
--dw-c: var(--dw-c-blue);
--dw-bg: var(--dw-bg-blue);
}
[data-color="purple"] {
--dw-c: var(--dw-c-purple);
--dw-bg: var(--dw-bg-purple);
}
[data-color="pink"] {
--dw-c: var(--dw-c-pink);
--dw-bg: var(--dw-bg-pink);
}
.dw-prose .dw-text-color {
color: var(--dw-c);
}
.dw-prose mark.dw-highlight {
background: var(--dw-bg, var(--dw-bg-yellow));
color: inherit;
border-radius: 2px;
padding: 0 1px;
}
/* The swatches in the selection toolbar's colour panel. */
.dw-swatch {
display: grid;
place-items: center;
width: 22px;
height: 22px;
border: 1px solid var(--color-line);
border-radius: var(--radius-xs);
background: var(--color-surface);
font-family: var(--font-sans);
font-size: 12px;
font-weight: 700;
color: var(--dw-c, var(--color-ink));
cursor: pointer;
}
.dw-swatch--fill {
background: var(--dw-bg);
}
.dw-swatch--none {
background: linear-gradient(135deg, transparent 45%, var(--color-danger) 45% 55%, transparent 55%);
}
.dw-swatch[aria-pressed="true"],
.dw-swatch:hover {
outline: 2px solid var(--color-focus-ring);
outline-offset: 1px;
}
/* ---- Callouts ---- */
.dw-prose .dw-callout {
display: flex;
gap: 10px;
padding: 12px 16px 12px 12px;
border-radius: var(--radius-md);
background: var(--dw-bg, var(--dw-bg-blue));
}
.dw-callout__side {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
user-select: none;
}
.dw-callout__emoji {
display: grid;
place-items: center;
width: 28px;
height: 28px;
border: none;
border-radius: var(--radius-sm);
background: none;
font-size: 20px;
line-height: 1;
cursor: pointer;
}
.dw-callout__emoji:hover {
background: color-mix(in srgb, var(--dw-c) 14%, transparent);
}
.dw-callout__color {
width: 12px;
height: 12px;
border: 2px solid var(--color-surface);
border-radius: 50%;
background: var(--dw-c);
cursor: pointer;
opacity: 0;
}
.dw-callout:hover .dw-callout__color,
.dw-callout__color:focus-visible {
opacity: 1;
}
.dw-prose[contenteditable="false"] .dw-callout__color {
display: none;
}
.dw-prose[contenteditable="false"] .dw-callout__emoji {
cursor: default;
}
.dw-callout__body {
flex: 1;
min-width: 0;
padding-top: 2px;
}
.dw-callout__body > * + * {
margin-top: 8px;
}
/* ---- To-do lists ---- */
.dw-prose ul[data-type="taskList"] {
list-style: none;
padding-left: 2px;
}
.dw-prose ul[data-type="taskList"] li {
display: flex;
align-items: flex-start;
gap: 8px;
}
.dw-prose ul[data-type="taskList"] li > label {
flex-shrink: 0;
margin-top: 0.3em;
user-select: none;
}
.dw-prose ul[data-type="taskList"] li > label input {
width: 16px;
height: 16px;
accent-color: var(--color-primary);
cursor: pointer;
}
.dw-prose ul[data-type="taskList"] li > div {
flex: 1;
min-width: 0;
}
.dw-prose ul[data-type="taskList"] li[data-checked="true"] > div > p {
color: var(--color-ink-muted);
text-decoration: line-through;
}
.dw-prose ul[data-type="taskList"] ul[data-type="taskList"] {
margin-top: 4px;
}
/* ---- Tables ---- */
.dw-prose .tableWrapper {
overflow-x: auto;
margin: 12px 0;
}
.dw-prose table {
border-collapse: collapse;
table-layout: fixed;
width: 100%;
overflow: hidden;
}
.dw-prose :is(td, th) {
position: relative;
min-width: 60px;
padding: 6px 10px;
border: 1px solid var(--color-line-strong);
vertical-align: top;
box-sizing: border-box;
}
.dw-prose :is(td, th) > * + * {
margin-top: 6px;
}
.dw-prose th {
background: var(--color-surface-sunken);
font-weight: 600;
text-align: left;
}
.dw-prose .selectedCell::after {
content: "";
position: absolute;
inset: 0;
background: var(--color-selection);
pointer-events: none;
}
.dw-prose .column-resize-handle {
position: absolute;
top: 0;
right: -2px;
bottom: -2px;
width: 4px;
background: var(--color-focus-ring);
pointer-events: none;
}
.dw-prose.resize-cursor {
cursor: col-resize;
}
/* ---- Code line numbers ---- */
.dw-prose pre.dw-code {
display: flex;
gap: 12px;
}
.dw-prose pre.dw-code > code {
flex: 1;
min-width: 0;
}
.dw-prose pre .dw-code__gutter {
display: none;
flex-shrink: 0;
min-width: 1.5em;
padding-right: 10px;
border-right: 1px solid var(--color-line);
color: var(--color-ink-faint);
text-align: right;
/* ProseMirror resets white-space on parts that are not editable. */
white-space: pre;
user-select: none;
}
.dw-prose pre.dw-code--numbered .dw-code__gutter {
display: block;
}
/* ---- PDFs shown inline ---- */
.dw-prose .dw-file-block > * + * {
margin-top: 6px;
}
.dw-pdf {
display: flex;
flex-direction: column;
gap: 8px;
max-height: 560px;
padding: 8px;
overflow-y: auto;
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
background: var(--color-surface-sunken);
}
.dw-pdf:focus-visible {
outline: 2px solid var(--color-focus-ring);
}
.dw-pdf__page {
width: 100%;
background: #fff;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.dw-pdf__page canvas {
display: block;
width: 100%;
height: auto;
}
.dw-pdf__status {
padding: 24px;
text-align: center;
font-family: var(--font-sans);
font-size: var(--text-ui-sm);
color: var(--color-ink-muted);
}
/* ---- The block grip and its menu ---- */
.dw-block-grip {
cursor: grab;
}
.dw-block-grip[aria-expanded="true"] {
background: var(--color-surface-hover);
color: var(--color-ink);
}
.dw-block-menu {
width: 15rem;
}
.dw-block-menu .dw-suggest__item {
width: 100%;
border: none;
background: none;
font: inherit;
text-align: left;
cursor: pointer;
}
.dw-block-menu .dw-suggest__item.is-active {
background: var(--color-surface-hover);
}
.dw-block-menu .dw-suggest__item:focus {
outline: none;
}
.dw-block-menu .dw-suggest__item.is-danger :is(.dw-suggest__label, .dw-suggest__icon) {
color: var(--color-danger);
}
.dw-block-menu__more {
margin-left: auto;
color: var(--color-ink-faint);
}
/* ---- Moving table rows (tablerows.ts) ---- */
.dw-row-grip {
position: absolute;
z-index: 5;
display: grid;
place-items: center;
width: 14px;
height: 22px;
padding: 0;
border: 1px solid var(--color-line-strong);
border-radius: var(--radius-xs);
background: var(--color-surface-raised);
color: var(--color-ink-faint);
cursor: grab;
touch-action: none;
}
.dw-row-grip::before {
content: "";
width: 4px;
height: 10px;
background: radial-gradient(circle, currentColor 1px, transparent 1.5px) 0 0 / 4px 4px;
}
.dw-row-grip:hover,
.dw-row-grip:active {
color: var(--color-ink);
border-color: var(--color-focus-ring);
}
.dw-row-grip:active {
cursor: grabbing;
}
.dw-row-grip[hidden],
.dw-row-drop[hidden] {
display: none;
}
.dw-row-drop {
position: absolute;
z-index: 5;
height: 2px;
background: var(--color-focus-ring);
pointer-events: none;
}
.dw-prose tr.dw-row-dragging {
opacity: 0.45;
}
@media (max-width: 640px), (hover: none) {
.dw-row-grip {
display: none;
}
}
+22 -2
View File
@@ -6,6 +6,10 @@ import CollaborationCaret from "@tiptap/extension-collaboration-caret";
import { Placeholder } from "@tiptap/extensions";
import StarterKit from "@tiptap/starter-kit";
import { BlockLinks } from "./blocklinks";
import { docwellAlign, docwellTables, docwellTasks, HeadingShortcuts } from "./blocks";
import { Callout } from "./callout";
import { DocwellCodeBlock } from "./codeblock";
import { DocwellHighlight, TextColor } from "./colors";
import { CommentHighlights } from "./comments";
import { DateMention } from "./dates";
import { DrawioBlock, ExcalidrawBlock, type ExcalidrawLoader } from "./diagrams";
@@ -17,8 +21,10 @@ import { docwellMath } from "./math";
import { docwellMention, type MentionHost } from "./mention";
import { MermaidBlock, type MermaidLoader } from "./mermaid";
import { PageLinks, type PageHost } from "./pagelinks";
import type { PdfLoader } from "./pdf";
import { SlashMenu, slashCommands } from "./slash";
import type { CollabProvider } from "./provider";
import { TableRows } from "./tablerows";
import { TableOfContents } from "./toc";
import { docwellToggles } from "./toggle";
@@ -54,6 +60,10 @@ export interface ExtensionOptions {
loadMermaid?: MermaidLoader;
/** Loads the Excalidraw editor; without it drawings show but cannot be edited. */
loadExcalidraw?: ExcalidrawLoader;
/** Loads pdf.js; without it PDF attachments show as download cards. */
loadPdf?: PdfLoader;
/** Whether code blocks show line numbers unless one was switched on or off itself. */
codeLineNumbers?: boolean;
labels?: EditorLabels;
/** Clicking highlighted comment text calls this with the comment id. */
onCommentSelect?: (id: string) => void;
@@ -84,14 +94,24 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
const list: AnyExtension[] = [
editorRef,
StarterKit.configure({
heading: { levels: [1, 2, 3] },
heading: { levels: [1, 2, 3, 4, 5, 6] },
codeBlock: false,
link: { openOnClick: false, autolink: true },
// Collaboration brings its own undo history, scoped to the local user.
undoRedo: opts.collab ? false : undefined,
}),
Placeholder.configure({ placeholder: opts.placeholder ?? "Type '/' for commands…" }),
DocwellImage.configure({ host: opts.files }),
FileAttachment.configure({ host: opts.files }),
FileAttachment.configure({ host: opts.files, loadPdf: opts.loadPdf, labels }),
DocwellCodeBlock.configure({ lineNumbers: opts.codeLineNumbers ?? false }),
HeadingShortcuts,
docwellAlign,
TextColor,
DocwellHighlight,
...docwellTasks(),
...docwellTables(),
TableRows.configure({ labels }),
Callout.configure({ labels }),
FileDrop.configure({ host: opts.files, onError: opts.onError }),
docwellMention(labels, opts.mentions),
DateMention.configure({ labels, me: () => opts.mentions?.me }),
+86 -7
View File
@@ -3,6 +3,8 @@
import { Extension, Node, mergeAttributes, type Editor } from "@tiptap/core";
import Image from "@tiptap/extension-image";
import { Plugin, PluginKey } from "@tiptap/pm/state";
import type { EditorLabels } from "./labels";
import { isPdf, showPdf, type PdfLoader } from "./pdf";
/**
* How the host app reaches attachments. Documents store a file's API path
@@ -28,7 +30,17 @@ export async function insertFiles(editor: Editor, host: FileHost, files: File[],
const up = await host.upload(file);
const node = up.mime.startsWith("image/")
? { type: "image", attrs: { src: up.url, alt: up.name } }
: { type: "fileAttachment", attrs: { url: up.url, name: up.name, size: up.size, mime: up.mime } };
: {
type: "fileAttachment",
// PDFs show their pages where the host can draw them.
attrs: {
url: up.url,
name: up.name,
size: up.size,
mime: up.mime,
view: isPdf(up.mime, up.name) ? "preview" : "card",
},
};
// Insert after the selection rather than over it: an inserted image is
// left selected, and the next file must not replace it.
editor
@@ -80,15 +92,34 @@ function formatSize(bytes: number): string {
return `${n.toFixed(i && n < 10 ? 1 : 0)} ${units[i]}`;
}
/** A non-image attachment: a download card with the file's name and size. */
export const FileAttachment = Node.create<{ host?: FileHost }>({
declare module "@tiptap/core" {
interface Commands<ReturnType> {
fileAttachment: {
/** Switches the selected PDF between showing its pages and a download card. */
toggleFilePreview: () => ReturnType;
};
}
}
export interface FileAttachmentOptions {
host?: FileHost;
/** Loads pdf.js; without it PDFs show as a download card. */
loadPdf?: PdfLoader;
labels: EditorLabels | null;
}
/**
* A non-image attachment: a download card with the file's name and size.
* A PDF with view "preview" also shows its pages, scrolling in a frame.
*/
export const FileAttachment = Node.create<FileAttachmentOptions>({
name: "fileAttachment",
group: "block",
atom: true,
draggable: true,
addOptions() {
return { host: undefined };
return { host: undefined, loadPdf: undefined, labels: null };
},
addAttributes() {
@@ -97,6 +128,19 @@ export const FileAttachment = Node.create<{ host?: FileHost }>({
name: { default: "file" },
size: { default: 0 },
mime: { default: "" },
view: { default: "card" },
};
},
addCommands() {
return {
toggleFilePreview:
() =>
({ editor, commands }) => {
const a = editor.getAttributes(this.name);
if (!editor.isActive(this.name) || !isPdf(a.mime, a.name)) return false;
return commands.updateAttributes(this.name, { view: a.view === "preview" ? "card" : "preview" });
},
};
},
@@ -109,6 +153,7 @@ export const FileAttachment = Node.create<{ host?: FileHost }>({
name: el.getAttribute("data-name") ?? el.textContent ?? "file",
size: Number(el.getAttribute("data-size") ?? 0),
mime: el.getAttribute("data-mime") ?? "",
view: el.getAttribute("data-view") === "preview" ? "preview" : "card",
}),
},
];
@@ -123,6 +168,7 @@ export const FileAttachment = Node.create<{ host?: FileHost }>({
"data-name": node.attrs.name,
"data-size": node.attrs.size,
"data-mime": node.attrs.mime,
"data-view": node.attrs.view,
}),
["a", { href: node.attrs.url, download: node.attrs.name }, node.attrs.name],
];
@@ -130,23 +176,52 @@ export const FileAttachment = Node.create<{ host?: FileHost }>({
addNodeView() {
return ({ node }) => {
const { host, loadPdf, labels } = this.options;
const dom = document.createElement("div");
dom.className = "dw-file";
dom.className = "dw-file-block";
dom.setAttribute("data-type", "file");
const card = document.createElement("div");
card.className = "dw-file";
const link = document.createElement("a");
link.className = "dw-file__name";
link.target = "_blank";
link.rel = "noopener";
const size = document.createElement("span");
size.className = "dw-file__size";
card.append(link, size);
dom.append(card);
let pages: HTMLDivElement | null = null;
let stop: (() => void) | null = null;
let shown = "";
const draw = (n: typeof node) => {
const url = String(n.attrs.url ?? "");
link.href = this.options.host ? this.options.host.resolve(url) : url;
const href = host ? host.resolve(url) : url;
link.href = href;
link.textContent = String(n.attrs.name ?? "file");
size.textContent = formatSize(Number(n.attrs.size ?? 0));
const preview = n.attrs.view === "preview" && isPdf(n.attrs.mime, n.attrs.name) && !!url;
if (!preview || !loadPdf || !labels) {
stop?.();
stop = null;
pages?.remove();
pages = null;
shown = "";
return;
}
if (shown === href) return;
stop?.();
if (!pages) {
pages = document.createElement("div");
pages.className = "dw-pdf";
pages.tabIndex = 0;
pages.setAttribute("role", "document");
dom.append(pages);
}
pages.setAttribute("aria-label", String(n.attrs.name ?? "PDF"));
shown = href;
stop = showPdf(pages, href, loadPdf, labels);
};
draw(node);
dom.append(link, size);
return {
dom,
update: (n) => {
@@ -154,6 +229,10 @@ export const FileAttachment = Node.create<{ host?: FileHost }>({
draw(n);
return true;
},
// Scrolling and clicking through the pages are not edits.
stopEvent: (e) => !!pages && pages.contains(e.target as globalThis.Node) && e.type !== "mousedown",
ignoreMutation: () => true,
destroy: () => stop?.(),
};
};
},
+120
View File
@@ -18,6 +18,55 @@ export interface EditorLabels {
link: string;
linkPrompt: string;
comment: string;
underline: string;
color: string;
/** Headings of the colour menu's two groups. */
textColor: string;
highlight: string;
/** Takes the colour off again. */
noColor: string;
align: string;
alignLeft: string;
alignCenter: string;
alignRight: string;
/** Turns the selected text into an inline formula. */
math: string;
/** Makes a new page titled like the selection and links the selection to it. */
linkedPage: string;
};
/** Names of the palette colours (colors.ts), by name. */
colors: Record<string, string>;
/** The toolbar shown while the cursor is in a table. */
table: {
toolbar: string;
/** The grip on a row's left edge. */
dragRow: string;
moveRowUp: string;
moveRowDown: string;
addRowBefore: string;
addRowAfter: string;
addColumnBefore: string;
addColumnAfter: string;
deleteRow: string;
deleteColumn: string;
toggleHeaderRow: string;
mergeCells: string;
splitCell: string;
deleteTable: string;
};
/** The menu behind the grip beside each block. */
blockMenu: {
open: string;
turnInto: string;
moveUp: string;
moveDown: string;
duplicate: string;
copy: string;
delete: string;
showLineNumbers: string;
hideLineNumbers: string;
showPages: string;
showAsFile: string;
};
mentions: string;
noPeople: string;
@@ -47,6 +96,11 @@ export interface EditorLabels {
embedInvalid: string;
linkUrl: string;
copyBlockLink: string;
calloutEmoji: string;
calloutColor: string;
pdfLoading: string;
/** One page of a PDF shown inline; {n} is its number. */
pdfPage: string;
};
/** The find and replace bar. count has {current} and {total} in it. */
find: {
@@ -84,8 +138,14 @@ export const englishLabels: EditorLabels = {
h1: { label: "Heading 1", description: "Big section heading" },
h2: { label: "Heading 2", description: "Medium section heading" },
h3: { label: "Heading 3", description: "Small section heading" },
h4: { label: "Heading 4", description: "Other headings: level 4" },
h5: { label: "Heading 5", description: "Other headings: level 5" },
h6: { label: "Heading 6", description: "Other headings: level 6" },
bullet: { label: "Bulleted list", description: "A simple list" },
ordered: { label: "Numbered list", description: "A list with numbers" },
todo: { label: "To-do list", description: "Tasks to tick off (or type [])" },
callout: { label: "Callout", description: "Set a note apart with an emoji and colour" },
table: { label: "Table", description: "Rows and columns" },
quote: { label: "Quote", description: "Set text apart as a quote" },
code: { label: "Code block", description: "Monospaced code" },
divider: { label: "Divider", description: "A line between sections" },
@@ -101,6 +161,11 @@ export const englishLabels: EditorLabels = {
toggle: { label: "Toggle", description: "A heading that hides the blocks under it" },
embed: { label: "Embed", description: "A video, design or document from YouTube, Figma and more" },
linkCard: { label: "Link card", description: "A link with its page's title and picture" },
newPage: { label: "New page", description: "Make a page and link it here" },
today: { label: "Today", description: "Insert today's date" },
tomorrow: { label: "Tomorrow", description: "Insert tomorrow's date" },
yesterday: { label: "Yesterday", description: "Insert yesterday's date" },
now: { label: "Now", description: "Insert the date and time" },
},
format: {
bold: "Bold",
@@ -110,6 +175,57 @@ export const englishLabels: EditorLabels = {
link: "Link",
linkPrompt: "Link address (leave empty to remove the link)",
comment: "Comment",
underline: "Underline",
color: "Colour",
textColor: "Text colour",
highlight: "Highlight",
noColor: "Default",
align: "Align",
alignLeft: "Align left",
alignCenter: "Align centre",
alignRight: "Align right",
math: "Inline math",
linkedPage: "Make a linked page",
},
colors: {
gray: "Grey",
red: "Red",
orange: "Orange",
yellow: "Yellow",
green: "Green",
teal: "Teal",
blue: "Blue",
purple: "Purple",
pink: "Pink",
},
table: {
toolbar: "Table",
dragRow: "Drag to move the row",
moveRowUp: "Move row up",
moveRowDown: "Move row down",
addRowBefore: "Add row above",
addRowAfter: "Add row below",
addColumnBefore: "Add column left",
addColumnAfter: "Add column right",
deleteRow: "Delete row",
deleteColumn: "Delete column",
toggleHeaderRow: "Header row",
mergeCells: "Merge cells",
splitCell: "Split cell",
deleteTable: "Delete table",
},
blockMenu: {
open: "Drag to move, click for actions",
turnInto: "Turn into",
moveUp: "Move up",
moveDown: "Move down",
duplicate: "Duplicate",
copy: "Copy",
delete: "Delete",
showLineNumbers: "Show line numbers",
hideLineNumbers: "Hide line numbers",
showPages: "Show pages",
showAsFile: "Show as file",
},
mentions: "Mention someone",
noPeople: "Nobody found",
@@ -137,6 +253,10 @@ export const englishLabels: EditorLabels = {
embedInvalid: "This address can't be embedded.",
linkUrl: "Address of the page to link",
copyBlockLink: "Copy link to this block",
calloutEmoji: "Change emoji",
calloutColor: "Change colour",
pdfLoading: "Loading PDF…",
pdfPage: "Page {n}",
},
find: {
find: "Find in page",
+27
View File
@@ -18,6 +18,11 @@ export interface PageRef {
/** Finds pages for "[[" links; without one, "[[" is just text. */
export interface PageHost {
search(query: string): Promise<PageRef[]>;
/**
* Makes a page titled title next to the page being edited (a child of it,
* where the host allows). Without it the editor cannot make linked pages.
*/
create?(title: string): Promise<PageRef>;
}
/** The app path of a page; page links are ordinary links to it. */
@@ -44,6 +49,28 @@ export function insertPageLink(editor: Editor, range: Range, page: PageRef, unti
.run();
}
/**
* Makes a page through the host and links to it: the selected text becomes
* the link (and the new page's title), or, with nothing selected, a link
* titled like the page is inserted. untitled names a page with no title.
*/
export async function createLinkedPage(editor: Editor, host: PageHost, untitled: string): Promise<void> {
if (!host.create) return;
const { from, to, empty } = editor.state.selection;
const title = empty ? "" : editor.state.doc.textBetween(from, to, " ").trim().slice(0, 200);
const page = await host.create(title);
if (empty || !title) {
insertPageLink(editor, { from, to: from }, page, untitled);
return;
}
editor
.chain()
.focus()
.setTextSelection({ from, to })
.setLink({ href: pagePath(page.id) })
.run();
}
export interface PageLinkOptions {
host?: PageHost;
labels: EditorLabels | null;
+95
View File
@@ -0,0 +1,95 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type { EditorLabels } from "./labels";
/** The part of pdf.js the viewer uses; hosts load it (see pdfjs.ts) so the bridge can leave it out. */
export interface PdfJs {
getDocument(src: { url: string; withCredentials?: boolean }): {
promise: Promise<PdfDocument>;
destroy(): Promise<void>;
};
}
interface PdfDocument {
numPages: number;
getPage(n: number): Promise<PdfPage>;
}
interface PdfPage {
getViewport(o: { scale: number }): { width: number; height: number };
render(o: { canvas: HTMLCanvasElement; viewport: { width: number; height: number } }): { promise: Promise<void> };
}
export type PdfLoader = () => Promise<PdfJs>;
/** A PDF attachment's file name. */
export const isPdf = (mime: unknown, name: unknown) =>
mime === "application/pdf" || (typeof name === "string" && /\.pdf$/i.test(name));
/**
* Draws the pages of the PDF at url into box, each as it scrolls into view.
* Returns a function that stops loading and frees the document.
*/
export function showPdf(box: HTMLElement, url: string, load: PdfLoader, labels: EditorLabels): () => void {
let stopped = false;
let observer: IntersectionObserver | null = null;
let task: ReturnType<PdfJs["getDocument"]> | null = null;
const status = document.createElement("div");
status.className = "dw-pdf__status";
status.textContent = labels.blocks.pdfLoading;
box.replaceChildren(status);
void (async () => {
try {
const pdfjs = await load();
if (stopped) return;
task = pdfjs.getDocument({ url });
const doc = await task.promise;
if (stopped) return;
status.remove();
const width = Math.max(box.clientWidth - 2, 200);
const ratio = window.devicePixelRatio || 1;
observer = new IntersectionObserver(
(entries) => {
for (const entry of entries) {
if (!entry.isIntersecting) continue;
const slot = entry.target as HTMLElement;
observer?.unobserve(slot);
void draw(slot, Number(slot.dataset.page));
}
},
{ root: box, rootMargin: "400px 0px" },
);
const first = await doc.getPage(1);
const base = first.getViewport({ scale: 1 });
for (let n = 1; n <= doc.numPages; n++) {
const slot = document.createElement("div");
slot.className = "dw-pdf__page";
slot.dataset.page = String(n);
// Until it is drawn, a page takes the first page's shape.
slot.style.aspectRatio = `${base.width} / ${base.height}`;
slot.setAttribute("aria-label", labels.blocks.pdfPage.replace("{n}", String(n)));
box.append(slot);
observer.observe(slot);
}
async function draw(slot: HTMLElement, n: number) {
const page = await doc.getPage(n);
if (stopped) return;
const scale = width / page.getViewport({ scale: 1 }).width;
const viewport = page.getViewport({ scale: scale * ratio });
const canvas = document.createElement("canvas");
canvas.width = Math.floor(viewport.width);
canvas.height = Math.floor(viewport.height);
slot.style.aspectRatio = `${viewport.width} / ${viewport.height}`;
slot.append(canvas);
await page.render({ canvas, viewport }).promise;
}
} catch {
if (!stopped) status.textContent = labels.blocks.loadFailed;
}
})();
return () => {
stopped = true;
observer?.disconnect();
void task?.destroy();
};
}
+12
View File
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
// pdf.js and its worker load only when a page shows a PDF inline.
import { getDocument, GlobalWorkerOptions } from "pdfjs-dist";
import workerUrl from "pdfjs-dist/build/pdf.worker.min.mjs?url";
import type { PdfJs } from "./pdf";
GlobalWorkerOptions.workerSrc = workerUrl;
/** pdf.js narrowed to what the viewer in pdf.ts uses. */
export const pdf = { getDocument } as unknown as PdfJs;
+38 -1
View File
@@ -4,9 +4,10 @@ import { Extension, type Editor, type Range } from "@tiptap/core";
import { PluginKey } from "@tiptap/pm/state";
import Suggestion from "@tiptap/suggestion";
import type { IconName } from "@docwell/ui/icons";
import { insertDate, isoDate } from "./dates";
import { promptEmbed, promptLinkCard, type LinkHost } from "./embeds";
import { insertFiles, type FileHost } from "./files";
import type { PageHost } from "./pagelinks";
import { createLinkedPage, type PageHost } from "./pagelinks";
import type { EditorLabels } from "./labels";
import { floatingList } from "./suggestion";
@@ -66,10 +67,24 @@ export function slashCommands(
block("h3", "heading", ["heading", "###"], (e, r) =>
e.chain().focus().deleteRange(r).setHeading({ level: 3 }).run(),
),
...([4, 5, 6] as const).map((level) =>
block(`h${level}`, "heading", ["heading", "other headings", "#".repeat(level)], (e, r) =>
e.chain().focus().deleteRange(r).setHeading({ level }).run(),
),
),
block("bullet", "list", ["list", "ul", "-"], (e, r) => e.chain().focus().deleteRange(r).toggleBulletList().run()),
block("ordered", "list-ordered", ["list", "ol", "1."], (e, r) =>
e.chain().focus().deleteRange(r).toggleOrderedList().run(),
),
block("todo", "todo", ["task", "checkbox", "checklist", "[]"], (e, r) =>
e.chain().focus().deleteRange(r).toggleTaskList().run(),
),
block("callout", "callout", ["note", "info", "tip", "warning", "aside", "box"], (e, r) =>
e.chain().focus().deleteRange(r).setCallout().run(),
),
block("table", "table", ["grid", "rows", "columns", "spreadsheet"], (e, r) =>
e.chain().focus().deleteRange(r).insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
),
block("quote", "quote", ["blockquote", ">"], (e, r) => e.chain().focus().deleteRange(r).toggleBlockquote().run()),
block("code", "code", ["codeblock", "```", "snippet"], (e, r) =>
e.chain().focus().deleteRange(r).toggleCodeBlock().run(),
@@ -101,12 +116,34 @@ export function slashCommands(
void promptLinkCard(e, l, links, onError);
}),
];
const day = (offset: number) => {
const d = new Date();
return isoDate(new Date(d.getFullYear(), d.getMonth(), d.getDate() + offset));
};
list.push(
block("today", "calendar", ["date", "day"], (e, r) => insertDate(e, r, { date: day(0), remind: false })),
block("tomorrow", "calendar", ["date", "day"], (e, r) => insertDate(e, r, { date: day(1), remind: false })),
block("yesterday", "calendar", ["date", "day"], (e, r) => insertDate(e, r, { date: day(-1), remind: false })),
block("now", "clock", ["time", "date", "timestamp"], (e, r) => {
insertDate(e, r, { date: day(0), remind: false });
const time = new Intl.DateTimeFormat(l.locale, { hour: "numeric", minute: "2-digit" }).format(new Date());
e.chain().focus().insertContent(`${time} `).run();
}),
);
if (pages) {
list.push(
block("pageLink", "link", ["page", "link", "[[", "wiki"], (e, r) =>
e.chain().focus().deleteRange(r).insertContent("[[").run(),
),
);
if (pages.create) {
list.push(
block("newPage", "page-plus", ["page", "doc", "subpage", "create"], (e, r) => {
e.chain().focus().deleteRange(r).run();
void createLinkedPage(e, pages, "").catch(onError);
}),
);
}
}
if (files?.upload) {
const upload = (accept: string) => (e: Editor, r: Range) => {
+72
View File
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Editor } from "@tiptap/core";
import { afterEach, describe, expect, it } from "vitest";
import { docwellExtensions } from "./extensions";
import { moveRow } from "./tablerows";
let editor: Editor | undefined;
afterEach(() => editor?.destroy());
const table = (rows: string[]) =>
`<p>before</p><table>${rows.map((r) => `<tr><td><p>${r}</p></td><td><p>${r}2</p></td></tr>`).join("")}</table>`;
function setup(html: string) {
editor = new Editor({ extensions: docwellExtensions(), content: html });
return editor;
}
const rowTexts = (e: Editor) => {
const out: string[] = [];
e.state.doc.descendants((n) => {
if (n.type.name === "tableRow") out.push(n.firstChild!.textContent);
return n.type.name !== "tableRow";
});
return out;
};
const tablePos = (e: Editor) => e.state.doc.child(0).nodeSize;
/** A position inside the first cell of row index. */
function inRow(e: Editor, index: number) {
let pos = -1;
let seen = 0;
e.state.doc.descendants((n, p) => {
if (pos >= 0) return false;
if (n.type.name === "tableRow" && seen++ === index) pos = p + 3;
return true;
});
return pos;
}
describe("moving table rows", () => {
it("moves a row to another place and keeps the cursor in it", () => {
const e = setup(table(["a", "b", "c"]));
e.view.dispatch(moveRow(e.state, tablePos(e), 0, 2)!);
expect(rowTexts(e)).toEqual(["b", "c", "a"]);
expect(e.state.selection.$from.parent.textContent).toBe("a");
e.view.dispatch(moveRow(e.state, tablePos(e), 2, 1)!);
expect(rowTexts(e)).toEqual(["b", "a", "c"]);
});
it("moves the cursor's row up and down from the keyboard command", () => {
const e = setup(table(["a", "b", "c"]));
e.commands.setTextSelection(inRow(e, 1));
expect(e.commands.moveTableRow(-1)).toBe(true);
expect(rowTexts(e)).toEqual(["b", "a", "c"]);
expect(e.commands.moveTableRow(-1)).toBe(false);
e.commands.moveTableRow(1);
e.commands.moveTableRow(1);
expect(rowTexts(e)).toEqual(["a", "c", "b"]);
expect(e.commands.moveTableRow(1)).toBe(false);
});
it("does nothing outside a table, or where a cell spans rows", () => {
const e = setup(
"<p>before</p><table><tr><td rowspan='2'><p>x</p></td><td><p>a</p></td></tr><tr><td><p>b</p></td></tr></table>",
);
expect(moveRow(e.state, tablePos(e), 0, 1)).toBeNull();
e.commands.setTextSelection(2);
expect(e.commands.moveTableRow(1)).toBe(false);
});
});
+242
View File
@@ -0,0 +1,242 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Extension } from "@tiptap/core";
import { Fragment, type Node as PMNode } from "@tiptap/pm/model";
import { Plugin, PluginKey, Selection, type EditorState, type Transaction } from "@tiptap/pm/state";
import type { EditorView } from "@tiptap/pm/view";
import type { EditorLabels } from "./labels";
declare module "@tiptap/core" {
interface Commands<ReturnType> {
tableRows: {
/** Moves the table row the selection is in one place up (-1) or down (1). */
moveTableRow: (direction: -1 | 1) => ReturnType;
};
}
}
/** Whether a row can move: rows joined by a cell spanning several rows cannot be pulled apart. */
export function rowsMovable(table: PMNode): boolean {
let ok = true;
table.forEach((row) => row.forEach((cell) => (ok &&= (cell.attrs.rowspan ?? 1) <= 1)));
return ok;
}
/**
* A transaction that moves row from of the table at tablePos to index to (an
* index in the table as it will be), leaving the cursor in the moved row.
* Null when nothing would change or the rows cannot move.
*/
export function moveRow(state: EditorState, tablePos: number, from: number, to: number): Transaction | null {
const table = state.doc.nodeAt(tablePos);
if (!table || table.type.name !== "table" || !rowsMovable(table)) return null;
const rows: PMNode[] = [];
table.forEach((r) => rows.push(r));
if (from === to || from < 0 || to < 0 || from >= rows.length || to >= rows.length) return null;
const [row] = rows.splice(from, 1);
rows.splice(to, 0, row!);
const tr = state.tr.replaceWith(tablePos, tablePos + table.nodeSize, table.copy(Fragment.fromArray(rows)));
let rowStart = tablePos + 1;
for (let i = 0; i < to; i++) rowStart += rows[i]!.nodeSize;
return tr.setSelection(Selection.near(tr.doc.resolve(rowStart + 1))).scrollIntoView();
}
/** The table around $pos and the index of the row $pos is in, or null. */
function rowAt(state: EditorState, pos: number): { tablePos: number; index: number } | null {
const $pos = state.doc.resolve(pos);
for (let d = $pos.depth; d > 0; d--) {
if ($pos.node(d).type.name === "table") return { tablePos: $pos.before(d), index: $pos.index(d) };
}
return null;
}
/**
* Moving table rows: a grip on the left edge of the row under the pointer
* drags the row to another place, and moveTableRow moves it from the
* keyboard or a toolbar.
*/
export const TableRows = Extension.create<{ labels: EditorLabels | null }>({
name: "tableRows",
addOptions() {
return { labels: null };
},
addCommands() {
return {
moveTableRow:
(direction) =>
({ state, dispatch }) => {
const at = rowAt(state, state.selection.from);
if (!at) return false;
const tr = moveRow(state, at.tablePos, at.index, at.index + direction);
if (!tr) return false;
dispatch?.(tr);
return true;
},
};
},
addKeyboardShortcuts() {
return {
"Mod-Alt-ArrowUp": () => this.editor.commands.moveTableRow(-1),
"Mod-Alt-ArrowDown": () => this.editor.commands.moveTableRow(1),
};
},
addProseMirrorPlugins() {
const label = this.options.labels?.table.dragRow ?? "Drag to move the row";
return [new Plugin({ key: new PluginKey("tableRows"), view: (view) => new RowGrip(view, label) })];
},
});
/** The grip beside the table row under the pointer, and the line showing where a dragged row will go. */
class RowGrip {
private grip = document.createElement("button");
private line = document.createElement("div");
private row: HTMLTableRowElement | null = null;
private drag: { tablePos: number; from: number; rows: HTMLTableRowElement[]; to: number } | null = null;
constructor(
private view: EditorView,
label: string,
) {
const g = this.grip;
g.type = "button";
g.className = "dw-row-grip";
g.contentEditable = "false";
g.setAttribute("aria-label", label);
g.title = label;
g.hidden = true;
// Keyboard and screen reader users move rows with the table toolbar or Ctrl+Alt+arrows.
g.tabIndex = -1;
g.addEventListener("pointerdown", this.start);
g.addEventListener("mouseleave", this.leave);
this.line.className = "dw-row-drop";
this.line.hidden = true;
view.dom.addEventListener("mousemove", this.move);
view.dom.addEventListener("mouseleave", this.leave);
}
private get host(): HTMLElement | null {
const host = this.view.dom.parentElement;
if (host && this.grip.parentElement !== host) {
host.classList.add("dw-block-host");
host.append(this.grip, this.line);
}
return host;
}
private hide = () => {
if (this.drag) return;
this.grip.hidden = true;
this.row = null;
};
private leave = (e: MouseEvent) => {
const to = e.relatedTarget as Node | null;
if (to && (this.grip.contains(to) || this.view.dom.contains(to))) return;
this.hide();
};
private move = (e: MouseEvent) => {
if (this.drag) return;
const tr = (e.target as HTMLElement | null)?.closest?.("tr");
const host = this.host;
if (!this.view.editable || !host || !(tr instanceof HTMLTableRowElement) || !this.view.dom.contains(tr)) {
return this.hide();
}
const at = this.locate(tr);
const table = at && this.view.state.doc.nodeAt(at.tablePos);
if (!at || !table || table.childCount < 2 || !rowsMovable(table)) return this.hide();
this.row = tr;
const box = tr.getBoundingClientRect();
const hostBox = host.getBoundingClientRect();
Object.assign(this.grip.style, {
top: `${box.top - hostBox.top + box.height / 2 - 11}px`,
left: `${box.left - hostBox.left - 7}px`,
});
this.grip.hidden = false;
};
private locate(tr: HTMLTableRowElement) {
try {
return rowAt(this.view.state, this.view.posAtDOM(tr, 0));
} catch {
return null;
}
}
private start = (e: PointerEvent) => {
if (!this.row || e.button !== 0) return;
const at = this.locate(this.row);
const tbody = this.row.parentElement;
if (!at || !tbody) return;
e.preventDefault();
this.grip.setPointerCapture(e.pointerId);
const rows = [...tbody.children].filter((r): r is HTMLTableRowElement => r instanceof HTMLTableRowElement);
this.drag = { tablePos: at.tablePos, from: at.index, rows, to: at.index };
this.row.classList.add("dw-row-dragging");
this.grip.addEventListener("pointermove", this.dragMove);
this.grip.addEventListener("pointerup", this.drop);
this.grip.addEventListener("pointercancel", this.cancel);
};
/** Shows the line at the gap between rows nearest the pointer. */
private dragMove = (e: PointerEvent) => {
const d = this.drag;
const host = this.host;
if (!d || !host) return;
let gap = d.rows.length;
for (const [i, r] of d.rows.entries()) {
const b = r.getBoundingClientRect();
if (e.clientY < b.top + b.height / 2) {
gap = i;
break;
}
}
// A gap next to the row itself leaves it where it is.
d.to = gap > d.from ? gap - 1 : gap;
const hostBox = host.getBoundingClientRect();
const first = d.rows[0]!.getBoundingClientRect();
const edge =
gap < d.rows.length ? d.rows[gap]!.getBoundingClientRect().top : d.rows.at(-1)!.getBoundingClientRect().bottom;
Object.assign(this.line.style, {
top: `${edge - hostBox.top - 1}px`,
left: `${first.left - hostBox.left}px`,
width: `${first.width}px`,
});
this.line.hidden = d.to === d.from;
};
private drop = () => {
const d = this.drag;
this.cancel();
if (!d || d.to === d.from) return;
const tr = moveRow(this.view.state, d.tablePos, d.from, d.to);
if (tr) this.view.dispatch(tr);
this.view.focus();
};
private cancel = () => {
this.row?.classList.remove("dw-row-dragging");
this.drag = null;
this.line.hidden = true;
this.grip.removeEventListener("pointermove", this.dragMove);
this.grip.removeEventListener("pointerup", this.drop);
this.grip.removeEventListener("pointercancel", this.cancel);
this.hide();
};
update() {
if (this.row && !this.row.isConnected) this.hide();
}
destroy() {
this.cancel();
this.grip.remove();
this.line.remove();
this.view.dom.removeEventListener("mousemove", this.move);
this.view.dom.removeEventListener("mouseleave", this.leave);
}
}
+15
View File
@@ -103,6 +103,21 @@ export const iconPaths = {
"M16 4.5a3.5 3.5 0 0 1 0 6.5",
"M18 14a6 6 0 0 1 3 6",
],
"align-left": ["M4 6h16", "M4 10h10", "M4 14h16", "M4 18h10"],
"align-center": ["M4 6h16", "M7 10h10", "M4 14h16", "M7 18h10"],
"align-right": ["M4 6h16", "M10 10h10", "M4 14h16", "M10 18h10"],
grip: ["M9 6h.01", "M15 6h.01", "M9 12h.01", "M15 12h.01", "M9 18h.01", "M15 18h.01"],
copy: ["M9 9h11v11H9z", "M5 15H4V4h11v1"],
"arrow-up": ["M12 19V5", "M6 11l6-6 6 6"],
"arrow-down": ["M12 5v14", "M6 13l6 6 6-6"],
callout: ["M4 5h16v14H4z", "M8 10h.01", "M11 10h5", "M8 14h8"],
palette: [
"M12 3a9 9 0 1 0 0 18c1 0 1.5-.7 1.5-1.5 0-1.2-1-1.5-1-2.5s.8-1.5 2-1.5H17a4 4 0 0 0 4-4c0-4.7-4-8.5-9-8.5z",
"M7.5 11h.01",
"M10 7.5h.01",
"M14.5 7.5h.01",
],
"page-plus": ["M6 3h8l4 4v14H6z", "M14 3v4h4", "M12 11v6", "M9 14h6"],
} as const;
export type IconName = keyof typeof iconPaths;
+5 -1
View File
@@ -9,7 +9,7 @@ import 'dart:convert';
import 'package:flutter/foundation.dart';
/// Protocol version this app speaks. The page reports its own in "ready".
const editorProtocolVersion = 1;
const editorProtocolVersion = 2;
/// Formatting the native toolbar can apply.
enum EditorCommand {
@@ -24,6 +24,10 @@ enum EditorCommand {
orderedList,
blockquote,
codeBlock,
underline,
taskList,
callout,
table,
undo,
redo,
}
+4
View File
@@ -129,10 +129,14 @@ class EditorToolbar extends StatelessWidget {
static const _buttons = [
(EditorCommand.bold, Icons.format_bold, 'Bold'),
(EditorCommand.italic, Icons.format_italic, 'Italic'),
(EditorCommand.underline, Icons.format_underline, 'Underline'),
(EditorCommand.strike, Icons.format_strikethrough, 'Strikethrough'),
(EditorCommand.heading1, Icons.title, 'Heading'),
(EditorCommand.bulletList, Icons.format_list_bulleted, 'Bulleted list'),
(EditorCommand.orderedList, Icons.format_list_numbered, 'Numbered list'),
(EditorCommand.taskList, Icons.checklist, 'To-do list'),
(EditorCommand.callout, Icons.lightbulb_outline, 'Callout'),
(EditorCommand.table, Icons.table_chart_outlined, 'Table'),
(EditorCommand.blockquote, Icons.format_quote, 'Quote'),
(EditorCommand.codeBlock, Icons.code, 'Code block'),
];
+230
View File
@@ -0,0 +1,230 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package convert
import (
"regexp"
"strconv"
"strings"
"unicode"
"unicode/utf8"
)
// The palette colours of text, highlights and callouts (Packages/editor
// colors.ts). Documents store the name; files that need a value get the
// light theme's.
var paletteText = map[string]string{
"gray": "#6b6f6d", "red": "#c0392b", "orange": "#c2571a", "yellow": "#9a7400", "green": "#3d7a1f",
"teal": "#1f7f79", "blue": "#2f6fbf", "purple": "#7c5cc4", "pink": "#b8327a",
}
var paletteBackground = map[string]string{
"gray": "#ecece9", "red": "#fbe3df", "orange": "#fbe7d7", "yellow": "#fbf1c7", "green": "#e4f1d8",
"teal": "#d9efec", "blue": "#dfe9f7", "purple": "#ebe4f7", "pink": "#f8e0ec",
}
func isPaletteColor(c string) bool {
_, ok := paletteText[c]
return ok
}
// rgb reads a "#rrggbb" colour.
func rgb(hex string) (r, g, b int) {
v, err := strconv.ParseUint(strings.TrimPrefix(hex, "#"), 16, 32)
if err != nil || len(hex) != 7 {
return 0, 0, 0
}
return int(v >> 16 & 0xff), int(v >> 8 & 0xff), int(v & 0xff)
}
// nearestPalette maps a "rrggbb" colour from another program to the
// palette colour of its hue, or "" for black, white and near-greys, which
// stay plain text (dark greys are usually just text).
func nearestPalette(hex string) string {
if len(strings.TrimPrefix(hex, "#")) != 6 {
return ""
}
r, g, b := rgb("#" + strings.TrimPrefix(strings.ToLower(hex), "#"))
hi, lo := max(r, g, b), min(r, g, b)
switch {
case hi < 60 || lo > 235:
return ""
case hi-lo < 40:
if hi > 90 && hi < 200 {
return "gray"
}
return ""
}
var hue float64
d := float64(hi - lo)
switch hi {
case r:
hue = 60 * float64(g-b) / d
case g:
hue = 60*float64(b-r)/d + 120
default:
hue = 60*float64(r-g)/d + 240
}
if hue < 0 {
hue += 360
}
for _, band := range []struct {
upTo float64
name string
}{{15, "red"}, {40, "orange"}, {70, "yellow"}, {160, "green"}, {200, "teal"}, {250, "blue"}, {290, "purple"}, {345, "pink"}} {
if hue < band.upTo {
return band.name
}
}
return "red"
}
// ---- Callouts --------------------------------------------------------------
// alert is a GitHub Markdown alert ("> [!NOTE]"), which callouts become in
// Markdown, with the colour and emoji a callout read from one gets.
type alert struct{ name, color, emoji string }
var alerts = []alert{
{"NOTE", "blue", "💡"}, {"TIP", "green", "✅"}, {"IMPORTANT", "purple", "❗"},
{"WARNING", "yellow", "⚠️"}, {"CAUTION", "red", "🚫"},
}
// alertFor is the alert closest to a callout colour.
func alertFor(color string) alert {
switch color {
case "green":
return alerts[1]
case "purple", "pink":
return alerts[2]
case "yellow", "orange":
return alerts[3]
case "red":
return alerts[4]
}
return alerts[0]
}
var alertMarker = regexp.MustCompile(`^\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*`)
func alertNamed(name string) alert {
for _, a := range alerts {
if a.name == strings.ToUpper(name) {
return a
}
}
return alerts[0]
}
// leadingEmoji splits an emoji, and the space after it, off the start of s.
// emoji is "" when s does not start with one followed by a space.
func leadingEmoji(s string) (emoji, rest string) {
i, joined := 0, true // joined: the next rune may start the emoji, or continue it after a ZWJ
for i < len(s) {
r, size := utf8.DecodeRuneInString(s[i:])
switch {
case joined && isEmojiBase(r):
joined = false
case i > 0 && (r == 0xFE0F || (r >= 0x1F3FB && r <= 0x1F3FF) || r == 0x20E3 || (r >= 0x1F1E6 && r <= 0x1F1FF)):
// Variation selectors, skin tones, keycaps and the second letter of a flag.
case i > 0 && r == 0x200D:
joined = true
case i > 0 && !joined && (r == 0x20 || r == 0xA0):
return s[:i], s[i+size:]
default:
return "", s
}
i += size
}
if i == 0 || joined {
return "", s
}
return s, ""
}
func isEmojiBase(r rune) bool {
return r >= 0x1F000 || (r >= 0x2190 && r <= 0x2BFF) || r == 0x2705 || unicode.Is(unicode.So, r)
}
// calloutParts is a callout's emoji and colour, with the defaults filled in.
func calloutParts(n Node) (emoji, color string) {
emoji, color = n.attr("emoji"), n.attr("color")
if !isPaletteColor(color) {
color = "blue"
}
if emoji == "" {
emoji = "💡"
}
return emoji, color
}
// newCallout is a callout node around body, which gets an empty paragraph
// when it has nothing.
func newCallout(emoji, color string, body []Node) Node {
if emoji == "" {
emoji = "💡"
}
if !isPaletteColor(color) {
color = "blue"
}
if len(body) == 0 {
body = []Node{{Type: "paragraph"}}
}
return Node{Type: "callout", Attrs: map[string]any{"emoji": emoji, "color": color}, Content: body}
}
// liftEmoji takes an emoji off the start of the first paragraph of body, as
// callouts imported from Markdown and Notion carry their icon there.
func liftEmoji(body []Node) (string, []Node) {
if len(body) == 0 || body[0].Type != "paragraph" || len(body[0].Content) == 0 || body[0].Content[0].Type != "text" {
return "", body
}
emoji, rest := leadingEmoji(body[0].Content[0].Text)
if emoji == "" {
return "", body
}
p := body[0]
p.Content = append([]Node{}, p.Content...)
p.Content[0].Text = rest
if rest == "" {
p.Content = p.Content[1:]
}
out := append([]Node{}, body...)
if len(p.Content) == 0 && len(out) > 1 {
return emoji, out[1:]
}
out[0] = p
return emoji, out
}
// ---- Tables ----------------------------------------------------------------
// cellText is a table cell's content on one line, for Markdown.
func (w *mdWriter) cellText(cell Node) string {
var parts []string
for _, b := range cell.Content {
var s string
switch b.Type {
case "paragraph", "heading":
s = w.inline(b.Content)
default:
s = escapeMD(PlainText(b))
}
s = strings.TrimSpace(strings.NewReplacer("\\\n", " ", "\n", " ").Replace(s))
if s != "" {
parts = append(parts, s)
}
}
return strings.Join(parts, " ")
}
// alignOf is a text block's alignment when it is not the default.
func alignOf(n Node) string {
switch a := n.attr("textAlign"); a {
case "center", "right":
return a
}
return ""
}
var cssAlign = regexp.MustCompile(`(?i)text-align\s*:\s*(center|right)`)
+153
View File
@@ -0,0 +1,153 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package convert
import (
"bytes"
"strings"
"testing"
)
const phaseA = `{"type":"doc","content":[
{"type":"heading","attrs":{"level":5,"textAlign":"center"},"content":[{"type":"text","text":"Small"}]},
{"type":"paragraph","attrs":{"textAlign":"right"},"content":[
{"type":"text","text":"red","marks":[{"type":"textColor","attrs":{"color":"red"}}]},
{"type":"text","text":" and "},
{"type":"text","text":"marked","marks":[{"type":"highlight","attrs":{"color":"green"}}]}]},
{"type":"taskList","content":[
{"type":"taskItem","attrs":{"checked":true},"content":[{"type":"paragraph","content":[{"type":"text","text":"done"}]}]},
{"type":"taskItem","attrs":{"checked":false},"content":[{"type":"paragraph","content":[{"type":"text","text":"todo"}]}]}]},
{"type":"callout","attrs":{"emoji":"🔥","color":"red"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Careful"}]}]},
{"type":"callout","attrs":{"emoji":"💡","color":"blue"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Plain"}]}]},
{"type":"table","content":[
{"type":"tableRow","content":[
{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Name"}]}]},
{"type":"tableHeader","content":[{"type":"paragraph","content":[{"type":"text","text":"Role"}]}]}]},
{"type":"tableRow","content":[
{"type":"tableCell","content":[{"type":"paragraph","content":[{"type":"text","text":"Ada | A"}]}]},
{"type":"tableCell","attrs":{"colspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Lead"}]},{"type":"paragraph","content":[{"type":"text","text":"and more"}]}]}]}]}
]}`
func TestPhaseABlocksMarkdown(t *testing.T) {
md := Markdown(mustParse(t, phaseA), Options{})
for _, want := range []string{
"##### Small\n",
"- [x] done\n- [ ] todo\n",
"> [!CAUTION]\n> 🔥 Careful\n",
"> [!NOTE]\n> Plain\n",
"| Name | Role |\n| --- | --- |\n| Ada \\| A | Lead and more |\n",
} {
if !strings.Contains(md, want) {
t.Errorf("markdown lacks %q:\n%s", want, md)
}
}
// And back: the same kinds of blocks come out again.
doc, err := FromMarkdown(md)
if err != nil {
t.Fatal(err)
}
j := asJSON(t, doc)
for _, want := range []string{
`"level":5`,
`{"type":"taskItem","attrs":{"checked":true}`,
`{"type":"callout","attrs":{"color":"red","emoji":"🔥"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Careful"}]}]}`,
`{"type":"callout","attrs":{"color":"blue","emoji":"💡"}`,
`"type":"tableHeader"`,
`"text":"Ada | A"`,
} {
if !strings.Contains(j, want) {
t.Errorf("import lacks %s:\n%s", want, j)
}
}
}
func TestPhaseABlocksHTML(t *testing.T) {
h := HTML(mustParse(t, phaseA), Options{})
for _, want := range []string{
`<h5 style="text-align:center">Small</h5>`,
`<p style="text-align:right"><span data-color="red" style="color:#c0392b">red</span> and <mark data-color="green"`,
`<li data-type="taskItem" data-checked="true"><input type="checkbox" disabled checked> <p>done</p>`,
`<aside data-type="callout" data-emoji="🔥" data-color="red"`,
`<tr><th><p>Name</p>`,
} {
if !strings.Contains(h, want) {
t.Errorf("html lacks %q:\n%s", want, h)
}
}
// Docwell's own HTML reads back as the document it came from.
doc, err := FromHTML(h)
if err != nil {
t.Fatal(err)
}
if got, want := Markdown(doc, Options{}), Markdown(mustParse(t, phaseA), Options{}); got != want {
t.Errorf("html round trip:\n%s\nwant\n%s", got, want)
}
j := asJSON(t, doc)
for _, want := range []string{`"textAlign":"right"`, `{"type":"textColor","attrs":{"color":"red"}}`, `{"type":"highlight","attrs":{"color":"green"}}`} {
if !strings.Contains(j, want) {
t.Errorf("html import lacks %s:\n%s", want, j)
}
}
}
func TestNotionCalloutsAndTodos(t *testing.T) {
md := notionAsides("Intro\n\n<aside>\n⚠️ Mind the gap\n\n</aside>\n\nAfter\n")
doc, err := FromMarkdown(md)
if err != nil {
t.Fatal(err)
}
if j := asJSON(t, doc); !strings.Contains(j, `{"type":"callout","attrs":{"color":"blue","emoji":"⚠️"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Mind the gap"}]}]}`) {
t.Errorf("aside = %s", j)
}
doc, err = FromHTML(`<figure class="callout"><div style="font-size:1.5em"><span class="icon">📌</span></div><div style="width:100%"><p>Pinned</p></div></figure>` +
`<ul class="to-do-list"><li><div class="checkbox checkbox-on"></div> <span class="to-do-children-checked">Bought milk</span></li>` +
`<li><div class="checkbox checkbox-off"></div> <span>Eggs</span></li></ul>`)
if err != nil {
t.Fatal(err)
}
j := asJSON(t, doc)
for _, want := range []string{
`{"type":"callout","attrs":{"color":"blue","emoji":"📌"},"content":[{"type":"paragraph","content":[{"type":"text","text":"Pinned"}]}]}`,
`{"type":"taskItem","attrs":{"checked":true},"content":[{"type":"paragraph","content":[{"type":"text","text":"Bought milk"}]}]}`,
`{"type":"taskItem","attrs":{"checked":false}`,
} {
if !strings.Contains(j, want) {
t.Errorf("notion html lacks %s:\n%s", want, j)
}
}
}
func TestLeadingEmoji(t *testing.T) {
for in, want := range map[string]string{
"💡 idea": "💡",
"⚠️ careful": "⚠️",
"👩‍💻 dev": "👩‍💻",
"🇵🇱 flag": "🇵🇱",
"plain": "",
"💡nospace": "",
} {
if got, _ := leadingEmoji(in); got != want {
t.Errorf("leadingEmoji(%q) = %q, want %q", in, got, want)
}
}
}
func TestPhaseABlocksPDF(t *testing.T) {
out, err := PDF("Blocks", mustParse(t, phaseA), PDFOptions{})
if err != nil {
t.Fatal(err)
}
if !bytes.HasPrefix(out, []byte("%PDF-")) {
t.Fatal("not a PDF")
}
}
func TestNearestPalette(t *testing.T) {
for in, want := range map[string]string{"FF0000": "red", "0070C0": "blue", "000000": "", "auto": "", "FFFFFF": "", "00B050": "green"} {
if got := nearestPalette(in); got != want {
t.Errorf("nearestPalette(%q) = %q, want %q", in, got, want)
}
}
}
+1 -1
View File
@@ -110,7 +110,7 @@ func TestFromHTMLSanitizes(t *testing.T) {
if title != "Hi" {
t.Errorf("title = %q", title)
}
if md := Markdown(rest, Options{}); !strings.Contains(md, "[ok](https://ok.test)") || !strings.Contains(md, "a · **b**") || !strings.Contains(md, "### deep") {
if md := Markdown(rest, Options{}); !strings.Contains(md, "[ok](https://ok.test)") || !strings.Contains(md, "| a | **b** |\n| --- | --- |") || !strings.Contains(md, "##### deep") {
t.Errorf("content = %s", md)
}
}
+65 -40
View File
@@ -197,9 +197,10 @@ func (n *xnode) find(name string) *xnode {
// maxDocxPart caps one unpacked part of a Word file (the document XML, one image).
const maxDocxPart = 50 << 20
// FromDOCX reads a Word document. Headings, lists, quotes, code, bold,
// italic, underline, strikethrough, links and images are kept; tables become
// one paragraph per row, as in HTML import. Images come back as assets.
// FromDOCX reads a Word document. Headings, lists, quotes, code, tables,
// alignment, bold, italic, underline, strikethrough, text colours and
// highlights (as the nearest palette colour), links and images are kept.
// Images come back as assets.
func FromDOCX(data []byte) (Node, []Asset, error) {
zr, err := zip.NewReader(bytes.NewReader(data), int64(len(data)))
if err != nil {
@@ -358,6 +359,7 @@ var headingStyle = regexp.MustCompile(`^heading\s*([1-9])$`)
type para struct {
kind string // paragraph, heading, quote, code, list
level int // heading level, or list depth
align string // "center" or "right", or "" for the default
ordered bool
inline []Node
text string // code paragraphs keep their plain text
@@ -402,7 +404,7 @@ func (d *docxReader) blocks(nodes []*xnode) []Node {
code = append(code, p.text)
case "heading":
if inl := trimInline(p.inline); len(inl) > 0 {
out = append(out, Node{Type: "heading", Attrs: map[string]any{"level": float64(min(p.level, 3))}, Content: inl})
out = append(out, withAlign(Node{Type: "heading", Attrs: map[string]any{"level": float64(min(p.level, 6))}, Content: inl}, p.align))
}
case "quote":
if inl := trimInline(p.inline); len(inl) > 0 {
@@ -415,7 +417,7 @@ func (d *docxReader) blocks(nodes []*xnode) []Node {
}
default:
if inl := trimInline(p.inline); len(inl) > 0 {
out = append(out, Node{Type: "paragraph", Content: inl})
out = append(out, withAlign(Node{Type: "paragraph", Content: inl}, p.align))
}
}
out = append(out, p.blocks...)
@@ -441,56 +443,50 @@ func (n *xnode) kidsOrNil() []*xnode {
return n.kids
}
// withAlign sets a text block's alignment when it has one.
func withAlign(n Node, align string) Node {
if align != "" {
n.Attrs = cloneAttrs(n.Attrs)
n.Attrs["textAlign"] = align
}
return n
}
// table reads a Word table. Rows marked to repeat as a header become header
// cells; cells spanning columns keep their span.
func (d *docxReader) table(t *xnode) []Node {
var out []Node
tbl := Node{Type: "table"}
for _, tr := range t.kids {
if tr.name != "tr" {
continue
}
var cells []Node
kind := "tableCell"
if tr.child("trPr").on("tblHeader") {
kind = "tableHeader"
}
row := Node{Type: "tableRow"}
for _, tc := range tr.kids {
if tc.name != "tc" {
continue
}
var cell []Node
for _, b := range d.blocks(tc.kids) {
if len(cell) > 0 {
cell = append(cell, Node{Type: "text", Text: " "})
}
if b.Type == "image" {
out = append(out, b)
continue
}
cell = append(cell, inlineOf(b)...)
attrs := map[string]any{"colspan": float64(1), "rowspan": float64(1), "colwidth": nil}
if span, err := strconv.Atoi(tc.child("tcPr").val("gridSpan")); err == nil && span > 1 && span < 1000 {
attrs["colspan"] = float64(span)
}
if len(cells) > 0 {
cells = append(cells, Node{Type: "text", Text: " · "})
content := d.blocks(tc.kids)
if len(content) == 0 {
content = []Node{{Type: "paragraph"}}
}
cells = append(cells, cell...)
row.Content = append(row.Content, Node{Type: kind, Attrs: attrs, Content: content})
}
if c := trimInline(cells); len(c) > 0 {
out = append(out, Node{Type: "paragraph", Content: c})
if len(row.Content) > 0 {
tbl.Content = append(tbl.Content, row)
}
}
return out
}
// inlineOf flattens a block to its inline content.
func inlineOf(b Node) []Node {
switch b.Type {
case "paragraph", "heading":
return b.Content
case "text", "hardBreak":
return []Node{b}
if len(tbl.Content) == 0 {
return nil
}
var out []Node
for _, c := range b.Content {
if len(out) > 0 && (c.Type == "paragraph" || c.Type == "listItem") {
out = append(out, Node{Type: "text", Text: " "})
}
out = append(out, inlineOf(c)...)
}
return out
return []Node{tbl}
}
func (d *docxReader) paragraph(p *xnode) para {
@@ -500,6 +496,12 @@ func (d *docxReader) paragraph(p *xnode) para {
if v, err := strconv.Atoi(ppr.val("outlineLvl")); err == nil && v < 9 {
outline = v + 1
}
switch ppr.val("jc") {
case "center":
out.align = "center"
case "right", "end":
out.align = "right"
}
switch {
case name == "title":
out.kind, out.level = "heading", 1
@@ -619,6 +621,23 @@ func (r *runReader) children(nodes []*xnode, marks []Mark) {
}
}
// wordHighlight maps Word's highlight colours to the palette.
var wordHighlight = map[string]string{
"yellow": "yellow", "darkYellow": "yellow", "green": "green", "darkGreen": "green", "cyan": "teal",
"darkCyan": "teal", "blue": "blue", "darkBlue": "blue", "magenta": "pink", "darkMagenta": "purple",
"red": "red", "darkRed": "red", "lightGray": "gray", "darkGray": "gray",
}
// withMark adds m unless a mark of its type is there already.
func withMark(marks []Mark, m Mark) []Mark {
for _, have := range marks {
if have.Type == m.Type {
return marks
}
}
return append(append([]Mark(nil), marks...), m)
}
func withLink(marks []Mark, href string) []Mark {
return append(append([]Mark(nil), marks...), Mark{Type: "link", Attrs: map[string]any{
"href": href, "target": "_blank", "rel": "noopener noreferrer nofollow", "class": nil,
@@ -654,6 +673,12 @@ func (r *runReader) run(n *xnode, marks []Mark) {
if s := strings.ToLower(rpr.val("rStyle")); strings.Contains(s, "code") {
add("code")
}
if c := nearestPalette(rpr.val("color")); c != "" {
marks = withMark(marks, Mark{Type: "textColor", Attrs: map[string]any{"color": c}})
}
if c, ok := wordHighlight[rpr.val("highlight")]; ok {
marks = withMark(marks, Mark{Type: "highlight", Attrs: map[string]any{"color": c}})
}
}
if r.link != "" {
marks = withLink(marks, r.link)
+131 -2
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"html"
"regexp"
"slices"
"strconv"
"strings"
)
@@ -59,7 +60,7 @@ func HTMLPage(title string, doc Node, o Options) string {
}
var htmlBlock = map[string]string{
"paragraph": "p", "blockquote": "blockquote", "bulletList": "ul", "orderedList": "ol", "listItem": "li",
"blockquote": "blockquote", "bulletList": "ul", "orderedList": "ol", "listItem": "li",
}
func writeHTML(b *strings.Builder, n Node, o Options) {
@@ -73,9 +74,55 @@ func writeHTML(b *strings.Builder, n Node, o Options) {
writeHTMLText(b, n, o)
case "heading":
level := min(max(n.intAttr("level", 1), 1), 6)
fmt.Fprintf(b, "<h%d>", level)
fmt.Fprintf(b, "<h%d%s>", level, htmlAlign(n))
children()
fmt.Fprintf(b, "</h%d>\n", level)
case "paragraph":
fmt.Fprintf(b, "<p%s>", htmlAlign(n))
children()
b.WriteString("</p>\n")
case "taskList":
b.WriteString("<ul data-type=\"taskList\">\n")
children()
b.WriteString("</ul>\n")
case "taskItem":
checked := n.Attrs["checked"] == true
box := ""
if checked {
box = " checked"
}
fmt.Fprintf(b, "<li data-type=\"taskItem\" data-checked=\"%t\"><input type=\"checkbox\" disabled%s> ", checked, box)
children()
b.WriteString("</li>\n")
case "callout":
emoji, color := calloutParts(n)
fmt.Fprintf(b, "<aside data-type=\"callout\" data-emoji=\"%s\" data-color=\"%s\" style=\"background:%s\">"+
"<span class=\"callout-emoji\">%s</span><div class=\"callout-body\">\n",
html.EscapeString(emoji), color, paletteBackground[color], html.EscapeString(emoji))
children()
b.WriteString("</div></aside>\n")
case "table":
b.WriteString("<table>\n<tbody>\n")
children()
b.WriteString("</tbody>\n</table>\n")
case "tableRow":
b.WriteString("<tr>")
children()
b.WriteString("</tr>\n")
case "tableCell", "tableHeader":
tag := "td"
if n.Type == "tableHeader" {
tag = "th"
}
b.WriteString("<" + tag)
for _, span := range []string{"colspan", "rowspan"} {
if v := n.intAttr(span, 1); v > 1 {
fmt.Fprintf(b, " %s=\"%d\"", span, v)
}
}
b.WriteString(">")
children()
b.WriteString("</" + tag + ">")
case "orderedList":
if start := n.intAttr("start", 1); start != 1 {
fmt.Fprintf(b, "<ol start=\"%d\">\n", start)
@@ -163,6 +210,14 @@ func writeHTML(b *strings.Builder, n Node, o Options) {
}
}
// htmlAlign is the style attribute of an aligned paragraph or heading.
func htmlAlign(n Node) string {
if a := alignOf(n); a != "" {
return " style=\"text-align:" + a + "\""
}
return ""
}
func writeHTMLText(b *strings.Builder, n Node, o Options) {
var open, close []string
for _, m := range n.Marks {
@@ -177,6 +232,18 @@ func writeHTMLText(b *strings.Builder, n Node, o Options) {
open, close = append(open, "<u>"), append([]string{"</u>"}, close...)
case "code":
open, close = append(open, "<code>"), append([]string{"</code>"}, close...)
case "textColor":
if c := m.attr("color"); isPaletteColor(c) {
open = append(open, "<span data-color=\""+c+"\" style=\"color:"+paletteText[c]+"\">")
close = append([]string{"</span>"}, close...)
}
case "highlight":
c := m.attr("color")
if !isPaletteColor(c) {
c = "yellow"
}
open = append(open, "<mark data-color=\""+c+"\" style=\"background:"+paletteBackground[c]+"\">")
close = append([]string{"</mark>"}, close...)
case "link":
if href := o.file(m.attr("href")); safeURL.MatchString(href) {
open, close = append(open, "<a href=\""+html.EscapeString(href)+"\">"), append([]string{"</a>"}, close...)
@@ -255,6 +322,36 @@ func (w *mdWriter) block(n Node, first, rest string) {
}
w.blocks(item.Content, p+"- ", rest+" ")
}
case "taskList":
// GitHub's task lists, which FromMarkdown reads back.
for i, item := range n.Content {
p := rest
if i == 0 {
p = first
}
box := "[ ] "
if item.Attrs["checked"] == true {
box = "[x] "
}
if len(item.Content) == 0 || item.Content[0].Type != "paragraph" {
item.Content = append([]Node{{Type: "paragraph"}}, item.Content...)
}
w.blocks(item.Content, p+"- "+box, rest+" ")
}
case "callout":
// A GitHub alert; the emoji goes first in the text unless it is the alert's own.
emoji, color := calloutParts(n)
a := alertFor(color)
body := n.Content
if emoji != a.emoji && len(body) > 0 && body[0].Type == "paragraph" {
p := body[0]
p.Content = append([]Node{{Type: "text", Text: emoji + " "}}, p.Content...)
body = append([]Node{p}, body[1:]...)
}
w.lines("[!"+a.name+"]", first+"> ", rest+"> ")
w.blocks(body, rest+"> ", rest+"> ")
case "table":
w.table(n, first, rest)
case "orderedList":
start := n.intAttr("start", 1)
for i, item := range n.Content {
@@ -331,6 +428,38 @@ func (w *mdWriter) block(n Node, first, rest string) {
}
}
// table writes a GitHub table. Its first row is the header, as Markdown
// tables need one; cells keep their text on one line.
func (w *mdWriter) table(n Node, first, rest string) {
cols := 0
for _, row := range n.Content {
cols = max(cols, len(row.Content))
}
if cols == 0 {
return
}
line := func(cells []string) string {
for len(cells) < cols {
cells = append(cells, "")
}
return "| " + strings.Join(cells, " | ") + " |"
}
for i, row := range n.Content {
var cells []string
for _, c := range row.Content {
cells = append(cells, w.cellText(c))
}
p := rest
if i == 0 {
p = first
}
w.lines(line(cells), p, rest)
if i == 0 {
w.lines(line(slices.Repeat([]string{"---"}, cols)), rest, rest)
}
}
}
func (w *mdWriter) inline(nodes []Node) string {
var b strings.Builder
for _, n := range nodes {
+204 -22
View File
@@ -22,14 +22,15 @@ type ImportOptions struct {
Resolve func(url string) (out string, ok bool)
}
// FromMarkdown reads CommonMark (with GitHub's strikethrough, autolinks and
// task lists, the latter as plain lists). Raw HTML in the Markdown is dropped.
// FromMarkdown reads CommonMark with GitHub's additions: strikethrough,
// autolinks, task lists, tables and alerts ("> [!NOTE]", read as callouts).
// Raw HTML in the Markdown is dropped.
func FromMarkdown(md string) (Node, error) { return FromMarkdownWith(md, ImportOptions{}) }
// FromMarkdownWith is FromMarkdown with options.
func FromMarkdownWith(md string, o ImportOptions) (Node, error) {
var buf bytes.Buffer
gm := goldmark.New(goldmark.WithExtensions(extension.Strikethrough, extension.Linkify, extension.TaskList))
gm := goldmark.New(goldmark.WithExtensions(extension.Strikethrough, extension.Linkify, extension.TaskList, extension.Table))
if err := gm.Convert([]byte(md), &buf); err != nil {
return Node{}, err
}
@@ -161,7 +162,61 @@ func (r *reader) blocks(n *html.Node) []Node {
return out
}
var headingLevel = map[atom.Atom]int{atom.H1: 1, atom.H2: 2, atom.H3: 3, atom.H4: 3, atom.H5: 3, atom.H6: 3}
var headingLevel = map[atom.Atom]int{atom.H1: 1, atom.H2: 2, atom.H3: 3, atom.H4: 4, atom.H5: 5, atom.H6: 6}
func hasClass(n *html.Node, class string) bool {
return strings.Contains(" "+attrOf(n, "class")+" ", " "+class+" ")
}
// aligned sets the alignment n's style asks for on the text blocks of out.
func aligned(n *html.Node, out []Node) []Node {
m := cssAlign.FindStringSubmatch(attrOf(n, "style"))
if m == nil {
return out
}
for i := range out {
if out[i].Type == "paragraph" || out[i].Type == "heading" {
out[i].Attrs = cloneAttrs(out[i].Attrs)
out[i].Attrs["textAlign"] = strings.ToLower(m[1])
}
}
return out
}
// checkbox is a list item's leading checkbox: an <input type=checkbox>
// (Markdown task lists, Docwell's HTML) or Notion's <div class="checkbox">,
// directly in the item or in its first paragraph.
func checkbox(li *html.Node) (found, checked bool) {
if v := attrOf(li, "data-checked"); attrOf(li, "data-type") == "taskItem" {
return true, v == "true"
}
for c := li.FirstChild; c != nil; c = c.NextSibling {
switch {
case c.Type == html.TextNode && strings.TrimSpace(c.Data) == "":
continue
case c.Type != html.ElementNode:
return false, false
case c.DataAtom == atom.Input && strings.EqualFold(attrOf(c, "type"), "checkbox"):
_, on := attrValue(c, "checked")
return true, on
case c.DataAtom == atom.Div && hasClass(c, "checkbox"):
return true, hasClass(c, "checkbox-on")
case c.DataAtom == atom.P || c.DataAtom == atom.Label:
return checkbox(c)
}
return false, false
}
return false, false
}
func attrValue(n *html.Node, key string) (string, bool) {
for _, a := range n.Attr {
if a.Key == key {
return a.Val, true
}
}
return "", false
}
var languageClass = regexp.MustCompile(`(?:^|\s)(?:language|lang)-([A-Za-z0-9_+#.-]{1,40})`)
@@ -170,11 +225,40 @@ func (r *reader) block(n *html.Node) []Node {
case atom.P, atom.Dt, atom.Dd, atom.Summary, atom.Figcaption, atom.Td, atom.Th:
// Text becomes a paragraph; images (blocks in the schema, but inside
// <p> in Markdown output) are lifted out next to it.
return r.blocks(n)
return aligned(n, r.blocks(n))
case atom.H1, atom.H2, atom.H3, atom.H4, atom.H5, atom.H6:
h := Node{Type: "heading", Attrs: map[string]any{"level": float64(headingLevel[n.DataAtom])}}
h.Content = trimInline(r.inlineChildren(n, nil))
return []Node{h}
return aligned(n, []Node{h})
case atom.Aside:
if attrOf(n, "data-type") == "callout" {
body := n
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type == html.ElementNode && hasClass(c, "callout-body") {
body = c
}
}
return []Node{newCallout(attrOf(n, "data-emoji"), attrOf(n, "data-color"), r.blocks(body))}
}
case atom.Figure:
// Notion: <figure class="callout"><div><span class="icon">💡</span></div><div>text</div></figure>
if hasClass(n, "callout") {
emoji := ""
var body []Node
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type != html.ElementNode {
continue
}
if emoji == "" && body == nil && strings.TrimSpace(textOf(c)) != "" && len([]rune(strings.TrimSpace(textOf(c)))) <= 4 {
emoji = strings.TrimSpace(textOf(c))
continue
}
body = append(body, r.block(c)...)
}
return []Node{newCallout(emoji, "", body)}
}
case atom.Table:
return r.table(n)
case atom.Ul, atom.Ol:
list := Node{Type: "bulletList"}
if n.DataAtom == atom.Ol {
@@ -185,11 +269,26 @@ func (r *reader) block(n *html.Node) []Node {
}
list.Attrs = map[string]any{"start": float64(start)}
}
tasks := attrOf(n, "data-type") == "taskList" || hasClass(n, "to-do-list")
for c := n.FirstChild; c != nil && !tasks && n.DataAtom == atom.Ul; c = c.NextSibling {
if c.Type == html.ElementNode {
tasks, _ = checkbox(c)
}
}
if tasks {
list = Node{Type: "taskList"}
}
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type != html.ElementNode {
continue
}
list.Content = append(list.Content, r.listItem(c))
item := r.listItem(c)
if tasks {
_, checked := checkbox(c)
item.Type = "taskItem"
item.Attrs = map[string]any{"checked": checked}
}
list.Content = append(list.Content, item)
}
if len(list.Content) == 0 {
return nil
@@ -199,6 +298,9 @@ func (r *reader) block(n *html.Node) []Node {
return []Node{{Type: "bulletList", Content: []Node{r.listItem(n)}}}
case atom.Blockquote:
content := r.blocks(n)
if c, ok := alertCallout(content); ok {
return []Node{c}
}
if len(content) == 0 {
content = []Node{{Type: "paragraph"}}
}
@@ -240,26 +342,92 @@ func (r *reader) block(n *html.Node) []Node {
return nil
}
return []Node{{Type: "image", Attrs: map[string]any{"src": src, "alt": attrOf(n, "alt"), "title": nil}}}
case atom.Tr:
// Tables are not in the schema yet; each row becomes a paragraph of cells.
var cells []Node
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type == html.ElementNode && (c.DataAtom == atom.Td || c.DataAtom == atom.Th) {
if len(cells) > 0 {
cells = append(cells, Node{Type: "text", Text: " · "})
}
cells = append(cells, trimInline(r.inlineChildren(c, nil))...)
}
}
if len(cells) == 0 {
return nil
}
return []Node{{Type: "paragraph", Content: cells}}
}
// Containers (div, section, table, ...) contribute their children.
return r.blocks(n)
}
// alertCallout turns a quote that starts with a GitHub alert marker
// ("[!NOTE]") into a callout of that kind.
func alertCallout(content []Node) (Node, bool) {
if len(content) == 0 || content[0].Type != "paragraph" || len(content[0].Content) == 0 || content[0].Content[0].Type != "text" {
return Node{}, false
}
first := content[0].Content[0]
m := alertMarker.FindStringSubmatch(first.Text)
if m == nil {
return Node{}, false
}
a := alertNamed(m[1])
p := content[0]
p.Content = append([]Node{}, p.Content...)
p.Content[0].Text = first.Text[len(m[0]):]
if p.Content[0].Text == "" {
p.Content = p.Content[1:]
}
// A line break after the marker is not part of the text.
if len(p.Content) > 0 && p.Content[0].Type == "hardBreak" {
p.Content = p.Content[1:]
}
body := append([]Node{p}, content[1:]...)
if len(p.Content) == 0 {
body = content[1:]
}
emoji, body := liftEmoji(body)
if emoji == "" {
emoji = a.emoji
}
return newCallout(emoji, a.color, body), true
}
// table reads an HTML table: the rows of its head, bodies and foot in
// order, header cells as tableHeader. Every cell holds at least a paragraph.
func (r *reader) table(n *html.Node) []Node {
t := Node{Type: "table"}
var rows func(*html.Node)
rows = func(n *html.Node) {
for c := n.FirstChild; c != nil; c = c.NextSibling {
if c.Type != html.ElementNode {
continue
}
switch c.DataAtom {
case atom.Thead, atom.Tbody, atom.Tfoot:
rows(c)
case atom.Tr:
row := Node{Type: "tableRow"}
for cell := c.FirstChild; cell != nil; cell = cell.NextSibling {
if cell.Type != html.ElementNode || (cell.DataAtom != atom.Td && cell.DataAtom != atom.Th) {
continue
}
kind := "tableCell"
if cell.DataAtom == atom.Th {
kind = "tableHeader"
}
attrs := map[string]any{"colspan": float64(1), "rowspan": float64(1), "colwidth": nil}
for _, span := range []string{"colspan", "rowspan"} {
if v, err := strconv.Atoi(attrOf(cell, span)); err == nil && v > 1 && v < 1000 {
attrs[span] = float64(v)
}
}
content := aligned(cell, r.blocks(cell))
if len(content) == 0 {
content = []Node{{Type: "paragraph"}}
}
row.Content = append(row.Content, Node{Type: kind, Attrs: attrs, Content: content})
}
if len(row.Content) > 0 {
t.Content = append(t.Content, row)
}
}
}
}
rows(n)
if len(t.Content) == 0 {
return nil
}
return []Node{t}
}
func (r *reader) listItem(n *html.Node) Node {
item := Node{Type: "listItem", Content: r.blocks(n)}
if len(item.Content) == 0 || item.Content[0].Type != "paragraph" {
@@ -314,6 +482,20 @@ func (r *reader) inline(n *html.Node, marks []mark) []Node {
marks = add(mark{Type: "underline"})
case atom.Code, atom.Kbd, atom.Samp:
marks = add(mark{Type: "code"})
case atom.Mark:
c := attrOf(n, "data-color")
if !isPaletteColor(c) {
c = "yellow"
}
marks = add(mark{Type: "highlight", Attrs: map[string]any{"color": c}})
case atom.Span, atom.Font:
if c := attrOf(n, "data-color"); isPaletteColor(c) {
marks = add(mark{Type: "textColor", Attrs: map[string]any{"color": c}})
}
// The emoji Docwell's HTML shows in a callout is in its data-emoji too.
if hasClass(n, "callout-emoji") {
return nil
}
case atom.A:
if href := r.url(attrOf(n, "href")); href != "" {
marks = add(mark{Type: "link", Attrs: map[string]any{
+46 -22
View File
@@ -117,7 +117,7 @@ func ReadNotion(data []byte) ([]NotionPage, []Asset, error) {
var doc Node
switch strings.ToLower(path.Ext(s.file)) {
case ".md":
doc, err = FromMarkdownWith(string(bytes.TrimPrefix(data, []byte(utf8BOM))), opts)
doc, err = FromMarkdownWith(notionAsides(string(bytes.TrimPrefix(data, []byte(utf8BOM)))), opts)
case ".csv":
doc, err = notionTable(data)
default:
@@ -254,8 +254,7 @@ func (n *notionReader) resolve(dir, raw string) (string, bool) {
return ref, true
}
// notionTable turns a database's CSV into paragraphs, one per row, with the
// column names in bold first.
// notionTable turns a database's CSV into a table, its first row the header.
func notionTable(data []byte) (Node, error) {
r := csv.NewReader(bytes.NewReader(bytes.TrimPrefix(data, []byte(utf8BOM))))
r.FieldsPerRecord = -1
@@ -264,28 +263,53 @@ func notionTable(data []byte) (Node, error) {
if err != nil {
return Node{}, err
}
doc := Node{Type: "doc"}
for i, row := range rows {
var cells []Node
for _, cell := range row {
if cell = strings.TrimSpace(cell); cell == "" {
cell = "–"
}
if len(cells) > 0 {
cells = append(cells, Node{Type: "text", Text: " · "})
}
t := Node{Type: "text", Text: cell}
if i == 0 {
t.Marks = []Mark{{Type: "bold"}}
}
cells = append(cells, t)
}
if c := trimInline(cells); len(c) > 0 {
doc.Content = append(doc.Content, Node{Type: "paragraph", Content: c})
}
cols := 0
for _, row := range rows {
cols = max(cols, len(row))
}
doc := Node{Type: "doc"}
if cols == 0 {
return doc, nil
}
table := Node{Type: "table"}
for i, row := range rows {
tr := Node{Type: "tableRow"}
for c := range cols {
kind := "tableCell"
if i == 0 {
kind = "tableHeader"
}
p := Node{Type: "paragraph"}
if c < len(row) {
if cell := strings.TrimSpace(row[c]); cell != "" {
p.Content = []Node{{Type: "text", Text: cell}}
}
}
attrs := map[string]any{"colspan": float64(1), "rowspan": float64(1), "colwidth": nil}
tr.Content = append(tr.Content, Node{Type: kind, Attrs: attrs, Content: []Node{p}})
}
table.Content = append(table.Content, tr)
}
doc.Content = []Node{table}
return doc, nil
}
// notionAside finds the <aside> blocks Notion writes callouts as in its
// Markdown export. Markdown readers drop raw HTML, text and all.
var notionAside = regexp.MustCompile(`(?ms)^[ \t]*<aside>[ \t]*\n(.*?)\n?[ \t]*</aside>[ \t]*$`)
// notionAsides rewrites Notion's callouts as GitHub alerts, which import
// reads as callouts (with the emoji Notion puts first in the text).
func notionAsides(md string) string {
return notionAside.ReplaceAllStringFunc(md, func(block string) string {
body := strings.TrimSpace(notionAside.FindStringSubmatch(block)[1])
lines := []string{"> [!NOTE]"}
for _, l := range strings.Split(body, "\n") {
lines = append(lines, strings.TrimRight("> "+l, " "))
}
return strings.Join(lines, "\n")
})
}
// utf8BOM starts some exported text files.
const utf8BOM = "\xef\xbb\xbf"
+137 -11
View File
@@ -89,12 +89,14 @@ func PDF(title string, doc Node, o PDFOptions) (out []byte, err error) {
// Layout, in millimetres and points.
const (
pdfMargin = 20.0
pdfGap = 3.0 // after a block
pdfTightGap = 1.2 // after a block in a list item
pdfBody = 11.0
pdfLine = 5.6
pdfIndent = 6.0
pdfMargin = 20.0
pdfGap = 3.0 // after a block
pdfTightGap = 1.2 // after a block in a list item
pdfBody = 11.0
pdfLine = 5.6
pdfIndent = 6.0
pdfTaskIndent = 8.0
pdfCellPad = 1.6
)
type pdfWriter struct {
@@ -155,18 +157,80 @@ func (w *pdfWriter) heading(text string, level int, size float64) {
w.f.Ln(pdfGap)
}
var pdfHeadingSize = map[int]float64{1: 18, 2: 15, 3: 13}
var pdfHeadingSize = map[int]float64{1: 18, 2: 15, 3: 13, 4: 12, 5: 11, 6: 10}
func (w *pdfWriter) block(n Node, indent, gap float64) {
switch n.Type {
case "paragraph":
w.at(indent)
w.inline(n.Content, "", pdfBody)
w.f.Ln(pdfLine)
if a := alignOf(n); a != "" {
// fpdf aligns whole cells only, so aligned text loses its inline formatting.
w.f.SetFont("go", "", pdfBody)
w.ink()
w.f.MultiCell(w.width-indent, pdfLine, pdfText(PlainText(n)), "", strings.ToUpper(a[:1]), false)
} else {
w.inline(n.Content, "", pdfBody)
w.f.Ln(pdfLine)
}
w.f.Ln(gap)
case "heading":
level := min(max(n.intAttr("level", 1), 1), 3)
level := min(max(n.intAttr("level", 1), 1), 6)
w.heading(PlainText(n), level, pdfHeadingSize[level])
case "taskList":
for i, item := range n.Content {
marker := "[ ]"
if item.Attrs["checked"] == true {
marker = "[x]"
}
w.room(pdfLine)
w.at(indent)
w.f.SetFont("mono", "", pdfBody-1)
w.ink()
w.f.CellFormat(pdfTaskIndent, pdfLine, marker, "", 0, "L", false, 0, "")
for j, c := range item.Content {
g := pdfTightGap
if j == len(item.Content)-1 && i == len(n.Content)-1 {
g = gap
}
if j == 0 && c.Type == "paragraph" {
w.f.SetLeftMargin(pdfMargin + indent + pdfTaskIndent)
w.inline(c.Content, "", pdfBody)
w.f.Ln(pdfLine)
w.f.Ln(g)
continue
}
if j == 0 {
w.f.Ln(pdfLine)
}
w.block(c, indent+pdfTaskIndent, g)
}
if len(item.Content) == 0 {
w.f.Ln(pdfLine)
}
}
case "callout":
// A quote-like bar in the callout's colour; the Go fonts have no emoji.
_, color := calloutParts(n)
page, top := w.f.PageNo(), w.f.GetY()
for i, c := range n.Content {
g := pdfTightGap
if i == len(n.Content)-1 {
g = 0
}
w.block(c, indent+pdfIndent, g)
}
if w.f.PageNo() != page {
top = pdfMargin
}
r, g, b := rgb(paletteText[color])
w.f.SetDrawColor(r, g, b)
w.f.SetLineWidth(1.2)
x := pdfMargin + indent + 1.5
w.f.Line(x, top, x, w.f.GetY())
w.f.Ln(gap)
case "table":
w.table(n, indent)
w.f.Ln(gap)
case "bulletList", "orderedList":
start := n.intAttr("start", 1)
for i, item := range n.Content {
@@ -287,9 +351,11 @@ func (w *pdfWriter) inline(nodes []Node, style string, size float64) {
for _, n := range nodes {
switch n.Type {
case "text":
family, st, href := "go", style, ""
family, st, href, color := "go", style, "", ""
for _, m := range n.Marks {
switch m.Type {
case "textColor":
color = paletteText[m.attr("color")]
case "bold":
st += "B"
case "italic":
@@ -317,6 +383,9 @@ func (w *pdfWriter) inline(nodes []Node, style string, size float64) {
w.f.WriteLinkString(pdfLine, pdfText(n.Text), href)
} else {
w.ink()
if color != "" {
w.f.SetTextColor(rgb(color))
}
w.f.Write(pdfLine, pdfText(n.Text))
}
case "hardBreak":
@@ -361,6 +430,63 @@ func pdfStyle(s string) string {
return out
}
// table draws a grid with each cell's text wrapped in its column; columns
// share the width evenly, and header cells are bold on a grey fill. A row
// that does not fit on the page starts a new one.
func (w *pdfWriter) table(n Node, indent float64) {
cols := 0
for _, row := range n.Content {
cols = max(cols, len(row.Content))
}
if cols == 0 {
return
}
colW := (w.width - indent) / float64(cols)
const lineH = 4.8
for _, row := range n.Content {
texts := make([][]string, cols)
lines := 1
for i, cell := range row.Content {
var parts []string
for _, b := range cell.Content {
if t := strings.TrimSpace(PlainText(b)); t != "" {
parts = append(parts, t)
}
}
style := ""
if cell.Type == "tableHeader" {
style = "B"
}
w.f.SetFont("go", style, pdfBody-1)
texts[i] = w.f.SplitText(pdfText(strings.Join(parts, "\n")), colW-2*pdfCellPad)
lines = max(lines, len(texts[i]))
}
h := float64(lines)*lineH + 2*pdfCellPad
w.room(h)
y := w.f.GetY()
for i := range cols {
x := pdfMargin + indent + float64(i)*colW
header := i < len(row.Content) && row.Content[i].Type == "tableHeader"
w.f.SetDrawColor(200, 200, 200)
w.f.SetLineWidth(0.2)
if header {
w.f.SetFillColor(244, 244, 241)
w.f.Rect(x, y, colW, h, "FD")
w.f.SetFont("go", "B", pdfBody-1)
} else {
w.f.Rect(x, y, colW, h, "D")
w.f.SetFont("go", "", pdfBody-1)
}
w.ink()
for j, line := range texts[i] {
w.f.SetXY(x+pdfCellPad, y+pdfCellPad+float64(j)*lineH)
w.f.CellFormat(colW-2*pdfCellPad, lineH, line, "", 0, "L", false, 0, "")
}
}
w.f.SetXY(pdfMargin+indent, y+h)
}
}
func (w *pdfWriter) code(text string, indent float64, label string) {
w.at(indent)
if label != "" {
+2 -2
View File
@@ -117,7 +117,7 @@ func TestFromDOCX(t *testing.T) {
"> Said someone",
"```\nx := 1\ny := 2\n```",
"![A chart](asset:0)",
"Name · Role\n\nAda · Lead",
"| Name | Role |\n| --- | --- |\n| Ada | Lead |",
"Zażółć gęślą jaźń",
} {
if !strings.Contains(md, want) {
@@ -183,7 +183,7 @@ func TestReadNotion(t *testing.T) {
if j := asJSON(t, pages[child].Doc); !strings.Contains(j, `"href":"`+PageRef(root)+`"`) {
t.Errorf("child = %s", j)
}
if md := Markdown(pages[db].Doc, Options{}); !strings.Contains(md, "**Name** · **Status**\n\nShip it · Done") {
if md := Markdown(pages[db].Doc, Options{}); !strings.Contains(md, "| Name | Status |\n| --- | --- |\n| Ship it | Done |") {
t.Errorf("database = %s", md)
}
if md := Markdown(pages[row].Doc, Options{}); !strings.Contains(md, "Row body\n\n![](https://example.test/i.png)") {
@@ -1,122 +1,63 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type { EditorLabels, MentionHost, PageHost } from "@docwell/editor";
import { englishLabels, type EditorLabels, type MentionHost, type PageHost } from "@docwell/editor";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useApi } from "../api";
import { useAuthStore } from "../stores/auth";
import { useSpacesStore } from "../stores/spaces";
const blocks = [
"text",
"h1",
"h2",
"h3",
"bullet",
"ordered",
"quote",
"code",
"divider",
"image",
"file",
"toc",
"math",
"mathInline",
"mermaid",
"drawio",
"excalidraw",
"pageLink",
"toggle",
"embed",
"linkCard",
];
const blockWords = [
"edit",
"done",
"cancel",
"save",
"remove",
"saving",
"latex",
"mermaid",
"mermaidError",
"emptyDrawio",
"emptyExcalidraw",
"loadFailed",
"toc",
"tocEmpty",
"expand",
"collapse",
"embed",
"embedUrl",
"embedInvalid",
"linkUrl",
"copyBlockLink",
] as const;
const findWords = [
"find",
"replace",
"previous",
"next",
"replaceOne",
"replaceAll",
"matchCase",
"close",
"count",
"none",
] as const;
const dateWords = [
"today",
"tomorrow",
"yesterday",
"nextWeek",
"remindWord",
"remindMe",
"reminderAt",
"someoneElse",
"edit",
] as const;
/** Groups of editor words, each looked up as editor.<group>.<word>; the words are the English labels' keys. */
const words = <K extends keyof EditorLabels>(group: K) => Object.keys(englishLabels[group] as object);
/** The editor's menu and button words in the app's language. */
export function useEditorLabels() {
const { t, locale } = useI18n();
// Placeholders the editor fills in itself pass through as they are.
const keep = { current: "{current}", total: "{total}", n: "{n}" };
const group = <K extends keyof EditorLabels>(name: K, prefix: string) =>
Object.fromEntries(words(name).map((w) => [w, t(`editor.${prefix}.${w}`, keep)])) as EditorLabels[K];
return computed<EditorLabels>(() => ({
locale: locale.value,
slashMenu: t("editor.slashMenu"),
noMatches: t("editor.noMatches"),
slash: Object.fromEntries(
blocks.map((b) => [
words("slash").map((b) => [
b,
{ label: t(`editor.blocks.${b}.label`), description: t(`editor.blocks.${b}.description`) },
]),
),
format: {
bold: t("editor.format.bold"),
italic: t("editor.format.italic"),
strike: t("editor.format.strike"),
code: t("editor.format.code"),
link: t("editor.format.link"),
linkPrompt: t("editor.format.linkPrompt"),
comment: t("editor.format.comment"),
},
format: group("format", "format"),
colors: group("colors", "colors"),
table: group("table", "table"),
blockMenu: group("blockMenu", "blockMenu"),
mentions: t("editor.mentions"),
noPeople: t("editor.noPeople"),
pageLinks: t("editor.pageLinks"),
noPages: t("editor.noPages"),
blocks: Object.fromEntries(blockWords.map((w) => [w, t(`editor.block.${w}`)])) as EditorLabels["blocks"],
// The editor fills in {current} and {total} itself, so they pass through.
find: Object.fromEntries(
findWords.map((w) => [w, t(`editor.find.${w}`, { current: "{current}", total: "{total}" })]),
) as EditorLabels["find"],
dates: Object.fromEntries(dateWords.map((w) => [w, t(`editor.dates.${w}`)])) as EditorLabels["dates"],
blocks: group("blocks", "block"),
find: group("find", "find"),
dates: group("dates", "dates"),
}));
}
/** "[[" page links find pages in the page's workspace through search. */
export function usePageLinks(workspace: () => string | undefined): PageHost {
/**
* "[[" page links find pages in the page's workspace through search. With
* parent, the editor can also make new pages, as children of that page.
*/
export function usePageLinks(
workspace: () => string | undefined,
parent?: () => { space: string; id: string } | undefined,
): PageHost {
const api = useApi();
const spaces = useSpacesStore();
return {
async create(title) {
const at = parent?.();
if (!at) throw new Error("no page to add the new page to");
const page = await spaces.createPage(at.space, at.id, title || undefined);
return { id: page.id, title: page.title, icon: page.icon };
},
async search(query) {
const ws = workspace();
if (!ws || !query.trim()) return [];
+101 -2
View File
@@ -495,6 +495,50 @@
"linkCard": {
"label": "Linkkarte",
"description": "Ein Link mit Titel und Bild seiner Seite"
},
"h4": {
"label": "Überschrift 4",
"description": "Weitere Überschriften: Ebene 4"
},
"h5": {
"label": "Überschrift 5",
"description": "Weitere Überschriften: Ebene 5"
},
"h6": {
"label": "Überschrift 6",
"description": "Weitere Überschriften: Ebene 6"
},
"todo": {
"label": "Aufgabenliste",
"description": "Aufgaben zum Abhaken (oder [] tippen)"
},
"callout": {
"label": "Hinweisbox",
"description": "Eine Notiz mit Emoji und Farbe hervorheben"
},
"table": {
"label": "Tabelle",
"description": "Zeilen und Spalten"
},
"newPage": {
"label": "Neue Seite",
"description": "Eine Seite anlegen und hier verlinken"
},
"today": {
"label": "Heute",
"description": "Das heutige Datum einfügen"
},
"tomorrow": {
"label": "Morgen",
"description": "Das morgige Datum einfügen"
},
"yesterday": {
"label": "Gestern",
"description": "Das gestrige Datum einfügen"
},
"now": {
"label": "Jetzt",
"description": "Datum und Uhrzeit einfügen"
}
},
"format": {
@@ -504,7 +548,18 @@
"code": "Code im Text",
"link": "Link",
"linkPrompt": "Linkadresse (leer lassen, um den Link zu entfernen)",
"comment": "Kommentieren"
"comment": "Kommentieren",
"underline": "Unterstrichen",
"color": "Farbe",
"textColor": "Textfarbe",
"highlight": "Markierung",
"noColor": "Standard",
"align": "Ausrichtung",
"alignLeft": "Linksbündig",
"alignCenter": "Zentriert",
"alignRight": "Rechtsbündig",
"math": "Formel im Text",
"linkedPage": "Verknüpfte Seite anlegen"
},
"pageLinks": "Link zu einer Seite",
"noPages": "Keine Seiten gefunden – tippe einen Teil eines Titels",
@@ -529,7 +584,51 @@
"embedUrl": "Adresse des Videos, Designs oder Dokuments",
"embedInvalid": "Diese Adresse kann nicht eingebettet werden.",
"linkUrl": "Adresse der zu verlinkenden Seite",
"copyBlockLink": "Link zu diesem Block kopieren"
"copyBlockLink": "Link zu diesem Block kopieren",
"calloutEmoji": "Emoji ändern",
"calloutColor": "Farbe ändern",
"pdfLoading": "PDF wird geladen…",
"pdfPage": "Seite {n}"
},
"colors": {
"gray": "Grau",
"red": "Rot",
"orange": "Orange",
"yellow": "Gelb",
"green": "Grün",
"teal": "Petrol",
"blue": "Blau",
"purple": "Lila",
"pink": "Pink"
},
"table": {
"toolbar": "Tabelle",
"dragRow": "Ziehen, um die Zeile zu verschieben",
"moveRowUp": "Zeile nach oben",
"moveRowDown": "Zeile nach unten",
"addRowBefore": "Zeile darüber",
"addRowAfter": "Zeile darunter",
"addColumnBefore": "Spalte links",
"addColumnAfter": "Spalte rechts",
"deleteRow": "Zeile löschen",
"deleteColumn": "Spalte löschen",
"toggleHeaderRow": "Kopfzeile",
"mergeCells": "Zellen verbinden",
"splitCell": "Zelle teilen",
"deleteTable": "Tabelle löschen"
},
"blockMenu": {
"open": "Ziehen zum Verschieben, klicken für Aktionen",
"turnInto": "Umwandeln in",
"moveUp": "Nach oben",
"moveDown": "Nach unten",
"duplicate": "Duplizieren",
"copy": "Kopieren",
"delete": "Löschen",
"showLineNumbers": "Zeilennummern zeigen",
"hideLineNumbers": "Zeilennummern ausblenden",
"showPages": "Seiten zeigen",
"showAsFile": "Als Datei zeigen"
}
},
"comments": {
+101 -2
View File
@@ -495,6 +495,50 @@
"linkCard": {
"label": "Link card",
"description": "A link with its page's title and picture"
},
"h4": {
"label": "Heading 4",
"description": "Other headings: level 4"
},
"h5": {
"label": "Heading 5",
"description": "Other headings: level 5"
},
"h6": {
"label": "Heading 6",
"description": "Other headings: level 6"
},
"todo": {
"label": "To-do list",
"description": "Tasks to tick off (or type [])"
},
"callout": {
"label": "Callout",
"description": "Set a note apart with an emoji and colour"
},
"table": {
"label": "Table",
"description": "Rows and columns"
},
"newPage": {
"label": "New page",
"description": "Make a page and link it here"
},
"today": {
"label": "Today",
"description": "Insert today's date"
},
"tomorrow": {
"label": "Tomorrow",
"description": "Insert tomorrow's date"
},
"yesterday": {
"label": "Yesterday",
"description": "Insert yesterday's date"
},
"now": {
"label": "Now",
"description": "Insert the date and time"
}
},
"format": {
@@ -504,7 +548,18 @@
"code": "Inline code",
"link": "Link",
"linkPrompt": "Link address (leave empty to remove the link)",
"comment": "Comment"
"comment": "Comment",
"underline": "Underline",
"color": "Colour",
"textColor": "Text colour",
"highlight": "Highlight",
"noColor": "Default",
"align": "Align",
"alignLeft": "Align left",
"alignCenter": "Align centre",
"alignRight": "Align right",
"math": "Inline math",
"linkedPage": "Make a linked page"
},
"pageLinks": "Link to a page",
"noPages": "No pages found — type part of a title",
@@ -529,7 +584,51 @@
"embedUrl": "Address of the video, design or document",
"embedInvalid": "This address can't be embedded.",
"linkUrl": "Address of the page to link",
"copyBlockLink": "Copy link to this block"
"copyBlockLink": "Copy link to this block",
"calloutEmoji": "Change emoji",
"calloutColor": "Change colour",
"pdfLoading": "Loading PDF…",
"pdfPage": "Page {n}"
},
"colors": {
"gray": "Grey",
"red": "Red",
"orange": "Orange",
"yellow": "Yellow",
"green": "Green",
"teal": "Teal",
"blue": "Blue",
"purple": "Purple",
"pink": "Pink"
},
"table": {
"toolbar": "Table",
"dragRow": "Drag to move the row",
"moveRowUp": "Move row up",
"moveRowDown": "Move row down",
"addRowBefore": "Add row above",
"addRowAfter": "Add row below",
"addColumnBefore": "Add column left",
"addColumnAfter": "Add column right",
"deleteRow": "Delete row",
"deleteColumn": "Delete column",
"toggleHeaderRow": "Header row",
"mergeCells": "Merge cells",
"splitCell": "Split cell",
"deleteTable": "Delete table"
},
"blockMenu": {
"open": "Drag to move, click for actions",
"turnInto": "Turn into",
"moveUp": "Move up",
"moveDown": "Move down",
"duplicate": "Duplicate",
"copy": "Copy",
"delete": "Delete",
"showLineNumbers": "Show line numbers",
"hideLineNumbers": "Hide line numbers",
"showPages": "Show pages",
"showAsFile": "Show as file"
}
},
"comments": {
+101 -2
View File
@@ -495,6 +495,50 @@
"linkCard": {
"label": "Tarjeta de enlace",
"description": "Un enlace con el título y la imagen de su página"
},
"h4": {
"label": "Encabezado 4",
"description": "Otros encabezados: nivel 4"
},
"h5": {
"label": "Encabezado 5",
"description": "Otros encabezados: nivel 5"
},
"h6": {
"label": "Encabezado 6",
"description": "Otros encabezados: nivel 6"
},
"todo": {
"label": "Lista de tareas",
"description": "Tareas para marcar (o escribe [])"
},
"callout": {
"label": "Destacado",
"description": "Resaltar una nota con un emoji y un color"
},
"table": {
"label": "Tabla",
"description": "Filas y columnas"
},
"newPage": {
"label": "Página nueva",
"description": "Crear una página y enlazarla aquí"
},
"today": {
"label": "Hoy",
"description": "Insertar la fecha de hoy"
},
"tomorrow": {
"label": "Mañana",
"description": "Insertar la fecha de mañana"
},
"yesterday": {
"label": "Ayer",
"description": "Insertar la fecha de ayer"
},
"now": {
"label": "Ahora",
"description": "Insertar la fecha y la hora"
}
},
"format": {
@@ -504,7 +548,18 @@
"code": "Código en línea",
"link": "Enlace",
"linkPrompt": "Dirección del enlace (déjala vacía para quitar el enlace)",
"comment": "Comentar"
"comment": "Comentar",
"underline": "Subrayado",
"color": "Color",
"textColor": "Color del texto",
"highlight": "Resaltado",
"noColor": "Predeterminado",
"align": "Alineación",
"alignLeft": "Alinear a la izquierda",
"alignCenter": "Centrar",
"alignRight": "Alinear a la derecha",
"math": "Fórmula en el texto",
"linkedPage": "Crear una página enlazada"
},
"pageLinks": "Enlace a una página",
"noPages": "No se encontraron páginas: escribe parte de un título",
@@ -529,7 +584,51 @@
"embedUrl": "Dirección del vídeo, diseño o documento",
"embedInvalid": "Esta dirección no se puede insertar.",
"linkUrl": "Dirección de la página que enlazar",
"copyBlockLink": "Copiar enlace a este bloque"
"copyBlockLink": "Copiar enlace a este bloque",
"calloutEmoji": "Cambiar emoji",
"calloutColor": "Cambiar color",
"pdfLoading": "Cargando PDF…",
"pdfPage": "Página {n}"
},
"colors": {
"gray": "Gris",
"red": "Rojo",
"orange": "Naranja",
"yellow": "Amarillo",
"green": "Verde",
"teal": "Verde azulado",
"blue": "Azul",
"purple": "Morado",
"pink": "Rosa"
},
"table": {
"toolbar": "Tabla",
"dragRow": "Arrastra para mover la fila",
"moveRowUp": "Subir fila",
"moveRowDown": "Bajar fila",
"addRowBefore": "Fila encima",
"addRowAfter": "Fila debajo",
"addColumnBefore": "Columna a la izquierda",
"addColumnAfter": "Columna a la derecha",
"deleteRow": "Eliminar fila",
"deleteColumn": "Eliminar columna",
"toggleHeaderRow": "Fila de encabezado",
"mergeCells": "Combinar celdas",
"splitCell": "Dividir celda",
"deleteTable": "Eliminar tabla"
},
"blockMenu": {
"open": "Arrastra para mover, haz clic para ver acciones",
"turnInto": "Convertir en",
"moveUp": "Subir",
"moveDown": "Bajar",
"duplicate": "Duplicar",
"copy": "Copiar",
"delete": "Eliminar",
"showLineNumbers": "Mostrar números de línea",
"hideLineNumbers": "Ocultar números de línea",
"showPages": "Mostrar páginas",
"showAsFile": "Mostrar como archivo"
}
},
"comments": {
+101 -2
View File
@@ -495,6 +495,50 @@
"linkCard": {
"label": "Carte de lien",
"description": "Un lien avec le titre et l’image de sa page"
},
"h4": {
"label": "Titre 4",
"description": "Autres titres : niveau 4"
},
"h5": {
"label": "Titre 5",
"description": "Autres titres : niveau 5"
},
"h6": {
"label": "Titre 6",
"description": "Autres titres : niveau 6"
},
"todo": {
"label": "Liste de tâches",
"description": "Des tâches à cocher (ou tapez [])"
},
"callout": {
"label": "Encadré",
"description": "Mettre une note en valeur avec un emoji et une couleur"
},
"table": {
"label": "Tableau",
"description": "Lignes et colonnes"
},
"newPage": {
"label": "Nouvelle page",
"description": "Créer une page et la lier ici"
},
"today": {
"label": "Aujourd'hui",
"description": "Insérer la date du jour"
},
"tomorrow": {
"label": "Demain",
"description": "Insérer la date de demain"
},
"yesterday": {
"label": "Hier",
"description": "Insérer la date d'hier"
},
"now": {
"label": "Maintenant",
"description": "Insérer la date et l'heure"
}
},
"format": {
@@ -504,7 +548,18 @@
"code": "Code en ligne",
"link": "Lien",
"linkPrompt": "Adresse du lien (laissez vide pour supprimer le lien)",
"comment": "Commenter"
"comment": "Commenter",
"underline": "Souligné",
"color": "Couleur",
"textColor": "Couleur du texte",
"highlight": "Surlignage",
"noColor": "Par défaut",
"align": "Alignement",
"alignLeft": "Aligner à gauche",
"alignCenter": "Centrer",
"alignRight": "Aligner à droite",
"math": "Formule dans le texte",
"linkedPage": "Créer une page liée"
},
"pageLinks": "Lien vers une page",
"noPages": "Aucune page trouvée — tapez une partie d’un titre",
@@ -529,7 +584,51 @@
"embedUrl": "Adresse de la vidéo, du design ou du document",
"embedInvalid": "Cette adresse ne peut pas être intégrée.",
"linkUrl": "Adresse de la page à lier",
"copyBlockLink": "Copier le lien vers ce bloc"
"copyBlockLink": "Copier le lien vers ce bloc",
"calloutEmoji": "Changer l'emoji",
"calloutColor": "Changer la couleur",
"pdfLoading": "Chargement du PDF…",
"pdfPage": "Page {n}"
},
"colors": {
"gray": "Gris",
"red": "Rouge",
"orange": "Orange",
"yellow": "Jaune",
"green": "Vert",
"teal": "Bleu canard",
"blue": "Bleu",
"purple": "Violet",
"pink": "Rose"
},
"table": {
"toolbar": "Tableau",
"dragRow": "Glisser pour déplacer la ligne",
"moveRowUp": "Monter la ligne",
"moveRowDown": "Descendre la ligne",
"addRowBefore": "Ligne au-dessus",
"addRowAfter": "Ligne en dessous",
"addColumnBefore": "Colonne à gauche",
"addColumnAfter": "Colonne à droite",
"deleteRow": "Supprimer la ligne",
"deleteColumn": "Supprimer la colonne",
"toggleHeaderRow": "Ligne d'en-tête",
"mergeCells": "Fusionner les cellules",
"splitCell": "Scinder la cellule",
"deleteTable": "Supprimer le tableau"
},
"blockMenu": {
"open": "Glisser pour déplacer, cliquer pour les actions",
"turnInto": "Transformer en",
"moveUp": "Monter",
"moveDown": "Descendre",
"duplicate": "Dupliquer",
"copy": "Copier",
"delete": "Supprimer",
"showLineNumbers": "Afficher les numéros de ligne",
"hideLineNumbers": "Masquer les numéros de ligne",
"showPages": "Afficher les pages",
"showAsFile": "Afficher comme fichier"
}
},
"comments": {
+101 -2
View File
@@ -495,6 +495,50 @@
"linkCard": {
"label": "Karta linku",
"description": "Link z tytułem i obrazkiem strony"
},
"h4": {
"label": "Nagłówek 4",
"description": "Inne nagłówki: poziom 4"
},
"h5": {
"label": "Nagłówek 5",
"description": "Inne nagłówki: poziom 5"
},
"h6": {
"label": "Nagłówek 6",
"description": "Inne nagłówki: poziom 6"
},
"todo": {
"label": "Lista zadań",
"description": "Zadania do odhaczenia (lub wpisz [])"
},
"callout": {
"label": "Wyróżnienie",
"description": "Notatka z emoji i kolorem tła"
},
"table": {
"label": "Tabela",
"description": "Wiersze i kolumny"
},
"newPage": {
"label": "Nowa strona",
"description": "Utwórz stronę i wstaw do niej link"
},
"today": {
"label": "Dzisiaj",
"description": "Wstaw dzisiejszą datę"
},
"tomorrow": {
"label": "Jutro",
"description": "Wstaw jutrzejszą datę"
},
"yesterday": {
"label": "Wczoraj",
"description": "Wstaw wczorajszą datę"
},
"now": {
"label": "Teraz",
"description": "Wstaw datę i godzinę"
}
},
"format": {
@@ -504,7 +548,18 @@
"code": "Kod w tekście",
"link": "Link",
"linkPrompt": "Adres linku (zostaw puste, aby usunąć link)",
"comment": "Komentarz"
"comment": "Komentarz",
"underline": "Podkreślenie",
"color": "Kolor",
"textColor": "Kolor tekstu",
"highlight": "Wyróżnienie",
"noColor": "Domyślny",
"align": "Wyrównanie",
"alignLeft": "Do lewej",
"alignCenter": "Do środka",
"alignRight": "Do prawej",
"math": "Wzór w tekście",
"linkedPage": "Utwórz połączoną stronę"
},
"pageLinks": "Link do strony",
"noPages": "Nie znaleziono stron — wpisz fragment tytułu",
@@ -529,7 +584,51 @@
"embedUrl": "Adres filmu, projektu lub dokumentu",
"embedInvalid": "Tego adresu nie da się osadzić.",
"linkUrl": "Adres strony do podlinkowania",
"copyBlockLink": "Kopiuj link do tego bloku"
"copyBlockLink": "Kopiuj link do tego bloku",
"calloutEmoji": "Zmień emoji",
"calloutColor": "Zmień kolor",
"pdfLoading": "Wczytywanie PDF…",
"pdfPage": "Strona {n}"
},
"colors": {
"gray": "Szary",
"red": "Czerwony",
"orange": "Pomarańczowy",
"yellow": "Żółty",
"green": "Zielony",
"teal": "Morski",
"blue": "Niebieski",
"purple": "Fioletowy",
"pink": "Różowy"
},
"table": {
"toolbar": "Tabela",
"dragRow": "Przeciągnij, aby przenieść wiersz",
"moveRowUp": "Wiersz wyżej",
"moveRowDown": "Wiersz niżej",
"addRowBefore": "Wiersz powyżej",
"addRowAfter": "Wiersz poniżej",
"addColumnBefore": "Kolumna z lewej",
"addColumnAfter": "Kolumna z prawej",
"deleteRow": "Usuń wiersz",
"deleteColumn": "Usuń kolumnę",
"toggleHeaderRow": "Wiersz nagłówka",
"mergeCells": "Scal komórki",
"splitCell": "Podziel komórkę",
"deleteTable": "Usuń tabelę"
},
"blockMenu": {
"open": "Przeciągnij, aby przenieść, kliknij, aby zobaczyć akcje",
"turnInto": "Zmień na",
"moveUp": "Przenieś wyżej",
"moveDown": "Przenieś niżej",
"duplicate": "Duplikuj",
"copy": "Kopiuj",
"delete": "Usuń",
"showLineNumbers": "Pokaż numery wierszy",
"hideLineNumbers": "Ukryj numery wierszy",
"showPages": "Pokaż strony",
"showAsFile": "Pokaż jako plik"
}
},
"comments": {
+2 -2
View File
@@ -100,8 +100,8 @@ export const useSpacesStore = defineStore("spaces", () => {
for (let p = parentOf.get(pageId); p; p = parentOf.get(p)) setExpanded(p, true);
}
async function createPage(spaceId: string, parent = "") {
const page = await api.spaces.createPage(spaceId, { parent });
async function createPage(spaceId: string, parent = "", title?: string) {
const page = await api.spaces.createPage(spaceId, title ? { parent, title } : { parent });
if (parent) setExpanded(parent, true);
await loadTree(spaceId);
return page;
+4 -1
View File
@@ -53,7 +53,10 @@ const historyOpen = ref(false);
const shareOpen = ref(false);
const labels = useEditorLabels();
const mentions = useMentions(() => page.value?.workspace);
const pageLinks = usePageLinks(() => page.value?.workspace);
const pageLinks = usePageLinks(
() => page.value?.workspace,
() => (page.value && editable.value ? { space: page.value.space, id: page.value.id } : undefined),
);
// Link cards: docwell-server reads the linked page's title and picture.
const linkHost = { preview: (url: string) => api.pages.preview(url) };
+323
View File
@@ -1457,6 +1457,271 @@
"langium": "3.3.1"
}
},
"node_modules/@napi-rs/canvas": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-0.1.100.tgz",
"integrity": "sha512-xglYA6q3XO5P3BNJYxVZ1IV7DLVjp1Py6nwag88YntrS+3vKHyYcMqXVS4ZztJmwz2uGvz1FWhI/4LgbR5uQDA==",
"license": "MIT",
"optional": true,
"workspaces": [
"e2e/*"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"optionalDependencies": {
"@napi-rs/canvas-android-arm64": "0.1.100",
"@napi-rs/canvas-darwin-arm64": "0.1.100",
"@napi-rs/canvas-darwin-x64": "0.1.100",
"@napi-rs/canvas-linux-arm-gnueabihf": "0.1.100",
"@napi-rs/canvas-linux-arm64-gnu": "0.1.100",
"@napi-rs/canvas-linux-arm64-musl": "0.1.100",
"@napi-rs/canvas-linux-riscv64-gnu": "0.1.100",
"@napi-rs/canvas-linux-x64-gnu": "0.1.100",
"@napi-rs/canvas-linux-x64-musl": "0.1.100",
"@napi-rs/canvas-win32-arm64-msvc": "0.1.100",
"@napi-rs/canvas-win32-x64-msvc": "0.1.100"
}
},
"node_modules/@napi-rs/canvas-android-arm64": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-0.1.100.tgz",
"integrity": "sha512-hjhCKhntPv9+t4ckHymdx0phYNcVW+GKQR6Lzw2zE+pOVjOplSmtx9nNNknTjbEDLcuLZqA1y8ufKg1XfgftzQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-darwin-arm64": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-0.1.100.tgz",
"integrity": "sha512-2PcswRaC7Ly645DGt88///zuFDhJxJYdKAs1uU3mfk1atYkXufgcgLfBpk6Tm12nCQBaNt1wpybuPZ4qOhTo8A==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-darwin-x64": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-0.1.100.tgz",
"integrity": "sha512-ePNZtj7pNIva/siZMg+HmbeozkIjqUIYdoymH8HaA3qK7LfzFN4WMBM8G6HQ9ZC+H3+Dnn5pqtiXpgLykaPOhw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm-gnueabihf": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-0.1.100.tgz",
"integrity": "sha512-d5cDB48oWFGU8/XPhUOFAlySgb/VAu7D+s8fi55K1Pcfg8aPplHWqMgibhVLU8ky7Pyg/fuiVLz4Nf3JrSTuUA==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm64-gnu": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-0.1.100.tgz",
"integrity": "sha512-rDxgxRu69RvDlX/bh9o22DxLsGr8EqsNgotL9+RwQE1S0b0cqeatqsw6aW45mukm0B42DIAaAacKaYQ8cqS1nw==",
"cpu": [
"arm64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm64-musl": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-0.1.100.tgz",
"integrity": "sha512-K3mDW66N+xT2/V439u1alFANiBUjdEx2gLiNYnCmUsva5jZMxWTjafBYwTzYK+EMFMHrUoabuU+T1BIP5CgbYQ==",
"cpu": [
"arm64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-riscv64-gnu": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-0.1.100.tgz",
"integrity": "sha512-mooqUBTIsccZpnoQC4NgrC1v6C1vof39etLNMnBwCY+p0gajWJvAHLGQ6g/gGyS5YrpDW+GefSN4+Cvcr08UWw==",
"cpu": [
"riscv64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-x64-gnu": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-0.1.100.tgz",
"integrity": "sha512-1eCvkDCazm7FFhsT7DfGOdSaHgZVK3bt/dSBl5EWHOWmnz+I7j8tPseJqqD81NF+MH21jKUK4wQSDjN0mdhnTg==",
"cpu": [
"x64"
],
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-x64-musl": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-0.1.100.tgz",
"integrity": "sha512-20arT6lnI19S68qNlii73TSEDbECNgzMz2EpldC1V3mZFuRkeujXkcebRk0LRJe9SEUAooYiLokfMViY8IX7yA==",
"cpu": [
"x64"
],
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-win32-arm64-msvc": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-arm64-msvc/-/canvas-win32-arm64-msvc-0.1.100.tgz",
"integrity": "sha512-DZFFT1wIAg37LJw37yhMRFfjATd3vTQzjZ1Yki8u2vhO6Hi5VE6BVaGQ1aaDu7xb4iMErz+9EOwjpS7xcxFeBw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-win32-x64-msvc": {
"version": "0.1.100",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-0.1.100.tgz",
"integrity": "sha512-MyT1j3mHC2+Lu4pBi9mKyMJhtP6U7k7EldY7sj/uS5gJA65gTXt8MefJQXLJo5d/vZbuWmfxzkEUNc/urV3pHA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/lzma-linux-x64-gnu": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz",
@@ -3573,6 +3838,19 @@
"@tiptap/core": "3.32.2"
}
},
"node_modules/@tiptap/extension-highlight": {
"version": "3.32.2",
"resolved": "https://registry.npmjs.org/@tiptap/extension-highlight/-/extension-highlight-3.32.2.tgz",
"integrity": "sha512-tgoIFlGNgVpmGhHOFHktMsl/EdERHMQ/yLEgWdoCfACsPDJt6aTG3mzkn15tbcRBH5LXA1qDrJuplu2jxD0dPg==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
"@tiptap/core": "3.32.2"
}
},
"node_modules/@tiptap/extension-horizontal-rule": {
"version": "3.32.2",
"resolved": "https://registry.npmjs.org/@tiptap/extension-horizontal-rule/-/extension-horizontal-rule-3.32.2.tgz",
@@ -3739,6 +4017,20 @@
"@tiptap/core": "3.32.2"
}
},
"node_modules/@tiptap/extension-table": {
"version": "3.32.2",
"resolved": "https://registry.npmjs.org/@tiptap/extension-table/-/extension-table-3.32.2.tgz",
"integrity": "sha512-CIFQaKOwdNFPaApymZRNhAnpGpl3Y53V1sqTgQV9FtI4qi6H3mAR032GtasUzo7DpBaOHpNNbMgph0yyVCJF9g==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
"@tiptap/core": "3.32.2",
"@tiptap/pm": "3.32.2"
}
},
"node_modules/@tiptap/extension-text": {
"version": "3.32.2",
"resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-3.32.2.tgz",
@@ -3752,6 +4044,19 @@
"@tiptap/core": "3.32.2"
}
},
"node_modules/@tiptap/extension-text-align": {
"version": "3.32.2",
"resolved": "https://registry.npmjs.org/@tiptap/extension-text-align/-/extension-text-align-3.32.2.tgz",
"integrity": "sha512-o1DKPodB0FKqpdYp/OKyM6nYSbZXnPEC9rWx/O/Vccs2OOeF08iOO3cKYs1lS/qNg/xFeR8gKxGMrve7CfCkKA==",
"license": "MIT",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/ueberdosis"
},
"peerDependencies": {
"@tiptap/core": "3.32.2"
}
},
"node_modules/@tiptap/extension-text-style": {
"version": "3.32.2",
"resolved": "https://registry.npmjs.org/@tiptap/extension-text-style/-/extension-text-style-3.32.2.tgz",
@@ -8280,6 +8585,18 @@
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
"license": "MIT"
},
"node_modules/pdfjs-dist": {
"version": "5.4.149",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-5.4.149.tgz",
"integrity": "sha512-Xe8/1FMJEQPUVSti25AlDpwpUm2QAVmNOpFP0SIahaPIOKBKICaefbzogLdwey3XGGoaP4Lb9wqiw2e9Jqp0LA==",
"license": "Apache-2.0",
"engines": {
"node": ">=20.16.0 || >=22.3.0"
},
"optionalDependencies": {
"@napi-rs/canvas": "^0.1.77"
}
},
"node_modules/perfect-debounce": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/perfect-debounce/-/perfect-debounce-2.1.0.tgz",
@@ -11208,12 +11525,17 @@
"@floating-ui/dom": "^1.8.0",
"@tiptap/core": "^3.32.2",
"@tiptap/extension-bubble-menu": "^3.32.2",
"@tiptap/extension-code-block": "^3.32.2",
"@tiptap/extension-collaboration": "^3.32.2",
"@tiptap/extension-collaboration-caret": "^3.32.2",
"@tiptap/extension-details": "^3.32.2",
"@tiptap/extension-highlight": "^3.32.2",
"@tiptap/extension-image": "^3.32.2",
"@tiptap/extension-list": "^3.32.2",
"@tiptap/extension-mathematics": "^3.32.2",
"@tiptap/extension-mention": "^3.32.2",
"@tiptap/extension-table": "^3.32.2",
"@tiptap/extension-text-align": "^3.32.2",
"@tiptap/extensions": "^3.32.2",
"@tiptap/pm": "^3.32.2",
"@tiptap/starter-kit": "^3.32.2",
@@ -11223,6 +11545,7 @@
"katex": "^0.18.10",
"lib0": "^0.2.119",
"mermaid": "^12.2.0",
"pdfjs-dist": "^5.4.149",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"y-protocols": "^1.0.7",