@meowdown/core 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/style.css +55 -46
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -22,10 +22,16 @@ The editor extension binds inline-format toggles (`Mod` = Cmd on macOS, Ctrl els
|
|
|
22
22
|
- `--meowdown-muted`: secondary text (blockquotes).
|
|
23
23
|
- `--meowdown-accent`: links, wikilinks, caret, inline code, tags.
|
|
24
24
|
- `--meowdown-mark`: Markdown syntax characters.
|
|
25
|
-
- `--meowdown-border`: horizontal rules.
|
|
25
|
+
- `--meowdown-border`: horizontal rules and table borders.
|
|
26
26
|
- `--meowdown-code-bg`: code block background.
|
|
27
|
+
- `--meowdown-table-header-bg`: table header row background.
|
|
27
28
|
- `--meowdown-font-mono`: monospace font stack.
|
|
28
29
|
- `--meowdown-gutter`: horizontal editor padding. Floating UI such as the block handle (in `@meowdown/react`) lives inside it; keep it at least `3.5rem`.
|
|
30
|
+
- `--meowdown-selection`: text `::selection` background.
|
|
31
|
+
- `--meowdown-node-outline`: outline of a selected node; border color of selected tables and cells.
|
|
32
|
+
- `--meowdown-node-selection`: background wash of a selected node or selected cells.
|
|
33
|
+
|
|
34
|
+
Selection colors are standalone variables, not derived from `--meowdown-accent`, so selection can be restyled independently.
|
|
29
35
|
|
|
30
36
|
Tags (`#tag`) render as pills via the `.md-tag` class, tinted from `--meowdown-accent`.
|
|
31
37
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Editor, PlainExtension } from "@prosekit/core";
|
|
|
2
2
|
import { ProseMirrorNode } from "@prosekit/pm/model";
|
|
3
3
|
|
|
4
4
|
//#region src/extensions/extension.d.ts
|
|
5
|
-
declare function defineEditorExtensionImpl(): import("@prosekit/core").Union<readonly [import("@prosekit/extensions/paragraph").ParagraphExtension, import("@prosekit/extensions/doc").DocExtension, import("@prosekit/extensions/text").TextExtension, import("@prosekit/extensions/blockquote").BlockquoteExtension, import("@prosekit/extensions/list").ListExtension, import("@prosekit/extensions/heading").HeadingExtension, import("@prosekit/extensions/table").
|
|
5
|
+
declare function defineEditorExtensionImpl(): import("@prosekit/core").Union<readonly [import("@prosekit/extensions/paragraph").ParagraphExtension, import("@prosekit/extensions/doc").DocExtension, import("@prosekit/extensions/text").TextExtension, import("@prosekit/extensions/blockquote").BlockquoteExtension, import("@prosekit/extensions/list").ListExtension, import("@prosekit/extensions/heading").HeadingExtension, import("@prosekit/core").Union<readonly [import("@prosekit/extensions/table").TableSpecExtension, import("@prosekit/extensions/table").TableRowSpecExtension, import("@prosekit/extensions/table").TableCellSpecExtension, import("@prosekit/extensions/table").TableHeaderCellSpecExtension, import("@prosekit/core").PlainExtension, import("@prosekit/extensions/table").TableCommandsExtension, import("@prosekit/core").PlainExtension]>, import("@prosekit/extensions/code-block").CodeBlockExtension, import("@prosekit/extensions/horizontal-rule").HorizontalRuleExtension, import("@prosekit/core").Union<readonly [import("@prosekit/core").Extension<{
|
|
6
6
|
Marks: {
|
|
7
7
|
mdMark: import("@prosekit/pm/model").Attrs;
|
|
8
8
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{defineBaseCommands as e,defineBaseKeymap as t,defineCommands as n,defineHistory as r,defineKeymap as i,defineMarkSpec as a,definePlugin as o,union as s}from"@prosekit/core";import{defineBlockquote as c}from"@prosekit/extensions/blockquote";import{defineCodeBlock as l}from"@prosekit/extensions/code-block";import{defineDoc as u}from"@prosekit/extensions/doc";import{defineGapCursor as d}from"@prosekit/extensions/gap-cursor";import{defineHeading as ee}from"@prosekit/extensions/heading";import{defineHorizontalRule as te}from"@prosekit/extensions/horizontal-rule";import{defineList as ne}from"@prosekit/extensions/list";import{defineModClickPrevention as re}from"@prosekit/extensions/mod-click-prevention";import{defineParagraph as ie}from"@prosekit/extensions/paragraph";import{defineTable as ae}from"@prosekit/extensions/table";import{defineText as oe}from"@prosekit/extensions/text";import{defineVirtualSelection as se}from"@prosekit/extensions/virtual-selection";import{Plugin as f,PluginKey as p,TextSelection as m}from"@prosekit/pm/state";import{ReplaceStep as ce,Step as h,StepResult as g,Transform as _}from"@prosekit/pm/transform";import{Mark as le}from"@prosekit/pm/model";import{GFM as v,parser as ue}from"@lezer/markdown";import{Decoration as de,DecorationSet as y}from"@prosekit/pm/view";function fe(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function pe(e,t){let[n,r,i]=t;return[n,r,i.map(t=>le.fromJSON(e,t))]}var b=class e extends h{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return g.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));o>=s||e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),c=Math.min(s,r+t.nodeSize);if(i>=c)return!1;let l=t.marks;for(let t of l)t.isInSet(a)||(n??=new _(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new _(e),n.addMark(i,c,t));return!1})}return g.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return me;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new ce(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(fe)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>pe(t,e)))}};h.jsonID(`batchSetMark`,b);const me=new b([]);function he(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function ge(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const _e={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!he(t))break;i||=ge(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},ve={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function ye(e){return e.end}const x=ue.configure([v,_e,ve]),be=x.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:ye}]});function S(e){return x.parseInline(e,0)}function C(e,t,n=[]){for(let r of e)t(r)&&n.push(r),C(r.children,t,n);return n}function xe(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const w=xe(x);function Se(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}const T=new Map([[w.Emphasis,`mdEm`],[w.StrongEmphasis,`mdStrong`],[w.InlineCode,`mdCode`],[w.Strikethrough,`mdDel`],[w.EmphasisMark,`mdMark`],[w.CodeMark,`mdMark`],[w.LinkMark,`mdMark`],[w.StrikethroughMark,`mdMark`],[w.URL,`mdLinkUri`],[w.Hashtag,`mdTag`],[w.Wikilink,`mdWikilink`],[w.WikilinkMark,`mdMark`]]);function Ce(e,t){let n=S(t),r=[];return E(n,[],0,t.length,t,e,r),r}function E(e,t,n,r,i,a,o){let s=n;for(let n of e){if(n.from>s&&D(o,s,n.from,t),n.type===w.Link||n.type===w.Image)we(n,t,i,a,o);else{let e=T.get(n.type),r=e?[...t,a.marks[e].create()]:t;n.children.length===0?D(o,n.from,n.to,r):E(n.children,r,n.from,n.to,i,a,o)}s=n.to}s<r&&D(o,s,r,t)}function we(e,t,n,r,i){let a=-1,o=null,s=0;for(let t of e.children)t.type===w.LinkMark?(s++,s===2&&(a=t.from)):t.type===w.URL&&o===null&&(o=t);let c=o?n.slice(o.from,o.to):``,l=c&&r.marks.mdLinkText?r.marks.mdLinkText.create({href:c}):null,u=e=>a>=0&&e<a&&l!==null,d=e.from;for(let a of e.children){if(a.from>d){let e=u(d)?[...t,l]:t;D(i,d,a.from,e)}let e=u(a.from)?[...t,l]:t,o=T.get(a.type),s=o?[...e,r.marks[o].create()]:e;a.children.length===0?D(i,a.from,a.to,s):E(a.children,s,a.from,a.to,n,r,i),d=a.to}d<e.to&&D(i,d,e.to,t)}function D(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Se(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const O=`inline-marks-applied`,k=new WeakMap;let Te=0,Ee=0;function De(e,t,n){let r=k.get(e);if(r?Ee++:(Te++,r=Ce(n,e.textContent),k.set(e,r)),t===0)return r;let i=[];for(let[e,n,a]of r)i.push([e+t,n+t,a]);return i}function Oe(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function ke(e,t){let n=[];return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let i=De(t,r+1,e.schema);return i.length>0&&n.push(...i),!1}),n}function Ae(){return new f({key:new p(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(O))return null;let r=ke(n,Oe(e,n));if(r.length===0)return null;let i=n.tr.step(new b(r));return i.setMeta(O,!0),i.setMeta(`addToHistory`,!1),i},view(e){return e.dispatch(je(e.state)),{}}})}function je(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Me(){return o(Ae())}function Ne(){return a({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Pe(){return a({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Fe(){return a({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function Ie(){return a({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Le(){return a({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function Re(){return a({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function ze(){return a({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Be(){return a({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function Ve(){return a({name:`mdWikilink`,inclusive:!1,toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function He(){return s(Ne(),Pe(),Fe(),Ie(),Le(),Re(),ze(),Be(),Ve())}function A(e,t=0){let n=t,r=0;for(let t=0;t<e.length;t++)e.charCodeAt(t)===96?(r++,r>n&&(n=r)):r=0;return n}const j={em:{node:w.Emphasis,delim:`*`},strong:{node:w.StrongEmphasis,delim:`**`},code:{node:w.InlineCode,delim:"`"},del:{node:w.Strikethrough,delim:`~~`}},Ue=new Set([w.EmphasisMark,w.CodeMark,w.LinkMark,w.StrikethroughMark]);function M(e){return[e.children[0],e.children.at(-1)]}function N(e){let{type:t,children:n}=e;if(t===w.Emphasis||t===w.StrongEmphasis||t===w.Strikethrough)return[n[0].to,n.at(-1).from];if(t===w.Link||t===w.Image){let e=n.find((e,t)=>t>0&&e.type===w.LinkMark);return e?[n[0].to,e.from]:null}return null}function P(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=N(r);return i&&i[0]<=t&&n<=i[1]?P(r.children,t,n):P(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function F(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return F(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}const I=e=>e===` `||e===` `;function We(e,t,n){for(;t<n&&I(e[t]);)t++;for(;n>t&&I(e[n-1]);)n--;return[t,n]}function Ge(e,t,n,r){let i=C(S(e),e=>e.type===r.node||Ue.has(e.type));for(let r=t;r<n;r++)if(!I(e[r])&&!i.some(e=>e.from<=r&&r<e.to))return!1;return!0}function Ke(e,t,n,r,i){let a=S(e),o=C(a,e=>e.type===r.node);return i?Ye(e,o,t,n):qe(e,a,o,t,n,r)}function qe(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=P(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=M(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=Je(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function Je(e,t,n,r,i){if(i.node!==w.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(A(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function Ye(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=M(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=F(a.children.slice(1,-1),s,c);s>t.to&&I(e[s-1]);)s--;for(;c<o.from&&I(e[c]);)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function Xe(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=S(e),o=C(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=M(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return L(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function L(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=N(n);return!e||t<e[0]||t>e[1]?!0:L(n.children,t)}return!1}function R(e){return(t,n)=>{if(t.selection.empty)return Ze(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=We(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Ge(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Ke(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(m.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function Ze(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=Xe(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(m.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(m.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function Qe(){return s(n({toggleEm:()=>R(j.em),toggleStrong:()=>R(j.strong),toggleCode:()=>R(j.code),toggleDel:()=>R(j.del)}),i({"Mod-b":R(j.strong),"Mod-i":R(j.em),"Mod-e":R(j.code),"Mod-Shift-x":R(j.del)}))}function $e(){return s(ie(),u(),oe(),c(),ne(),ee(),ae(),l(),te(),He(),Me(),Qe(),t(),e(),r(),d(),se(),re())}function et(){return $e()}const tt=new Set([`mdStrong`,`mdEm`,`mdCode`,`mdDel`,`mdLinkText`,`mdLinkUri`,`mdWikilink`]),nt=new Set([`mdMark`,`mdLinkUri`]),rt=new Set([`mdMark`,`mdLinkUri`]),z=new Set([`mdLinkText`,`mdLinkUri`]),it=new Set([`mdStrong`,`mdEm`,`mdCode`,`mdDel`,`mdWikilink`]);function at(e){return new f({key:new p(`mark-mode`),props:{attributes:{"data-mark-mode":e},decorations:e===`focus`?e=>ct(e):void 0,clipboardTextSerializer:e===`show`?void 0:st}})}function ot(e){return o(at(e))}function st(e){let t=[];return e.content.forEach(e=>{let n=[];e.descendants(e=>!e.isText||!e.text?!0:(e.marks.some(e=>rt.has(e.type.name))||n.push(e.text),!1)),t.push(n.join(``))}),t.join(`
|
|
2
|
-
`)}function
|
|
1
|
+
import{defineBaseCommands as e,defineBaseKeymap as t,defineCommands as n,defineHistory as r,defineKeymap as i,defineMarkSpec as a,definePlugin as o,union as s}from"@prosekit/core";import{defineBlockquote as c}from"@prosekit/extensions/blockquote";import{defineCodeBlock as l}from"@prosekit/extensions/code-block";import{defineDoc as u}from"@prosekit/extensions/doc";import{defineGapCursor as d}from"@prosekit/extensions/gap-cursor";import{defineHeading as ee}from"@prosekit/extensions/heading";import{defineHorizontalRule as te}from"@prosekit/extensions/horizontal-rule";import{defineList as ne}from"@prosekit/extensions/list";import{defineModClickPrevention as re}from"@prosekit/extensions/mod-click-prevention";import{defineParagraph as f}from"@prosekit/extensions/paragraph";import{defineText as ie}from"@prosekit/extensions/text";import{defineVirtualSelection as ae}from"@prosekit/extensions/virtual-selection";import{Plugin as p,PluginKey as m,TextSelection as h}from"@prosekit/pm/state";import{ReplaceStep as oe,Step as g,StepResult as _,Transform as v}from"@prosekit/pm/transform";import{Mark as se}from"@prosekit/pm/model";import{GFM as ce,parser as le}from"@lezer/markdown";import{defineTableCellSpec as ue,defineTableCommands as de,defineTableDropIndicator as fe,defineTableHeaderCellSpec as pe,defineTableRowSpec as me,defineTableSpec as he}from"@prosekit/extensions/table";import{tableEditing as ge}from"prosemirror-tables";import{Decoration as _e,DecorationSet as y}from"@prosekit/pm/view";function ve(e){let[t,n,r]=e;return[t,n,r.map(e=>e.toJSON())]}function ye(e,t){let[n,r,i]=t;return[n,r,i.map(t=>se.fromJSON(e,t))]}var b=class e extends g{constructor(e){super(),this.chunks=e}apply(e){if(this.chunks.length===0)return _.ok(e);let t=e.content.size,n;for(let[r,i,a]of this.chunks){if(r>=i)continue;let o=Math.max(0,Math.min(r,t)),s=Math.max(o,Math.min(i,t));o>=s||e.nodesBetween(o,s,(t,r)=>{if(!t.isText)return!0;let i=Math.max(o,r),c=Math.min(s,r+t.nodeSize);if(i>=c)return!1;let l=t.marks;for(let t of l)t.isInSet(a)||(n??=new v(e),n.removeMark(i,c,t));for(let t of a)t.isInSet(l)||(n??=new v(e),n.addMark(i,c,t));return!1})}return _.ok(n?n.doc:e)}invert(e){if(this.chunks.length===0)return be;let t=this.chunks[0][0],n=this.chunks[0][1];for(let[,e]of this.chunks)e>n&&(n=e);let r=e.content.size,i=Math.max(0,Math.min(t,r)),a=Math.max(i,Math.min(n,r));return new oe(i,a,e.slice(i,a),!1)}map(e){return null}toJSON(){return{stepType:`batchSetMark`,chunks:this.chunks.map(ve)}}static fromJSON(t,n){let r=n.chunks;return new e(r.map(e=>ye(t,e)))}};g.jsonID(`batchSetMark`,b);const be=new b([]);function xe(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===45||e===95||e>127&&/[\p{L}\p{N}]/u.test(String.fromCharCode(e))}function Se(e){return e>=65&&e<=90||e>=97&&e<=122||e>127&&/\p{L}/u.test(String.fromCharCode(e))}const Ce={defineNodes:[{name:`Hashtag`}],parseInline:[{name:`Hashtag`,parse(e,t,n){if(t!==35||!/\s|^$/.test(e.slice(n-1,n)))return-1;let r=n+1,i=!1;for(;r<e.end;){let t=e.char(r);if(!xe(t))break;i||=Se(t),r++}return i?e.addElement(e.elt(`Hashtag`,n,r)):-1}}]},we={defineNodes:[{name:`Wikilink`},{name:`WikilinkMark`}],parseInline:[{name:`Wikilink`,before:`Link`,parse(e,t,n){if(t!==91||e.char(n+1)!==91)return-1;let r=!1;for(let t=n+2;t<e.end-1;t++){let i=e.char(t);if(i===93){if(e.char(t+1)!==93||!r)return-1;let i=t+2;return e.addElement(e.elt(`Wikilink`,n,i,[e.elt(`WikilinkMark`,n,n+2),e.elt(`WikilinkMark`,t,i)]))}if(i===91||i===10)return-1;i!==32&&i!==9&&(r=!0)}return-1}}]};function Te(e){return e.end}const x=le.configure([ce,Ce,we]),Ee=x.configure({parseInline:[{name:`SkipInline`,before:`Escape`,parse:Te}]});function S(e){return x.parseInline(e,0)}function C(e,t,n=[]){for(let r of e)t(r)&&n.push(r),C(r.children,t,n);return n}function De(e){let t={};for(let n of e.nodeSet.types)t[n.name]=n.id;return t}const w=De(x);function Oe(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}const T=new Map([[w.Emphasis,`mdEm`],[w.StrongEmphasis,`mdStrong`],[w.InlineCode,`mdCode`],[w.Strikethrough,`mdDel`],[w.EmphasisMark,`mdMark`],[w.CodeMark,`mdMark`],[w.LinkMark,`mdMark`],[w.StrikethroughMark,`mdMark`],[w.URL,`mdLinkUri`],[w.Hashtag,`mdTag`],[w.Wikilink,`mdWikilink`],[w.WikilinkMark,`mdMark`]]);function ke(e,t){let n=S(t),r=[];return E(n,[],0,t.length,t,e,r),r}function E(e,t,n,r,i,a,o){let s=n;for(let n of e){if(n.from>s&&D(o,s,n.from,t),n.type===w.Link||n.type===w.Image)Ae(n,t,i,a,o);else{let e=T.get(n.type),r=e?[...t,a.marks[e].create()]:t;n.children.length===0?D(o,n.from,n.to,r):E(n.children,r,n.from,n.to,i,a,o)}s=n.to}s<r&&D(o,s,r,t)}function Ae(e,t,n,r,i){let a=-1,o=null,s=0;for(let t of e.children)t.type===w.LinkMark?(s++,s===2&&(a=t.from)):t.type===w.URL&&o===null&&(o=t);let c=o?n.slice(o.from,o.to):``,l=c&&r.marks.mdLinkText?r.marks.mdLinkText.create({href:c}):null,u=e=>a>=0&&e<a&&l!==null,d=e.from;for(let a of e.children){if(a.from>d){let e=u(d)?[...t,l]:t;D(i,d,a.from,e)}let e=u(a.from)?[...t,l]:t,o=T.get(a.type),s=o?[...e,r.marks[o].create()]:e;a.children.length===0?D(i,a.from,a.to,s):E(a.children,s,a.from,a.to,n,r,i),d=a.to}d<e.to&&D(i,d,e.to,t)}function D(e,t,n,r){if(t>=n)return;let i=e.at(-1);if(i&&i[1]===t&&Oe(i[2],r)){e[e.length-1]=[i[0],n,i[2]];return}e.push([t,n,r])}const O=`inline-marks-applied`,k=new WeakMap;let je=0,Me=0;function Ne(e,t,n){let r=k.get(e);if(r?Me++:(je++,r=ke(n,e.textContent),k.set(e,r)),t===0)return r;let i=[];for(let[e,n,a]of r)i.push([e+t,n+t,a]);return i}function Pe(e,t){let n=1/0,r=-1/0;for(let t of e)for(let e of t.mapping.maps)e.forEach((e,t,i,a)=>{i<n&&(n=i),a>r&&(r=a)});let i=t.doc.content.size;return n>r?{from:0,to:i}:{from:Math.max(0,n),to:Math.min(i,r)}}function Fe(e,t){let n=[];return e.doc.nodesBetween(t.from,t.to,(t,r)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;if(t.childCount===0)return!1;let i=Ne(t,r+1,e.schema);return i.length>0&&n.push(...i),!1}),n}function Ie(){return new p({key:new m(`inline-mark`),appendTransaction(e,t,n){for(let t of e)if(t.getMeta(O))return null;let r=Fe(n,Pe(e,n));if(r.length===0)return null;let i=n.tr.step(new b(r));return i.setMeta(O,!0),i.setMeta(`addToHistory`,!1),i},view(e){return e.dispatch(Le(e.state)),{}}})}function Le(e){return e.tr.setMeta(`inline-marks-trigger`,!0)}function Re(){return o(Ie())}function ze(){return a({name:`mdMark`,inclusive:!1,toDOM:()=>[`span`,{class:`md-mark`},0],parseDOM:[{tag:`span.md-mark`}]})}function Be(){return a({name:`mdEm`,toDOM:()=>[`em`,0],parseDOM:[{tag:`em`}]})}function Ve(){return a({name:`mdStrong`,toDOM:()=>[`strong`,0],parseDOM:[{tag:`strong`}]})}function He(){return a({name:`mdCode`,toDOM:()=>[`code`,0],parseDOM:[{tag:`code`}]})}function Ue(){return a({name:`mdLinkText`,inclusive:!1,attrs:{href:{default:``}},toDOM:e=>[`a`,{href:e.attrs.href},0],parseDOM:[{tag:`a`,getAttrs:e=>({href:e.getAttribute(`href`)??``})}]})}function We(){return a({name:`mdLinkUri`,inclusive:!1,toDOM:()=>[`span`,{class:`md-link-uri`},0],parseDOM:[{tag:`span.md-link-uri`}]})}function Ge(){return a({name:`mdDel`,toDOM:()=>[`del`,0],parseDOM:[{tag:`del`}]})}function Ke(){return a({name:`mdTag`,toDOM:()=>[`span`,{class:`md-tag`},0],parseDOM:[{tag:`span.md-tag`}]})}function qe(){return a({name:`mdWikilink`,inclusive:!1,toDOM:()=>[`span`,{class:`md-wikilink`},0],parseDOM:[{tag:`span.md-wikilink`}]})}function Je(){return s(ze(),Be(),Ve(),He(),Ue(),We(),Ge(),Ke(),qe())}function A(e,t=0){let n=t,r=0;for(let t=0;t<e.length;t++)e.charCodeAt(t)===96?(r++,r>n&&(n=r)):r=0;return n}const j={em:{node:w.Emphasis,delim:`*`},strong:{node:w.StrongEmphasis,delim:`**`},code:{node:w.InlineCode,delim:"`"},del:{node:w.Strikethrough,delim:`~~`}},Ye=new Set([w.EmphasisMark,w.CodeMark,w.LinkMark,w.StrikethroughMark]);function M(e){return[e.children[0],e.children.at(-1)]}function N(e){let{type:t,children:n}=e;if(t===w.Emphasis||t===w.StrongEmphasis||t===w.Strikethrough)return[n[0].to,n.at(-1).from];if(t===w.Link||t===w.Image){let e=n.find((e,t)=>t>0&&e.type===w.LinkMark);return e?[n[0].to,e.from]:null}return null}function P(e,t,n){for(let r of e){if(r.to<=t||r.from>=n||t<=r.from&&r.to<=n)continue;let i=N(r);return i&&i[0]<=t&&n<=i[1]?P(r.children,t,n):P(e,Math.min(t,r.from),Math.max(n,r.to))}return[t,n]}function F(e,t,n){for(let r of e)if(!(r.to<=t||r.from>=n)&&(t>r.from||r.to>n))return F(e,Math.min(t,r.from),Math.max(n,r.to));return[t,n]}const I=e=>e===` `||e===` `;function Xe(e,t,n){for(;t<n&&I(e[t]);)t++;for(;n>t&&I(e[n-1]);)n--;return[t,n]}function Ze(e,t,n,r){let i=C(S(e),e=>e.type===r.node||Ye.has(e.type));for(let r=t;r<n;r++)if(!I(e[r])&&!i.some(e=>e.from<=r&&r<e.to))return!1;return!0}function Qe(e,t,n,r,i){let a=S(e),o=C(a,e=>e.type===r.node);return i?tt(e,o,t,n):$e(e,a,o,t,n,r)}function $e(e,t,n,r,i,a){for(let e=0;e!==i-r;){e=i-r,[r,i]=P(t,r,i);for(let e of n)e.to===r&&(r=e.from),e.from===i&&(i=e.to)}let o=[];for(let e of n)if(r<=e.from&&e.to<=i){let[t,n]=M(e);o.push({from:t.from,to:t.to,insert:``}),o.push({from:n.from,to:n.to,insert:``})}let[s,c]=et(e,r,i,o,a);return o.push({from:r,to:r,insert:s},{from:i,to:i,insert:c}),o}function et(e,t,n,r,i){if(i.node!==w.InlineCode)return[i.delim,i.delim];let a=e.slice(t,n);for(let e of[...r].sort((e,t)=>t.from-e.from))a=a.slice(0,e.from-t)+a.slice(e.to-t);let o="`".repeat(A(a)+1),s=a.startsWith("`")||a.endsWith("`")?` `:``;return[o+s,s+o]}function tt(e,t,n,r){let i=[];for(let a of t){if(a.to<=n||a.from>=r)continue;let[t,o]=M(a),s=Math.max(n,t.to),c=Math.min(r,o.from);for(s>=c&&([s,c]=[t.to,o.from]),[s,c]=F(a.children.slice(1,-1),s,c);s>t.to&&I(e[s-1]);)s--;for(;c<o.from&&I(e[c]);)c++;s>t.to?i.push({from:s,to:s,insert:e.slice(o.from,o.to)}):i.push({from:t.from,to:t.to,insert:``}),c<o.from?i.push({from:c,to:c,insert:e.slice(t.from,t.to)}):i.push({from:o.from,to:o.to,insert:``})}return i}function nt(e,t,n){let{delim:r}=n,i=r.length;if(e.slice(t-i,t)===r&&e.startsWith(r,t)&&e[t-i-1]!==r[0]&&e[t+i]!==r[0])return{kind:`unwrap`,from:t-i,to:t+i};let a=S(e),o=C(a,e=>e.type===n.node).findLast(e=>e.from<=t&&t<=e.to);if(o){let[e,n]=M(o);return{kind:`move`,pos:t===o.from?e.to:t===o.to?n.from:o.to}}return L(a,t)||e[t-1]===r[0]||e[t]===r[0]?null:{kind:`insert`,pos:t}}function L(e,t){for(let n of e)if(n.from<t&&t<n.to){let e=N(n);return!e||t<e[0]||t>e[1]?!0:L(n.children,t)}return!1}function R(e){return(t,n)=>{if(t.selection.empty)return rt(e,t,n);let{from:r,to:i,anchor:a,head:o}=t.selection,s=[];t.doc.nodesBetween(r,i,(t,n)=>{if(t.type.spec.code)return!1;if(!t.isTextblock)return!0;let a=t.textContent,o=n+1,[c,l]=Xe(a,Math.max(r-o,0),Math.min(i-o,a.length));return c<l&&s.push({text:a,base:o,from:c,to:l,active:Ze(a,c,l,e)}),!1});let c=s.length>0&&s.every(e=>e.active),l=s.filter(e=>c||!e.active).flatMap(t=>Qe(t.text,t.from,t.to,e,c).map(e=>({from:e.from+t.base,to:e.to+t.base,insert:e.insert})));if(l.length===0)return!1;if(n){let e=t.tr;l.sort((e,t)=>t.from-e.from||t.to-e.to);for(let t of l)t.insert?e.insertText(t.insert,t.from,t.to):e.delete(t.from,t.to);e.setSelection(h.create(e.doc,e.mapping.map(a,a<=o?1:-1),e.mapping.map(o,o<a?1:-1))),n(e.scrollIntoView())}return!0}}function rt(e,t,n){let{$from:r}=t.selection,i=r.parent;if(!i.isTextblock||i.type.spec.code)return!1;let a=nt(i.textContent,r.parentOffset,e);if(!a)return!1;if(n){let i=r.start(),o=t.tr;a.kind===`unwrap`&&o.delete(i+a.from,i+a.to),a.kind===`move`&&o.setSelection(h.create(o.doc,i+a.pos)),a.kind===`insert`&&(o.insertText(e.delim+e.delim,i+a.pos),o.setSelection(h.create(o.doc,i+a.pos+e.delim.length))),n(o.scrollIntoView())}return!0}function it(){return s(n({toggleEm:()=>R(j.em),toggleStrong:()=>R(j.strong),toggleCode:()=>R(j.code),toggleDel:()=>R(j.del)}),i({"Mod-b":R(j.strong),"Mod-i":R(j.em),"Mod-e":R(j.code),"Mod-Shift-x":R(j.del)}))}function at(){return s(he(),me(),ue(),pe(),o(ge()),de(),fe())}function ot(){return s(f(),u(),ie(),c(),ne(),ee(),at(),l(),te(),Je(),Re(),it(),t(),e(),r(),d(),ae(),re())}function st(){return ot()}const ct=new Set([`mdStrong`,`mdEm`,`mdCode`,`mdDel`,`mdLinkText`,`mdLinkUri`,`mdWikilink`]),lt=new Set([`mdMark`,`mdLinkUri`]),ut=new Set([`mdMark`,`mdLinkUri`]),z=new Set([`mdLinkText`,`mdLinkUri`]),dt=new Set([`mdStrong`,`mdEm`,`mdCode`,`mdDel`,`mdWikilink`]);function ft(e){return new p({key:new m(`mark-mode`),props:{attributes:{"data-mark-mode":e},decorations:e===`focus`?e=>ht(e):void 0,clipboardTextSerializer:e===`show`?void 0:mt}})}function pt(e){return o(ft(e))}function mt(e){let t=[];return e.content.forEach(e=>{let n=[];e.descendants(e=>!e.isText||!e.text?!0:(e.marks.some(e=>ut.has(e.type.name))||n.push(e.text),!1)),t.push(n.join(``))}),t.join(`
|
|
2
|
+
`)}function ht(e){let{$anchor:t,empty:n}=e.selection;if(!n)return y.empty;let r=t.parent;if(!r.isTextblock)return null;let i=t.start(),a=t.parentOffset,o=gt(r,a);if(o.size===0)return y.empty;let s=[],c=new Set,l=!1;for(let e of o)if(z.has(e)){if(l)continue;l=!0,vt(r,i,a,s,c)}else _t(r,i,e,a,s,c);let u=s.map(([e,t])=>_e.inline(e,t,{class:`show`}));return y.create(e.doc,u)}function gt(e,t){let n=new Set,r=0;return e.forEach(e=>{let i=r+e.nodeSize;if(t>=r&&t<=i)for(let t of e.marks){let e=t.type.name;ct.has(e)&&n.add(e)}r=i}),n}function _t(e,t,n,r,i,a){let o=t,s=0,c=-1,l=-1;e.forEach(u=>{let d=u.marks.some(e=>e.type.name===n);d&&c===-1&&(c=o,l=s),!d&&c!==-1&&(r>=l&&r<=s&&V(e,t,c,o,i,a),c=-1,l=-1),o+=u.nodeSize,s+=u.nodeSize}),c!==-1&&r>=l&&r<=s&&V(e,t,c,o,i,a)}function vt(e,t,n,r,i){let a=e.childCount;if(a===0)return;let o=-1,s=0;for(let t=0;t<a;t++){let r=e.child(t),i=s+r.nodeSize;if(n>=s&&n<=i&&r.marks.some(e=>z.has(e.type.name))){o=t;break}s=i}if(o===-1)return;let c=o;for(;c>0&&B(e.child(c-1));)c--;let l=o;for(;l<a-1&&B(e.child(l+1));)l++;let u=t;for(let t=0;t<c;t++)u+=e.child(t).nodeSize;let d=u;for(let t=c;t<=l;t++)d+=e.child(t).nodeSize;V(e,t,u,d,r,i)}function B(e){let t=!1,n=!1,r=!1;for(let i of e.marks){let e=i.type.name;e===`mdMark`?t=!0:z.has(e)?n=!0:dt.has(e)&&(r=!0)}return!!(n||t&&!r)}function V(e,t,n,r,i,a){let o=t;e.forEach(e=>{let t=o,s=o+e.nodeSize;if(t>=n&&s<=r)for(let n of e.marks){let e=n.type.name;if(lt.has(e)){let e=`${t}_${s}`;a.has(e)||(a.add(e),i.push([t,s]));break}}o=s})}function yt(e){let t=new xt;return H(e,t),t.finish()}const bt=[``,`# `,`## `,`### `,`#### `,`##### `,`###### `];var xt=class{constructor(){this.parts=[],this.linePrefix=``,this.pendingFirst=null,this.atLineStart=!0,this.deferredBlankPrefix=null}write(e){if(e===``)return;if(this.emitDeferredBlankLine(),this.atLineStart&&=(this.parts.push(this.pendingFirst??this.linePrefix),this.pendingFirst=null,!1),!e.includes(`
|
|
3
3
|
`)){this.parts.push(e);return}let t=e.split(`
|
|
4
4
|
`);for(let e=0;e<t.length;e++)e>0&&this.parts.push(`
|
|
5
5
|
`,this.linePrefix),t[e]!==``&&this.parts.push(t[e])}closeBlock(){this.atLineStart||this.parts.push(`
|
|
6
6
|
`),this.atLineStart=!0,this.deferredBlankPrefix=this.linePrefix}suppressBlank(){this.deferredBlankPrefix=null}withPrefix(e,t,n){let r=this.linePrefix,i=this.pendingFirst;if(this.linePrefix=r+e,t!==null){let e=i??r;this.pendingFirst=e+t}n(),this.linePrefix=r,this.pendingFirst=i}finish(){return this.parts.join(``).replace(/\s+$/,``)+`
|
|
7
7
|
`}emitDeferredBlankLine(){let e=this.deferredBlankPrefix;e!==null&&(this.parts.push(e.trimEnd(),`
|
|
8
|
-
`),this.deferredBlankPrefix=null)}};function H(e,t){switch(e.type.name){case`doc`:U(e,t);return;case`paragraph`:G(e,t),t.closeBlock();return;case`heading`:{let n=e.attrs.level;t.write(
|
|
8
|
+
`),this.deferredBlankPrefix=null)}};function H(e,t){switch(e.type.name){case`doc`:U(e,t);return;case`paragraph`:G(e,t),t.closeBlock();return;case`heading`:{let n=e.attrs.level;t.write(bt[n]??`# `),G(e,t),t.closeBlock();return}case`blockquote`:t.withPrefix(`> `,`> `,()=>U(e,t)),t.closeBlock();return;case`list`:K(e,t,W(e));return;case`codeBlock`:Ct(e,t);return;case`horizontalRule`:t.write(`---`),t.closeBlock();return;case`table`:wt(e,t);return;case`text`:e.text&&t.write(e.text);return}}function U(e,t,n=!1){let r=e.childCount,i=0;for(;i<r;){let a=e.child(i);if(a.type.name!==`list`){n&&i>0&&t.suppressBlank(),H(a,t),i++;continue}let o=i+1;for(;o<r&&e.child(o).type.name===`list`;)o++;let s=St(e,i,o);for(let r=i;r<o;r++)(r===i?n&&i>0:s)&&t.suppressBlank(),K(e.child(r),t,s);i=o}}function St(e,t,n){for(let r=t;r<n;r++)if(!W(e.child(r)))return!1;return!0}function W(e){let t=e.childCount;for(let n=0;n<t;n++){let t=e.child(n);if(t.type.name!==`list`&&!(t.type.name===`paragraph`&&n===0))return!1}return!0}function G(e,t){let n=e.childCount;for(let r=0;r<n;r++){let n=e.child(r);n.isText&&n.text&&t.write(n.text)}}function K(e,t,n){let r=e.attrs,i=r.kind===`ordered`?`${r.order??1}. `:r.kind===`task`?r.checked?`- [x] `:`- [ ] `:`- `,a=` `.repeat(r.kind===`task`?2:i.length);t.withPrefix(a,i,()=>U(e,t,n)),t.closeBlock()}function Ct(e,t){let n=e.attrs.language??``,r=e.textContent,i="`".repeat(A(r,2)+1);t.write(i),n&&t.write(n),t.write(`
|
|
9
9
|
`),t.write(r),t.write(`
|
|
10
|
-
`),t.write(i),t.closeBlock()}function
|
|
10
|
+
`),t.write(i),t.closeBlock()}function wt(e,t){let n=e.childCount;if(n===0)return;let r=[],i=0,a=-1;for(let t=0;t<n;t++){let n=e.child(t),o=[],s=!1;for(let e=0;e<n.childCount;e++){let t=n.child(e);t.type.name===`tableHeaderCell`&&(s=!0),o.push(Tt(t))}s&&a<0&&(a=t),o.length>i&&(i=o.length),r.push(o)}if(i===0)return;let o=`| `+Array(i).fill(`---`).join(` | `)+` |`,s=a>=0?r[a]:Array(i).fill(``);t.write(q(s,i)),t.write(`
|
|
11
11
|
`),t.write(o);for(let e=0;e<n;e++)e!==a&&(t.write(`
|
|
12
|
-
`),t.write(q(r[e],i)));t.closeBlock()}function q(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function
|
|
12
|
+
`),t.write(q(r[e],i)));t.closeBlock()}function q(e,t){let n=`|`;for(let r=0;r<t;r++)n+=` `+(e[r]??``)+` |`;return n}function Tt(e){let t=e.textContent.trim();return!t.includes(`|`)&&!t.includes(`
|
|
13
13
|
`)?t:t.replaceAll(`|`,String.raw`\|`).replaceAll(`
|
|
14
|
-
`,` `)}function
|
|
14
|
+
`,` `)}function Et(e,t){let n=Dt(e,Ee.parse(t).cursor(),t);return e.nodes.doc(n)}function Dt(e,t,n){let r=[];if(!t.firstChild())return r;do r.push(...J(e,t,n));while(t.nextSibling());return t.parent(),r}function J(e,t,n){switch(t.type.id){case w.ATXHeading1:return[Y(e,t,n,1)];case w.ATXHeading2:return[Y(e,t,n,2)];case w.ATXHeading3:return[Y(e,t,n,3)];case w.ATXHeading4:return[Y(e,t,n,4)];case w.ATXHeading5:return[Y(e,t,n,5)];case w.ATXHeading6:return[Y(e,t,n,6)];case w.SetextHeading1:return[Y(e,t,n,1)];case w.SetextHeading2:return[Y(e,t,n,2)];case w.Paragraph:return[X(e,t,n)];case w.Blockquote:return[Z(e,t,n)];case w.BulletList:return Q(e,t,n,`bullet`,1);case w.OrderedList:return Ot(e,t,n);case w.FencedCode:case w.CodeBlock:return[jt(e,t,n)];case w.HorizontalRule:return[e.nodes.horizontalRule()];case w.Table:return[Mt(e,t,n)];case w.Task:return[X(e,t,n)];default:return[]}}function Y(e,t,n,r){let i=t.from,a=t.to;if(t.firstChild()){t.type.id===w.HeaderMark&&(i=t.to);let e=-1,n=-1;do e=t.type.id,n=t.from;while(t.nextSibling());e===w.HeaderMark&&n>i&&(a=n),t.parent()}let o=n.slice(i,a).trim();return e.nodes.heading({level:r},o)}function X(e,t,n){let r=n.slice(t.from,t.to);return e.nodes.paragraph(r)}function Z(e,t,n){let r=[];if(t.firstChild()){do{if(t.type.id===w.QuoteMark)continue;r.push(...J(e,t,n))}while(t.nextSibling());t.parent()}return e.nodes.blockquote(r)}function Q(e,t,n,r,i){let a=[];if(t.firstChild()){do t.type.id===w.ListItem&&a.push(kt(e,t,n,r,i));while(t.nextSibling());t.parent()}return a}function Ot(e,t,n){let r=1;if(t.firstChild()){if(t.type.id===w.ListItem&&t.firstChild()){if(t.type.id===w.ListMark){let e=n.slice(t.from,t.to),i=Number.parseInt(e,10);Number.isFinite(i)&&(r=i)}t.parent()}t.parent()}return Q(e,t,n,`ordered`,r)}function kt(e,t,n,r,i){let a=[],o=null;if(t.firstChild()){do{if(t.type.id===w.ListMark)continue;if(r===`bullet`&&t.type.id===w.Task){let r=At(e,t,n);o=r.checked,a.push(r.paragraph);continue}a.push(...J(e,t,n))}while(t.nextSibling());t.parent()}return e.nodes.list({kind:o===null?r:`task`,order:r===`ordered`?i:null,checked:o??!1,collapsed:!1},a)}function At(e,t,n){let r=!1,i=t.from,a=t.to;t.firstChild()&&(t.type.id===w.TaskMarker&&(r=n.slice(t.from,t.to).toLowerCase().includes(`x`),i=t.to),t.parent());let o=n.slice(i,a);return o.startsWith(` `)&&(o=o.slice(1)),{checked:r,paragraph:o===``?e.nodes.paragraph():e.nodes.paragraph(o)}}function jt(e,t,n){let r=``,i=``;if(t.firstChild()){do switch(t.type.id){case w.CodeInfo:r=n.slice(t.from,t.to);break;case w.CodeText:i=n.slice(t.from,t.to);break}while(t.nextSibling());t.parent()}return e.nodes.codeBlock({language:r},i)}function Mt(e,t,n){let r=[];if(t.firstChild()){do{let i=t.type.id;i===w.TableHeader?r.push($(e,t,n,!0)):i===w.TableRow&&r.push($(e,t,n,!1))}while(t.nextSibling());t.parent()}return e.nodes.table(r)}function $(e,t,n,r){let i=[];if(t.firstChild()){do if(t.type.id===w.TableCell){let a=n.slice(t.from,t.to).trim(),o=e.nodes.paragraph(a);i.push(r?e.nodes.tableHeaderCell(o):e.nodes.tableCell(o))}while(t.nextSibling());t.parent()}return e.nodes.tableRow(i)}export{st as defineEditorExtension,pt as defineMarkMode,yt as docToMarkdown,Et as markdownToDoc};
|
package/dist/style.css
CHANGED
|
@@ -147,52 +147,6 @@ img.ProseMirror-separator {
|
|
|
147
147
|
display: none;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
.ProseMirror .tableWrapper {
|
|
151
|
-
overflow-x: auto;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.ProseMirror table {
|
|
155
|
-
border-collapse: collapse;
|
|
156
|
-
table-layout: fixed;
|
|
157
|
-
width: 100%;
|
|
158
|
-
overflow: hidden;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.ProseMirror td, .ProseMirror th {
|
|
162
|
-
box-sizing: border-box;
|
|
163
|
-
vertical-align: top;
|
|
164
|
-
border-width: 1px;
|
|
165
|
-
padding-left: .75rem;
|
|
166
|
-
padding-right: .75rem;
|
|
167
|
-
position: relative;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
prosekit-table-handle-drop-indicator {
|
|
171
|
-
background-color: highlighttext;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.ProseMirror .column-resize-handle {
|
|
175
|
-
z-index: 20;
|
|
176
|
-
pointer-events: none;
|
|
177
|
-
background-color: highlighttext;
|
|
178
|
-
width: 4px;
|
|
179
|
-
position: absolute;
|
|
180
|
-
top: 0;
|
|
181
|
-
bottom: 0;
|
|
182
|
-
right: -2px;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.ProseMirror.resize-cursor {
|
|
186
|
-
cursor: ew-resize;
|
|
187
|
-
cursor: col-resize;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
.ProseMirror .selectedCell {
|
|
191
|
-
--color: 210, 100%, 56%;
|
|
192
|
-
border: 1px double hsl(var(--color));
|
|
193
|
-
background-color: hsla(var(--color), 20%);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
150
|
:root {
|
|
197
151
|
--meowdown-text: light-dark(#3f3f46, #d4d4d8);
|
|
198
152
|
--meowdown-heading: light-dark(#18181b, #fafafa);
|
|
@@ -201,7 +155,11 @@ prosekit-table-handle-drop-indicator {
|
|
|
201
155
|
--meowdown-mark: light-dark(#a78bfa, #8b5cf6);
|
|
202
156
|
--meowdown-border: light-dark(#e4e4e7, #3f3f46);
|
|
203
157
|
--meowdown-code-bg: light-dark(#f4f4f5, #18181b);
|
|
158
|
+
--meowdown-table-header-bg: light-dark(#fafafa, #27272a);
|
|
204
159
|
--meowdown-font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
160
|
+
--meowdown-node-outline: light-dark(#53f, #8870ff);
|
|
161
|
+
--meowdown-node-selection: light-dark(#5533ff1a, #8870ff1f);
|
|
162
|
+
--meowdown-selection: light-dark(#5533ff38, #8870ff4d);
|
|
205
163
|
--meowdown-gutter: 3.5rem;
|
|
206
164
|
}
|
|
207
165
|
|
|
@@ -312,6 +270,57 @@ prosekit-table-handle-drop-indicator {
|
|
|
312
270
|
margin: 1.5em 0;
|
|
313
271
|
}
|
|
314
272
|
|
|
273
|
+
.ProseMirror table {
|
|
274
|
+
border-collapse: collapse;
|
|
275
|
+
table-layout: fixed;
|
|
276
|
+
width: 100%;
|
|
277
|
+
overflow: hidden;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.ProseMirror td, .ProseMirror th {
|
|
281
|
+
box-sizing: border-box;
|
|
282
|
+
border: 1px solid var(--meowdown-border);
|
|
283
|
+
vertical-align: top;
|
|
284
|
+
text-align: left;
|
|
285
|
+
padding: .4rem .75rem;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.ProseMirror th {
|
|
289
|
+
color: var(--meowdown-heading);
|
|
290
|
+
background: var(--meowdown-table-header-bg);
|
|
291
|
+
font-weight: 600;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.ProseMirror table.ProseMirror-selectednode td, .ProseMirror table.ProseMirror-selectednode th {
|
|
295
|
+
border-color: var(--meowdown-node-outline);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.ProseMirror .selectedCell {
|
|
299
|
+
border: 1px double var(--meowdown-node-outline);
|
|
300
|
+
background: var(--meowdown-node-selection);
|
|
301
|
+
--meowdown-selection: transparent;
|
|
302
|
+
caret-color: #0000;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.ProseMirror ::selection {
|
|
306
|
+
background: var(--meowdown-selection);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.ProseMirror .ProseMirror-selectednode {
|
|
310
|
+
--meowdown-selection: transparent;
|
|
311
|
+
outline: 1px solid var(--meowdown-node-outline);
|
|
312
|
+
background: var(--meowdown-node-selection);
|
|
313
|
+
border-radius: 2px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.ProseMirror pre.ProseMirror-selectednode {
|
|
317
|
+
border-radius: .6rem;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
.ProseMirror.prosekit-dragging {
|
|
321
|
+
--meowdown-node-selection: transparent;
|
|
322
|
+
}
|
|
323
|
+
|
|
315
324
|
.ProseMirror .md-tag {
|
|
316
325
|
background: color-mix(in oklab, var(--meowdown-accent) 10%, transparent);
|
|
317
326
|
color: color-mix(in oklab, var(--meowdown-accent) 80%, var(--meowdown-heading));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"@lezer/markdown": "^1.6.4",
|
|
22
22
|
"@prosekit/core": "^0.12.3",
|
|
23
23
|
"@prosekit/extensions": "^0.17.4",
|
|
24
|
-
"@prosekit/pm": "^0.1.18"
|
|
24
|
+
"@prosekit/pm": "^0.1.18",
|
|
25
|
+
"prosemirror-tables": "^1.8.5"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"@ocavue/tsconfig": "^0.7.1",
|