efficient-easel 10.3.1 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +11 -6
  2. package/dist/{canvas-typing-CJodefPO.d.ts → canvas-typing-DvoqQINU.d.ts} +43 -1
  3. package/dist/chunk-2PTAR4TA.js +56 -0
  4. package/dist/{chunk-BJNZKYK7.js → chunk-3KAQXJVI.js} +1 -1
  5. package/dist/{chunk-FCLW4LEN.js → chunk-47RGVCPH.js} +7 -7
  6. package/dist/{chunk-BGY4Q2SL.js → chunk-4MPCFKFG.js} +1 -1
  7. package/dist/{chunk-JSPZU7X2.js → chunk-7GYJG6CL.js} +1 -1
  8. package/dist/{chunk-P4CL4YQI.js → chunk-AFSSKGTD.js} +1 -1
  9. package/dist/{chunk-OGCROOTI.js → chunk-DGAXQTDW.js} +1 -1
  10. package/dist/chunk-FGJSCWUN.js +7 -0
  11. package/dist/chunk-GCCBEY2W.js +2 -0
  12. package/dist/chunk-GG4FGBFR.js +1 -0
  13. package/dist/chunk-HUI44HA5.js +5 -0
  14. package/dist/chunk-I55LUW3C.js +12 -0
  15. package/dist/{chunk-BRDCD4LK.js → chunk-IFS5P7CO.js} +1 -1
  16. package/dist/chunk-IOZKOGFR.js +1 -0
  17. package/dist/{chunk-545BRJIU.js → chunk-O66SKO3J.js} +1 -1
  18. package/dist/chunk-OHRS7Q3E.js +5 -0
  19. package/dist/{chunk-BPMLHWWM.js → chunk-PQMCHTVE.js} +1 -1
  20. package/dist/{chunk-535CJ7J4.js → chunk-UB5JFMRN.js} +1 -1
  21. package/dist/chunk-VWXUMVCD.js +1 -0
  22. package/dist/{chunk-26GHWMNN.js → chunk-XAF6J6TB.js} +12 -12
  23. package/dist/{chunk-QDAJKEG3.js → chunk-YJQYO6TA.js} +1 -1
  24. package/dist/{chunk-VYHA6EA6.js → chunk-YXIR3EI3.js} +4 -4
  25. package/dist/copy/index.d.ts +2 -2
  26. package/dist/copy/index.js +19 -25
  27. package/dist/drag/drag.css +11 -1
  28. package/dist/drag/index.d.ts +9 -3
  29. package/dist/drag/index.js +1 -1
  30. package/dist/easel/index.d.ts +8 -1
  31. package/dist/easel/index.js +1 -1
  32. package/dist/fields/index.js +1 -1
  33. package/dist/screen/components/AddBlockRow.js +1 -1
  34. package/dist/screen/components/AddChildRow.js +4 -1
  35. package/dist/screen/components/AddSidePanel.d.ts +13 -17
  36. package/dist/screen/components/AddSidePanel.js +1 -1
  37. package/dist/screen/components/MediaSidePanel.js +1 -1
  38. package/dist/screen/components/NodeContextMenu.d.ts +3 -15
  39. package/dist/screen/components/NodeContextMenu.js +1 -1
  40. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  41. package/dist/screen/components/ScreenChrome.js +1 -1
  42. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  43. package/dist/screen/components/ScreenMount.js +1 -1
  44. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  45. package/dist/screen/components/SectionScreenShell.js +16 -16
  46. package/dist/screen/components/usePartBridge.js +1 -1
  47. package/dist/screen/index.d.ts +1 -1
  48. package/dist/screen/index.js +1 -1
  49. package/dist/screen/lib/key-scope.js +1 -1
  50. package/dist/screen/lib/puck/device-fields.js +1 -1
  51. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  52. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  53. package/dist/screen/lib/screen-parts.d.ts +6 -62
  54. package/dist/screen/lib/screen-parts.js +1 -1
  55. package/dist/screen/screen.css +2 -8
  56. package/dist/screen/words.d.ts +16 -23
  57. package/dist/screen/words.js +1 -1
  58. package/dist/strings/catalogue.js +1 -1
  59. package/dist/strings/index.js +1 -1
  60. package/dist/text-styles/index.js +19 -19
  61. package/package.json +1 -1
  62. package/dist/chunk-5545A3PC.js +0 -4
  63. package/dist/chunk-D6N77AOS.js +0 -1
  64. package/dist/chunk-EVY5SXFW.js +0 -5
  65. package/dist/chunk-G5MRFCCW.js +0 -5
  66. package/dist/chunk-JTUUIVBZ.js +0 -1
  67. package/dist/chunk-MMAC2VER.js +0 -57
  68. package/dist/chunk-O2NLQBFX.js +0 -1
  69. package/dist/chunk-PE6ZY5IW.js +0 -11
  70. package/dist/chunk-THZ46DC5.js +0 -2
  71. package/dist/chunk-TJ6NRHYF.js +0 -1
