@pretextbook/web-editor 0.0.10 → 0.0.12

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.
Files changed (41) hide show
  1. package/README.md +128 -128
  2. package/dist/App.d.ts +0 -0
  3. package/dist/components/BubbleMenu.d.ts +0 -0
  4. package/dist/components/CodeEditor.d.ts +0 -0
  5. package/dist/components/CodeEditorMenu.d.ts +0 -0
  6. package/dist/components/Editors.d.ts +0 -0
  7. package/dist/components/FloatingMenu.d.ts +0 -0
  8. package/dist/components/FullPreview.d.ts +0 -0
  9. package/dist/components/MenuBar.d.ts +0 -0
  10. package/dist/components/TheoremLike.d.ts +0 -0
  11. package/dist/components/TiptapMenuBar.d.ts +0 -0
  12. package/dist/components/VisualEditor.d.ts +0 -0
  13. package/dist/defaultContent.d.ts +0 -0
  14. package/dist/extensions/AxiomLike.d.ts +0 -0
  15. package/dist/extensions/Blocks.d.ts +0 -0
  16. package/dist/extensions/Definition.d.ts +0 -0
  17. package/dist/extensions/Divisions.d.ts +0 -0
  18. package/dist/extensions/Emph.d.ts +0 -0
  19. package/dist/extensions/ExampleLike.d.ts +0 -0
  20. package/dist/extensions/Inline.d.ts +0 -0
  21. package/dist/extensions/Keyboard.d.ts +0 -0
  22. package/dist/extensions/Math.d.ts +0 -0
  23. package/dist/extensions/RawPtx.d.ts +0 -0
  24. package/dist/extensions/RemarkLike.d.ts +0 -0
  25. package/dist/extensions/Statement.d.ts +0 -0
  26. package/dist/extensions/TheoremLike.d.ts +0 -0
  27. package/dist/extensions/Title.d.ts +0 -0
  28. package/dist/extensions/UnknownMark.d.ts +0 -0
  29. package/dist/extensions/getCursorPos.d.ts +0 -0
  30. package/dist/index.d.ts +0 -0
  31. package/dist/index.es.js +120 -115
  32. package/dist/index.es.js.map +1 -1
  33. package/dist/index.js +3 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/json2ptx.d.ts +0 -0
  36. package/dist/knownTags.d.ts +0 -0
  37. package/dist/main.d.ts +0 -0
  38. package/dist/ptxSourceSlice.d.ts +0 -0
  39. package/dist/utils.d.ts +0 -0
  40. package/dist/web-editor.css +0 -0
  41. package/package.json +89 -89
package/dist/index.js CHANGED
@@ -874,7 +874,7 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
874
874
  `?C.slice(0,x)+C.slice(x+1):C.slice(0,x)+`
875
875
  `+C.slice(x+1);return C}function ke(C,x){return new ye(C,x).document}return m0}var G8=U8();function K8(r){const e=String(r),t=[];return{toOffset:i,toPoint:n};function n(s){if(typeof s=="number"&&s>-1&&s<=e.length){let o=0;for(;;){let a=t[o];if(a===void 0){const l=om(e,t[o-1]);a=l===-1?e.length+1:l+1,t[o]=a}if(a>s)return{line:o+1,column:s-(o>0?t[o-1]:0)+1,offset:s};o++}}}function i(s){if(s&&typeof s.line=="number"&&typeof s.column=="number"&&!Number.isNaN(s.line)&&!Number.isNaN(s.column)){for(;t.length<s.line;){const a=t[t.length-1],l=om(e,a),u=l===-1?e.length+1:l+1;if(a===u)break;t.push(u)}const o=(s.line>1?t[s.line-2]:0)+s.column-1;if(o<t[s.line-1])return o}}}function om(r,e){const t=r.indexOf("\r",e),n=r.indexOf(`
