Add the slash menu, bubble menu, mentions and inline comments

Editor:
- "/" opens a filterable block menu (text, headings, lists, quote, code,
  divider, and image or file upload when the host can store files).
- Selecting text shows a formatting toolbar (bold, italic, strike, code,
  link) and, for anyone who may comment, a Comment button.
- "@" finds people in the page's workspace; the mention node is always in
  the schema so documents with mentions open in every client.
- The popups are plain DOM in the design system's slash-menu style, so
  the framework-free mobile bridge keeps building and can use them.
- Menu words come from the host; the web app passes English or Polish.

Inline comments (basic): commenters cannot edit the document, so a
comment's anchor is a pair of Yjs relative positions stored with the
comment rather than a mark in the text. Highlights follow local edits by
mapping and are re-resolved when comments change or remote edits arrive.
Pages get a comments panel (side column, or a bottom sheet on narrow
screens). Authors and space admins can delete comments.

Server: comments collection and endpoints, and a people lookup any
workspace member may use for mentions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tajniak81andClaude Opus 5.5 committed 2026-10-31 17:25:19 +01:00
1 parent dac6d6da63
commit 92cd81fd96
32 files changed
+1992 -123

No files matched your search

@@ -0,0 +1,40 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
/// <reference path="../pb_data/types.d.ts" />
// Inline comments. A comment points at a range of the page's text through
// anchor: Yjs relative positions (encoded by the editor), which follow the
// text as people edit. Commenters cannot change the document, so the anchor
// lives here instead of as a mark in the text.
migrate(
(app) => {
const users = app.findCollectionByNameOrId("users");
const pages = app.findCollectionByNameOrId("pages");
const workspaces = app.findCollectionByNameOrId("workspaces");
app.save(
new Collection({
type: "base",
name: "comments",
fields: [
{ name: "page", type: "relation", collectionId: pages.id, maxSelect: 1, required: true, cascadeDelete: true },
{ name: "workspace", type: "relation", collectionId: workspaces.id, maxSelect: 1, required: true, cascadeDelete: true },
{ name: "author", type: "relation", collectionId: users.id, maxSelect: 1, cascadeDelete: false },
{ name: "body", type: "text", required: true, max: 5000 },
// The commented text when the comment was written.
{ name: "quote", type: "text", max: 500 },
{ name: "anchor", type: "json", maxSize: 4096 },
{ name: "created", type: "autodate", onCreate: true, onUpdate: false },
{ name: "updated", type: "autodate", onCreate: true, onUpdate: true },
],
indexes: ["CREATE INDEX idx_comments_page ON comments (page, created)"],
}),
);
},
(app) => {
try {
app.delete(app.findCollectionByNameOrId("comments"));
} catch (_) {}
},
);
+10
View File
@@ -38,6 +38,7 @@ export type PageItem = Schemas["PageItem"];
export type Attachment = Schemas["Attachment"];
export type SearchHit = Schemas["SearchHit"];
export type ShareLink = Schemas["ShareLink"];
export type Comment = Schemas["Comment"];
export type SharedPage = Schemas["SharedPage"];
export type SearchResult = Schemas["SearchResult"];
export type GroupRequest = Schemas["GroupRequest"];
@@ -166,6 +167,10 @@ export function createClient(opts: ClientOptions) {
post<Session>("/api/v1/auth/invites/accept", { token, name, password }),
},
comments: {
remove: (id: string) => request<void>("DELETE", `/api/v1/comments/${encodeURIComponent(id)}`),
},
files: {
/** A short-lived token for ?token= on file URLs (img tags cannot send headers). */
token: () => post<{ token: string; expires: string }>("/api/v1/files/token"),
@@ -232,6 +237,8 @@ export function createClient(opts: ClientOptions) {
createSpace: (id: string, input: CreateSpaceRequest) =>
post<Space>(`/api/v1/workspaces/${encodeURIComponent(id)}/spaces`, input),
groups: (id: string) => request<Group[]>("GET", `/api/v1/workspaces/${encodeURIComponent(id)}/groups`),
people: (id: string, q: string, limit?: number) =>
request<MemberUser[]>("GET", `/api/v1/workspaces/${encodeURIComponent(id)}/people${query({ q, limit })}`),
search: (id: string, q: string, limit?: number) =>
request<SearchResult>("GET", `/api/v1/workspaces/${encodeURIComponent(id)}/search${query({ q, limit })}`),
favorites: (id: string) => request<PageItem[]>("GET", `/api/v1/workspaces/${encodeURIComponent(id)}/favorites`),
@@ -309,6 +316,9 @@ export function createClient(opts: ClientOptions) {
form.append("file", file, name);
return upload<Attachment>(`/api/v1/pages/${encodeURIComponent(id)}/attachments`, form);
},
comments: (id: string) => request<Comment[]>("GET", `/api/v1/pages/${encodeURIComponent(id)}/comments`),
addComment: (id: string, input: { body: string; quote?: string; anchor?: Record<string, unknown> | null }) =>
post<Comment>(`/api/v1/pages/${encodeURIComponent(id)}/comments`, input),
/** The public link; rejects with a 404 ApiError when sharing is off. */
shareLink: (id: string) => request<ShareLink>("GET", `/api/v1/pages/${encodeURIComponent(id)}/share`),
setShareLink: (id: string, includeSubpages: boolean) =>
+179
View File
@@ -1290,6 +1290,64 @@ export interface paths {
patch?: never;
trace?: never;
};
"/api/v1/workspaces/{id}/people": {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
/** Find people in the workspace by name or email (for mentions; any member) */
get: operations["listPeople"];
put?: never;
post?: never;
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/pages/{id}/comments": {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
/** The page's inline comments, oldest first */
get: operations["listComments"];
put?: never;
/** Comment on the page (commenter) */
post: operations["createComment"];
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/v1/comments/{id}": {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
get?: never;
put?: never;
post?: never;
/** Delete a comment (its author, or a space admin) */
delete: operations["deleteComment"];
options?: never;
head?: never;
patch?: never;
trace?: never;
};
}
export type webhooks = Record<string, never>;
export interface components {
@@ -1690,6 +1748,19 @@ export interface components {
/** @description Pages under the shared page */
pages: components["schemas"]["PageNode"][];
};
Comment: {
id: string;
page: string;
author: components["schemas"]["MemberUser"];
body: string;
quote: string;
/** @description As sent when the comment was created; null when there was none */
anchor: {
[key: string]: unknown;
} | null;
created: string;
canDelete: boolean;
};
};
responses: {
/** @description Signed in */
@@ -3992,4 +4063,112 @@ export interface operations {
404: components["responses"]["Error"];
};
};
listPeople: {
parameters: {
query?: {
q?: string;
limit?: number;
};
header?: never;
path: {
id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["MemberUser"][];
};
};
404: components["responses"]["Error"];
};
};
listComments: {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Comment"][];
};
};
404: components["responses"]["Error"];
};
};
createComment: {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
requestBody: {
content: {
"application/json": {
body: string;
/** @description The commented text */
quote?: string;
/** @description The editor's encoding of the commented range (opaque to the server) */
anchor?: {
[key: string]: unknown;
};
};
};
};
responses: {
/** @description Created */
201: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": components["schemas"]["Comment"];
};
};
400: components["responses"]["Error"];
403: components["responses"]["Error"];
404: components["responses"]["Error"];
};
};
deleteComment: {
parameters: {
query?: never;
header?: never;
path: {
id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description Deleted */
204: {
headers: {
[name: string]: unknown;
};
content?: never;
};
403: components["responses"]["Error"];
404: components["responses"]["Error"];
};
};
}
+45 -44
View File
@@ -5,30 +5,30 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<title>Docwell editor</title>
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){this.content=e}n.prototype={constructor:n,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,r){var i=r&&r!=e?this.remove(r):this,a=i.find(e),o=i.content.slice();return a==-1?o.push(r||e,t):(o[a+1]=t,r&&(o[a]=r)),new n(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var r=this.content.slice();return r.splice(t,2),new n(r)},addToStart:function(e,t){return new n([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var r=this.remove(e).content.slice();return r.push(e,t),new n(r)},addBefore:function(e,t,r){var i=this.remove(t),a=i.content.slice(),o=i.find(e);return a.splice(o==-1?a.length:o,0,t,r),new n(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=n.from(e),e.size?new n(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=n.from(e),e.size?new n(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=n.from(e);for(var r=0;r<e.content.length;r+=2)t=t.remove(e.content[r]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},n.from=function(e){if(e instanceof n)return e;var t=[];if(e)for(var r in e)t.push(r,e[r]);return new n(t)};function r(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(i),c=t.child(i);if(s==c)n+=s.nodeSize;else{if(!s.sameMarkup(c))return n;if(s.isText&&s.text!=c.text){let e=s.text,t=c.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&o(e.charCodeAt(r-1))&&a(e.charCodeAt(r))&&n--,n}if(s.content.size||c.content.size){let e=r(s.content,c.content,n+1);if(e!=null)return e}n+=s.nodeSize}}}function i(e,t,n,r){for(let s=e.childCount,c=t.childCount;;){if(s==0||c==0)return s==c?null:{a:n,b:r};let l=e.child(--s),u=t.child(--c),d=l.nodeSize;if(l==u)n-=d,r-=d;else{if(!l.sameMarkup(u))return{a:n,b:r};if(l.isText&&l.text!=u.text){let e=l.text,t=u.text,i=e.length,s=t.length;for(;i>0&&s>0&&e[i-1]==t[s-1];)i--,s--,n--,r--;return i&&s&&i<e.length&&o(e.charCodeAt(i-1))&&a(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(l.content.size||u.content.size){let e=i(l.content,u.content,n-1,r-1);if(e)return e}n-=d,r-=d}}}function a(e){return e>=56320&&e<57344}function o(e){return e>=55296&&e<56320}var s=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(Line truncated
`)}};he.empty=new he(!0);var ge=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function _e(e){let t=[];do t.push(ve(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function ve(e){let t=[];do t.push(ye(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ye(e){let t=Ce(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=xe(e,t);else break;return t}function be(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function xe(e,t){let n=be(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:be(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Se(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Ce(e){if(e.eat(`(`)){let t=_e(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Se(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function we(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Te(e,t){return t-e}function Ee(e,t){let n=[];return r(t),n.sort(Te);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function De(e){let t=Object.create(null);return n(Ee(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ee(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new he(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Te);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Oe(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function ke(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Ae(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0){if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r)}else i.validate&&i.validate(a);n[r]=a}return n}function je(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new Pe(e,r,t[r]);return n}var Me=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=je(e,n.attrs),this.defaultAttrs=ke(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==he.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ae(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new de(this,this.coLine truncated
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Ue.hasOwnProperty(a)&&this.parser.normalizeLists&&Xe(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:He.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Ve.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),t)}ignoreFallback(e,t){e.nodeName!=`BR`||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=d.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):$e(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=qe(e,i,a.options);a.options&Ke&&a.content.length==0&&(o|=Ke);let s=d.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):$e(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new Je(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=We);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function Xe(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Ue.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Ze(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatcheLine truncated
`))}})}function Gt(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Kt(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new kt(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new p(s.from(o),0,0),1,!0))}function qt(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Jt(e,t,n=1,r){let i=e.doc.resolve(t),a=s.empty,o=s.empty;for(let e=i.depth,t=i.depth-n,c=n-1;e>t;e--,c--){a=s.from(i.node(e).copy(a));let t=r&&r[c];o=s.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Ot(t,t,new p(a.append(o),n,n),!0))}function Yt(e,t){let n=e.resolve(t),r=n.index();return Zt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Xt(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Zt(e,t){return!!(e&&t&&!e.isLeaf&&Xt(e,t))}function Qt(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Zt(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function $t(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Wt(e,r.node(),r.before(),s)}o.inlineContent&&Nt(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Ot(l,c.map(t+n,-1),p.empty,!0)),r===!0){let t=e.doc.resolve(l);Ut(e,t.node(),t.before(),e.steps.length)}return e}function en(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function tn(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function nn(e,t,n=t,r=p.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return rn(i,a,r)?new Ot(t,n,r):new an(i,a,r).fit()}function rn(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var an=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=s.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=s.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new p(i,a,o);return e>-1?new kt(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Ot(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t=Line truncated
`).scrollIntoView()),!0)};function cr(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var lr=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=cr(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(S.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},ur=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof kn||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=cr(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(C.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},dr=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(qt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ft(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function fr(e){return(t,n)=>{if(t.selection instanceof w&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!qt(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof C||t.selection instanceof kn)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=cr(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=qt(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,qt(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var pr=fr(),mr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(w.create(e.doc,i))),!0)},hr=(e,t)=>(t&&t(e.tr.setSelection(new kn(e.doc))),!0);function gr(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Yt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function _r(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,c,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&gr(e,t,n))return!0;let u=!l&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,c=s.empty;for(let e=o.length-1;e>=0;e--)c=s.from(o[e].create(null,c));c=s.from(i.copy(c));let l=e.tr.step(new kt(t.pos-1,r,t.pos,r,new p(c,1,0),o.length,!0)),u=l.doc.resolve(r+2*o.length);u.nodeAfter&&u.nodeAfter.type==i.type&&Yt(l.doc,u.pos)&&l.join(u.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:S.findFrom(t,1),f=d&&d.$from.blockRange(d.$to),m=f&&Ft(f);if(m!=null&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(u&&Zn(a,`start`,!0)&&Zn(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let c=a,l=1;for(;!c.isTextblock;c=c.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,c.content)){if(n){let r=s.empty;for(let e=o.length-1;e>=0;e--)r=s.from(o[e].copy(r));n(e.tr.step(new kt(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new p(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function vr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(C.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var yr=vr(-1),br=vr(1);function xr(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Lt(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function Sr(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function Cr(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var wr=Cr(Gn,qn,Qn),Tr=Cr(Gn,tr,nr),Er={Enter:Cr(sr,urLine truncated
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:Ir(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(ci&&l.focusNode&&l.focusNode!=s.node&&D(l.focusNode)){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&fi)&&Vr(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Vr(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&ci)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?$i:Qi,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ea:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?$i:ea}n=a}this.dirty=$i}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?$i:Qi;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},na=class extends ta{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=D(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Zi&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ra=class extends ta{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},ia=class e extends ta{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=et.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&ea||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ea&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Zi){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Zi}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=Ta(a,n,o,r)),t>0&&(a=Ta(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},aa=class e extends ta{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!O(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=et.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=ga(u,r,n),l?c=new la(t,n,r,i,u,d||null,f,l):n.isText?new sa(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;bLine truncated
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};function n(e){this.content=e}n.prototype={constructor:n,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,r){var i=r&&r!=e?this.remove(r):this,a=i.find(e),o=i.content.slice();return a==-1?o.push(r||e,t):(o[a+1]=t,r&&(o[a]=r)),new n(o)},remove:function(e){var t=this.find(e);if(t==-1)return this;var r=this.content.slice();return r.splice(t,2),new n(r)},addToStart:function(e,t){return new n([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var r=this.remove(e).content.slice();return r.push(e,t),new n(r)},addBefore:function(e,t,r){var i=this.remove(t),a=i.content.slice(),o=i.find(e);return a.splice(o==-1?a.length:o,0,t,r),new n(a)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=n.from(e),e.size?new n(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=n.from(e),e.size?new n(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=n.from(e);for(var r=0;r<e.content.length;r+=2)t=t.remove(e.content[r]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},n.from=function(e){if(e instanceof n)return e;var t=[];if(e)for(var r in e)t.push(r,e[r]);return new n(t)};function r(e,t,n){for(let i=0;;i++){if(i==e.childCount||i==t.childCount)return e.childCount==t.childCount?null:n;let s=e.child(i),c=t.child(i);if(s==c)n+=s.nodeSize;else{if(!s.sameMarkup(c))return n;if(s.isText&&s.text!=c.text){let e=s.text,t=c.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&o(e.charCodeAt(r-1))&&a(e.charCodeAt(r))&&n--,n}if(s.content.size||c.content.size){let e=r(s.content,c.content,n+1);if(e!=null)return e}n+=s.nodeSize}}}function i(e,t,n,r){for(let s=e.childCount,c=t.childCount;;){if(s==0||c==0)return s==c?null:{a:n,b:r};let l=e.child(--s),u=t.child(--c),d=l.nodeSize;if(l==u)n-=d,r-=d;else{if(!l.sameMarkup(u))return{a:n,b:r};if(l.isText&&l.text!=u.text){let e=l.text,t=u.text,i=e.length,s=t.length;for(;i>0&&s>0&&e[i-1]==t[s-1];)i--,s--,n--,r--;return i&&s&&i<e.length&&o(e.charCodeAt(i-1))&&a(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(l.content.size||u.content.size){let e=i(l.content,u.content,n-1,r-1);if(e)return e}n-=d,r-=d}}}function a(e){return e>=56320&&e<57344}function o(e){return e>=55296&&e<56320}var s=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(Line truncated
`)}};fe.empty=new fe(!0);var pe=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function me(e){let t=[];do t.push(he(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function he(e){let t=[];do t.push(ge(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function ge(e){let t=be(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=ve(e,t);else break;return t}function _e(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function ve(e,t){let n=_e(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:_e(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function ye(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function be(e){if(e.eat(`(`)){let t=me(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=ye(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function xe(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Se(e,t){return t-e}function Ce(e,t){let n=[];return r(t),n.sort(Se);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function we(e){let t=Object.create(null);return n(Ce(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Ce(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new fe(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Se);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Te(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function Ee(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function De(e,t){let n=Object.create(null);for(let r in e){let i=e[r],a=t&&t[r];if(a===void 0){if(i.hasDefault)a=i.default;else throw RangeError(`No value supplied for attribute `+r)}else i.validate&&i.validate(a);n[r]=a}return n}function Oe(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new je(e,r,t[r]);return n}var ke=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Oe(e,n.attrs),this.defaultAttrs=Ee(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==fe.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:De(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new ce(this,this.coLine truncated
`);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;Be.hasOwnProperty(a)&&this.parser.normalizeLists&&qe(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:ze.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(Re.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
`),t)}ignoreFallback(e,t){e.nodeName!=`BR`||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node){if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=d.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):Xe(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=We(e,i,a.options);a.options&Ue&&a.content.length==0&&(o|=Ue);let s=d.none;return n=n.filter(t=>!(a.type?a.type.allowsMarkType(t.type):Xe(t.type,e))||(s=t.addToSet(s),!1)),this.nodes.push(new Ge(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=Ve);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function qe(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&Be.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function Je(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatcheLine truncated
`))}})}function Ht(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function Ut(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new Et(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new p(s.from(o),0,0),1,!0))}function Wt(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Gt(e,t,n=1,r){let i=e.doc.resolve(t),a=s.empty,o=s.empty;for(let e=i.depth,t=i.depth-n,c=n-1;e>t;e--,c--){a=s.from(i.node(e).copy(a));let t=r&&r[c];o=s.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new Tt(t,t,new p(a.append(o),n,n),!0))}function Kt(e,t){let n=e.resolve(t),r=n.index();return Jt(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function qt(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Jt(e,t){return!!(e&&t&&!e.isLeaf&&qt(e,t))}function Yt(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let i,a,o=r.index(e);if(e==r.depth?(i=r.nodeBefore,a=r.nodeAfter):n>0?(i=r.node(e+1),o++,a=r.node(e).maybeChild(o)):(i=r.node(e).maybeChild(o-1),a=r.node(e+1)),i&&!i.isTextblock&&Jt(i,a)&&r.node(e).canReplace(o,o+1))return t;if(e==0)break;t=n<0?r.before(e):r.after(e)}}function Xt(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);Vt(e,r.node(),r.before(),s)}o.inlineContent&&At(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new Tt(l,c.map(t+n,-1),p.empty,!0)),r===!0){let t=e.doc.resolve(l);Bt(e,t.node(),t.before(),e.steps.length)}return e}function Zt(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function Qt(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+ +(n>0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function $t(e,t,n=t,r=p.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return en(i,a,r)?new Tt(t,n,r):new tn(i,a,r).fit()}function en(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var tn=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=s.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=s.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new p(i,a,o);return e>-1?new Et(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new Tt(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t=Line truncated
`).scrollIntoView()),!0)};function ar(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var or=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=ar(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(T.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},sr=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof En||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=ar(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(E.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},cr=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Wt(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Mt(r);return i!=null&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function lr(e){return(t,n)=>{if(t.selection instanceof D&&t.selection.node.isBlock){let{$from:e}=t.selection;return!e.parentOffset||!Wt(t.doc,e.pos)?!1:(n&&n(t.tr.split(e.pos).scrollIntoView()),!0)}if(!t.selection.$from.depth)return!1;let r=t.tr;!t.selection.empty&&(t.selection instanceof E||t.selection instanceof En)&&r.deleteSelection();let{$from:i}=r.selection,a=r.steps.length,o=[],s,c,l=!1,u=!1;for(let t=i.depth;;t--)if(i.node(t).isBlock){l=i.end(t)==i.pos+(i.depth-t),u=i.start(t)==i.pos-(i.depth-t),c=ar(i.node(t-1).contentMatchAt(i.indexAfter(t-1)));let n=e&&e(i.parent,l,i);o.unshift(n||(l&&c?{type:c}:null)),s=t;break}else{if(t==1)return!1;o.unshift(null)}let d=i.pos,f=Wt(r.doc,d,o.length,o);if(f||=(o[0]=c?{type:c}:null,Wt(r.doc,d,o.length,o)),!f)return!1;if(r.split(d,o.length,o),!l&&u&&i.node(s).type!=c){let e=r.mapping.slice(a),t=e.map(i.before(s)),n=r.doc.resolve(t);c&&i.node(s-1).canReplaceWith(n.index(),n.index()+1,c)&&r.setNodeMarkup(e.map(i.before(s)),c)}return n&&n(r.scrollIntoView()),!0}}var ur=lr(),dr=(e,t)=>{let{$from:n,to:r}=e.selection,i,a=n.sharedDepth(r);return a!=0&&(i=n.before(a),t&&t(e.tr.setSelection(D.create(e.doc,i))),!0)},fr=(e,t)=>(t&&t(e.tr.setSelection(new En(e.doc))),!0);function pr(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Kt(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function mr(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,c,l=i.type.spec.isolating||a.type.spec.isolating;if(!l&&pr(e,t,n))return!0;let u=!l&&t.parent.canReplace(t.index(),t.index()+1);if(u&&(o=(c=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&c.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,c=s.empty;for(let e=o.length-1;e>=0;e--)c=s.from(o[e].create(null,c));c=s.from(i.copy(c));let l=e.tr.step(new Et(t.pos-1,r,t.pos,r,new p(c,1,0),o.length,!0)),u=l.doc.resolve(r+2*o.length);u.nodeAfter&&u.nodeAfter.type==i.type&&Kt(l.doc,u.pos)&&l.join(u.pos),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:T.findFrom(t,1),f=d&&d.$from.blockRange(d.$to),m=f&&Mt(f);if(m!=null&&m>=t.depth)return n&&n(e.tr.lift(f,m).scrollIntoView()),!0;if(u&&Jn(a,`start`,!0)&&Jn(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let c=a,l=1;for(;!c.isTextblock;c=c.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,c.content)){if(n){let r=s.empty;for(let e=o.length-1;e>=0;e--)r=s.from(o[e].copy(r));n(e.tr.step(new Et(t.pos-o.length,t.pos+a.nodeSize,t.pos+l,t.pos+a.nodeSize-l,new p(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function hr(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(E.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var gr=hr(-1),_r=hr(1);function vr(e,t=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),s=o&&Pt(o,e,t);return s?(r&&r(n.tr.wrap(o,s).scrollIntoView()),!0):!1}}function yr(e,t=null){return function(n,r){let i=!1;for(let r=0;r<n.selection.ranges.length&&!i;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];n.doc.nodesBetween(a,o,(r,a)=>{if(i)return!1;if(r.isTextblock&&!r.hasMarkup(e,t)){if(r.type==e)i=!0;else{let t=n.doc.resolve(a),r=t.index();i=t.parent.canReplaceWith(r,r+1,e)}}})}if(!i)return!1;if(r){let i=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:a},$to:{pos:o}}=n.selection.ranges[r];i.setBlockType(a,o,e,t)}r(i.scrollIntoView())}return!0}}function br(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var xr=br(Hn,Wn,Yn),Sr=br(Hn,Qn,$n),Cr={Enter:br(ir,srLine truncated
`),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:Nr(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(ai&&l.focusNode&&l.focusNode!=s.node&&A(l.focusNode)){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&li)&&Rr(o.node,o.offset,l.anchorNode,l.anchorOffset)&&Rr(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&ai)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Xi:Yi,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Zi:i.markDirty(e-r,t-r);return}i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Xi:Zi}n=a}this.dirty=Xi}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Xi:Yi;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},$i=class extends Qi{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let e=A(a)?a:document.createElement(`span`);e!=a&&(e.appendChild(a),a=e),e.hasAttribute(`contenteditable`)||(e.contentEditable=`false`),e.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Ji&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ea=class extends Qi{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},ta=class e extends Qi{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return o&&o.dom||(o=Ze.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Zi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Zi&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ji){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Ji}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=Sa(a,n,o,r)),t>0&&(a=Sa(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},na=class e extends Qi{constructor(e,t,n,r,i,a,o){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(!j(u))throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=Ze.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=pa(u,r,n),l?c=new oa(t,n,r,i,u,d||null,f,l):n.isText?new ia(t,n,r,i,u,f):new e(t,n,r,i,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(t.preserveWhitespace=`full`),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;bLine truncated
`),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=et.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&&!D(e);)e=e.nextSibling;if(!e)break;o=e}if(c||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Be.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
`),slice:t}}function ro(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=Ze.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=go(n),mi&&_o(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&&!A(e);)e=e.nextSibling;if(!e)break;o=e}if(c||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||Le.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!io.test(e.parentNode.nodeName)?{ignore:!0}:null}}),d)c=vo(uo(c,+d[1],+d[2]),d[4]);else if(c=p.maxOpen(ao(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=uo(c,e,t)}return e.someProp(`transformPasted`,t=>{c=t(c,e,l)}),c}var io=/^(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 ao(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&&so(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=co(a[a.length-1],i.length));let n=oo(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return s.from(a)}return e}function oo(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,s.from(e));return e}function so(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=so(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(oo(n,e,i+1))))}}function co(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,co(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(r))}function lo(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=lo(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 uo(e,t,n){return t<e.openStart&&(e=new p(lo(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new p(lo(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var fo={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 po(){return document.implementation.createHTMLDocument(`title`)}var mo=null;function ho(e){let t=window.trustedTypes;if(!t)return e;if(!mo){if(mo=t.defaultPolicy)try{return mo.createHTML(e)}catch{}mo=t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e})}return mo.createHTML(e)}function go(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=po(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(e),a;if((a=i&&fo[i[1].toLowerCase()])&&(e=a.map(e=>`<`+e+`>`).join(``)+e+a.map(e=>`</`+e+`>`).reverse().join(``)),r.innerHTML=ho(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 _o(e){let t=e.querySelectorAll(si?`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 vo(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 yo={},bo={},xo={touchstart:!0,touchmove:!0},So=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 Hu(e,t){return Vu(e,{from:0,to:e.content.size},t)}function Uu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Wu(e,t){let n=j(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 Gu(e,t){let n=$l(typeof t==`string`?t:t.name,e.schema);return n===`node`?Wu(e,t):n===`mark`?du(e,t):{}}function Ku(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=Ku(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 Ju(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 Yu(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=ml(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 Xu=(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]},Zu=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 Qu(e,t){return t.nodes[e]||t.marks[e]||null}function $u(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 ed=(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 td(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?hl(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>dl(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=>dl(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 nd(e,t,n={}){if(!t)return Jl(e,null,n)||td(e,null,n);let r=$l(t,e.schema);return r===`node`?Jl(e,t,n):r===`mark`&&td(e,t,n)}var rd=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=hu(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)},id=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function ad(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function od(e,t){let{nodeExtensions:n}=Eu(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=N(M(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function sd(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&&(sd(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function cd(e){return e instanceof w}function ld(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 ud(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!ld(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var dd=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function fd(e,t){let n=t.mapping.mapResult(e.position);return{position:new dd(n.pos),mapResult:n}}function pdLine truncated
`),i=n.isParagraphContinuation??(e=>kf(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(`
`,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 Bu(e,t){return zu(e,{from:0,to:e.content.size},t)}function Vu(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}function Hu(e,t){let n=N(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 Uu(e,t){let n=Zl(typeof t==`string`?t:t.name,e.schema);return n===`node`?Hu(e,t):n===`mark`?lu(e,t):{}}function Wu(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 Gu(e){let t=Wu(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 Ku(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}})})}),Gu(r)}function qu(e,t,n){let r=[];return e===t?n.resolve(e).marks().forEach(t=>{let i=fl(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 Ju=(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]},Yu=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 Xu(e,t){return t.nodes[e]||t.marks[e]||null}function Zu(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 Qu=(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 $u(e,t,n={}){let{empty:r,ranges:i}=e.selection,a=t?pl(t,e.schema):null;if(r)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!a||a.name===e.type.name).find(e=>ll(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=>ll(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 ed(e,t,n={}){if(!t)return Kl(e,null,n)||$u(e,null,n);let r=Zl(t,e.schema);return r===`node`?Kl(e,t,n):r===`mark`&&$u(e,t,n)}var td=(e,t)=>{let{$from:n,$to:r,$anchor:i}=e.selection;if(t){let n=pu(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)},nd=e=>{let{$from:t,$to:n}=e.selection;return!(t.parentOffset>0||t.pos!==n.pos)};function rd(e,t){return Array.isArray(t)?t.some(t=>(typeof t==`string`?t:t.name)===e.name):t}function id(e,t){let{nodeExtensions:n}=wu(t),r=n.find(t=>t.name===e);if(!r)return!1;let i=F(P(r,`group`,{name:r.name,options:r.options,storage:r.storage}));return typeof i==`string`&&i.split(` `).includes(`list`)}function ad(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&&(ad(e,{ignoreWhitespace:n,checkChildren:t})||(r=!1))}),r}return!1}function od(e){return e instanceof D}function sd(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 cd(e){if(typeof e!=`object`||!e)return!1;let t=e;if(!sd(t))return!1;let n=t.toJSON();return!(typeof n!=`object`||!n||n.stepType!==`replace`)}var ld=class e{constructor(e){this.position=e}static fromJSON(t){return new e(t.position)}toJSON(){return{position:this.position}}};function ud(e,t){let n=t.mapping.mapResult(e.position);return{position:new ld(n.pos),mapResult:n}}function ddLine truncated
`),i=n.isParagraphContinuation??(e=>Uf(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 jf(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=Af(p,g.map(e=>Of(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 Mf=4;function Nf(e){let t=0;for(let n of e)t=n===` `?t+Mf-t%Mf:t+1;return t}function Pf(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 Gf(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=Wf(p,g.map(e=>Hf(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 Kf=4;function qf(e){let t=0;for(let n of e)t=n===` `?t+Kf-t%Kf:t+1;return t}function Jf(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=Nf(a);return(Nf(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=qf(a);return(qf(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 Ff(e,t){let n={...e};return Ef(e)&&Ef(t)&&Object.keys(t).forEach(r=>{Ef(t[r])&&Ef(e[r])?n[r]=Ff(e[r],t[r]):n[r]=t[r]}),n}function If(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 Lf=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},Rf=(e,t)=>{if(ul(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 zf(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:Vn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function Bf(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}=zf({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=qc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Jc({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))||(zc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function Vf(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 Hf(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=ed(l)+i;for(let e of a){let a=Rf(u,e.find);if(a&&Vf(l,a,i)&&Bf({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function Uf(e){let{editor:t,rules:n}=e,r=new T({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:_u(s.from(e),a.schema);let{from:i}=c,o=i+e.length;Hf({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 Hf({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&&Hf({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?Hf({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var Wf=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{...N(M(this,`addOptions`,{name:this.name}))}}get storage(){return{...N(M(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Ff(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}},Gf=class e extends Wf{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)}},Kf=class{constructor(e){this.find=e.find,this.handler=e.handler}},qf=(e,t,n)=>{if(ul(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 Jf(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Jc({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||qf(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 Yf=null,Xf=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function Zf(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=qc({state:e,transaction:s});if(Jf({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`,()=>{Yf===t&&(Yf=null)}),n.map(e=>new T({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(Yf=t)},i=()=>{Yf&&=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=Yf;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:_u(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=Xf(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(wf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var Qf=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Bu(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Ru(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=M(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Qu(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=zu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Qu(t.name,this.schema)},r=[],i=M(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&M(t,`exitable`,n)&&(a.ArrowRight=()=>Gf.handleExit({editor:e,mark:t})),i){leLine truncated
`);l+=e.type===`paragraph`?`\n\n${o}`:`\n${o}`}}),l}function Yf(e,t){let n={...e};return Tf(e)&&Tf(t)&&Object.keys(t).forEach(r=>{Tf(t[r])&&Tf(e[r])?n[r]=Yf(e[r],t[r]):n[r]=t[r]}),n}function Xf(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 Zf=class{constructor(e){this.find=e.find,this.handler=e.handler,this.undoable=e.undoable??!0}},Qf=(e,t)=>{if(cl(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 $f(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:Rn.create({doc:o.doc,selection:o.selection,storedMarks:o.storedMarks}).tr}}function ep(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}=$f({editor:t,from:n,to:r,text:i,insertText:c}),f=u?n+i.length:r,p=Gc({state:l.state,transaction:d}),m={from:n-(o[0].length-i.length),to:f},{commands:h,chain:g,can:_}=new Kc({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))||(Lc(d),d.setMeta(`inputRule`,!0),a.undoable&&d.setMeta(s,{transform:d,from:n,to:f,text:i}),l.dispatch(d)),!0)}function tp(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 np(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=Qu(l)+i;for(let e of a){let a=Qf(u,e.find);if(a&&tp(l,a,i)&&ep({editor:t,from:n,to:r,text:i,rule:e,match:a,plugin:o,insertText:s}))return!0}return!1}function rp(e){let{editor:t,rules:n}=e,r=new O({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:hu(s.from(e),a.schema);let{from:i}=c,o=i+e.length;np({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 np({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&&np({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?np({editor:t,from:a.pos,to:a.pos,text:`
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var ip=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{...F(P(this,`addOptions`,{name:this.name}))}}get storage(){return{...F(P(this,`addStorage`,{name:this.name,options:this.options}))}}configure(e={}){let t=this.extend({...this.config,addOptions:()=>Yf(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}},ap=class e extends ip{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)}},op=class{constructor(e){this.find=e.find,this.handler=e.handler}},sp=(e,t,n)=>{if(cl(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 cp(e){let{editor:t,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:s}=e,{commands:c,chain:l,can:u}=new Kc({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||sp(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 lp=null,up=e=>{var t;let n=new ClipboardEvent(`paste`,{clipboardData:new DataTransfer});return(t=n.clipboardData)==null||t.setData(`text/html`,e),n};function dp(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=Gc({state:e,transaction:s});if(cp({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`,()=>{lp===t&&(lp=null)}),n.map(e=>new O({view(e){let n=n=>{r=e.dom.parentElement?.contains(n.target)?e.dom.parentElement:null,r&&(lp=t)},i=()=>{lp&&=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=lp;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:hu(s.from(t),r.schema);let{from:n}=f,i=n+t.length,a=up(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(Cf(m)&&h&&m!==h.b)return l({rule:e,state:r,from:m,to:h,pasteEvt:o})}}))}var fp=class{constructor(e,t){this.splittableMarks=[],this.nonClearableMarks=[],this.decorationManager=null,this.editor=t,this.baseExtensions=e,this.extensions=Ru(e),this.hasSchemaSpec=t.options.schemaSpec!==void 0,this.schema=Iu(this.extensions,t,t.options.schemaSpec),this.setupExtensions()}get commands(){return this.extensions.reduce((e,t)=>{let n=P(t,`addCommands`,{name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:this.editor,type:Xu(t.name,this.schema)});return n?{...e,...n()}:e},{})}get plugins(){let{editor:e}=this,t=Lu([...this.extensions].reverse()).flatMap(t=>{let n={name:t.name,options:t.options,storage:this.editor.extensionStorage[t.name],editor:e,type:Xu(t.name,this.schema)},r=[],i=P(t,`addKeyboardShortcuts`,n),a={};if(t.type===`mark`&&P(t,`exitable`,n)&&(a.ArrowRight=()=>ap.handleExit({editor:e,mark:t})),i){leLine truncated
`)}}})]}}),ep=F.create({name:`commands`,addCommands(){return{...Xd}}}),tp=F.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=fu(e.before,[e,...t]);Ju(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 Ct){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()}}),np=F.create({name:`drop`,addProseMirrorPlugins(){return[new T({key:new E(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),rp=F.create({name:`editable`,addProseMirrorPlugins(){return[new T({key:new E(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),ip=new E(`focusEvents`),ap=F.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new T({key:ip,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}}}})]}}),op=F.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:S.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 Sl()||Gl()?i:r},addProseMirrorPlugins(){return[new T({key:new E(`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=S.atStart(t.doc).from,l=S.atEnd(t.doc).to;if(a||o!==c||s!==l||!sd(n.doc))return;let u=n.tr,d=qc({state:n,transaction:u}),{commands:f}=new Jc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),sp=F.create({name:`paste`,addProseMirrorPlugins(){return[new T({key:new E(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),cp=F.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new T({key:new E(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),lp=F.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=Eu(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 T({key:new E(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),up=!1;function dp(e){if(up)return;up=!0;let t;try{let n=Ot.fromJSON(e,{from:0,tLine truncated
`)}}})]}}),mp=L.create({name:`commands`,addCommands(){return{...Jd}}}),hp=L.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=uu(e.before,[e,...t]);Ku(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 bt){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()}}),gp=L.create({name:`drop`,addProseMirrorPlugins(){return[new O({key:new k(`tiptapDrop`),props:{handleDrop:(e,t,n,r)=>{this.editor.emit(`drop`,{editor:this.editor,event:t,slice:n,moved:r})}}})]}}),_p=L.create({name:`editable`,addProseMirrorPlugins(){return[new O({key:new k(`editable`),props:{editable:()=>this.editor.options.editable}})]}}),vp=new k(`focusEvents`),yp=L.create({name:`focusEvents`,addProseMirrorPlugins(){let{editor:e}=this;return[new O({key:vp,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}}}})]}}),bp=L.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:T.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 bl()||Ul()?i:r},addProseMirrorPlugins(){return[new O({key:new k(`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=T.atStart(t.doc).from,l=T.atEnd(t.doc).to;if(a||o!==c||s!==l||!ad(n.doc))return;let u=n.tr,d=Gc({state:n,transaction:u}),{commands:f}=new Kc({editor:this.editor,state:d});if(f.clearNodes(),u.steps.length)return u}})]}}),xp=L.create({name:`paste`,addProseMirrorPlugins(){return[new O({key:new k(`tiptapPaste`),props:{handlePaste:(e,t,n)=>{this.editor.emit(`paste`,{editor:this.editor,event:t,slice:n})}}})]}}),Sp=L.create({name:`tabindex`,addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new O({key:new k(`tabindex`),props:{attributes:()=>!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:this.options.value??`0`}}})]}}),Cp=L.create({name:`textDirection`,addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];let{nodeExtensions:e}=wu(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 O({key:new k(`textDirection`),props:{attributes:()=>{let e=this.options.direction;return e?{dir:e}:{}}}})]}}),wp=!1;function Tp(e){if(wp)return;wp=!0;let t;try{let n=Tt.fromJSON(e,{from:0,tLine truncated
position: relative;
}
@@ -98,53 +98,54 @@ img.ProseMirror-separator {
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}`,mp=class extends ef{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:fd,createMappablePosition:pd},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=bl(t,this.options.autofocus);this.editorState=Vn.create({doc:t,schema:this.schema,selection:e||void 0})}dp(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():Jc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Jc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=Cf(pp,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 tf&&!this.hasWarnedStaleDecorationRead&&$d(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=Ou(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
}`,Op=class extends Qd{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:ud,createMappablePosition:dd},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=vl(t,this.options.autofocus);this.editorState=Rn.create({doc:t,schema:this.schema,selection:e||void 0})}Tp(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():Kc.createFakeChain()}can(){return this.commandManager?this.commandManager.can():Kc.createFallbackCan()}injectCSS(){this.options.injectCSS&&typeof document<`u`&&(this.css=xf(Dp,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 $d&&!this.hasWarnedStaleDecorationRead&&Zd(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=Eu(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],r=this.state.recoLine truncated
`,textSerializers:n={}}=e||{};return Hu(this.state.doc,{blockSeparator:t,textSerializers:{...Uu(this.schema),...n}})}get isEmpty(){return sd(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 fp(t,this,!1,n)}get $doc(){return this.$pos(0)}};function hp(e){return new Lf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=N(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(Yu(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 gp(e){return new Lf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=N(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 _p(e){return new Lf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=N(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 vp(e){return new Lf({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=N(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&Lt(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&&Yt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var yp=class e extends Wf{constructor(...e){super(...e),this.type=`node`}static create(t={}){let n=typeof t==`function`?t():t;return new e(n)}configure(e){return super.configure(e)}extend(e){let t=typeof e==`function`?e():e;return super.extend(t)}};function bp(e){return new Kf({find:e.find,handler:({state:t,range:n,match:r,pasteEvent:i})=>{let a=N(e.getAttributes,void 0,r,i);if(a===!1||a===null)return null;let{tr:o}=t,s=r[r.length-1],c=r[0],l=n.to;if(s){let i=c.search(/\S/),u=n.from+c.indexOf(s),d=u+s.length;if(Yu(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>u).length)return null;d<n.to&&o.delete(d,n.to),u>n.from&&o.delete(n.from+i,u),l=n.from+i+s.length,o.addMark(n.from+i,l,e.type.create(a||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(e.type)}}})}var xp=()=>new Map,Sp=e=>{let t=xp();return e.forEach((e,n)=>{t.set(n,e)}),t},Cp=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},wp=(e,t)=>{let n=[];for(let[r,i]of e)n.push(t(i,r));return n},Tp=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Ep=()=>new Set,Dp=e=>e[e.length-1],Op=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},kp=Array.from,Ap=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},jp=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Mp=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Np=Array.isArray,Pp=class{constructor(){this._observers=xp()}on(e,t){return Cp(this._observers,e,Ep).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return kp((this._observers.get(e)||xp()).values()).forEach(e=>e(...t))}destroy(){this._observers=xp()}},Fp=class{constructor(){this._observers=xp()}on(e,t){Cp(this._observers,e,Ep).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return kp((this._observers.get(e)||xp()).values()).forEach(e=>e(...t))}destroy(){this._observers=xp()}},IpLine truncated
`)}},Jh=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[oh]?sh(e,t):Np(e)?Ap(e,e=>jp(t,t=>Jh(e,t))):ch(e)?mh(e,(e,n)=>Jh(e,t[n])):!1,Yh=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Jh(t,n)}equals(e){return this.constructor===e.constructor&&xh(this.shape,e.shape)}[Kh](){return!0}[oh](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){km()}get nullable(){return Eg(this,Vg)}get optional(){return new ig(this)}cast(e){return Gg(e,this),e}expect(e){return Gg(e,this),e}},Xh=class extends Yh{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}},B=(e,t=null)=>new Xh(e,t);B(Xh);var Zh=class extends Yh{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}},V=e=>new Zh(e);B(Zh);var Qh=class extends Yh{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}},$h=(...e)=>new Qh(e),eg=B(Qh),tg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),ng=e=>{if(Ig.check(e))return[tg(e)];if(eg.check(e))return e.shape.map(e=>e+``);if(Fg.check(e))return[`[+-]?\\d+.?\\d*`];if(Lg.check(e))return[`.*`];if(Dg.check(e))return e.shape.map(ng).flat(1);R()};B(class extends Yh{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(ng).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 rg=Symbol(`optional`),ig=class extends Yh{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[rg](){return!0}},ag=B(ig),og=class extends Yh{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new og,B(og);var sg=class e extends Yh{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):mh(this.shape,(n,r)=>{let i=this._isPartial&&!hh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},cg=e=>new sg(e),lg=B(sg),ug=V(e=>e!=null&&(e.constructor===Object||e.constructor==null)),dg=class extends Yh{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&mh(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)})}},fg=(e,t)=>new dg(e,t),pg=B(dg),mg=class extends Yh{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&mh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},hg=(...e)=>new mg(e);B(mg);var gg=class extends Yh{constructor(e){super(),this.shape=e.length===1?e[0]:new Tg(e)}check(e,t){let n=Np(e)&&Ap(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},_g=(...e)=>new gg(e),vg=B(gg),yg=V(e=>Np(e)),bg=class extends Yh{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}},xg=(e,t=null)=>new bg(e,t);B(bg);var Sg=xg(Yh),Cg=B(class extends Yh{constructor(e){super(),this.len=e.length-1,this.args=hg(...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}}),wg=V(e=>typeof e==`function`);B(class extends Yh{constructor(e){super(),this.shape=e}check(e,t){let n=Ap(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Tg=class extends Yh{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=jp(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Eg=(...e)=>e.findIndex(e=>Dg.check(e))>=0?Eg(...e.map(e=>Wg(e)).map(e=>Dg.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Tg(e),Dg=B(Tg),Og=()=>!0,kg=V(Og),Ag=B(Zh,e=>e.shape===Og),jg=V(e=>typeof e==`bigint`),Mg=V(e=>e===jg),Ng=V(e=>typeof e==`symbol`);V(e=>e===Ng);var Pg=V(e=>typeof e==`number`),Fg=V(e=>e===Pg),Ig=V(e=>typeof e==`string`),Lg=V(e=>e===Ig),Rg=V(e=>typeof e==`boolean`),zg=V(e=>e===Rg),Bg=$h(void 0);B(Qh,e=>e.shape.length===1&&e.shape[0]===void 0),$h(void 0);var Vg=$h(null),Hg=B(Qh,e=>e.shape.length===1&&e.shape[0]===null);B(Uint8Array),B(Xh,e=>e.shape===Uint8Array);var Ug=Eg(Pg,Ig,Vg,Bg,jg,Rg,Ng);(()=>{let e=_g(kg),t=fg(Ig,kg),n=Eg(Pg,Ig,Vg,Rg,e,t);return e.shape=n,t.shape.values=n,n})();var Wg=e=>{if(Sg.check(e))return e;if(ug.check(e)){let t={};for(let n in Line truncated
`;n.right=new J(H(o,U(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Bb(i)),n.right.integrate(e,0),n.forward()}$y(e,t,n,s)},ab=(e,t,n,r,i)=>{let a=t,o=xp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===q){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 q:{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&&eb(i,n);break}}}t=t.right}return s},ob=(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===q){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},sb=e=>{let t=0;return W(e.doc,n=>{let r=e._start,i=e._start,a=xp(),o=Sp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case q:eb(o,i.content);break;default:t+=ab(n,r,i,a,o),a=Sp(o),r=i}i=i.right}}),t},cb=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&&Vv(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===q&&e.constructor!==wb&&t.add(e.parent)})}W(n,n=>{w_(e,e.deleteSet,e=>{if(e instanceof wb||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===q?t.add(r):ob(n,e)});for(let e of t)sb(e)})},lb=(e,t,n)=>{let r=n,i=Sp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Xb:case Mb:case Bb:n<t.right.length&&Rv(e,H(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}a&&ab(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Sy(o._searchMarker,t.index,-r+n),t},ub=class extends fy{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=[];W(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},ph(o)||(e.attributes=lh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Xb:case Mb: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 Bb: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 q:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Yy(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Yy(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;Yy(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Yy(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),eb(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}},db=class e extends G{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??my(),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 ub(this,e,t);Cy(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??my();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Bb&&(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)):W(this.doc,n=>{let r=new Xy(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)&&rb(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&lb(n,r,a.delete):ib(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??my();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(Av(s,e)||t!==void 0&&Av(s,t))switch(s.content.constructor){case Bb:{let r=i.get(`ychange`);e!==void 0&&!Av(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&&!Av(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 Xb:case Mb:{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 q:Av(s,e)&&(c(),eb(i,s.content))}s=s.right}c()};return e||t?W(a,n=>{e&&jv(n,e),t&&jv(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)):W(r,r=>{let i=Qy(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),rb(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):W(r,r=>{let i=Qy(r,this,e,!n);rb(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)):W(n,n=>{lb(n,Qy(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)):W(r,r=>{let i=Qy(r,this,e,!1);i.right!==null&&ib(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):W(this.doc,t=>{Iy(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):W(this.doc,n=>{Ly(n,this,e,t)})}getAttribute(e){return Ry(this,e)}getAttributes(){return zy(this)}_write(e){e.writeTypeRef(Gb)}},fb=e=>new db,pb=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??my()}[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===K||t.constructor===mb)&&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})}},mb=class e extends G{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 G?e.clone():e)),t}get length(){return this.doc??my(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new pb(this,e)}querySelector(e){e=e.toUpperCase();let t=new pb(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),kp(new pb(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Cy(this,e,new _b(this,t,e))}toString(){return Oy(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),Dy(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):W(this.doc,n=>{Ny(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)W(this.doc,n=>{let r=e&&e instanceof G?e._item:e;jy(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 Om(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):W(this.doc,n=>{Fy(n,this,e,t)})}toArray(){return Ty(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Ay(this,e)}slice(e=0,t=this.length){return wy(this,e,t)}forEach(e){Dy(this,e)}_write(e){e.writeTypeRef(qb)}},hb=e=>new mb,K=class e extends mb{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 dh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof G?e.Line truncated
`,textSerializers:n={}}=e||{};return Bu(this.state.doc,{blockSeparator:t,textSerializers:{...Vu(this.schema),...n}})}get isEmpty(){return ad(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 Ep(t,this,!1,n)}get $doc(){return this.$pos(0)}};function kp(e){return new Zf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=F(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(qu(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 Ap(e){return new Zf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=F(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 jp(e){return new Zf({find:e.find,handler:({state:t,range:n,match:r})=>{let i=t.doc.resolve(n.from),a=F(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 Mp(e){return new Zf({find:e.find,handler:({state:t,range:n,match:r,chain:i})=>{let a=F(e.getAttributes,void 0,r)||{},o=t.tr.delete(n.from,n.to),s=o.doc.resolve(n.from).blockRange(),c=s&&Pt(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&&Kt(o.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(r,l))&&o.join(n.from-1)},undoable:e.undoable})}var Np=e=>`touches`in e,Pp=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.resizinLine truncated
`)}},gg=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ch]?wh(e,t):Yp(e)?Kp(e,e=>qp(t,t=>gg(e,t))):Th(e)?jh(e,(e,n)=>gg(e,t[n])):!1,_g=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),gg(t,n)}equals(e){return this.constructor===e.constructor&&Rh(this.shape,e.shape)}[mg](){return!0}[Ch](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Km()}get nullable(){return Yg(this,u_)}get optional(){return new Dg(this)}cast(e){return m_(e,this),e}expect(e){return m_(e,this),e}},vg=class extends _g{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}},V=(e,t=null)=>new vg(e,t);V(vg);var yg=class extends _g{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}},bg=e=>new yg(e);V(yg);var xg=class extends _g{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}},Sg=(...e)=>new xg(e),Cg=V(xg),wg=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),Tg=e=>{if(a_.check(e))return[wg(e)];if(Cg.check(e))return e.shape.map(e=>e+``);if(i_.check(e))return[`[+-]?\\d+.?\\d*`];if(o_.check(e))return[`.*`];if(Xg.check(e))return e.shape.map(Tg).flat(1);z()};V(class extends _g{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(Tg).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 Eg=Symbol(`optional`),Dg=class extends _g{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[Eg](){return!0}},Og=V(Dg),kg=class extends _g{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new kg,V(kg);var Ag=class e extends _g{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):jh(this.shape,(n,r)=>{let i=this._isPartial&&!Mh(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},jg=e=>new Ag(e),Mg=V(Ag),Ng=bg(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Pg=class extends _g{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&jh(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)})}},Fg=(e,t)=>new Pg(e,t),Ig=V(Pg),Lg=class extends _g{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&jh(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Rg=(...e)=>new Lg(e);V(Lg);var zg=class extends _g{constructor(e){super(),this.shape=e.length===1?e[0]:new Jg(e)}check(e,t){let n=Yp(e)&&Kp(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Bg=(...e)=>new zg(e),Vg=V(zg),Hg=bg(e=>Yp(e)),Ug=class extends _g{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}},Wg=(e,t=null)=>new Ug(e,t);V(Ug);var Gg=Wg(_g),Kg=V(class extends _g{constructor(e){super(),this.len=e.length-1,this.args=Rg(...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}}),qg=bg(e=>typeof e==`function`);V(class extends _g{constructor(e){super(),this.shape=e}check(e,t){let n=Kp(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Jg=class extends _g{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=qp(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Yg=(...e)=>e.findIndex(e=>Xg.check(e))>=0?Yg(...e.map(e=>p_(e)).map(e=>Xg.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Jg(e),Xg=V(Jg),Zg=()=>!0,Qg=bg(Zg),$g=V(yg,e=>e.shape===Zg),e_=bg(e=>typeof e==`bigint`),t_=bg(e=>e===e_),n_=bg(e=>typeof e==`symbol`);bg(e=>e===n_);var r_=bg(e=>typeof e==`number`),i_=bg(e=>e===r_),a_=bg(e=>typeof e==`string`),o_=bg(e=>e===a_),s_=bg(e=>typeof e==`boolean`),c_=bg(e=>e===s_),l_=Sg(void 0);V(xg,e=>e.shape.length===1&&e.shape[0]===void 0),Sg(void 0);var u_=Sg(null),d_=V(xg,e=>e.shape.length===1&&e.shape[0]===null);V(Uint8Array),V(vg,e=>e.shape===Uint8Array);var f_=Yg(r_,a_,u_,l_,e_,s_,n_);(()=>{let e=Bg(Qg),t=Fg(a_,Qg),n=Yg(r_,a_,u_,s_,e,t);return e.shape=n,t.shape.values=n,n})();var p_=e=>{if(Gg.check(e))return e;if(Ng.check(e)){let t={Line truncated
`;n.right=new J(H(o,U(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new fx(i)),n.right.integrate(e,0),n.forward()}Tb(e,t,n,s)},jb=(e,t,n,r,i)=>{let a=t,o=Lp();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===q){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 q:{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&&Eb(i,n);break}}}t=t.right}return s},Mb=(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===q){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Nb=e=>{let t=0;return W(e.doc,n=>{let r=e._start,i=e._start,a=Lp(),o=Rp(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case q:Eb(o,i.content);break;default:t+=jb(n,r,i,a,o),a=Rp(o),r=i}i=i.right}}),t},Pb=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&&py(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===q&&e.constructor!==Xb&&t.add(e.parent)})}W(n,n=>{q_(e,e.deleteSet,e=>{if(e instanceof Xb||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===q?t.add(r):Mb(n,e)});for(let e of t)Nb(e)})},Fb=(e,t,n)=>{let r=n,i=Rp(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Sx:case ix:case fx:n<t.right.length&&uy(e,H(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&&Jy(o._searchMarker,t.index,-r+n),t},Ib=class extends Ry{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=[];W(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},Ah(o)||(e.attributes=Eh({},o))),c=0}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Sx:case ix: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 fx: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 q:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(xb(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),xb(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;xb(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(xb(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Eb(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}},Lb=class e extends G{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??By(),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 Ib(this,e,t);Yy(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??By();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===fx&&(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)):W(this.doc,n=>{let r=new Sb(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&&Fb(n,r,a.delete):Ab(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??By();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(ny(s,e)||t!==void 0&&ny(s,t))switch(s.content.constructor){case fx:{let r=i.get(`ychange`);e!==void 0&&!ny(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&&!ny(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 Sx:case ix:{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 q:ny(s,e)&&(c(),Eb(i,s.content))}s=s.right}c()};return e||t?W(a,n=>{e&&ry(n,e),t&&ry(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)):W(r,r=>{let i=wb(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||{})):W(r,r=>{let i=wb(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)):W(n,n=>{Fb(n,wb(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)):W(r,r=>{let i=wb(r,this,e,!1);i.right!==null&&Ab(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):W(this.doc,t=>{cb(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):W(this.doc,n=>{lb(n,this,e,t)})}getAttribute(e){return ub(this,e)}getAttributes(){return db(this)}_write(e){e.writeTypeRef(_x)}},Rb=e=>new Lb,zb=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??By()}[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===K||t.constructor===Bb)&&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})}},Bb=class e extends G{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 G?e.clone():e)),t}get length(){return this.doc??By(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new zb(this,e)}querySelector(e){e=e.toUpperCase();let t=new zb(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Gp(new zb(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Yy(this,e,new Ub(this,t,e))}toString(){return eb(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),$y(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):W(this.doc,n=>{ab(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)W(this.doc,n=>{let r=e&&e instanceof G?e._item:e;rb(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 Gm(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):W(this.doc,n=>{sb(n,this,e,t)})}toArray(){return Zy(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return nb(this,e)}slice(e=0,t=this.length){return Xy(this,e,t)}forEach(e){$y(this,e)}_write(e){e.writeTypeRef(yx)}},Vb=e=>new Bb,K=class e extends Bb{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 Oh(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof G?e.Line 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:()=>Aw(this.editor,this.type)}},addInputRules(){return[vp({find:jw,type:this.type})]}}),Nw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Pw=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Fw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Iw=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,Lw=Gf.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 kw(`strong`,{...P(this.options.HTMLAttributes,e),children:kw(`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:Nw,type:this.type}),hp({find:Fw,type:this.type})]},addPasteRules(){return[bp({find:Pw,type:this.type}),bp({find:Iw,type:this.type})]}}),Rw=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},zw=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 Bw(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var Vw=Gf.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,P(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(Bw(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:Rw,type:this.type})]},addPasteRules(){return[bp({find:zw,type:this.type})]}}),Hw=4,Uw=/^```([a-z]+)?[\s\n]$/,Ww=/^~~~([a-z]+)?[\s\n]$/,Gw=yp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Hw,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`,P(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??Hw,{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:()=>nT(this.editor,this.type)}},addInputRules(){return[Mp({find:rT,type:this.type})]}}),aT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,oT=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,sT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,cT=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,lT=ap.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 tT(`strong`,{...I(this.options.HTMLAttributes,e),children:tT(`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[kp({find:aT,type:this.type}),kp({find:sT,type:this.type})]},addPasteRules(){return[Ip({find:oT,type:this.type}),Ip({find:cT,type:this.type})]}}),uT=e=>{let t=/`([^`]+)`(?!`)$/.exec(e);return!t||t.index>0&&e[t.index-1]==="`"?null:{index:t.index,text:t[0],replaceWith:t[1]}},dT=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 fT(e){let t=new Set((e.match(/`+/g)||[]).map(e=>e.length)),n=1;for(;t.has(n);)n+=1;return n}var pT=ap.create({name:`code`,addOptions(){return{HTMLAttributes:{}}},excludes:`_`,code:!0,exitable:!0,parseHTML(){return[{tag:`code`}]},renderHTML({HTMLAttributes:e}){return[`code`,I(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(fT(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[kp({find:uT,type:this.type})]},addPasteRules(){return[Ip({find:dT,type:this.type})]}}),mT=4,hT=/^```([a-z]+)?[\s\n]$/,gT=/^~~~([a-z]+)?[\s\n]$/,_T=Fp.create({name:`codeBlock`,addOptions(){return{languageClassPrefix:`language-`,exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:mT,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`,I(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??mT,{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??Hw,{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??mT,{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(C.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
`),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(E.create(e.doc,p)),!0}):e.commands.command(({tr:e})=>{let{from:i,to:a}=r,o=n.doc.textBetween(i,a,`
`,`
`).split(`
`).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(S.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[_p({find:Uw,type:this.type,getAttributes:e=>({language:e[1]})}),_p({find:Ww,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new T({key:new E(`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(C.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),Kw=yp.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(T.near(r.resolve(o))),!0)):e.commands.exitCode()}}},addInputRules(){return[jp({find:hT,type:this.type,getAttributes:e=>({language:e[1]})}),jp({find:gT,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new O({key:new k(`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(E.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta(`paste`,!0),e.dispatch(a),!0}}})]}}),vT=Fp.create({name:`doc`,topNode:!0,content:`block+`,renderMarkdown:(e,t)=>e.content?t.renderChildren(e.content,`
`):``}),qw=yp.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`,P(this.options.HTMLAttributes,e)]},renderText(){return`
`):``}),yT=Fp.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`,I(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()}}}),Jw=yp.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]}`,P(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=>_p({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),Yw=yp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,P(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!Sf(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return cd(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(C.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(w.create(t.doc,n.pos)):t.setSelection(C.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(C.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[gp({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Xw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Zw=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Qw=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,$w=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,eT=Gf.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`,P(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:Xw,type:this.type}),hp({find:Qw,type:this.type})]},addPasteRules(){return[bp({find:Zw,type:this.type}),bp({find:$w,type:this.type})]}}),tT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,DE=`️`,OE=`‍`,kE=``,AE=null,jE=null;function ME(e=[]){let t={};gT.groups=t;let n=new gT;AE??=IE(tT),jE??=IE(nT),Q(n,`'`,qT),Q(n,`{`,AT),Q(n,`}`,jT),Q(n,`[`,MT),Q(n,`]`,NT),Q(n,`(`,PT),Q(n,`)`,FT),Q(n,`<`,IT),Q(n,`>`,LT),Q(n,`(`,RT),Q(n,`)`,zT),Q(n,`「`,BT),Q(n,`」`,VT),Q(n,`『`,HT),Q(n,`』`,UT),Q(n,`<`,WT),Q(n,`>`,GT),Q(n,`&`,KT),Q(n,`*`,JT),Q(n,`@`,YT),Q(n,"`",ZT),Q(n,`^`,QT),Q(n,`:`,$T),Q(n,`,`,eE),Q(n,`$`,tE),Q(n,`.`,nE),Q(n,`=`,rE),Q(n,`!`,iE),Q(n,`-`,aE),Q(n,`%`,oE),Q(n,`|`,sE),Q(n,`+`,cE),Q(n,`#`,lE),Q(n,`?`,uE),Q(n,`"`,dE),Q(n,`/`,mE),Q(n,`;`,pE),Q(n,`~`,hE),Q(n,`_`,gE),Q(n,`\\`,XT),Q(n,`・`,fE);let r=Z(n,CE,DT,{[rT]:!0});Z(r,CE,r);let i=Z(r,bE,bT,{[oT]:!0}),a=Z(r,xE,xT,{[sT]:!0}),o=Z(n,bE,vT,{[iT]:!0});Z(o,CE,i),Z(o,bE,o),Z(i,CE,i),Z(i,bE,i);let s=Z(n,xE,yT,{[aT]:!0});Z(s,bE),Z(s,CE,a),Z(s,xE,s),Z(a,CE,a),Z(a,bE),Z(a,xE,a);let c=Q(n,EE,kT,{[fT]:!0}),l=Q(n,TE,OT,{[fT]:!0}),u=Z(n,wE,OT,{[fT]:!0});Q(n,kE,u),Q(l,EE,c),Q(l,kE,u),Z(l,wE,u),Q(u,TE),Q(u,EE),Z(u,wE,u),Q(u,kE,u);let d=Z(n,SE,_E,{[lT]:!0});Q(d,`#`),Z(d,SE,d),Q(d,DE,d);let f=Q(d,OE);Q(f,`#`),Z(f,SE,d);let p=[[bE,o],[CE,i]],m=[[bE,null],[xE,s],[CE,a]];for(let e=0;e<AE.length;e++)FE(n,AE[e],CT,vT,p);for(let e=0;e<jE.length;e++)FE(n,jE[e],wT,yT,m);mT(CT,{tld:!0,ascii:!0},t),mT(wT,{utld:!0,alpha:!0},t),FE(n,`file`,TT,vT,p),FE(n,`mailto`,TT,vT,p),FE(n,`http`,ET,vT,p),FE(n,`https`,ET,vT,p),FE(n,`ftp`,ET,vT,p),FE(n,`ftps`,ET,vT,p),mT(TT,{scheme:!0,ascii:!0},t),mT(ET,{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]?{[uT]:!0}:{[dT]:!0};r.indexOf(`-`)>=0?i[cT]=!0:bE.test(r)?CE.test(r)?i[oT]=!0:i[iT]=!0:i[rT]=!0,_T(n,r,r,i)}return _T(n,`localhost`,ST,{ascii:!0}),n.jd=new gT(vE),{start:n,tokens:Object.assign({groups:t},yE)}}function NE(e,t){let n=PE(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 PE(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 FE(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 gT(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new gT(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function IE(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 LE={defaultProtocol:`http`,events:null,format:zE,formatHref:zE,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function RE(e,t=null){let n=Object.assign({},LE);e&&(n=Object.assign(n,e instanceof RE?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()}RE.prototype={o:LE,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]:LE[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 zE(e){return e}function BE(e,t){this.t=`token`,this.v=e,this.tk=t}BE.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=LE.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);return o.href=r,s&&(o.clLine 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()}}}),bT=Fp.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]}`,I(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=>jp({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}}),xT=Fp.create({name:`horizontalRule`,addOptions(){return{HTMLAttributes:{},nextNodeType:`paragraph`}},group:`block`,parseHTML(){return[{tag:`hr`}]},renderHTML({HTMLAttributes:e}){return[`hr`,I(this.options.HTMLAttributes,e)]},markdownTokenName:`hr`,parseMarkdown:(e,t)=>t.createNode(`horizontalRule`),renderMarkdown:()=>`---`,addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{if(!bf(t,t.schema.nodes[this.name]))return!1;let{selection:n}=t,{$to:r}=n,i=e();return od(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(E.create(t.doc,n.pos+1)):n.nodeAfter.isBlock?t.setSelection(D.create(t.doc,n.pos)):t.setSelection(E.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(E.create(t.doc,r+1)))}t.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Ap({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ST=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,CT=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,wT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,TT=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ET=ap.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`,I(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[kp({find:ST,type:this.type}),kp({find:wT,type:this.type})]},addPasteRules(){return[Ip({find:CT,type:this.type}),Ip({find:TT,type:this.type})]}}),DT=`aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zLine truncated
`,$E=`️`,eD=`‍`,tD=``,nD=null,rD=null;function iD(e=[]){let t={};HT.groups=t;let n=new HT;nD??=cD(DT),rD??=cD(OT),Q(n,`'`,yE),Q(n,`{`,nE),Q(n,`}`,rE),Q(n,`[`,iE),Q(n,`]`,aE),Q(n,`(`,oE),Q(n,`)`,sE),Q(n,`<`,cE),Q(n,`>`,lE),Q(n,`(`,uE),Q(n,`)`,dE),Q(n,`「`,fE),Q(n,`」`,pE),Q(n,`『`,mE),Q(n,`』`,hE),Q(n,`<`,gE),Q(n,`>`,_E),Q(n,`&`,vE),Q(n,`*`,bE),Q(n,`@`,xE),Q(n,"`",CE),Q(n,`^`,wE),Q(n,`:`,TE),Q(n,`,`,EE),Q(n,`$`,DE),Q(n,`.`,OE),Q(n,`=`,kE),Q(n,`!`,AE),Q(n,`-`,jE),Q(n,`%`,ME),Q(n,`|`,NE),Q(n,`+`,PE),Q(n,`#`,FE),Q(n,`?`,IE),Q(n,`"`,LE),Q(n,`/`,BE),Q(n,`;`,zE),Q(n,`~`,VE),Q(n,`_`,HE),Q(n,`\\`,SE),Q(n,`・`,RE);let r=Z(n,YE,$T,{[kT]:!0});Z(r,YE,r);let i=Z(r,KE,KT,{[MT]:!0}),a=Z(r,qE,qT,{[NT]:!0}),o=Z(n,KE,WT,{[AT]:!0});Z(o,YE,i),Z(o,KE,o),Z(i,YE,i),Z(i,KE,i);let s=Z(n,qE,GT,{[jT]:!0});Z(s,KE),Z(s,YE,a),Z(s,qE,s),Z(a,YE,a),Z(a,KE),Z(a,qE,a);let c=Q(n,QE,tE,{[RT]:!0}),l=Q(n,ZE,eE,{[RT]:!0}),u=Z(n,XE,eE,{[RT]:!0});Q(n,tD,u),Q(l,QE,c),Q(l,tD,u),Z(l,XE,u),Q(u,ZE),Q(u,QE),Z(u,XE,u),Q(u,tD,u);let d=Z(n,JE,UE,{[FT]:!0});Q(d,`#`),Z(d,JE,d),Q(d,$E,d);let f=Q(d,eD);Q(f,`#`),Z(f,JE,d);let p=[[KE,o],[YE,i]],m=[[KE,null],[qE,s],[YE,a]];for(let e=0;e<nD.length;e++)sD(n,nD[e],YT,WT,p);for(let e=0;e<rD.length;e++)sD(n,rD[e],XT,GT,m);BT(YT,{tld:!0,ascii:!0},t),BT(XT,{utld:!0,alpha:!0},t),sD(n,`file`,ZT,WT,p),sD(n,`mailto`,ZT,WT,p),sD(n,`http`,QT,WT,p),sD(n,`https`,QT,WT,p),sD(n,`ftp`,QT,WT,p),sD(n,`ftps`,QT,WT,p),BT(ZT,{scheme:!0,ascii:!0},t),BT(QT,{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]?{[IT]:!0}:{[LT]:!0};r.indexOf(`-`)>=0?i[PT]=!0:KE.test(r)?YE.test(r)?i[MT]=!0:i[AT]=!0:i[kT]=!0,UT(n,r,r,i)}return UT(n,`localhost`,JT,{ascii:!0}),n.jd=new HT(WE),{start:n,tokens:Object.assign({groups:t},GE)}}function aD(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 sD(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 HT(r),a.jr=i.slice(),e.j[o]=a),e=a}return a=new HT(n),a.jr=i.slice(),e.j[t[o-1]]=a,a}function cD(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 lD={defaultProtocol:`http`,events:null,format:dD,formatHref:dD,nl2br:!1,tagName:`a`,target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function uD(e,t=null){let n=Object.assign({},lD);e&&(n=Object.assign(n,e instanceof uD?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()}uD.prototype={o:lD,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]:lD[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 dD(e){return e}function fD(e,t){this.t=`token`,this.v=e,this.tk=t}fD.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=lD.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);return o.href=r,s&&(o.clLine truncated
1. Must only contain digits, lowercase ASCII letters or "-"
2. Cannot start or end with "-"
3. "-" cannot repeat`);$.customSchemes.push([e,t])}function eD(){$.scanner=ME($.customSchemes);for(let e=0;e<$.tokenQueue.length;e++)$.tokenQueue[e][1]({scanner:$.scanner});$.parser=qE($.scanner.tokens);for(let e=0;e<$.pluginQueue.length;e++)$.pluginQueue[e][1]({scanner:$.scanner,parser:$.parser});return $.initialized=!0,$}function tD(e){return $.initialized||eD(),JE($.parser.start,e,NE($.scanner.start,e))}tD.scan=NE;function nD(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 RE(n),i=tD(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 rD=`[\0- \xA0 ᠎ -\u2029  ]`,iD=new RegExp(rD),aD=RegExp(`${rD}$`),oD=RegExp(`${rD}+$`),sD=new RegExp(rD,`g`);function cD(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(oD)?.[0];if(!i)return;let a=t.to-i.length,o=Yu(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 lD(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function uD(e){return new T({key:new E(`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=fu(n.doc,[...t]);if(!t.some(Kc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof Ot)||!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=>cD(o,t,e.type))}if(Ju(s).forEach(({newRange:t})=>{let n=pu(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(!aD.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(iD).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=tD(n).map(t=>t.toObject(e.defaultProtocol));if(!lD(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=>{Yu(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 dD(e){return new T({key:new E(`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=Gu(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 fD=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,pD=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function mD(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function hD(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&mD(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 gD(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||mD(e,t.index??0)||hD(e,t.index??0)?!1:!!r.trim()&&n(i)}function _D(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 vD(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function yD(e){return{href:e.data?.href,title:e.data?.title??null}}function bD(e){let t=hp({find:t=>{let n=fD.exec(t);return!n||!gD(t,n,e.isAllowedHref)?null:_D(n)},type:e.type,getAttributes:yD});return new Lf({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 xD(e){let t=bp({find:t=>{let n=[];for(let r of t.matchAll(pD))gD(t,r,e.isAllowedHref)&&n.push(_D(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>vD(t,e)));return[...n,...r]},type:e.type,getAttributes:yD});return new Kf({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 SD(e){return new T({key:new E(`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=nD(c,{defaultProtocol: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(TD,this.editor.getAttributes(ED)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=vp({find:DD,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=vp({find:DD,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ED),editor:this.editor})),[e]}}),kD=(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}},AD=(e,t,n,r)=>{let i=kD(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},jD=(e,t,n)=>AD(e.state,e.view.dispatch,t,n),MD=(e,t)=>F.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>jD(this.editor,e,t);return{Delete:n,"Mod-Delete":n}}}),ND=[[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`]],PD=`abcdefghijklmnopqrstuvwxyz`,FD=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function ID(e){let t=e,n=``;for(let[e,r]of ND)for(;t>=e;)n+=r,t-=e;return n}function LD(e){return ID(e).toUpperCase()}function RD(e){let t=e.toLowerCase(),n=0,r=0;for(;n<t.length;){let e=!1;for(let[i,a]of ND)if(t.startsWith(a,n)){r+=i,n+=a.length,e=!0;break}if(!e)return 0}return r}function zD(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=RD(e);return t<=0?!1:(e===e.toLowerCase()?ID(t):LD(t))===e}function BD(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 VD(e){if(e<=26)return PD[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?PD[n]:PD[t]+PD[n]}function HD(e){if(e&&!/^\d+$/.test(e)){if(zD(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 UD(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=HD(e);if(t===`i`||t===`I`)return RD(e);if(t===`a`||t===`A`){let t=BD(e);return t>0?t:1}let n=parseInt(e,10);return Number.isNaN(n)?1:n}function WD(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return VD(t);case`A`:return VD(t).toUpperCase();case`i`:return ID(t);case`I`:return LD(t);default:return String(t)}}function GD(e){if(e.length===0)return!1;let t=HD(e[0])??`numeric`,n=UD(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=WD(t,n+r);if(e[r]!==i)return!1}return!0}function KD(e){return{type:HD(e),start:UD(e)}}function qD(e){let{type:t,start:n}=KD(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function JD(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${VD(r)}${n}`;case`A`:return`${VD(r).toUpperCase()}${n}`;case`i`:return`${ID(r)}${n}`;case`I`:return`${LD(r)}${n}`;default:return`${r}${n}`}}function YD(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function XD(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var ZD=`&nbsp;`,QD=1,$D=e=>(e?.level??QD)>QD;function eO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function tO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var nO=yp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,P(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(eO(e))return{type:`listItem`,content:[{type:`paragraph`,content:tO(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`);$.customSchemes.push([e,t])}function ED(){$.scanner=iD($.customSchemes);for(let e=0;e<$.tokenQueue.length;e++)$.tokenQueue[e][1]({scanner:$.scanner});$.parser=yD($.scanner.tokens);for(let e=0;e<$.pluginQueue.length;e++)$.pluginQueue[e][1]({scanner:$.scanner,parser:$.parser});return $.initialized=!0,$}function DD(e){return $.initialized||ED(),bD($.parser.start,e,aD($.scanner.start,e))}DD.scan=aD;function OD(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 uD(n),i=DD(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 kD=`[\0- \xA0 ᠎ -\u2029  ]`,AD=new RegExp(kD),jD=RegExp(`${kD}$`),MD=RegExp(`${kD}+$`),ND=new RegExp(kD,`g`);function PD(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(MD)?.[0];if(!i)return;let a=t.to-i.length,o=qu(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 FD(e){return e.length===1?e[0].isLink:e.length===3&&e[1].isLink?[`()`,`[]`].includes(e[0].value+e[2].value):!1}function ID(e){return new O({key:new k(`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=uu(n.doc,[...t]);if(!t.some(Wc)){let t=[];s.steps.forEach((e,n)=>{if(!(e instanceof Tt)||!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=>PD(o,t,e.type))}if(Ku(s).forEach(({newRange:t})=>{let n=du(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(!jD.test(e))return;i=n[0],a=r.doc.textBetween(i.pos,t.to,void 0,` `)}if(i&&a){let t=a.split(AD).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=DD(n).map(t=>t.toObject(e.defaultProtocol));if(!FD(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=>{qu(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 LD(e){return new O({key:new k(`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=Uu(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 RD=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,zD=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function BD(e,t){let n=0;for(let r=t-1;r>=0&&e[r]===`\\`;--r)n+=1;return n%2==1}function VD(e,t){let n=0,r=0;for(;r<t;){if(e[r]!=="`"||n===0&&BD(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 HD(e,t,n){let[,r,i]=t;return(t.index?e[t.index-1]:void 0)===`!`||BD(e,t.index??0)||VD(e,t.index??0)?!1:!!r.trim()&&n(i)}function UD(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 WD(e,t){return e.index<t.index+t.text.length&&t.index<e.index+e.text.length}function GD(e){return{href:e.data?.href,title:e.data?.title??null}}function KD(e){let t=kp({find:t=>{let n=RD.exec(t);return!n||!HD(t,n,e.isAllowedHref)?null:UD(n)},type:e.type,getAttributes:GD});return new Zf({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 qD(e){let t=Ip({find:t=>{let n=[];for(let r of t.matchAll(zD))HD(t,r,e.isAllowedHref)&&n.push(UD(r));let r=(e.findPlainUrls?.call(e,t)??[]).filter(e=>!n.some(t=>WD(t,e)));return[...n,...r]},type:e.type,getAttributes:GD});return new op({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 JD(e){return new O({key:new k(`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=OD(c,{defaultProtocol: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(ZD,this.editor.getAttributes(QD)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=Mp({find:$D,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Mp({find:$D,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(QD),editor:this.editor})),[e]}}),tO=(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}},nO=(e,t,n,r)=>{let i=tO(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},rO=(e,t,n)=>nO(e.state,e.view.dispatch,t,n),iO=(e,t)=>L.create({name:`${e}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){let n=()=>rO(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`]],oO=`abcdefghijklmnopqrstuvwxyz`,sO=String.raw`\d+|[ivxlcdmIVXLCDM]+|${`[a-zA-Z]{1,2}`}`;function cO(e){let t=e,n=``;for(let[e,r]of aO)for(;t>=e;)n+=r,t-=e;return n}function lO(e){return cO(e).toUpperCase()}function uO(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 dO(e){if(!/^[ivxlcdmIVXLCDM]+$/.test(e))return!1;let t=uO(e);return t<=0?!1:(e===e.toLowerCase()?cO(t):lO(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 pO(e){if(e<=26)return oO[e-1];let t=Math.floor((e-1)/26)-1,n=(e-1)%26;return t<0?oO[n]:oO[t]+oO[n]}function mO(e){if(e&&!/^\d+$/.test(e)){if(dO(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 hO(e){if(/^\d+$/.test(e))return parseInt(e,10);let t=mO(e);if(t===`i`||t===`I`)return uO(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 gO(e,t){if(e===`numeric`)return String(t);switch(e){case`a`:return pO(t);case`A`:return pO(t).toUpperCase();case`i`:return cO(t);case`I`:return lO(t);default:return String(t)}}function _O(e){if(e.length===0)return!1;let t=mO(e[0])??`numeric`,n=hO(e[0]);if(n<1)return!1;for(let r=0;r<e.length;r++){let i=gO(t,n+r);if(e[r]!==i)return!1}return!0}function vO(e){return{type:mO(e),start:hO(e)}}function yO(e){let{type:t,start:n}=vO(e),r={};return t&&(r.type=t),n!==1&&(r.start=n),r}function bO(e,t,n=`. `){let r=t+1;if(!e||e===`1`)return`${r}${n}`;switch(e){case`a`:return`${pO(r)}${n}`;case`A`:return`${pO(r).toUpperCase()}${n}`;case`i`:return`${cO(r)}${n}`;case`I`:return`${lO(r)}${n}`;default:return`${r}${n}`}}function xO(e){return!e[0]||e[0].type===`paragraph`?e:[{type:`paragraph`,content:[]},...e]}function SO(e){let t=e.content?.[0];return t?.type===`paragraph`&&!t.content?.length}var CO=`&nbsp;`,wO=1,TO=e=>(e?.level??wO)>wO;function EO(e){let t=e.tokens?.[0];return!!(e.text&&e.tokens?.length===1&&t?.type===`list`&&t.ordered&&t.raw===e.text)}function DO(e,t){return t.tokenizeInline?t.parseInline(t.tokenizeInline(e)):t.parseInline([{type:`text`,raw:e,text:e}])}var OO=Fp.create({name:`listItem`,addOptions(){return{HTMLAttributes:{},bulletListTypeName:`bulletList`,orderedListTypeName:`orderedList`}},content:`paragraph block*`,defining:!0,parseHTML(){return[{tag:`li`}]},renderHTML({HTMLAttributes:e}){return[`li`,I(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(EO(e))return{type:`listItem`,content:[{type:`paragraph`,content:DO(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 bO=RegExp(`^(${FD})([.)])\\s+(.+)$`);function xO(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(bO);if(!t)return null;n.push({marker:t[1],content:t[3]})}return GD(n.map(e=>e.marker))?{type:`orderedList`,attrs:qD(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function SO(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=vO(a.contentLines),c=o.join(`
`)}),r=h,n=h}return[t,r]}var KO=RegExp(`^(${sO})([.)])\\s+(.+)$`);function qO(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(KO);if(!t)return null;n.push({marker:t[1],content:t[3]})}return _O(n.map(e=>e.marker))?{type:`orderedList`,attrs:yO(n[0].marker),content:n.map(e=>({type:`listItem`,content:[{type:`paragraph`,content:[{type:`text`,text:e.content}]}]}))}:null}function JO(e,t,n){let r=[],i=0;for(;i<e.length;){let a=e[i];if(a.indent===t){let{paragraphLines:o,blockLines:s}=WO(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=SO(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 CO(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 wO=64;function TO(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 EO(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!fO.test(n))return[[],0,[]];let r=wO,i=TO(e,r),a=yO(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=TO(e,r),a=yO(i);return[a[0],a[1],i]}var DO=`listItem`,OO=`textStyle`,kO=/^(\d+)\.\s$/;function AO(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 jO=yp.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=AO(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=AO(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=P(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?CO(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]=EO(e);if(r.length===0)return;let o=SO(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(DO,this.editor.getAttributes(OO)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new T({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=xO(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=vp({find:kO,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=vp({find:kO,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(OO)}),joinPredicate:e,editor:this.editor})),[t]}}),MO=/^\s*(\[([( |x])?\])\s$/,NO=`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0`,PO=(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`}`},FO=yp.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`,P(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)=>Pf(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[MD(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=NO;let l=e=>{let t=PO(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=Mu(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[vp({find:MO,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),IO=yp.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=jf(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=jf(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()}}});F.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(OD.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(nO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(dO.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(jO.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(FO.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(IO.configure(this.options.taskList)),e}});var LO=`&nbsp;`,RO=`\xA0`,zO=yp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,P(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===LO||n[0].text===LO||n[0].raw===RO||n[0].text===RO)&&r.length===1&&r[0].type===`text`&&(r[0].text===LO||r[0].text===RO)?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?LO:``}return t.renderChildren(r)},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),BO=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,VO=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,HO=Gf.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`,P(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:BO,type:this.type})]},addPasteRules(){return[bp({find:VO,type:this.type})]}}),UO=yp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),WO=Gf.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`,P(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),toggleULine 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=JO(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 YO(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 XO=64;function ZO(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 QO(e){let t=e.indexOf(`
`),n=t===-1?e:e.slice(0,t);if(!RO.test(n))return[[],0,[]];let r=XO,i=ZO(e,r),a=GO(i);for(;a[1]===i.length&&i.length===r;)r*=2,i=ZO(e,r),a=GO(i);return[a[0],a[1],i]}var $O=`listItem`,ek=`textStyle`,tk=/^(\d+)\.\s$/;function nk(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 rk=Fp.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=nk(n);if(e)return e}let r=e.querySelector(`li`);if(r){let e=r.getAttribute(`style`);if(e){let t=nk(e);if(t)return t}}return null}}}},parseHTML(){return[{tag:`ol`}]},renderHTML({HTMLAttributes:e}){let{start:t,type:n,...r}=e,i=I(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?YO(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]=QO(e);if(r.length===0)return;let o=JO(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($O,this.editor.getAttributes(ek)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new O({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=qO(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=Mp({find:tk,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:e});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Mp({find:tk,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ek)}),joinPredicate:e,editor:this.editor})),[t]}}),ik=/^\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`,ok=(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`}`},sk=Fp.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`,I(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)=>Jf(e,t,`- [${e.attrs?.checked?`x`:` `}] `,void 0,{indentMainContent:!0}),addExtensions(){return this.options.nested?[iO(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=ok(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=Au(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[Mp({find:ik,type:this.type,getAttributes:e=>({checked:e[e.length-1]===`x`})})]}}),ck=Fp.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=Gf(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=Gf(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()}}});L.create({name:`listKit`,addExtensions(){let e=[];return this.options.bulletList!==!1&&e.push(eO.configure(this.options.bulletList)),this.options.listItem!==!1&&e.push(OO.configure(this.options.listItem)),this.options.listKeymap!==!1&&e.push(LO.configure(this.options.listKeymap)),this.options.orderedList!==!1&&e.push(rk.configure(this.options.orderedList)),this.options.taskItem!==!1&&e.push(sk.configure(this.options.taskItem)),this.options.taskList!==!1&&e.push(ck.configure(this.options.taskList)),e}});var lk=`&nbsp;`,uk=`\xA0`,dk=Fp.create({name:`paragraph`,priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:`block`,content:`inline*`,parseHTML(){return[{tag:`p`}]},renderHTML({HTMLAttributes:e}){return[`p`,I(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===lk||n[0].text===lk||n[0].raw===uk||n[0].text===uk)&&r.length===1&&r[0].type===`text`&&(r[0].text===lk||r[0].text===uk)?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?lk:``}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+~~))$/,pk=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,mk=ap.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`,I(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[kp({find:fk,type:this.type})]},addPasteRules(){return[Ip({find:pk,type:this.type})]}}),hk=Fp.create({name:`text`,group:`inline`,parseMarkdown:e=>({type:`text`,text:e.text||``}),renderMarkdown:e=>e.text||``}),gk=ap.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`,I(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),toggleULine truncated
`);return/\s/.test(n)}):!1}function bj(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 xj(e,t,n,r){return n?()=>{let n=r.getState(e.state)?.decorationId;return t.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:bj(e)}function Sj({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&&!yj(r)}function Cj({view:e,pluginKeyRef:t}){let n=e.state.tr.setMeta(t,{exit:!0});e.dispatch(n)}function wj({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),M.create(a.doc,[hs.inline(s.from,s.to,{nodeName:t,class:d.join(` `),"data-decoration-id":c||void 0,"data-decoration-content":r})])}}}function Tj({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 Ej({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 Dj({placement:e,offset:t,flip:n,floatingUi:r}){var i;let a=[mj({mainAxis:t.mainAxis??4,crossAxis:t.crossAxis??0})];return n&&a.push(gj()),r!=null&&(i=r.middleware)!=null&&i.length&&a.push(...r.middleware),{placement:e,strategy:r?.strategy??`absolute`,middleware:a}}function Oj(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 kj({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&&Oj(r).appendChild(o),s.onPosition||(o.style.visibility=`hidden`,o.style.width=`max-content`);let d=pj(c,o,()=>{_j(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 Aj({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,_=Ej({editor:e,items:n}),v=Dj({placeLine 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-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}}}@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;--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--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-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-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-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;colLine 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-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}}}@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;--spacing:.25rem;--font-weight-normal:400;--font-weight-medium:500;--font-weight-semibold:600;--radius-xs:4px;--radius-sm:6px;--radius-md:10px;--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-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-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-setLine truncated
/*$vite$:1*/</style>
</head>
<body>
+2
View File
@@ -12,6 +12,8 @@
"./editor.css": "./src/editor.css"
},
"dependencies": {
"@docwell/ui": "*",
"@floating-ui/dom": "^1.8.0",
"@tiptap/core": "^3.32.2",
"@tiptap/extension-bubble-menu": "^3.32.2",
"@tiptap/extension-collaboration": "^3.32.2",
+109 -4
View File
@@ -1,10 +1,14 @@
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<script setup lang="ts">
import type { JSONContent } from "@tiptap/core";
import type { Editor, JSONContent } from "@tiptap/core";
import { EditorContent, useEditor } from "@tiptap/vue-3";
import { onBeforeUnmount, watch } from "vue";
import { BubbleMenu } from "@tiptap/vue-3/menus";
import { DwIcon, type IconName } from "@docwell/ui";
import { computed, onBeforeUnmount, watch } from "vue";
import { docwellExtensions, type CollabUser } from "./extensions";
import type { FileHost } from "./files";
import { englishLabels, type EditorLabels } from "./labels";
import type { MentionHost } from "./mention";
import type { CollabProvider } from "./provider";
const props = withDefaults(
@@ -16,10 +20,24 @@ const props = withDefaults(
provider?: CollabProvider;
user?: CollabUser;
files?: FileHost;
mentions?: MentionHost;
labels?: EditorLabels;
/** Shows the Comment button on selections, also when the editor is read-only. */
canComment?: boolean;
}>(),
{ editable: true },
);
const emit = defineEmits<{ update: [content: JSONContent]; blur: []; error: [err: unknown] }>();
const emit = defineEmits<{
update: [content: JSONContent];
blur: [];
error: [err: unknown];
/** The user asked to comment on the selected range. */
comment: [selection: { from: number; to: number; text: string }];
/** Highlighted comment text was clicked. */
"comment-select": [id: string];
}>();
const labels = computed(() => props.labels ?? englishLabels);
const editor = useEditor({
content: props.provider ? undefined : props.content,
@@ -28,6 +46,9 @@ const editor = useEditor({
placeholder: props.placeholder,
collab: props.provider ? { provider: props.provider, user: props.user ?? { name: "?", color: "#888" } } : undefined,
files: props.files,
mentions: props.mentions,
labels: props.labels,
onCommentSelect: (id) => emit("comment-select", id),
onError: (e) => emit("error", e),
}),
editorProps: { attributes: { class: "dw-prose" } },
@@ -42,9 +63,93 @@ watch(
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 };
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 => ({
id,
icon,
label,
active: () => e.isActive(id),
run: () => e.chain().focus().toggleMark(id).run(),
});
return [
mark("bold", "bold", f.bold),
mark("italic", "italic", f.italic),
mark("strike", "strike", f.strike),
mark("code", "code", f.code),
{
id: "link",
icon: "link",
label: f.link,
active: () => e.isActive("link"),
run: () => {
const href = window.prompt(f.linkPrompt, (e.getAttributes("link").href as string | undefined) ?? "https://");
if (href === null) return;
const chain = e.chain().focus().extendMarkRange("link");
if (!href.trim() || href.trim() === "https://") chain.unsetLink().run();
else chain.setLink({ href: href.trim() }).run();
},
},
];
});
function comment() {
const e = editor.value;
if (!e) return;
const { from, to } = e.state.selection;
emit("comment", { from, to, text: e.state.doc.textBetween(from, to, " ").slice(0, 500) });
}
// Shown for a text selection; read-only editors only show it for commenting.
function shouldShow({ editor: e, from, to }: { editor: Editor; from: number; to: number }) {
if (from === to || e.isActive("codeBlock") || e.isActive("image") || e.isActive("fileAttachment")) return false;
return e.isEditable || props.canComment;
}
defineExpose({ editor });
</script>
<template>
<EditorContent :editor="editor" />
<div>
<BubbleMenu
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"
data-testid="bubble-menu"
>
<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-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>
</BubbleMenu>
<EditorContent :editor="editor" />
</div>
</template>
+138
View File
@@ -0,0 +1,138 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { Extension, type Editor } from "@tiptap/core";
import { Plugin, PluginKey, type EditorState } from "@tiptap/pm/state";
import { Decoration, DecorationSet } from "@tiptap/pm/view";
import {
absolutePositionToRelativePosition,
relativePositionToAbsolutePosition,
ySyncPluginKey,
} from "@tiptap/y-tiptap";
import { fromBase64, toBase64 } from "lib0/buffer";
import * as Y from "yjs";
/**
* Where a comment points: Yjs relative positions of the range's ends, which
* keep pointing at the same text while people edit around it. Only editors
* on a shared (collaborative) document can make or read them.
*/
export interface CommentAnchor {
from: string;
to: string;
}
/** A comment to highlight: its id and anchor (null anchors are not drawn). */
export interface CommentMark {
id: string;
anchor: CommentAnchor | null;
}
type SyncState = {
type: Y.XmlFragment;
doc: Y.Doc;
binding: { mapping: Parameters<typeof absolutePositionToRelativePosition>[2] };
};
function sync(state: EditorState): SyncState | null {
const s = ySyncPluginKey.getState(state) as Partial<SyncState> | undefined;
return s?.type && s.binding && s.doc ? (s as SyncState) : null;
}
/** Encodes the range from–to of the editor's document. */
export function encodeAnchor(editor: Editor, from: number, to: number): CommentAnchor | null {
const s = sync(editor.state);
if (!s) return null;
const rel = (pos: number) =>
toBase64(Y.encodeRelativePosition(absolutePositionToRelativePosition(pos, s.type, s.binding.mapping)));
return { from: rel(from), to: rel(to) };
}
/**
* The range an anchor points at in state's document, or null when its text
* was deleted. The Yjs document must already contain state's changes.
*/
export function decodeAnchor(state: EditorState, anchor: CommentAnchor | null): { from: number; to: number } | null {
const s = sync(state);
if (!s || !anchor?.from || !anchor.to) return null;
try {
const abs = (b64: string) =>
relativePositionToAbsolutePosition(s.doc, s.type, Y.decodeRelativePosition(fromBase64(b64)), s.binding.mapping);
const from = abs(anchor.from);
const to = abs(anchor.to);
if (from === null || to === null || to <= from || to > state.doc.content.size) return null;
return { from, to };
} catch {
return null;
}
}
type Highlights = { marks: CommentMark[]; active: string; decos: DecorationSet };
const key = new PluginKey<Highlights>("docwellComments");
/** Replaces the highlighted comments (and which one is active). */
export function setCommentMarks(editor: Editor, marks: CommentMark[], active = "") {
editor.view.dispatch(editor.state.tr.setMeta(key, { marks, active }));
}
function draw(state: EditorState, marks: CommentMark[], active: string): DecorationSet {
const decos: Decoration[] = [];
for (const m of marks) {
const range = decodeAnchor(state, m.anchor);
if (!range) continue;
decos.push(
Decoration.inline(range.from, range.to, {
class: m.id === active ? "dw-comment is-active" : "dw-comment",
"data-comment": m.id,
}),
);
}
return DecorationSet.create(state.doc, decos);
}
/**
* Highlights commented text. Clicking a highlight calls onSelect with the
* comment's id, so the host can scroll its comment list to it.
*
* Anchors are resolved through Yjs only when the comments change or a remote
* edit arrives; a local edit reaches the Yjs document after the transaction,
* so for those the highlights are mapped through the edit instead.
*/
export const CommentHighlights = Extension.create<{ onSelect?: (id: string) => void }>({
name: "commentHighlights",
addOptions() {
return { onSelect: undefined };
},
addProseMirrorPlugins() {
const onSelect = () => this.options.onSelect;
return [
new Plugin<Highlights>({
key,
state: {
init: () => ({ marks: [], active: "", decos: DecorationSet.empty }),
apply(tr, value, _old, state) {
const set = tr.getMeta(key) as { marks: CommentMark[]; active: string } | undefined;
if (set) return { ...set, decos: draw(state, set.marks, set.active) };
if (!tr.docChanged || !value.marks.length) return value;
const remote = (tr.getMeta(ySyncPluginKey) as { isChangeOrigin?: boolean } | undefined)?.isChangeOrigin;
return {
...value,
decos: remote ? draw(state, value.marks, value.active) : value.decos.map(tr.mapping, tr.doc),
};
},
},
props: {
decorations: (state) => key.getState(state)?.decos ?? DecorationSet.empty,
handleClick(_view, _pos, event) {
const id = (event.target as HTMLElement | null)?.closest?.("[data-comment]")?.getAttribute("data-comment");
if (!id) return false;
onSelect()?.(id);
return false;
},
},
}),
];
},
});
+89
View File
@@ -149,3 +149,92 @@
white-space: nowrap;
user-select: none;
}
/* "@" mentions. */
.dw-prose .dw-mention {
border-radius: var(--radius-xs);
background: var(--color-accent-soft);
padding: 0 0.15em;
font-weight: 500;
white-space: nowrap;
}
/* Commented text; the active comment's text stands out more. */
.dw-prose .dw-comment {
background: color-mix(in srgb, var(--color-warning-soft) 70%, transparent);
border-bottom: 2px solid color-mix(in srgb, var(--color-warning) 55%, transparent);
cursor: pointer;
}
.dw-prose .dw-comment.is-active {
background: var(--color-warning-soft);
border-bottom-color: var(--color-warning);
}
/* The "/" and "@" popups (suggestion.ts): the design system's slash menu,
drawn without a framework so every host can show it. */
.dw-suggest {
position: fixed;
z-index: 60;
left: 0;
top: 0;
width: 20rem;
max-width: calc(100vw - 16px);
max-height: 22rem;
overflow-y: auto;
padding: 4px;
border: 1px solid var(--color-line);
border-radius: var(--radius-md);
background: var(--color-surface-raised);
box-shadow: var(--dw-shadow-menu);
font-family: var(--font-sans);
}
.dw-suggest__query {
padding: 8px 8px 4px;
font-family: var(--font-mono);
font-size: var(--text-ui-xs);
color: var(--color-ink-muted);
}
.dw-suggest__empty {
padding: 6px 8px;
font-size: var(--text-ui-sm);
color: var(--color-ink-muted);
}
.dw-suggest__item {
display: flex;
align-items: center;
gap: 12px;
padding: 6px 8px;
border-radius: var(--radius-sm);
cursor: pointer;
}
.dw-suggest__item.is-active {
background: var(--color-surface-hover);
}
.dw-suggest__icon {
display: grid;
place-items: center;
flex-shrink: 0;
width: 36px;
height: 36px;
border: 1px solid var(--color-line);
border-radius: var(--radius-sm);
background: var(--color-surface);
color: var(--color-ink-muted);
}
.dw-suggest__text {
display: flex;
flex-direction: column;
min-width: 0;
}
.dw-suggest__label {
font-size: var(--text-ui-md);
font-weight: 500;
color: var(--color-ink);
}
.dw-suggest__desc {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--text-ui-xs);
color: var(--color-ink-muted);
}
+13
View File
@@ -5,7 +5,11 @@ import Collaboration from "@tiptap/extension-collaboration";
import CollaborationCaret from "@tiptap/extension-collaboration-caret";
import { Placeholder } from "@tiptap/extensions";
import StarterKit from "@tiptap/starter-kit";
import { CommentHighlights } from "./comments";
import { DocwellImage, FileAttachment, FileDrop, type FileHost } from "./files";
import { englishLabels, type EditorLabels } from "./labels";
import { docwellMention, type MentionHost } from "./mention";
import { SlashMenu, slashCommands } from "./slash";
import type { CollabProvider } from "./provider";
export interface CollabUser {
@@ -19,6 +23,11 @@ export interface ExtensionOptions {
collab?: { provider: CollabProvider; user: CollabUser };
/** Loads and uploads attachments; without it images use their src as is. */
files?: FileHost;
/** Finds people for "@" mentions. */
mentions?: MentionHost;
labels?: EditorLabels;
/** Clicking highlighted comment text calls this with the comment id. */
onCommentSelect?: (id: string) => void;
onError?: (e: unknown) => void;
}
@@ -27,6 +36,7 @@ export interface ExtensionOptions {
* must build its editor from this list so documents stay compatible.
*/
export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
const labels = opts.labels ?? englishLabels;
const list: AnyExtension[] = [
StarterKit.configure({
heading: { levels: [1, 2, 3] },
@@ -38,6 +48,9 @@ export function docwellExtensions(opts: ExtensionOptions = {}): AnyExtension[] {
DocwellImage.configure({ host: opts.files }),
FileAttachment.configure({ host: opts.files }),
FileDrop.configure({ host: opts.files, onError: opts.onError }),
docwellMention(labels, opts.mentions),
SlashMenu.configure({ commands: slashCommands(labels, opts.files, opts.onError), labels }),
CommentHighlights.configure({ onSelect: opts.onCommentSelect }),
];
if (opts.collab) {
list.push(
+4
View File
@@ -3,5 +3,9 @@
export { default as DocwellEditor } from "./DocwellEditor.vue";
export type { JSONContent } from "@tiptap/core";
export { docwellExtensions, userColor, type CollabUser, type ExtensionOptions } from "./extensions";
export { decodeAnchor, encodeAnchor, setCommentMarks, type CommentAnchor, type CommentMark } from "./comments";
export { englishLabels, type EditorLabels } from "./labels";
export type { MentionHost, Person } from "./mention";
export { filterCommands, slashCommands, type SlashCommand } from "./slash";
export { insertFiles, type FileHost, type UploadedFile } from "./files";
export { CollabProvider, type CollabProviderOptions, type CollabStatus } from "./provider";
+51
View File
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* The editor's own words (menus, buttons). The editor has no i18n of its own:
* hosts pass translated labels, and English is the default.
*/
export interface EditorLabels {
slashMenu: string;
noMatches: string;
slash: Record<string, { label: string; description: string }>;
format: {
bold: string;
italic: string;
strike: string;
code: string;
link: string;
linkPrompt: string;
comment: string;
};
mentions: string;
noPeople: string;
}
export const englishLabels: EditorLabels = {
slashMenu: "Insert block",
noMatches: "No matching blocks",
slash: {
text: { label: "Text", description: "Plain paragraph" },
h1: { label: "Heading 1", description: "Big section heading" },
h2: { label: "Heading 2", description: "Medium section heading" },
h3: { label: "Heading 3", description: "Small section heading" },
bullet: { label: "Bulleted list", description: "A simple list" },
ordered: { label: "Numbered list", description: "A list with numbers" },
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" },
image: { label: "Image", description: "Upload a picture" },
file: { label: "File", description: "Attach a file to download" },
},
format: {
bold: "Bold",
italic: "Italic",
strike: "Strikethrough",
code: "Inline code",
link: "Link",
linkPrompt: "Link address (leave empty to remove the link)",
comment: "Comment",
},
mentions: "Mention someone",
noPeople: "Nobody found",
};
+40
View File
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import Mention from "@tiptap/extension-mention";
import type { EditorLabels } from "./labels";
import { floatingList } from "./suggestion";
/** A person who can be mentioned. */
export interface Person {
id: string;
label: string;
/** Shown under the name, e.g. the email address. */
hint?: string;
}
/** Finds people for "@" mentions; without one, typing "@" does nothing special. */
export interface MentionHost {
search(query: string): Promise<Person[]>;
}
/**
* "@" mentions. The node is always part of the schema so documents with
* mentions open everywhere; only editors with a host get the people picker.
*/
export function docwellMention(labels: EditorLabels, host?: MentionHost) {
return Mention.configure({
HTMLAttributes: { class: "dw-mention" },
renderText: ({ node }) => `@${node.attrs.label ?? node.attrs.id}`,
suggestion: {
char: "@",
allow: () => !!host,
items: async ({ query }) => (host ? (await host.search(query).catch(() => [])).slice(0, 8) : []),
render: floatingList<Person>({
label: labels.mentions,
empty: labels.noPeople,
toItem: (p) => ({ label: p.label, description: p.hint, icon: "at" }),
pick: (props, p) => props.command({ id: p.id, label: p.label }),
}),
},
});
}
+127
View File
@@ -0,0 +1,127 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
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 { insertFiles, type FileHost } from "./files";
import type { EditorLabels } from "./labels";
import { floatingList } from "./suggestion";
/** One "/" command. */
export interface SlashCommand {
id: string;
label: string;
description: string;
icon: IconName;
/** Extra words the filter matches, e.g. "h1" for Heading 1. */
keywords: string[];
run: (editor: Editor, range: Range) => void;
}
/** Opens the system file picker and resolves with the chosen files. */
function pickFiles(accept: string): Promise<File[]> {
return new Promise((resolve) => {
const input = document.createElement("input");
input.type = "file";
input.accept = accept;
input.multiple = true;
input.onchange = () => resolve([...(input.files ?? [])]);
input.click();
});
}
/** The block commands, in menu order. */
export function slashCommands(l: EditorLabels, files?: FileHost, onError?: (e: unknown) => void): SlashCommand[] {
const block = (
id: string,
icon: IconName,
keywords: string[],
apply: (e: Editor, r: Range) => void,
): SlashCommand => ({
id,
icon,
keywords,
label: l.slash[id]?.label ?? id,
description: l.slash[id]?.description ?? "",
run: apply,
});
const list: SlashCommand[] = [
block("text", "text", ["paragraph", "p"], (e, r) => e.chain().focus().deleteRange(r).setParagraph().run()),
block("h1", "heading", ["heading", "title", "#"], (e, r) =>
e.chain().focus().deleteRange(r).setHeading({ level: 1 }).run(),
),
block("h2", "heading", ["heading", "subtitle", "##"], (e, r) =>
e.chain().focus().deleteRange(r).setHeading({ level: 2 }).run(),
),
block("h3", "heading", ["heading", "###"], (e, r) =>
e.chain().focus().deleteRange(r).setHeading({ level: 3 }).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("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(),
),
block("divider", "divider", ["hr", "rule", "line", "---"], (e, r) =>
e.chain().focus().deleteRange(r).setHorizontalRule().run(),
),
];
if (files?.upload) {
const upload = (accept: string) => (e: Editor, r: Range) => {
e.chain().focus().deleteRange(r).run();
void pickFiles(accept).then((picked) => insertFiles(e, files, picked).catch(onError));
};
list.push(
block("image", "image", ["picture", "photo", "img"], upload("image/*")),
block("file", "paperclip", ["attachment", "upload", "pdf"], upload("")),
);
}
return list;
}
/** Filters commands by what follows the "/": label, id or keywords. */
export function filterCommands(commands: SlashCommand[], query: string): SlashCommand[] {
const q = query.trim().toLowerCase();
if (!q) return commands;
return commands.filter(
(c) =>
c.label.toLowerCase().includes(q) || c.id.startsWith(q) || c.keywords.some((k) => k.toLowerCase().startsWith(q)),
);
}
/** Typing "/" at the start of a word opens the block menu. */
export const SlashMenu = Extension.create<{ commands: SlashCommand[]; labels: EditorLabels }>({
name: "slashMenu",
addOptions() {
return { commands: [], labels: undefined as unknown as EditorLabels };
},
addProseMirrorPlugins() {
return [
Suggestion<SlashCommand>({
editor: this.editor,
pluginKey: new PluginKey("slashMenu"),
char: "/",
allowSpaces: false,
startOfLine: false,
// Not inside code, where "/" is just a character.
allow: ({ state, range }) => {
const $from = state.doc.resolve(range.from);
return !$from.parent.type.spec.code;
},
items: ({ query }) => filterCommands(this.options.commands, query),
render: floatingList<SlashCommand>({
label: this.options.labels.slashMenu,
empty: this.options.labels.noMatches,
showQuery: true,
toItem: (c) => ({ label: c.label, description: c.description, icon: c.icon }),
pick: (p, c) => c.run(p.editor, p.range),
}),
}),
];
},
});
+179
View File
@@ -0,0 +1,179 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import { autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
import type { SuggestionKeyDownProps, SuggestionProps } from "@tiptap/suggestion";
import { iconPaths, type IconName } from "@docwell/ui/icons";
/** One row of a suggestion list. */
export interface ListItem {
label: string;
description?: string;
icon?: IconName;
}
const svgNS = "http://www.w3.org/2000/svg";
function icon(name: IconName): SVGSVGElement {
const svg = document.createElementNS(svgNS, "svg");
for (const [k, v] of Object.entries({
width: "18",
height: "18",
viewBox: "0 0 24 24",
fill: "none",
stroke: "currentColor",
"stroke-width": "1.75",
"stroke-linecap": "round",
"stroke-linejoin": "round",
"aria-hidden": "true",
})) {
svg.setAttribute(k, v);
}
for (const d of iconPaths[name]) {
const path = document.createElementNS(svgNS, "path");
path.setAttribute("d", d);
svg.append(path);
}
return svg;
}
/**
* A Suggestion render() for a floating list ("/" commands, "@" mentions). It
* draws plain DOM in the design system's slash-menu style (see editor.css),
* so it works in every host, including the framework-free mobile bridge. The
* editor keeps focus: arrows move, Enter or Tab picks, Escape closes.
*/
export function floatingList<T>(opts: {
label: string;
empty: string;
toItem: (item: T) => ListItem;
pick: (props: SuggestionProps<T>, item: T) => void;
showQuery?: boolean;
}) {
return () => {
let box: HTMLDivElement | null = null;
let stop: (() => void) | null = null;
let current: SuggestionProps<T> | null = null;
let active = 0;
const choose = (i: number) => {
const item = current?.items[i];
if (current && item !== undefined) opts.pick(current, item);
};
const draw = () => {
if (!box || !current) return;
const p = current;
box.replaceChildren();
if (opts.showQuery) {
const q = document.createElement("div");
q.className = "dw-suggest__query";
q.textContent = `/${p.query}`;
box.append(q);
}
if (!p.items.length) {
const empty = document.createElement("div");
empty.className = "dw-suggest__empty";
empty.setAttribute("role", "status");
empty.textContent = opts.empty;
box.append(empty);
return;
}
p.items.forEach((raw, i) => {
const it = opts.toItem(raw);
const row = document.createElement("div");
row.className = i === active ? "dw-suggest__item is-active" : "dw-suggest__item";
row.setAttribute("role", "option");
row.setAttribute("aria-selected", String(i === active));
// Pick on mousedown so the editor keeps focus.
row.addEventListener("mousedown", (e) => {
e.preventDefault();
choose(i);
});
const glyph = document.createElement("span");
glyph.className = "dw-suggest__icon";
glyph.append(icon(it.icon ?? "text"));
const text = document.createElement("span");
text.className = "dw-suggest__text";
const label = document.createElement("span");
label.className = "dw-suggest__label";
label.textContent = it.label;
text.append(label);
if (it.description) {
const desc = document.createElement("span");
desc.className = "dw-suggest__desc";
desc.textContent = it.description;
text.append(desc);
}
row.append(glyph, text);
box!.append(row);
});
box.querySelector(".is-active")?.scrollIntoView({ block: "nearest" });
};
const place = () => {
const rect = current?.clientRect?.();
if (!box || !rect) return;
const anchor = { getBoundingClientRect: () => current?.clientRect?.() ?? rect };
stop?.();
stop = autoUpdate(anchor, box, () => {
if (!box) return;
void computePosition(anchor, box, {
placement: "bottom-start",
strategy: "fixed",
middleware: [offset(6), flip(), shift({ padding: 8 })],
}).then(({ x, y }) => {
if (box) Object.assign(box.style, { left: `${x}px`, top: `${y}px` });
});
});
};
const close = () => {
stop?.();
stop = null;
box?.remove();
box = null;
};
return {
onStart(p: SuggestionProps<T>) {
current = p;
active = 0;
box = document.createElement("div");
box.className = "dw-suggest";
box.setAttribute("role", "listbox");
box.setAttribute("aria-label", opts.label);
document.body.append(box);
draw();
place();
},
onUpdate(p: SuggestionProps<T>) {
if (p.items !== current?.items) active = 0;
current = p;
draw();
place();
},
onKeyDown({ event }: SuggestionKeyDownProps) {
const n = current?.items.length ?? 0;
if (event.key === "Escape") {
close();
return true;
}
if (!n) return false;
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
active = (active + (event.key === "ArrowDown" ? 1 : -1) + n) % n;
draw();
return true;
}
if (event.key === "Enter" || event.key === "Tab") {
choose(active);
return true;
}
return false;
},
onExit() {
current = null;
close();
},
};
};
}
+1
View File
@@ -7,6 +7,7 @@
"main": "./src/index.ts",
"exports": {
".": "./src/index.ts",
"./icons": "./src/icons.ts",
"./theme.css": "./src/theme.css"
},
"peerDependencies": {
+54
View File
@@ -1814,3 +1814,57 @@ class SharedPage {
'pages': pages.map((e) => e.toJson()).toList(),
};
}
class Comment {
const Comment({
required this.id,
required this.page,
required this.author,
required this.body,
required this.quote,
required this.anchor,
required this.created,
required this.canDelete,
});
factory Comment.fromJson(Map<String, dynamic> json) => Comment(
id: json['id'] as String,
page: json['page'] as String,
author: MemberUser.fromJson(json['author'] as Map<String, dynamic>),
body: json['body'] as String,
quote: json['quote'] as String,
anchor: json['anchor'] == null
? null
: json['anchor'] as Map<String, dynamic>,
created: json['created'] as String,
canDelete: json['canDelete'] as bool,
);
final String id;
final String page;
final MemberUser author;
final String body;
final String quote;
/// As sent when the comment was created; null when there was none
final Map<String, dynamic>? anchor;
final String created;
final bool canDelete;
Map<String, dynamic> toJson() => {
'id': id,
'page': page,
'author': author.toJson(),
'body': body,
'quote': quote,
'anchor': anchor,
'created': created,
'canDelete': canDelete,
};
}
+22
View File
@@ -105,6 +105,28 @@ func EditPages(spaceRole string) error {
return nil
}
// CommentPages (writing comments) needs commenter.
func CommentPages(spaceRole string) error {
if err := ViewSpace(spaceRole); err != nil {
return err
}
if !SpaceAtLeast(spaceRole, SpaceCommenter) {
return apperr.Forbidden("commenter role required")
}
return nil
}
// DeleteComment: authors delete their own comments, space admins any.
func DeleteComment(actorID, authorID, spaceRole string) error {
if actorID != "" && actorID == authorID {
return nil
}
if !SpaceAtLeast(spaceRole, SpaceAdmin) {
return apperr.Forbidden("only the author or a space admin can delete this comment")
}
return nil
}
// PurgePage (permanent delete from the trash) needs space admin.
func PurgePage(spaceRole string) error {
if err := ViewSpace(spaceRole); err != nil {
+15
View File
@@ -96,3 +96,18 @@ func TestGroupRules(t *testing.T) {
t.Error("SetSpaceGroup")
}
}
func TestCommentRules(t *testing.T) {
if CommentPages(SpaceCommenter) != nil || CommentPages(SpaceViewer) == nil || CommentPages("") == nil {
t.Error("CommentPages needs commenter")
}
if DeleteComment("u", "u", SpaceViewer) != nil {
t.Error("authors delete their own")
}
if DeleteComment("u", "v", SpaceEditor) == nil || DeleteComment("u", "v", SpaceAdmin) != nil {
t.Error("only space admins delete other people's comments")
}
if DeleteComment("", "", SpaceViewer) == nil {
t.Error("an empty author is nobody's comment")
}
}
+32
View File
@@ -255,6 +255,19 @@ type BrandingSettings struct {
Logo string `json:"logo"`
}
// Comment defines model for Comment.
type Comment struct {
// Anchor As sent when the comment was created; null when there was none
Anchor *map[string]interface{} `json:"anchor"`
Author MemberUser `json:"author"`
Body string `json:"body"`
CanDelete bool `json:"canDelete"`
Created string `json:"created"`
Id string `json:"id"`
Page string `json:"page"`
Quote string `json:"quote"`
}
// CreateInviteRequest defines model for CreateInviteRequest.
type CreateInviteRequest struct {
Email openapi_types.Email `json:"email"`
@@ -794,6 +807,16 @@ type UploadAttachmentMultipartBody struct {
File openapi_types.File `json:"file"`
}
// CreateCommentJSONBody defines parameters for CreateComment.
type CreateCommentJSONBody struct {
// Anchor The editor's encoding of the commented range (opaque to the server)
Anchor *map[string]interface{} `json:"anchor,omitempty"`
Body string `json:"body"`
// Quote The commented text
Quote *string `json:"quote,omitempty"`
}
// SavePageContentJSONBody defines parameters for SavePageContent.
type SavePageContentJSONBody struct {
// Content Tiptap JSON with type "doc"
@@ -888,6 +911,12 @@ type SetWorkspaceMemberJSONBody struct {
Role WorkspaceRole `json:"role"`
}
// ListPeopleParams defines parameters for ListPeople.
type ListPeopleParams struct {
Q *string `form:"q,omitempty" json:"q,omitempty"`
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
}
// ListRecentPagesParams defines parameters for ListRecentPages.
type ListRecentPagesParams struct {
Limit *int `form:"limit,omitempty" json:"limit,omitempty"`
@@ -963,6 +992,9 @@ type UpdatePageJSONRequestBody UpdatePageJSONBody
// UploadAttachmentMultipartRequestBody defines body for UploadAttachment for multipart/form-data ContentType.
type UploadAttachmentMultipartRequestBody UploadAttachmentMultipartBody
// CreateCommentJSONRequestBody defines body for CreateComment for application/json ContentType.
type CreateCommentJSONRequestBody CreateCommentJSONBody
// SavePageContentJSONRequestBody defines body for SavePageContent for application/json ContentType.
type SavePageContentJSONRequestBody SavePageContentJSONBody
+144
View File
@@ -0,0 +1,144 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package directory
import (
"context"
"encoding/json"
"fmt"
"strings"
"docwell/server/internal/access"
"docwell/server/internal/apperr"
"docwell/server/internal/store/pocketbase"
)
// ---- Inline comments -------------------------------------------------------
type Comment struct {
ID string `json:"id"`
Page string `json:"page"`
Author MemberUser `json:"author"`
Body string `json:"body"`
Quote string `json:"quote"`
// Anchor is the editor's encoding of the commented range; the server
// stores it without looking inside.
Anchor json.RawMessage `json:"anchor"`
Created string `json:"created"`
CanDelete bool `json:"canDelete"`
}
type commentRecord struct {
ID string `json:"id"`
Page string `json:"page"`
Author string `json:"author"`
Body string `json:"body"`
Quote string `json:"quote"`
Anchor json.RawMessage `json:"anchor"`
Created string `json:"created"`
Expand struct {
Author *struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
} `json:"author"`
} `json:"expand"`
}
func (r commentRecord) view(c access.Caller, role string) Comment {
out := Comment{
ID: r.ID, Page: r.Page, Body: r.Body, Quote: r.Quote, Anchor: r.Anchor, Created: r.Created,
CanDelete: access.DeleteComment(c.ID, r.Author, role) == nil,
}
if len(out.Anchor) == 0 {
out.Anchor = json.RawMessage("null")
}
if a := r.Expand.Author; a != nil {
out.Author = MemberUser{ID: a.ID, Email: a.Email, Name: a.Name}
}
return out
}
// ListComments lists a page's comments, oldest first (viewer).
func (s *Service) ListComments(ctx context.Context, c access.Caller, pageID string) ([]Comment, error) {
p, a, err := s.pageFor(ctx, c, pageID)
if err != nil {
return nil, err
}
recs, err := listAll[commentRecord](ctx, s, "comments", pocketbase.ListOptions{
Filter: fmt.Sprintf("page = '%s'", p.ID), Sort: "created", Expand: "author",
})
if err != nil {
return nil, err
}
out := make([]Comment, 0, len(recs))
for _, r := range recs {
out = append(out, r.view(c, a.role))
}
return out, nil
}
type CreateCommentInput struct {
Body string `json:"body"`
Quote string `json:"quote"`
Anchor json.RawMessage `json:"anchor"`
}
// CreateComment adds a comment to a page (commenter; not in the trash).
func (s *Service) CreateComment(ctx context.Context, c access.Caller, pageID string, in CreateCommentInput) (Comment, error) {
p, a, err := s.pageFor(ctx, c, pageID)
if err != nil {
return Comment{}, err
}
if err := access.CommentPages(a.role); err != nil {
return Comment{}, err
}
if p.DeletedAt != "" {
return Comment{}, apperr.Invalid("restore the page from the trash first")
}
body := strings.TrimSpace(in.Body)
switch {
case body == "":
return Comment{}, apperr.InvalidFields(map[string]string{"body": "Write something first."})
case len(body) > 5000:
return Comment{}, apperr.InvalidFields(map[string]string{"body": "The comment is too long (max 5000)."})
case len(in.Anchor) > 4096:
return Comment{}, apperr.InvalidFields(map[string]string{"anchor": "The anchor is too large."})
}
quote := strings.TrimSpace(in.Quote)
if r := []rune(quote); len(r) > 500 {
quote = string(r[:500])
}
fields := map[string]any{"page": p.ID, "workspace": p.Workspace, "author": c.ID, "body": body, "quote": quote}
if len(in.Anchor) > 0 && json.Valid(in.Anchor) {
fields["anchor"] = in.Anchor
}
rec, err := pocketbase.Create[commentRecord](ctx, s.pb, "comments", fields)
if err != nil {
return Comment{}, mapPB(err, "page not found")
}
rec, err = pocketbase.GetExpand[commentRecord](ctx, s.pb, "comments", rec.ID, "author")
if err != nil {
return Comment{}, mapPB(err, "comment not found")
}
return rec.view(c, a.role), nil
}
// DeleteComment removes a comment (its author, or a space admin).
func (s *Service) DeleteComment(ctx context.Context, c access.Caller, id string) error {
if !validID(id) {
return apperr.NotFound("comment not found")
}
rec, err := pocketbase.Get[commentRecord](ctx, s.pb, "comments", id)
if err != nil {
return mapPB(err, "comment not found")
}
_, a, err := s.pageFor(ctx, c, rec.Page)
if err != nil {
return apperr.NotFound("comment not found")
}
if err := access.DeleteComment(c.ID, rec.Author, a.role); err != nil {
return err
}
return mapPB(s.pb.Delete(ctx, "comments", rec.ID), "comment not found")
}
+65
View File
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package directory
import (
"context"
"fmt"
"sort"
"strings"
"docwell/server/internal/access"
"docwell/server/internal/auth"
"docwell/server/internal/store/pocketbase"
)
// ListPeople finds people in a workspace by name or email, for mentions. Any
// member may look; it lists the explicit members and the organization's
// admins (who are in every workspace through the cascade).
func (s *Service) ListPeople(ctx context.Context, c access.Caller, wsID, query string, limit int) ([]MemberUser, error) {
ws, _, err := s.workspaceFor(ctx, c, wsID)
if err != nil {
return nil, err
}
if limit <= 0 || limit > 50 {
limit = 10
}
q := filterValue(query)
match := ""
if q != "" {
match = fmt.Sprintf(" && (user.name ~ '%s' || user.email ~ '%s')", q, q)
}
members, err := pocketbase.List[memberRecord](ctx, s.pb, "workspace_members", pocketbase.ListOptions{
PerPage: limit, Filter: fmt.Sprintf("workspace = '%s'", ws.ID) + match, Expand: "user",
})
if err != nil {
return nil, err
}
seen := map[string]bool{}
out := []MemberUser{}
add := func(u *auth.UserRecord) {
if u == nil || seen[u.ID] || u.Status == "disabled" {
return
}
seen[u.ID] = true
out = append(out, MemberUser{ID: u.ID, Email: u.Email, Name: u.Name})
}
for _, m := range members.Items {
add(m.Expand.User)
}
adminMatch := ""
if q != "" {
adminMatch = fmt.Sprintf(" && (name ~ '%s' || email ~ '%s')", q, q)
}
admins, err := pocketbase.List[auth.UserRecord](ctx, s.pb, "users", pocketbase.ListOptions{
PerPage: limit, Filter: fmt.Sprintf("organization = '%s' && role = 'admin'", ws.Organization) + adminMatch,
})
if err != nil {
return nil, err
}
for i := range admins.Items {
add(&admins.Items[i])
}
sort.Slice(out, func(i, j int) bool { return strings.ToLower(out[i].Name) < strings.ToLower(out[j].Name) })
return out[:min(limit, len(out))], nil
}
+1
View File
@@ -151,6 +151,7 @@ func (a *api) routes(mux *routeMux) {
a.searchRoutes(mux)
a.transferRoutes(mux)
a.shareRoutes(mux)
a.commentRoutes(mux)
}
func (a *api) decode(w http.ResponseWriter, r *http.Request, v any) bool {
+36
View File
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
package httpapi
import (
"context"
"net/http"
"docwell/server/internal/access"
"docwell/server/internal/directory"
)
// CommentService is the part of directory.Service for inline comments.
type CommentService interface {
ListComments(ctx context.Context, c access.Caller, pageID string) ([]directory.Comment, error)
CreateComment(ctx context.Context, c access.Caller, pageID string, in directory.CreateCommentInput) (directory.Comment, error)
DeleteComment(ctx context.Context, c access.Caller, id string) error
}
func (a *api) commentRoutes(mux *routeMux) {
mux.HandleFunc("GET /api/v1/pages/{id}/comments", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
list, err := a.dir.ListComments(r.Context(), caller(r), r.PathValue("id"))
a.respond(w, list, err)
}))
mux.HandleFunc("POST /api/v1/pages/{id}/comments", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
var in directory.CreateCommentInput
if !a.decode(w, r, &in) {
return
}
cm, err := a.dir.CreateComment(r.Context(), caller(r), r.PathValue("id"), in)
a.respondStatus(w, http.StatusCreated, cm, err)
}))
mux.HandleFunc("DELETE /api/v1/comments/{id}", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
a.respondNoContent(w, a.dir.DeleteComment(r.Context(), caller(r), r.PathValue("id")))
}))
}
+7
View File
@@ -31,6 +31,7 @@ type DirectoryService interface {
ListMembers(ctx context.Context, c access.Caller, wsID string) ([]directory.Member, error)
SetMember(ctx context.Context, c access.Caller, wsID, email, role string) (directory.Member, error)
RemoveMember(ctx context.Context, c access.Caller, wsID, userID string) error
ListPeople(ctx context.Context, c access.Caller, wsID, query string, limit int) ([]directory.MemberUser, error)
SpaceService
InviteService
@@ -40,6 +41,7 @@ type DirectoryService interface {
SearchService
TransferService
ShareService
CommentService
}
func caller(r *http.Request) access.Caller {
@@ -139,6 +141,11 @@ func (a *api) directoryRoutes(mux *routeMux) {
m, err := a.dir.SetMember(r.Context(), caller(r), r.PathValue("id"), in.Email, in.Role)
a.respond(w, m, err)
}))
mux.HandleFunc("GET /api/v1/workspaces/{id}/people", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
limit, _ := strconv.Atoi(r.URL.Query().Get("limit"))
people, err := a.dir.ListPeople(r.Context(), caller(r), r.PathValue("id"), r.URL.Query().Get("q"), limit)
a.respond(w, people, err)
}))
mux.HandleFunc("DELETE /api/v1/workspaces/{id}/members/{userId}", a.requireUser(func(w http.ResponseWriter, r *http.Request) {
a.respondNoContent(w, a.dir.RemoveMember(r.Context(), caller(r), r.PathValue("id"), r.PathValue("userId")))
}))
@@ -0,0 +1,146 @@
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<script setup lang="ts">
import type { Comment } from "@docwell/api-client";
import { DwButton, DwCallout } from "@docwell/ui";
import { nextTick, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useApi } from "../api";
import { useFormErrors } from "../composables/useFormErrors";
// The page's comments beside the text. A new comment starts from a text
// selection in the editor (draft); active is the comment whose text is lit.
const props = defineProps<{
page: string;
comments: Comment[];
draft: { quote: string; anchor: Record<string, unknown> | null } | null;
active: string;
canComment: boolean;
}>();
const emit = defineEmits<{ changed: []; close: []; cancel: []; select: [id: string] }>();
const api = useApi();
const { locale } = useI18n();
const errors = useFormErrors();
const body = ref("");
const busy = ref(false);
const box = ref<HTMLTextAreaElement | null>(null);
const list = ref<HTMLElement | null>(null);
watch(
() => props.draft,
async (v) => {
body.value = "";
errors.reset();
if (v) {
await nextTick();
box.value?.focus();
}
},
);
// Bring the active comment into view when its text is clicked.
watch(
() => props.active,
async (id) => {
await nextTick();
list.value?.querySelector(`[data-id="${id}"]`)?.scrollIntoView({ block: "nearest" });
},
);
async function submit() {
if (!props.draft || !body.value.trim()) return;
busy.value = true;
errors.reset();
try {
await api.pages.addComment(props.page, { body: body.value, quote: props.draft.quote, anchor: props.draft.anchor });
body.value = "";
emit("changed");
} catch (e) {
errors.show(e);
} finally {
busy.value = false;
}
}
async function remove(c: Comment) {
busy.value = true;
errors.reset();
try {
await api.comments.remove(c.id);
emit("changed");
} catch (e) {
errors.show(e);
} finally {
busy.value = false;
}
}
const when = (s: string) =>
new Date(s.replace(" ", "T")).toLocaleString(locale.value, { dateStyle: "medium", timeStyle: "short" });
</script>
<template>
<aside class="flex flex-col gap-3" :aria-label="$t('comments.title')" data-testid="comments">
<div class="flex items-center justify-between gap-2">
<h2 class="dw-label">{{ $t("comments.title") }}</h2>
<DwButton variant="ghost" size="sm" icon="close" :aria-label="$t('page.history.close')" @click="emit('close')" />
</div>
<DwCallout v-if="errors.message.value" tone="danger" size="ui">{{ errors.message.value }}</DwCallout>
<form v-if="draft" class="rounded-md border border-line-strong bg-surface-raised p-3" @submit.prevent="submit">
<p v-if="draft.quote" class="mb-2 line-clamp-3 border-l-2 border-warning pl-2 text-ui-sm text-ink-muted">
{{ draft.quote }}
</p>
<textarea
ref="box"
v-model="body"
rows="3"
maxlength="5000"
class="dw-input w-full"
:aria-label="$t('comments.write')"
:placeholder="$t('comments.write')"
data-testid="comment-body"
@keydown.ctrl.enter.prevent="submit"
@keydown.meta.enter.prevent="submit"
@keydown.esc.prevent="emit('cancel')"
/>
<p v-if="errors.fields.value.body" class="text-ui-sm text-danger">{{ errors.fields.value.body }}</p>
<div class="mt-2 flex justify-end gap-2">
<DwButton size="sm" variant="ghost" @click="emit('cancel')">{{ $t("comments.cancel") }}</DwButton>
<DwButton size="sm" type="submit" variant="primary" :disabled="busy || !body.trim()" data-testid="comment-send">
{{ $t("comments.send") }}
</DwButton>
</div>
</form>
<p v-else-if="canComment && !comments.length" class="text-ui-sm text-ink-muted">{{ $t("comments.hint") }}</p>
<ul ref="list" class="flex flex-col gap-2">
<li
v-for="c in comments"
:key="c.id"
:data-id="c.id"
class="cursor-pointer rounded-md border p-3"
:class="c.id === active ? 'border-warning bg-warning-soft/40' : 'border-line bg-surface-raised'"
data-testid="comment"
@click="emit('select', c.id)"
>
<p v-if="c.quote" class="mb-1 line-clamp-2 border-l-2 border-warning pl-2 text-ui-sm text-ink-muted">
{{ c.quote }}
</p>
<p class="text-ui-sm">
<span class="font-semibold">{{ c.author.name || c.author.email || $t("page.someone") }}</span>
<span class="text-ink-muted"> · {{ when(c.created) }}</span>
</p>
<p class="mt-1 text-ui-md whitespace-pre-wrap">{{ c.body }}</p>
<button
v-if="c.canDelete"
class="mt-1 text-ui-sm text-danger hover:underline"
:disabled="busy"
@click.stop="remove(c)"
>
{{ $t("comments.delete") }}
</button>
</li>
</ul>
</aside>
</template>
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
import type { EditorLabels, MentionHost } from "@docwell/editor";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
import { useApi } from "../api";
const blocks = ["text", "h1", "h2", "h3", "bullet", "ordered", "quote", "code", "divider", "image", "file"];
/** The editor's menu and button words in the app's language. */
export function useEditorLabels() {
const { t } = useI18n();
return computed<EditorLabels>(() => ({
slashMenu: t("editor.slashMenu"),
noMatches: t("editor.noMatches"),
slash: Object.fromEntries(
blocks.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"),
},
mentions: t("editor.mentions"),
noPeople: t("editor.noPeople"),
}));
}
/** "@" mentions find people in the page's workspace. */
export function useMentions(workspace: () => string | undefined): MentionHost {
const api = useApi();
return {
async search(query) {
const ws = workspace();
if (!ws) return [];
const people = await api.workspaces.people(ws, query, 8);
return people.map((p) => ({ id: p.id, label: p.name || p.email, hint: p.email }));
},
};
}
+69
View File
@@ -294,5 +294,74 @@
"editorsOnly": "Editors of this space can turn the public link on or off.",
"readOnly": "Shared page · read only",
"gone": "This link does not work any more. Ask the person who shared it for a new one."
},
"editor": {
"slashMenu": "Insert block",
"noMatches": "No matching blocks",
"mentions": "Mention someone",
"noPeople": "Nobody found",
"blocks": {
"text": {
"label": "Text",
"description": "Plain paragraph"
},
"h1": {
"label": "Heading 1",
"description": "Big section heading"
},
"h2": {
"label": "Heading 2",
"description": "Medium section heading"
},
"h3": {
"label": "Heading 3",
"description": "Small section heading"
},
"bullet": {
"label": "Bulleted list",
"description": "A simple list"
},
"ordered": {
"label": "Numbered list",
"description": "A list with numbers"
},
"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"
},
"image": {
"label": "Image",
"description": "Upload a picture"
},
"file": {
"label": "File",
"description": "Attach a file to download"
}
},
"format": {
"bold": "Bold",
"italic": "Italic",
"strike": "Strikethrough",
"code": "Inline code",
"link": "Link",
"linkPrompt": "Link address (leave empty to remove the link)",
"comment": "Comment"
}
},
"comments": {
"title": "Comments",
"write": "Write a comment…",
"send": "Comment",
"cancel": "Cancel",
"delete": "Delete",
"hint": "Select some text and choose Comment to start a discussion."
}
}
+69
View File
@@ -294,5 +294,74 @@
"editorsOnly": "Edytorzy tej przestrzeni mogą włączać i wyłączać link publiczny.",
"readOnly": "Udostępniona strona · tylko do odczytu",
"gone": "Ten link już nie działa. Poproś osobę, która go udostępniła, o nowy."
},
"editor": {
"slashMenu": "Wstaw blok",
"noMatches": "Brak pasujących bloków",
"mentions": "Wspomnij kogoś",
"noPeople": "Nikogo nie znaleziono",
"blocks": {
"text": {
"label": "Tekst",
"description": "Zwykły akapit"
},
"h1": {
"label": "Nagłówek 1",
"description": "Duży nagłówek sekcji"
},
"h2": {
"label": "Nagłówek 2",
"description": "Średni nagłówek sekcji"
},
"h3": {
"label": "Nagłówek 3",
"description": "Mały nagłówek sekcji"
},
"bullet": {
"label": "Lista punktowana",
"description": "Prosta lista"
},
"ordered": {
"label": "Lista numerowana",
"description": "Lista z numerami"
},
"quote": {
"label": "Cytat",
"description": "Wyróżnij tekst jako cytat"
},
"code": {
"label": "Blok kodu",
"description": "Kod o stałej szerokości"
},
"divider": {
"label": "Separator",
"description": "Linia między sekcjami"
},
"image": {
"label": "Obraz",
"description": "Prześlij zdjęcie"
},
"file": {
"label": "Plik",
"description": "Dołącz plik do pobrania"
}
},
"format": {
"bold": "Pogrubienie",
"italic": "Kursywa",
"strike": "Przekreślenie",
"code": "Kod w tekście",
"link": "Link",
"linkPrompt": "Adres linku (zostaw puste, aby usunąć link)",
"comment": "Komentarz"
}
},
"comments": {
"title": "Komentarze",
"write": "Napisz komentarz…",
"send": "Skomentuj",
"cancel": "Anuluj",
"delete": "Usuń",
"hint": "Zaznacz fragment tekstu i wybierz Komentarz, aby rozpocząć dyskusję."
}
}
+168 -73
View File
@@ -1,15 +1,25 @@
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
<script setup lang="ts">
import type { Page } from "@docwell/api-client";
import { CollabProvider, DocwellEditor, insertFiles, userColor } from "@docwell/editor";
import type { Comment, Page } from "@docwell/api-client";
import {
CollabProvider,
DocwellEditor,
encodeAnchor,
insertFiles,
setCommentMarks,
userColor,
type CommentAnchor,
} from "@docwell/editor";
import { DwBreadcrumbs, DwButton, DwCallout, DwIcon, DwMenu, type MenuItem } from "@docwell/ui";
import { computed, onBeforeUnmount, ref, shallowRef, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import { useApi, useToken } from "../../api";
import PageHistory from "../../components/PageHistory.vue";
import PageComments from "../../components/PageComments.vue";
import PageList from "../../components/PageList.vue";
import ShareDialog from "../../components/ShareDialog.vue";
import { useEditorLabels, useMentions } from "../../composables/useEditorHosts";
import { useFileHost } from "../../composables/useFiles";
import { saveBlob } from "../../lib/download";
import { useRuntimeConfig } from "../../platform";
@@ -36,6 +46,46 @@ const title = ref("");
const busy = ref(false);
const historyOpen = ref(false);
const shareOpen = ref(false);
const labels = useEditorLabels();
const mentions = useMentions(() => page.value?.workspace);
// Inline comments: listed in a side panel, their text lit in the editor.
const commentsOpen = ref(false);
const comments = ref<Comment[]>([]);
const activeComment = ref("");
const draft = ref<{ quote: string; anchor: Record<string, unknown> | null } | null>(null);
const canComment = computed(() => !!page.value && !page.value.inTrash && spaceAtLeast(page.value.role, "commenter"));
async function loadComments() {
if (!page.value) return;
const id = page.value.id;
const list = await api.pages.comments(id).catch(() => null);
if (list && page.value?.id === id) comments.value = list;
}
function drawComments() {
const editor = editorRef.value?.editor;
if (!editor) return;
setCommentMarks(
editor,
comments.value.map((c) => ({ id: c.id, anchor: (c.anchor as CommentAnchor | null) ?? null })),
activeComment.value,
);
}
function startComment(sel: { from: number; to: number; text: string }) {
const editor = editorRef.value?.editor;
const anchor = editor ? encodeAnchor(editor, sel.from, sel.to) : null;
draft.value = { quote: sel.text, anchor: anchor as Record<string, unknown> | null };
commentsOpen.value = true;
historyOpen.value = false;
}
function selectComment(id: string) {
activeComment.value = id;
commentsOpen.value = true;
}
async function commentsChanged() {
draft.value = null;
await loadComments();
}
// Attachments: images and files load through a short-lived file token.
const files = useFileHost(() => page.value?.id ?? props.id);
@@ -54,6 +104,8 @@ async function attachPicked() {
input.value = "";
await run(() => insertFiles(editor, files.host, picked));
}
// Redraw comment highlights when the list, the active one or the editor changes.
watch([comments, activeComment, () => editorRef.value?.editor], drawComments);
// The page body is a shared Yjs document; edits sync live and the server saves them.
const provider = shallowRef<CollabProvider | null>(null);
@@ -128,6 +180,7 @@ async function load(id: string) {
spaces.reveal(p.space, p.id);
// Best effort: the recent list is a convenience.
api.pages.visit(p.id).catch(() => {});
void loadComments();
} catch {
page.value = null;
notFound.value = true;
@@ -163,6 +216,9 @@ watch(
await saveTitle();
closeDoc();
historyOpen.value = false;
comments.value = [];
draft.value = null;
activeComment.value = "";
}
await load(id);
},
@@ -286,6 +342,18 @@ const purge = () =>
>
{{ $t("page.history.title") }}
</DwButton>
<DwButton
variant="ghost"
size="sm"
icon="comment"
:class="{ 'bg-surface-hover text-ink': commentsOpen }"
:aria-pressed="commentsOpen"
data-testid="comments-toggle"
@click="commentsOpen = !commentsOpen"
>
<span class="hidden sm:inline">{{ $t("comments.title") }}</span>
<span v-if="comments.length" class="tabular-nums">{{ comments.length }}</span>
</DwButton>
<DwButton variant="ghost" size="sm" icon="share" data-testid="share-open" @click="shareOpen = true">
{{ $t("share.button") }}
</DwButton>
@@ -293,80 +361,107 @@ const purge = () =>
</Teleport>
<ShareDialog v-if="page" v-model="shareOpen" :page="page" />
<article class="mx-auto max-w-doc px-4 pt-6 pb-16 sm:px-16 sm:pt-10">
<DwCallout v-if="notFound" tone="info" size="ui">{{ $t("page.notFound") }}</DwCallout>
<template v-if="page">
<DwCallout v-if="page.inTrash" tone="warning" size="ui" class="mb-4 items-center" role="status">
{{ page.deletedAt ? $t("page.inTrash") : $t("page.parentInTrash") }}
<template v-if="page.deletedAt && spaceAtLeast(page.role, 'editor')" #actions>
<span class="flex shrink-0 flex-wrap gap-2">
<DwButton size="sm" icon="restore" :disabled="busy" @click="restore">{{ $t("page.restore") }}</DwButton>
<DwButton
v-if="spaceAtLeast(page.role, 'admin')"
size="sm"
variant="danger"
:disabled="busy"
@click="purge"
>
{{ $t("page.deleteForever") }}
</DwButton>
</span>
</template>
</DwCallout>
<div class="flex min-h-full items-start">
<article class="mx-auto min-w-0 max-w-doc flex-1 px-4 pt-6 pb-16 sm:px-16 sm:pt-10">
<DwCallout v-if="notFound" tone="info" size="ui">{{ $t("page.notFound") }}</DwCallout>
<template v-if="page">
<DwCallout v-if="page.inTrash" tone="warning" size="ui" class="mb-4 items-center" role="status">
{{ page.deletedAt ? $t("page.inTrash") : $t("page.parentInTrash") }}
<template v-if="page.deletedAt && spaceAtLeast(page.role, 'editor')" #actions>
<span class="flex shrink-0 flex-wrap gap-2">
<DwButton size="sm" icon="restore" :disabled="busy" @click="restore">{{ $t("page.restore") }}</DwButton>
<DwButton
v-if="spaceAtLeast(page.role, 'admin')"
size="sm"
variant="danger"
:disabled="busy"
@click="purge"
>
{{ $t("page.deleteForever") }}
</DwButton>
</span>
</template>
</DwCallout>
<input
v-model="title"
:readonly="!editable"
:placeholder="$t('home.untitled')"
:aria-label="$t('page.title')"
maxlength="500"
class="w-full rounded-xs bg-transparent font-serif text-doc-title text-ink outline-none placeholder:text-ink-faint"
data-testid="page-title"
@input="onTitleInput"
@blur="saveTitle"
@keydown.enter.prevent="($event.target as HTMLInputElement).blur()"
/>
<p v-if="!spaceAtLeast(page.role, 'editor')" class="mt-2 text-ui-sm text-ink-muted">{{ $t("page.readOnly") }}</p>
<input
v-model="title"
:readonly="!editable"
:placeholder="$t('home.untitled')"
:aria-label="$t('page.title')"
maxlength="500"
class="w-full rounded-xs bg-transparent font-serif text-doc-title text-ink outline-none placeholder:text-ink-faint"
data-testid="page-title"
@input="onTitleInput"
@blur="saveTitle"
@keydown.enter.prevent="($event.target as HTMLInputElement).blur()"
/>
<p v-if="!spaceAtLeast(page.role, 'editor')" class="mt-2 text-ui-sm text-ink-muted">
{{ $t("page.readOnly") }}
</p>
<PageHistory
v-if="historyOpen"
:page="page"
:can-restore="editable"
class="mt-4"
@close="historyOpen = false"
@error="emit('error', $event)"
/>
<PageHistory
v-if="historyOpen"
:page="page"
:can-restore="editable"
class="mt-4"
@close="historyOpen = false"
@error="emit('error', $event)"
/>
<DocwellEditor
v-if="provider && synced && filesReady"
ref="editorRef"
:key="page.id"
:provider="provider"
:files="files.host"
:user="me"
:editable="editable"
:placeholder="editable ? $t('page.placeholder') : ''"
class="mt-4"
data-testid="page-editor"
@error="emit('error', $event)"
/>
<DocwellEditor
v-if="provider && synced && filesReady"
ref="editorRef"
:key="page.id"
:provider="provider"
:files="files.host"
:mentions="mentions"
:labels="labels"
:can-comment="canComment"
:user="me"
:editable="editable"
:placeholder="editable ? $t('page.placeholder') : ''"
class="mt-4"
data-testid="page-editor"
@error="emit('error', $event)"
@comment="startComment"
@comment-select="selectComment"
/>
<!-- A trashed page's children are hidden with it; they come back on restore. -->
<section v-if="!page.inTrash" class="mt-10">
<div class="flex flex-wrap items-center justify-between gap-2">
<h2 class="dw-label">{{ $t("page.subpages") }}</h2>
<div v-if="editable" class="flex gap-1">
<DwButton variant="ghost" size="sm" icon="plus" :disabled="busy" @click="addChild">{{
$t("sidebar.addSubpage")
}}</DwButton>
<DwButton variant="ghost" size="sm" icon="trash" :disabled="busy" @click="trash">{{
$t("page.moveToTrash")
}}</DwButton>
<!-- A trashed page's children are hidden with it; they come back on restore. -->
<section v-if="!page.inTrash" class="mt-10">
<div class="flex flex-wrap items-center justify-between gap-2">
<h2 class="dw-label">{{ $t("page.subpages") }}</h2>
<div v-if="editable" class="flex gap-1">
<DwButton variant="ghost" size="sm" icon="plus" :disabled="busy" @click="addChild">{{
$t("sidebar.addSubpage")
}}</DwButton>
<DwButton variant="ghost" size="sm" icon="trash" :disabled="busy" @click="trash">{{
$t("page.moveToTrash")
}}</DwButton>
</div>
</div>
</div>
<PageList v-if="children.length" :items="children" class="mt-2" />
<p v-else class="mt-2 text-ui-md text-ink-muted">{{ $t("page.noSubpages") }}</p>
</section>
</template>
</article>
<PageList v-if="children.length" :items="children" class="mt-2" />
<p v-else class="mt-2 text-ui-md text-ink-muted">{{ $t("page.noSubpages") }}</p>
</section>
</template>
</article>
<!-- Beside the text on wide screens; a sheet over the bottom on narrow ones. -->
<PageComments
v-if="page && commentsOpen"
:page="page.id"
:comments="comments"
:draft="draft"
:active="activeComment"
:can-comment="canComment"
class="fixed inset-x-0 bottom-0 z-30 max-h-[60vh] overflow-y-auto border-t border-line bg-surface p-4 shadow-dialog lg:sticky lg:top-0 lg:z-auto lg:max-h-[calc(100dvh-5rem)] lg:w-80 lg:shrink-0 lg:border-t-0 lg:border-l lg:shadow-none"
@changed="commentsChanged"
@cancel="draft = null"
@close="
commentsOpen = false;
draft = null;
activeComment = '';
"
@select="activeComment = $event"
/>
</div>
</template>
+87
View File
@@ -1535,6 +1535,79 @@ paths:
application/octet-stream:
schema: { type: string, format: binary }
"404": { $ref: "#/components/responses/Error" }
/api/v1/workspaces/{id}/people:
parameters:
- { name: id, in: path, required: true, schema: { type: string } }
get:
operationId: listPeople
tags: [workspaces]
summary: Find people in the workspace by name or email (for mentions; any member)
security: [{ bearer: [] }]
parameters:
- { name: q, in: query, schema: { type: string } }
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 50 } }
responses:
"200":
description: OK
content:
application/json:
schema: { type: array, items: { $ref: "#/components/schemas/MemberUser" } }
"404": { $ref: "#/components/responses/Error" }
/api/v1/pages/{id}/comments:
parameters:
- { name: id, in: path, required: true, schema: { type: string } }
get:
operationId: listComments
tags: [comments]
summary: The page's inline comments, oldest first
security: [{ bearer: [] }]
responses:
"200":
description: OK
content:
application/json:
schema: { type: array, items: { $ref: "#/components/schemas/Comment" } }
"404": { $ref: "#/components/responses/Error" }
post:
operationId: createComment
tags: [comments]
summary: Comment on the page (commenter)
security: [{ bearer: [] }]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [body]
properties:
body: { type: string, maxLength: 5000 }
quote: { type: string, maxLength: 500, description: The commented text }
anchor:
type: object
additionalProperties: true
description: The editor's encoding of the commented range (opaque to the server)
responses:
"201":
description: Created
content:
application/json:
schema: { $ref: "#/components/schemas/Comment" }
"400": { $ref: "#/components/responses/Error" }
"403": { $ref: "#/components/responses/Error" }
"404": { $ref: "#/components/responses/Error" }
/api/v1/comments/{id}:
parameters:
- { name: id, in: path, required: true, schema: { type: string } }
delete:
operationId: deleteComment
tags: [comments]
summary: Delete a comment (its author, or a space admin)
security: [{ bearer: [] }]
responses:
"204": { description: Deleted }
"403": { $ref: "#/components/responses/Error" }
"404": { $ref: "#/components/responses/Error" }
components:
securitySchemes:
bearer:
@@ -1998,3 +2071,17 @@ components:
description: Tiptap JSON; files load from /api/v1/share/{token}/files/{fileId}
root: { $ref: "#/components/schemas/PageRef" }
pages: { type: array, items: { $ref: "#/components/schemas/PageNode" }, description: Pages under the shared page, in tree order (only when the link includes subpages) }
Comment:
type: object
required: [id, page, author, body, quote, anchor, created, canDelete]
properties:
id: { type: string }
page: { type: string }
author: { $ref: "#/components/schemas/MemberUser" }
body: { type: string }
quote: { type: string }
anchor:
oneOf: [{ type: object, additionalProperties: true }, { type: "null" }]
description: As sent when the comment was created; null when there was none
created: { type: string }
canDelete: { type: boolean }
+1 -2
View File
@@ -1,9 +1,8 @@
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.17/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY=
golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c=
golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o=
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
golang.org/x/net v0.60.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg=
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
+2
View File
@@ -5972,6 +5972,8 @@
"version": "0.0.1",
"license": "AGPL-3.0-or-later",
"dependencies": {
"@docwell/ui": "*",
"@floating-ui/dom": "^1.8.0",
"@tiptap/core": "^3.32.2",
"@tiptap/extension-bubble-menu": "^3.32.2",
"@tiptap/extension-collaboration": "^3.32.2",