@@ -1 +0,0 @@
1
- import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as s,setList as a,isSafeLinkHref as c}from"./chunk-546BBOPE.js";var u=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),d=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function h(l,o){const i=o.rules??t,s=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const s=[[]],a=()=>s[s.length-1],h=()=>{const t=a();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&s.push([])},p=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=a();" "===t&&(0===o.length&&s.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(u.has(o))return;if("br"===o)return void s.push([]);let i=e,f=n,m=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(f=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();m=c(t)?t:null}const g=1===t.nodeType?l.style:null;if(g){const t=g.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===g.fontStyle||"oblique"===g.fontStyle?f=!0:"normal"===g.fontStyle&&(f=!1)}const b=d.has(o);b&&h();for(const e of[...t.childNodes])p(e,i,f,m);b&&h()};p(i.content,!1,!1,null);for(;s.length>1&&0===s[s.length-1].length;)s.pop();return s.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const s of i){const i=f(t,s.bold?o("bold"):null,s.italic?o("italic"):null,s.links),a=e([i]).text;if(n([i],r(a,l)))return a}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?s.join("\n"):1===s.length?s[0]:s.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function f(t,e,n,r){let o=0,i=null,s=null,a=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),s=e?.[c]?s??l(++o,"bold"):null,a=n?.[c]?a??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,s,a].filter(t=>null!==t)}})}}var p="application/x-efficient-markup",m=/^([0-9]{1,3})\. $/;function g(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const s=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:m.exec(n[e]),s=t.bullet||r,a=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=a?a.length+2:s?2:0,h={bullet:s,number:a,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:s,text:s.map(t=>t.text).join("\n")}}function b(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function k(t,e){const[n,r]=b(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function x(t,e){const[n,r]=b(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return k(t,e)}function v(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function y(t,e,n){return[v(t,e),v(t,n)]}function w(t,e,n){return e===n?[k(t,e),k(t,e)]:[x(t,e),k(t,n)]}function D(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function T(t,o,i,s,a){const c=g(t,o),[u,d,h]=b(c,Math.min(i,s)),[f,p,m]=b(c,Math.max(i,s)),k=D(u,d),x=D(f,p),v=u.chars.slice(0,k),y=f.chars.slice(x),w=i!==s&&u.chars[k]&&(h!==m||k<x)?u.chars[k].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,k);let T=(A=c.lines,Math.max(0,...A.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var A;const S=t=>{let e;if(void 0!==a.markup){const t=T;e=r(a.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(a.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...v,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...y]}}else l.chars.push(...y);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},E=void 0!==a.markup?[null]:[(t=>{let e=t.filter(t=>!a.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of a.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(T++,t);n&&(e=[...e,n])}if(void 0!==a.color){e=e.filter(t=>"color"!==t.kind);const t=null===a.color?null:l(T++,"color",a.color);t&&(e=[...e,t])}return e})(w),w,[]];let M="",N="";for(const t of E){const r=S(t),l=e(r.lines).text;if(M=l,N=r.shown,n(r.lines,g(l,o).lines))break}return{text:M,caret:Math.min(i,s)+N.length}}function A(t,e,n,r){const l=g(t,e),[o,,i]=b(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?T(t,e,n,r,{text:"\n"}):S(t,e,i,!1,n)}function S(t,n,r,l,o){const i=g(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function E(t,n,r,l){const o=g(t,n),[i,s,a]=b(o,Math.min(r,l)),[c,u,d]=b(o,Math.max(r,l)),h=o.lines.slice(a,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?D(i,s):0,o=r===d-a?D(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function M(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function N(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,s]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,s]=t.target);const a=[i,s];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:A(e,n,i,s),range:a}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=h({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:T(e,n,i,s,{markup:l}),range:a}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:T(e,n,i,s,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:a}}if(l.startsWith("delete")){const t=g(e,n),r=t.text;if(i===s){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:S(e,n,c,!1,i),range:a};if(o?0===i:i===r.length)return null;o?i=M(r,i,-1):s=M(r,s,1)}return{kind:"type",edit:T(e,n,i,s,{text:""}),range:[i,s]}}return null}var B=1e3;function C(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,s){const a="type"===i&&"type"===r&&s-l<1e3;r=i,l=s,n=[],a||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var j={sup:"sub",sub:"sup"};function q(t){const{value:e,rules:n,start:r,end:l,style:s,pending:a}=t,c=j[s];if(r===l){const t=o(e,r,l,n),i=a&&a.at===r?a:null,u=t.has(s),d=!!i?.add.includes(s)||!i?.drop.includes(s)&&u;let h=(i?.add??[]).filter(t=>t!==s),f=(i?.drop??[]).filter(t=>t!==s);return d&&u?f.push(s):d||u||h.push(s),!d&&c&&(h=h.filter(t=>t!==c),t.has(c)&&(f=[...f.filter(t=>t!==c),c])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:r}:null}}let u=e,d=r,h=l;if(c&&!o(u,d,h,n).has(s)&&o(u,d,h,n).has(c)){const t=i(u,d,h,c,n);({text:u,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(u,d,h,s,n)}}var F=/^(block|list-item|flex|grid|table|flow-root)$/;function L(t){const e=t.ownerDocument.defaultView;return!!e&&F.test(e.getComputedStyle(t).display)}function O(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let o="",i=!1;const s=()=>{i&&(o+="\n",i=!1)},a=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&s(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){s(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=L(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;a(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),a(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function P(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(O(e,t.skip).text!==g(n,r).text)return null;const l=t.now??(()=>Date.now()),i=C();let c=e,u=!1,d=null,f=null,m=[t.caret[0],t.caret[1]],b=null,k=!1;const x=()=>t.onSelect?.(),v={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},D=()=>c.ownerDocument,A=()=>D().defaultView?.getSelection()??null,S=()=>{if(!f)return!0;Q();const e=O(c,t.skip);if(e.text!==g(n,r).text)return!1;const[l,o]=f,[i,s]=e.dom(l),[a,u]=e.dom(o);return D().activeElement!==c&&c.focus({preventScroll:!0}),A()?.setBaseAndExtent(i,s,a,u),m=f,M=f,f=null,x(),!0};let M=null;const B=()=>{if(!M)return!1;const t=A(),e=t?.anchorNode??null;return!(e&&e.isConnected&&c.contains(e))||e===c&&0===t.anchorOffset&&(0!==M[0]||0!==M[1])},j=()=>{f=M,S()},F=()=>{S(),D().activeElement===c&&B()&&j();const e=A();if(!(e&&e.anchorNode&&e.focusNode&&c.contains(e.anchorNode)&&c.contains(e.focusNode)))return m;const n=O(c,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return m=r<=l?[r,l]:[l,r],m},L=t=>{const e=D().defaultView;t<=0||!e?M=null:e.requestAnimationFrame(()=>{u||f||(Q(),D().activeElement===c?(B()&&(j(),x()),L(t-1)):M=null)})},P=(t,e)=>{f=[t,e];const n=t=>{if(u)return;if(S())return void L(3);const e=D().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},V=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),P(e.caret,e.caret),x()):P(e.caret,e.caret)},W=t=>w(g(n,r),t[0],t[1]),I=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[s,a]=y(g(n,r),e.selectionStart,e.selectionEnd);P(s,a),x()},K=t=>{if(u)return;const e=F(),[l,o]=W(e),i=q({value:n,rules:r,start:l,end:o,style:t,pending:b});if("pending"===i.kind)return b=i.pending,void x();I(i.result,e)},R=e=>{n=e.text,t.write(n),P(e.start,e.end)},U=e=>{u||(u=!0,X.removeEventListener("selectionchange",Y),J(c),t.end(e))},$=(t,e)=>{const l=F();!u&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",g(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(p,E(n,r,l[0],l[1])),e&&V(T(n,r,l[0],l[1],{text:""}),l,"edit"))},z=t=>t.preventDefault(),H=()=>{t.remount?.()},Z=[["keydown",t=>{if(u||t.isComposing)return;const e=t.metaKey||t.ctrlKey;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void U("escape");if("Enter"===t.key&&(!t.shiftKey||e))return t.preventDefault(),t.stopPropagation(),void U("enter");if(e&&("z"===t.key||"Z"===t.key||"y"===t.key)){t.preventDefault(),t.stopPropagation();const e=F(),r={text:n,start:e[0],end:e[1]},l="y"===t.key||t.shiftKey?i.redo(r):i.undo(r);l&&R(l)}}],["beforeinput",e=>{if(u)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=F(),o=O(c,t.skip),s="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,a=s&&!s.collapsed?[o.at(s.startContainer,s.startOffset),o.at(s.endContainer,s.endOffset)]:null,d=N({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:D(),sel:l,target:a,pending:b&&b.at===W(l)[0]?b:null});if(d){if("type"!==d.kind&&"edit"!==d.kind||(b=null),"history"===d.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===d.dir?i.undo(t):i.redo(t);return void(e&&R(e))}"format"!==d.kind?V(d.edit,d.range,d.kind):K(d.style)}}],["compositionstart",()=>{d=F()}],["compositionend",e=>{const o=d;if(d=null,!u&&o)if(e.data){const s=T(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=s.text,t.write(n),H(),P(s.caret,s.caret)}else H(),P(o[0],o[0])}],["paste",e=>{if(u)return;e.preventDefault();const l=F(),o=e.clipboardData,i=o?.getData(p)??"",s=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):h({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:D(),multiline:t.multiline,rules:r});V(T(n,r,l[0],l[1],{markup:s}),l,"edit")}],["copy",t=>$(t,!1)],["cut",t=>$(t,!0)],["drop",z],["dragstart",z],["blur",e=>{if(u||null!==d||k)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{u||(n.isConnected&&n===t.element()?k||n.ownerDocument.activeElement===n||U("blur"):P(m[0],m[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{k=!1}]];function G(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of Z)t.addEventListener(e,n)}function J(t){for(const[e,n]of Z)t.removeEventListener(e,n);null===v.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",v.contenteditable),null===v.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",v.spellcheck),t.removeAttribute("data-es-typing")}function Q(){const e=t.element();e&&e!==c&&(J(c),c=e,G(c))}const X=c.ownerDocument;function Y(){u||x()}return X.addEventListener("selectionchange",Y),G(c),c.focus({preventScroll:!0}),P(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=g(t,r).text.length,[l,o]=F();n=t,i.reset(),P(Math.min(l,e),Math.min(o,e))},stop(t="stop"){U(t)},pressed(){const[t,e]=W(F()),l=o(n,t,e,r),i={};for(const e of["bold","italic","underline","strike","sup","sub","link"]){const n=l.has(e),r=b&&b.at===t?b:null;i[e]=!!r?.add.includes(e)||!r?.drop.includes(e)&&n}return{marks:i,list:s(n,t,e,r),selected:e>t}},press:K,insert(t){if(u)return;k=!1;const e=F(),[r,l]=W(e),o=r+t.length;I({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),Q(),c.focus({preventScroll:!0})},hold(){u||(F(),k=!0)},list(e){if(u||!t.multiline)return;const l=F(),[o,i]=W(l),c=s(n,o,i,r);I(a(n,o,i,c===e?null:e,r),l)}}}export{p as MARKUP_CLIPBOARD_TYPE,B as TYPING_BURST_MS,C as createHistory,T as editVisible,q as markPress,E as markupOfRange,A as newLine,h as pasteToMarkup,N as richInput,g as richLayout,w as selectionToSource,y as selectionToVisible,S as setBullet,P as startCanvasTyping,O as textMap,k as toSource,x as toSourceStart,v as toVisible};