876
876
  `,e);return n===-1?t:t===-1||t+1===n?n:t<n?t:n}function J8(r){return!r||typeof r!="object"?"":"position"in r||"type"in r?am(r.position):"start"in r||"end"in r?am(r):"line"in r||"column"in r?g0(r):""}function g0(r){return lm(r&&r.line)+":"+lm(r&&r.column)}function am(r){return g0(r&&r.start)+"-"+g0(r&&r.end)}function lm(r){return r&&typeof r=="number"?r:1}class bt extends Error{constructor(e,t,n){super(),typeof t=="string"&&(n=t,t=void 0);let i="",s={},o=!1;if(t&&("line"in t&&"column"in t?s={place:t}:"start"in t&&"end"in t?s={place:t}:"type"in t?s={ancestors:[t],place:t.position}:s={...t}),typeof e=="string"?i=e:!s.cause&&e&&(o=!0,i=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof n=="string"){const l=n.indexOf(":");l===-1?s.ruleId=n:(s.source=n.slice(0,l),s.ruleId=n.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=J8(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}bt.prototype.file="",bt.prototype.name="",bt.prototype.reason="",bt.prototype.message="",bt.prototype.stack="",bt.prototype.column=void 0,bt.prototype.line=void 0,bt.prototype.ancestors=void 0,bt.prototype.cause=void 0,bt.prototype.fatal=void 0,bt.prototype.place=void 0,bt.prototype.ruleId=void 0,bt.prototype.source=void 0;function Y8(r){const e=K8(r);let t;try{t=G8.parseXml(String(r),{includeOffsets:!0,preserveCdata:!0,preserveComments:!0,preserveDocumentType:!0,preserveXmlDeclaration:!0})}catch(s){const o=s,a=e.toPoint(o.pos),l=new bt("Could not parse XML with `@rgrove/parse-xml`",{cause:o,place:a,ruleId:"error",source:"xast-util-from-xml"});throw l.fatal=!0,l.url="https://github.com/syntax-tree/xast-util-from-xml#throws",l}const n={location:e},i=Q8(t,n);return cm(t,i,n),i}function X8(r){return{type:"cdata",value:r.text}}function Z8(r){return{type:"comment",value:r.content}}function Q8(r,e){return{type:"root",children:um(r.children,e)}}function e9(r){return{type:"doctype",name:r.name,public:r.publicId||void 0,system:r.systemId||void 0}}function t9(r,e){const t=um(r.children,e);return{type:"element",name:r.name,attributes:{...r.attributes},children:t}}function r9(r){return{type:"instruction",name:r.name,value:r.content}}function n9(r){return{type:"text",value:r.text}}function i9(r){const e=[];return r.version&&e.push('version="'+r.version+'"'),r.encoding&&e.push('encoding="'+r.encoding+'"'),r.standalone&&e.push('standalone="'+r.standalone+'"'),{type:"instruction",name:"xml",value:e.join(" ")}}function um(r,e){const t=[];let n=-1;for(;++n<r.length;){const i=r[n];let s;i.type==="cdata"?s=X8(i):i.type==="comment"?s=Z8(i):i.type==="doctype"?s=e9(i):i.type==="element"?s=t9(i,e):i.type==="pi"?s=r9(i):i.type==="text"?s=n9(i):i.type==="xmldecl"&&(s=i9(i)),s&&(cm(i,s,e),t.push(s))}return t}function cm(r,e,t){const n=r.start===-1?void 0:t.location.toPoint(r.start),i=r.end===-1?void 0:t.location.toPoint(r.end);n&&i&&(e.position={start:n,end:i})}const s9=/["&'<>`]/g,o9=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,a9=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,l9=/[|\\{}()[\]^$+*?.]/g,dm=new WeakMap;function u9(r,e){if(r=r.replace(e.subset?c9(e.subset):s9,n),e.subset||e.escapeOnly)return r;return r.replace(o9,t).replace(a9,n);function t(i,s,o){return e.format((i.charCodeAt(0)-55296)*1024+i.charCodeAt(1)-56320+65536,o.charCodeAt(s+2),e)}function n(i,s,o){return e.format(i.charCodeAt(0),o.charCodeAt(s+1),e)}}function c9(r){let e=dm.get(r);return e||(e=d9(r),dm.set(r,e)),e}function d9(r){const e=[];let t=-1;for(;++t<r.length;)e.push(r[t].replace(l9,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}function f9(r){return"&#x"+r.toString(16).toUpperCase()+";"}function h9(r,e){return u9(r,Object.assign({format:f9},e))}const p9=/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;function qn(r,e,t){const n=m9(r);return t?n.replace(t,i):i(n);function i(s){return h9(s,{subset:e})}}function m9(r){return String(r||"").replace(p9,"")}const g9=/]]>/g,v9=[">"];function y9(r){return"<![CDATA["+qn(r.value,v9,g9)+"]]>"}function b9(r){return"<!--"+qn(r.value,["-"])+"-->"}const w9=[" ",`
877
- `," ",'"',"&","'","/","<","=",">"];function xo(r){return qn(r,w9)}function fm(r,e){const t=String(r);if(typeof e!="string")throw new TypeError("Expected character");let n=0,i=t.indexOf(e);for(;i!==-1;)n++,i=t.indexOf(e,i+e.length);return n}function v0(r,e){const t=String(r);let n=e.options.quote||'"';if(e.options.quoteSmart){const i=n==='"'?"'":'"';fm(t,n)>fm(t,i)&&(n=i)}return n+qn(t,["<","&",n])+n}function x9(r,e){const t=xo(r.name),n=r.public,i=r.system;let s="<!DOCTYPE";return t!==""&&(s+=" "+t),n?s+=" PUBLIC "+v0(n,e):i&&(s+=" SYSTEM"),i&&(s+=" "+v0(i,e)),s+">"}const S9={}.hasOwnProperty;function k9(r,e){const t=xo(r.name),n=gm(r,e),i=r.attributes||{},s=n?!1:e.options.closeEmptyElements,o=[];let a;for(a in i)if(S9.call(i,a)){const l=i[a];l!=null&&o.push(xo(a)+"="+v0(l,e))}return"<"+t+(o.length===0?"":" "+o.join(" "))+(s?(e.options.tightClose?"":" ")+"/":"")+">"+n+(s?"":"</"+t+">")}const T9=/\?>/g,M9=[">"];function C9(r){const e=xo(r.name)||"x",t=qn(r.value,M9,T9);return"<?"+e+(t?" "+t:"")+"?>"}const E9=["&","<"];function hm(r){return qn(r.value,E9)}function A9(r,e){return e.options.allowDangerousXml?r.value:hm(r)}const O9={}.hasOwnProperty,pm={cdata:y9,comment:b9,doctype:x9,element:k9,instruction:C9,raw:A9,root:gm,text:hm};function mm(r,e){const t=r&&r.type;if(!t)throw new Error("Expected node, not `"+r+"`");if(!O9.call(pm,t))throw new Error("Cannot compile unknown node `"+t+"`");const n=pm[t];return n(r,e)}function gm(r,e){const t=r&&r.children||[];let n=-1;const i=[];for(;++n<t.length;)i[n]=mm(t[n],e);return i.join("")}function vm(r,e){const t={options:{}};if(typeof t.options.quote=="string"&&t.options.quote!=='"'&&t.options.quote!=="'")throw new Error("Invalid quote `"+t.options.quote+"`, expected `'` or `\"`");const n=Array.isArray(r)?{type:"root",children:r}:r;return mm(n,t)}const ym=(function(r){if(r==null)return R9;if(typeof r=="function")return So(r);if(typeof r=="object")return Array.isArray(r)?N9(r):D9(r);if(typeof r=="string")return I9(r);throw new Error("Expected function, string, or object as test")});function N9(r){const e=[];let t=-1;for(;++t<r.length;)e[t]=ym(r[t]);return So(n);function n(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function D9(r){const e=r;return So(t);function t(n){const i=n;let s;for(s in r)if(i[s]!==e[s])return!1;return!0}}function I9(r){return So(e);function e(t){return t&&t.type===r}}function So(r){return e;function e(t,n,i){return!!(P9(t)&&r.call(this,t,typeof n=="number"?n:void 0,i||void 0))}}function R9(){return!0}function P9(r){return r!==null&&typeof r=="object"&&"type"in r}function Hx(r){return r}const bm=[],z9=!0,wm=!1,xm="skip";function L9(r,e,t,n){let i;typeof e=="function"&&typeof t!="function"?(n=t,t=e):i=e;const s=ym(i),o=n?-1:1;a(r,void 0,[])();function a(l,u,c){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const f=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(f?"<"+f+">":""))+")"})}return h;function h(){let f=bm,m,v,y;if((!e||s(l,u,c[c.length-1]||void 0))&&(f=B9(t(l,c)),f[0]===wm))return f;if("children"in l&&l.children){const w=l;if(w.children&&f[0]!==xm)for(v=(n?w.children.length:-1)+o,y=c.concat(w);v>-1&&v<w.children.length;){const k=w.children[v];if(m=a(k,v,y)(),m[0]===wm)return m;v=typeof m[1]=="number"?m[1]:v+o}}return f}}}function B9(r){return Array.isArray(r)?r:typeof r=="number"?[z9,r]:r==null?bm:[r]}function F9(r,e,t,n){let i,s,o;typeof e=="function"&&typeof t!="function"?(s=void 0,o=e,i=t):(s=e,o=t,i=n),L9(r,s,a,i);function a(l,u){const c=u[u.length-1],d=c?c.children.indexOf(l):void 0;return o(l,d,c)}}const $9=["theorem","lemma","corollary","proposition","claim","fact","proof"],H9=["convention","insight","note","observation","remark","warning"],V9=["assumption","axiom","conjecture","heuristic","hypothesis","principle"],_9=["introduction","part","chapter","section","subsection","worksheet"],j9=["example","question","problem"],q9=["solution","answer","hint"],W9=["ptxdoc","p","m","me","md","ol","ul","li",..._9,"title","definition","statement",...$9,...V9,...H9,...j9,...q9,"term","em","alert","c","pre"];function U9(r){let e=r.trim();e=`<ptxdoc>
877
+ `," ",'"',"&","'","/","<","=",">"];function xo(r){return qn(r,w9)}function fm(r,e){const t=String(r);if(typeof e!="string")throw new TypeError("Expected character");let n=0,i=t.indexOf(e);for(;i!==-1;)n++,i=t.indexOf(e,i+e.length);return n}function v0(r,e){const t=String(r);let n=e.options.quote||'"';if(e.options.quoteSmart){const i=n==='"'?"'":'"';fm(t,n)>fm(t,i)&&(n=i)}return n+qn(t,["<","&",n])+n}function x9(r,e){const t=xo(r.name),n=r.public,i=r.system;let s="<!DOCTYPE";return t!==""&&(s+=" "+t),n?s+=" PUBLIC "+v0(n,e):i&&(s+=" SYSTEM"),i&&(s+=" "+v0(i,e)),s+">"}const S9={}.hasOwnProperty;function k9(r,e){const t=xo(r.name),n=gm(r,e),i=r.attributes||{},s=n?!1:e.options.closeEmptyElements,o=[];let a;for(a in i)if(S9.call(i,a)){const l=i[a];l!=null&&o.push(xo(a)+"="+v0(l,e))}return"<"+t+(o.length===0?"":" "+o.join(" "))+(s?(e.options.tightClose?"":" ")+"/":"")+">"+n+(s?"":"</"+t+">")}const T9=/\?>/g,M9=[">"];function C9(r){const e=xo(r.name)||"x",t=qn(r.value,M9,T9);return"<?"+e+(t?" "+t:"")+"?>"}const E9=["&","<"];function hm(r){return qn(r.value,E9)}function A9(r,e){return e.options.allowDangerousXml?r.value:hm(r)}const O9={}.hasOwnProperty,pm={cdata:y9,comment:b9,doctype:x9,element:k9,instruction:C9,raw:A9,root:gm,text:hm};function mm(r,e){const t=r&&r.type;if(!t)throw new Error("Expected node, not `"+r+"`");if(!O9.call(pm,t))throw new Error("Cannot compile unknown node `"+t+"`");const n=pm[t];return n(r,e)}function gm(r,e){const t=r&&r.children||[];let n=-1;const i=[];for(;++n<t.length;)i[n]=mm(t[n],e);return i.join("")}function vm(r,e){const t={options:{}};if(typeof t.options.quote=="string"&&t.options.quote!=='"'&&t.options.quote!=="'")throw new Error("Invalid quote `"+t.options.quote+"`, expected `'` or `\"`");const n=Array.isArray(r)?{type:"root",children:r}:r;return mm(n,t)}const ym=(function(r){if(r==null)return R9;if(typeof r=="function")return So(r);if(typeof r=="object")return Array.isArray(r)?N9(r):D9(r);if(typeof r=="string")return I9(r);throw new Error("Expected function, string, or object as test")});function N9(r){const e=[];let t=-1;for(;++t<r.length;)e[t]=ym(r[t]);return So(n);function n(...i){let s=-1;for(;++s<e.length;)if(e[s].apply(this,i))return!0;return!1}}function D9(r){const e=r;return So(t);function t(n){const i=n;let s;for(s in r)if(i[s]!==e[s])return!1;return!0}}function I9(r){return So(e);function e(t){return t&&t.type===r}}function So(r){return e;function e(t,n,i){return!!(P9(t)&&r.call(this,t,typeof n=="number"?n:void 0,i||void 0))}}function R9(){return!0}function P9(r){return r!==null&&typeof r=="object"&&"type"in r}function Hx(r){return r}const bm=[],z9=!0,wm=!1,xm="skip";function L9(r,e,t,n){let i;typeof e=="function"&&typeof t!="function"?(n=t,t=e):i=e;const s=ym(i),o=n?-1:1;a(r,void 0,[])();function a(l,u,c){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const f=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(h,"name",{value:"node ("+(l.type+(f?"<"+f+">":""))+")"})}return h;function h(){let f=bm,m,v,y;if((!e||s(l,u,c[c.length-1]||void 0))&&(f=B9(t(l,c)),f[0]===wm))return f;if("children"in l&&l.children){const w=l;if(w.children&&f[0]!==xm)for(v=(n?w.children.length:-1)+o,y=c.concat(w);v>-1&&v<w.children.length;){const k=w.children[v];if(m=a(k,v,y)(),m[0]===wm)return m;v=typeof m[1]=="number"?m[1]:v+o}}return f}}}function B9(r){return Array.isArray(r)?r:typeof r=="number"?[z9,r]:r==null?bm:[r]}function F9(r,e,t,n){let i,s,o;typeof e=="function"&&typeof t!="function"?(s=void 0,o=e,i=t):(s=e,o=t,i=n),L9(r,s,a,i);function a(l,u){const c=u[u.length-1],d=c?c.children.indexOf(l):void 0;return o(l,d,c)}}const $9=["theorem","lemma","corollary","proposition","claim","fact","proof"],H9=["convention","insight","note","observation","remark","warning"],V9=["assumption","axiom","conjecture","heuristic","hypothesis","principle"],_9=["introduction","part","chapter","section","subsection","worksheet"],j9=["example","question","problem"],q9=["solution","answer","hint"],W9=["ptxdoc","p","m","me","md","ol","ul","li",..._9,"title","definition","statement",...$9,...V9,...H9,...j9,...q9,"term","em","alert","c","pre"];function U9(r){let e=r.trim();if(e.startsWith("<?xml")){const i=e.indexOf("?>");i!==-1&&(e=e.slice(i+2).trim())}e=`<ptxdoc>
878
878
  ${e}
879
879
  </ptxdoc>`;const t=Y8(e);return console.log("xast before: ",t),F9(t,(i,s,o)=>{if(i.type==="element"&&!W9.includes(i.name)){const a={type:"element",name:"rawptx",attributes:{},children:[{type:"text",value:vm(i)}]};return typeof s!="number"||!o?void 0:(o.children.splice(s,1,a),xm)}}),console.log("xast after: ",t),vm(t)}function G9(){return{label:{parseHTML:r=>r.getAttribute("label")},"xml:id":{parseHTML:r=>r.getAttribute("xml:id")},component:{parseHTML:r=>r.getAttribute("component")}}}function Sr(r,e){return[ut({find:new RegExp(`^#${r}\\s$`,"i"),type:e}),ut({find:new RegExp(`(?:^)(<${r}>(\\s))$`,"i"),type:e}),ut({find:new RegExp(`(?:^)(${r}:(\\s))$`,"i"),type:e})]}const K9=["theorem","lemma","corollary","proposition","claim","fact"],J9=Se.create({name:"theoremLike",addExtensions(){const r=[];for(const e of K9)r.push(we.create({name:e,content:"title? statement proof*",group:"block theoremLike",selectable:!0,draggable:!0,defining:!1,parseHTML(){return[{tag:e}]},addAttributes(){return G9()},renderHTML({HTMLAttributes:t}){return["article",ge({class:`${e} theorem-like`,ptxtag:e},t)]},addNodeView(){return bn($i)},addInputRules(){return Sr(e,this.type)}}));return r.push(we.create({name:"proof",content:"title? BasicBlock+",group:"block",selectable:!0,draggable:!0,parseHTML(){return[{tag:"proof"}]},renderHTML({HTMLAttributes:e}){return["article",ge({class:"proof",ptxtag:"proof"},e),0]},addNodeView(){return bn(im)},addInputRules(){return Sr("proof",this.type)}})),r}}),Y9=["assumption","axiom","conjecture","heuristic","hypothesis","principle"],X9=Se.create({name:"axiomLike",addExtensions(){const r=[];for(const e of Y9)r.push(we.create({name:e,content:"title? statement",group:"block axiomLike",selectable:!0,draggable:!0,parseHTML(){return[{tag:e}]},renderHTML({HTMLAttributes:t}){return["article",ge({class:`${e} axiom-like`,label:e},t),0]},addNodeView(){return bn($i)},addInputRules(){return Sr(e,this.type)}}));return r}}),Z9=we.create({name:"statement",content:"BasicBlock+",group:"blockContent",parseHTML(){return[{tag:"statement"}]},renderHTML(){return["div",{class:"statement",ptxtag:"statement"},0]},addInputRules(){return Sr("statement",this.type)}}),Q9=["example","question","problem"],ew=Se.create({name:"exampleLike",addExtensions(){const r=[];for(const e of Q9)r.push(we.create({name:e,content:"title? (BasicBlock*|(statement hint* answer* solution*))",group:"block exampleLike",selectable:!0,draggable:!0,defining:!1,parseHTML(){return[{tag:e}]},addAttributes(){return{label:{parseHTML:t=>t.getAttribute("label")},"xml:id":{parseHTML:t=>t.getAttribute("xml:id")},component:{parseHTML:t=>t.getAttribute("component")}}},renderHTML({HTMLAttributes:t}){return["article",ge({class:`${e} theorem-like`,ptxtag:e},t)]},addNodeView(){return bn($i)},addInputRules(){return Sr(e,this.type)}}));for(const e of["hint","answer","solution"])r.push(we.create({name:e,content:"title? BasicBlock+",group:"block solutionLike",selectable:!0,draggable:!0,defining:!1,parseHTML(){return[{tag:e}]},addAttributes(){return{label:{parseHTML:t=>t.getAttribute("label")},"xml:id":{parseHTML:t=>t.getAttribute("xml:id")},component:{parseHTML:t=>t.getAttribute("component")}}},renderHTML({HTMLAttributes:t}){return["article",ge({class:"proof",ptxtag:"proof"},t),0]},addNodeView(){return bn(im)},addInputRules(){return Sr("proof",this.type)}}));return r}}),tw=["convention","insight","note","observation","remark","warning"],rw=Se.create({name:"remarkLike",addExtensions(){return tw.map(r=>we.create({name:r,content:"title? BasicBlock+",group:"block remarkLike",selectable:!0,draggable:!0,parseHTML(){return[{tag:r}]},renderHTML({HTMLAttributes:e}){return["article",ge({class:`${r} remark-like`,label:r},e),0]},addNodeView(){return bn($i)},addInputRules(){return Sr(r,this.type)}}))}}),nw=we.create({name:"p",content:"inline*",group:"BasicBlock paragraph",draggable:!0,defining:!1,priority:1e3,parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:r}){return["div",ge({class:"p",ptxtag:"p"},r),0]},addInputRules(){return[ut({find:new RegExp("^#p\\s$"),type:this.type})]}}),iw=Se.create({name:"blocks",addExtensions(){return[nw,J9,ew,X9,rw,Z9]}});var y0=4,sw=/^```([a-z]+)?[\s\n]$/,ow=/^~~~([a-z]+)?[\s\n]$/,aw=we.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:y0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:r=>{var e;const{languageClassPrefix:t}=this.options;if(!t)return null;const s=[...((e=r.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:r,HTMLAttributes:e}){return["pre",ge(this.options.HTMLAttributes,e),["code",{class:r.attrs.language?this.options.languageClassPrefix+r.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(r,e)=>{var t;return((t=r.raw)==null?void 0:t.startsWith("```"))===!1&&r.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:r.lang||null},r.text?[e.createTextNode(r.text)]:[])},renderMarkdown:(r,e)=>{var t;let n="";const i=((t=r.attrs)==null?void 0:t.language)||"";return r.content?n=[`\`\`\`${i}`,e.renderChildren(r.content),"```"].join(`
880
880
  `):n=`\`\`\`${i}
@@ -911,7 +911,8 @@ $&`),i=i.replace(h,`$&
911
911
  `);else u[c].trim().startsWith("<title>")&&(u[c]+=`
912
912
  `);break;case"many":for(let c=0;c<u.length-1;c++)(u[c].trim().startsWith("</")||u[c].trim().startsWith("<")&&u[c+1].trim().startsWith("<"))&&(u[c]+=`
913
913
  `);break}return i=u.join(`
914
- `),i}const Tx=we.create({name:"ptxFragment",topNode:!0,content:"ptxdoc"}),Mx=[lw.configure({defaultLanguage:"xml"}),Tx,W8,vh,Ah,yh,iw,L8,uw,cw,dw,C8,E8,A8,i6.configure({mode:"deepest"}),o6,s6],v1=({content:r,onChange:e})=>{const t=z.useRef(null),n=l7({extensions:Mx,content:"",onContentError(a){console.log("Content error: ",a.error),a.disableCollaboration(),a.editor.setEditable(!1,!1)},enableContentCheck:!0,onUpdate:({editor:a})=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{e(kx(fw(a.getJSON())))},500)}});z.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]);const i=z.useRef(!0);z.useEffect(()=>{if(n&&r!==n.getHTML()&&i.current){const a=r;if(n)try{n.commands.setContent(U9(a),{emitUpdate:!1})}catch(l){console.error("Error setting content: ",l)}}},[r,n]),z.useEffect(()=>{if(!n)return;const a=()=>{i.current=!1};return n.on("update",a),()=>{n.off("update",a)}},[n]),z.useEffect(()=>{i.current=!0},[r]);const[s,o]=z.useState(!1);return z.useEffect(()=>{n&&n.setEditable(s,!1)},[n,s]),Y.jsxs("div",{className:"pretext-plus-editor__visual-editor",children:[Y.jsxs("div",{className:"pretext-plus-editor__visual-editor-header",children:[Y.jsx("p",{className:"pretext-plus-editor__visual-editor-title",children:"Simple Preview"}),Y.jsxs("label",{className:"pretext-plus-editor__edit-toggle",children:[Y.jsx("input",{className:"pretext-plus-editor__edit-checkbox",type:"checkbox",checked:s,onChange:()=>o(!s)}),"Edit"]})]}),Y.jsx("div",{className:(s?"editable":"read-only")+" ptx-page",children:Y.jsx(n7,{editor:n})}),Y.jsx(yx,{editor:n})]})},y1=(r,e,t)=>{const n=document.createElement("form");n.method="POST",n.action=r,n.target=t,n.style.display="none";for(const i in e)if(Object.hasOwnProperty.call(e,i)){const s=document.createElement("input");s.type="hidden",s.name=i,s.value=e[i],n.appendChild(s)}document.body.appendChild(n),n.submit(),n.remove()},b1=({content:r,title:e,onRebuild:t})=>{const[n,i]=z.useState(!1),s=z.useRef(null);z.useEffect(()=>{o()},[]);const o=()=>{const l=r,u=e||"Document Title";if(i(!0),t){t(l,u,(d,h)=>{y1(d,h,"fullPreview")});return}},a=()=>{i(!1)};return Y.jsxs("div",{className:"pretext-plus-editor__full-preview",children:[Y.jsxs("div",{className:"pretext-plus-editor__preview-header",children:[Y.jsx("p",{className:"pretext-plus-editor__preview-title",children:"Full Preview"}),Y.jsx("button",{className:"pretext-plus-editor__rebuild-button",onClick:()=>o(),children:"Rebuild"})]}),Y.jsxs("div",{className:"pretext-plus-editor__preview-container",children:[n&&Y.jsx("div",{className:"pretext-plus-editor__rebuilding-overlay",children:Y.jsxs("div",{className:"pretext-plus-editor__rebuilding-popup",children:[Y.jsx("div",{className:"pretext-plus-editor__spinner"}),Y.jsx("p",{className:"pretext-plus-editor__rebuilding-text",children:"Rebuilding..."})]})}),Y.jsx("iframe",{ref:s,className:"pretext-plus-editor__preview-iframe",name:"fullPreview",onLoad:a})]})]})},Cx=r=>{let e;return r.showPreviewModeToggle===!1?e=null:e=Y.jsxs("label",{className:"pretext-plus-editor__preview-toggle",children:[Y.jsx("input",{type:"checkbox",checked:!r.isChecked,onChange:r.onChange,className:"pretext-plus-editor__preview-toggle-input"}),Y.jsxs("div",{className:"pretext-plus-editor__preview-toggle-container",children:[Y.jsx("span",{className:"pretext-plus-editor__preview-toggle-label",children:"Simple"}),Y.jsx("span",{className:`pretext-plus-editor__preview-toggle-slider ${r.isChecked?"pretext-plus-editor__preview-toggle-slider--active":""}`,children:Y.jsx("span",{className:`pretext-plus-editor__preview-toggle-dot ${r.isChecked?"pretext-plus-editor__preview-toggle-dot--active":""}`})}),Y.jsx("span",{className:"pretext-plus-editor__preview-toggle-label",children:"Full"})]}),Y.jsx("span",{className:"pretext-plus-editor__preview-toggle-caption",children:"Preview Mode"}),Y.jsx("input",{type:"checkbox",checked:r.isChecked,onChange:r.onChange,className:"pretext-plus-editor__preview-toggle-input"})]}),Y.jsxs("div",{className:"pretext-plus-editor__menu-bar",children:[Y.jsx("div",{className:"pretext-plus-editor__menu-left",children:r.title!==void 0&&r.onTitleChange&&Y.jsxs("label",{className:"pretext-plus-editor__title-label",children:["Title"," ",Y.jsx("input",{className:"pretext-plus-editor__title-input",type:"text",value:r.title,onChange:t=>r.onTitleChange?.(t.target.value)})]})}),Y.jsxs("div",{className:"pretext-plus-editor__menu-right",children:[r.onSaveButton&&Y.jsx("button",{className:"pretext-plus-editor__button pretext-plus-editor__button--save",onClick:r.onSaveButton,children:r.saveButtonLabel||"Save"}),r.onCancelButton&&Y.jsx("button",{className:"pretext-plus-editor__button pretext-plus-editor__button--cancel",onClick:r.onCancelButton,children:r.cancelButtonLabel||"Cancel"}),e]})]})},Ex=`
914
+ `),i}const Tx=we.create({name:"ptxFragment",topNode:!0,content:"ptxdoc"}),Mx=[lw.configure({defaultLanguage:"xml"}),Tx,W8,vh,Ah,yh,iw,L8,uw,cw,dw,C8,E8,A8,i6.configure({mode:"deepest"}),o6,s6],v1=({content:r,onChange:e})=>{const t=z.useRef(null),n=z.useRef(!1),i=l7({extensions:Mx,content:r,onContentError(l){console.log("Content error: ",l.error),l.disableCollaboration(),l.editor.setEditable(!1,!1)},enableContentCheck:!0,onUpdate:({editor:l})=>{console.log("Editor update detected."),t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{n.current&&e(kx(fw(l.getJSON())))},500)}});z.useEffect(()=>()=>{t.current&&clearTimeout(t.current)},[]);const s=z.useRef(!0);z.useEffect(()=>{if(i&&r!==i.getHTML()&&s.current){const l=r;if(i)try{i.commands.setContent(U9(l),{emitUpdate:!1}),console.log("External content set in visual editor.")}catch(u){console.error("Error setting content: ",u)}}},[r,i]),z.useEffect(()=>{if(!i)return;const l=()=>{s.current=!1};return i.on("update",l),()=>{i.off("update",l)}},[i]),z.useEffect(()=>{s.current=!0},[r]);const[o,a]=z.useState(!1);return z.useEffect(()=>{n.current=o,i&&i.setEditable(o,!1)},[i,o]),Y.jsxs("div",{className:"pretext-plus-editor__visual-editor",children:[Y.jsxs("div",{className:"pretext-plus-editor__visual-editor-header",children:[Y.jsx("p",{className:"pretext-plus-editor__visual-editor-title",children:"Simple Preview"}),Y.jsxs("label",{className:"pretext-plus-editor__edit-toggle",children:[Y.jsx("input",{className:"pretext-plus-editor__edit-checkbox",type:"checkbox",checked:o,onChange:()=>a(!o)}),"Edit"]})]}),Y.jsx("div",{className:(o?"editable":"read-only")+" ptx-page",children:Y.jsx(n7,{editor:i})}),Y.jsx(yx,{editor:i})]})},y1=(r,e,t)=>{const n=document.createElement("form");n.method="POST",n.action=r,n.target=t,n.style.display="none";for(const i in e)if(Object.hasOwnProperty.call(e,i)){const s=document.createElement("input");s.type="hidden",s.name=i,s.value=e[i],n.appendChild(s)}document.body.appendChild(n),n.submit(),n.remove()},b1=({content:r,title:e,onRebuild:t})=>{const[n,i]=z.useState(!1),s=z.useRef(null);z.useEffect(()=>{o()},[]);const o=()=>{const l=r,u=e||"Document Title";if(i(!0),t){t(l,u,(d,h)=>{y1(d,h,"fullPreview")});return}},a=()=>{i(!1)};return Y.jsxs("div",{className:"pretext-plus-editor__full-preview",children:[Y.jsxs("div",{className:"pretext-plus-editor__preview-header",children:[Y.jsx("p",{className:"pretext-plus-editor__preview-title",children:"Full Preview"}),Y.jsx("button",{className:"pretext-plus-editor__rebuild-button",onClick:()=>o(),children:"Rebuild"})]}),Y.jsxs("div",{className:"pretext-plus-editor__preview-container",children:[n&&Y.jsx("div",{className:"pretext-plus-editor__rebuilding-overlay",children:Y.jsxs("div",{className:"pretext-plus-editor__rebuilding-popup",children:[Y.jsx("div",{className:"pretext-plus-editor__spinner"}),Y.jsx("p",{className:"pretext-plus-editor__rebuilding-text",children:"Rebuilding..."})]})}),Y.jsx("iframe",{ref:s,className:"pretext-plus-editor__preview-iframe",name:"fullPreview",onLoad:a})]})]})},Cx=r=>{let e;return r.showPreviewModeToggle===!1?e=null:e=Y.jsxs("label",{className:"pretext-plus-editor__preview-toggle",children:[Y.jsx("input",{type:"checkbox",checked:!r.isChecked,onChange:r.onChange,className:"pretext-plus-editor__preview-toggle-input"}),Y.jsxs("div",{className:"pretext-plus-editor__preview-toggle-container",children:[Y.jsx("span",{className:"pretext-plus-editor__preview-toggle-label",children:"Simple"}),Y.jsx("span",{className:`pretext-plus-editor__preview-toggle-slider ${r.isChecked?"pretext-plus-editor__preview-toggle-slider--active":""}`,children:Y.jsx("span",{className:`pretext-plus-editor__preview-toggle-dot ${r.isChecked?"pretext-plus-editor__preview-toggle-dot--active":""}`})}),Y.jsx("span",{className:"pretext-plus-editor__preview-toggle-label",children:"Full"})]}),Y.jsx("span",{className:"pretext-plus-editor__preview-toggle-caption",children:"Preview Mode"}),Y.jsx("input",{type:"checkbox",checked:r.isChecked,onChange:r.onChange,className:"pretext-plus-editor__preview-toggle-input"})]}),Y.jsxs("div",{className:"pretext-plus-editor__menu-bar",children:[Y.jsx("div",{className:"pretext-plus-editor__menu-left",children:r.title!==void 0&&r.onTitleChange&&Y.jsxs("label",{className:"pretext-plus-editor__title-label",children:["Title"," ",Y.jsx("input",{className:"pretext-plus-editor__title-input",type:"text",value:r.title,onChange:t=>r.onTitleChange?.(t.target.value)})]})}),Y.jsxs("div",{className:"pretext-plus-editor__menu-right",children:[r.onSaveButton&&Y.jsx("button",{className:"pretext-plus-editor__button pretext-plus-editor__button--save",onClick:r.onSaveButton,children:r.saveButtonLabel||"Save"}),r.onCancelButton&&Y.jsx("button",{className:"pretext-plus-editor__button pretext-plus-editor__button--cancel",onClick:r.onCancelButton,children:r.cancelButtonLabel||"Cancel"}),e]})]})},Ex=`
915
+ <?xml version="1.0" encoding="UTF-8"?>
915
916
  <section>
916
917
  <title>My Section</title>
917
918
  <p>