efficient-easel 11.3.0 → 12.0.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.
- package/README.md +20 -41
- package/dist/{canvas-typing-DvoqQINU.d.ts → canvas-typing-CZ11Y5tb.d.ts} +16 -105
- package/dist/chrome/chrome.css +5 -5
- package/dist/chunk-2SOOKBHH.js +21 -0
- package/dist/{chunk-66LWADFP.js → chunk-2XMHLXMA.js} +1 -1
- package/dist/chunk-33C6ALT5.js +1 -0
- package/dist/{chunk-XJCMEEBH.js → chunk-36LVP5WD.js} +7 -7
- package/dist/chunk-47JTYRQC.js +2 -0
- package/dist/{chunk-EXKKLTXH.js → chunk-5NM5TPAX.js} +1 -1
- package/dist/{chunk-ZXGQT75B.js → chunk-5QP7ZE35.js} +1 -1
- package/dist/chunk-5R7FE4VT.js +57 -0
- package/dist/{chunk-FPAVNX3Y.js → chunk-5XUMLKQF.js} +3 -3
- package/dist/{chunk-PPL7GB7D.js → chunk-62VPYC7F.js} +1 -1
- package/dist/chunk-643PVCEG.js +1 -0
- package/dist/chunk-AYWN5NRH.js +1 -0
- package/dist/{chunk-4ACVXF5V.js → chunk-CZYR5V77.js} +1 -1
- package/dist/{chunk-PPHUWGLZ.js → chunk-EC2I7SIY.js} +1 -1
- package/dist/{chunk-DGAXQTDW.js → chunk-FHLYUIJJ.js} +1 -1
- package/dist/{chunk-65Z5FSAW.js → chunk-G3GWAP5R.js} +5 -5
- package/dist/{chunk-2FZJWH24.js → chunk-H4UMY7QF.js} +1 -1
- package/dist/chunk-KE2CXEIK.js +13 -0
- package/dist/chunk-KR4OCYRP.js +1 -0
- package/dist/{chunk-IFS5P7CO.js → chunk-LZS7JZK5.js} +1 -1
- package/dist/chunk-O3RLI7XE.js +1 -0
- package/dist/{chunk-47RGVCPH.js → chunk-QFVRMARS.js} +12 -12
- package/dist/chunk-TBF5CVPA.js +1 -0
- package/dist/chunk-UMDQ6CLQ.js +2 -0
- package/dist/chunk-UX7UJPC5.js +5 -0
- package/dist/chunk-VVPZMWJE.js +1 -0
- package/dist/chunk-WDQY6JMM.js +7 -0
- package/dist/chunk-WP7AZDCV.js +5 -0
- package/dist/chunk-WRFD4EXD.js +1 -0
- package/dist/{chunk-AFSSKGTD.js → chunk-WUO2GBPO.js} +1 -1
- package/dist/{chunk-BPFPM3L4.js → chunk-WY5U4XFO.js} +3 -3
- package/dist/{chunk-XWK7WZQS.js → chunk-X4VIDPKV.js} +1 -1
- package/dist/{chunk-TWFM6GNK.js → chunk-XY5ZHRMR.js} +1 -1
- package/dist/chunk-YHZSBL2N.js +1 -0
- package/dist/copy/copy.css +8 -108
- package/dist/copy/index.d.ts +39 -9
- package/dist/copy/index.js +18 -19
- package/dist/drag/drag.css +8 -8
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.d.ts +3 -3
- package/dist/easel/index.js +1 -1
- package/dist/fields/fields.css +8 -8
- package/dist/fields/index.js +1 -1
- package/dist/gold/index.d.ts +3 -3
- package/dist/gold/index.js +1 -1
- package/dist/icons/index.d.ts +1 -0
- package/dist/markup/index.d.ts +1 -629
- package/dist/markup/index.js +1 -1
- package/dist/menu/menu.css +1 -1
- package/dist/panel/index.js +1 -1
- package/dist/panel/panel.css +12 -12
- package/dist/pick/index.d.ts +30 -8
- package/dist/pick/index.js +3 -7
- package/dist/pick/pick.css +10 -84
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaSidePanel.js +1 -1
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/PageEditGuardNotices.js +1 -1
- package/dist/screen/components/PanelToggleIcon.d.ts +6 -5
- package/dist/screen/components/PanelToggleIcon.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenDocumentContext.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +15 -15
- package/dist/screen/components/SidePanelHead.js +1 -1
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/device-fields.js +1 -1
- package/dist/screen/lib/puck/slot-child-name.js +1 -1
- package/dist/screen/lib/puck/style-clipboard.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +16 -16
- package/dist/screen/words.js +1 -1
- package/dist/shell/shell.css +10 -8
- package/dist/strings/catalogue.d.ts +2 -2
- package/dist/strings/catalogue.js +1 -1
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +1 -1
- package/dist/text-styles/index.d.ts +14 -233
- package/dist/text-styles/index.js +36 -35
- package/dist/text-styles/model.d.ts +267 -0
- package/dist/text-styles/model.js +1 -0
- package/dist/text-styles/text-styles.css +6 -6
- package/dist/{words-dsex49Jh.d.ts → words-notpwHR2.d.ts} +13 -7
- package/package.json +8 -3
- package/dist/chunk-26GHWMNN.js +0 -21
- package/dist/chunk-546BBOPE.js +0 -1
- package/dist/chunk-AZOCY74V.js +0 -57
- package/dist/chunk-BHRC3ASL.js +0 -1
- package/dist/chunk-DD7A6RRL.js +0 -5
- package/dist/chunk-EQFBUNEB.js +0 -1
- package/dist/chunk-FAAZZXIS.js +0 -1
- package/dist/chunk-FFYXVAAL.js +0 -1
- package/dist/chunk-FGJSCWUN.js +0 -7
- package/dist/chunk-GCCBEY2W.js +0 -2
- package/dist/chunk-GG4FGBFR.js +0 -1
- package/dist/chunk-KQMML6JM.js +0 -4
- package/dist/chunk-Q6AM43CA.js +0 -1
- package/dist/chunk-SJPKSE5G.js +0 -13
- package/dist/chunk-U7KFFC7N.js +0 -5
- package/dist/chunk-VWXUMVCD.js +0 -1
- package/dist/chunk-ZAOM6PFH.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as l,spanFor as r,marksIn as o,toggleMark as i,listIn as a,setList as s,colorOver as c,unlinkAt as u,linkOver as d,colorIn as h,findLink as f,isSafeLinkHref as p}from"efficient-shell/markup";import{Tooltip as m,ColorSwatch as g,ColorPickerPanel as b,Button as k}from"efficient-shell/ui";import{jsxs as v,jsx as y}from"react/jsx-runtime";var x=1e3;function w(t=200){let e=[],n=[],l=null,r=0;return{record(o,i,a){const s="type"===i&&"type"===l&&a-r<1e3;l=i,r=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const r=e.pop();return r?(n.push(t),l=null,r):null},redo(t){const r=n.pop();return r?(e.push(t),l=null,r):null},reset(){e=[],n=[],l=null}}}var D=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),M=/* @__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 T(r,o){const i=o.rules??t,a=r.html&&""!==r.html.trim()?function(t,r,o){const i=r.createElement("template");i.innerHTML=t;const a=[[]],s=()=>a[a.length-1],c=()=>{const t=s();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&a.push([])},u=(t,e,n,l)=>{if(3===t.nodeType){for(const r of t.textContent??""){const t=/\s/.test(r)?" ":r,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:l})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const r=t,o=1===t.nodeType?r.localName:"";if(D.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,h=l;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(r.getAttribute("href")??"").trim();h=p(t)?t:null}const f=1===t.nodeType?r.style:null;if(f){const t=f.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===f.fontStyle||"oblique"===f.fontStyle?d=!0:"normal"===f.fontStyle&&(d=!1)}const m=M.has(o);m&&c();for(const e of[...t.childNodes])u(e,i,d,h);m&&c()};u(i.content,!1,!1,null);for(;a.length>1&&0===a[a.length-1].length;)a.pop();return a.map(t=>function(t,r){const o=e=>t.map((n,l)=>n[e]&&(" "!==n.ch||Boolean(t[l-1]?.[e])&&Boolean(t[l+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 a of i){const i=N(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],l(s,r)))return s}return t.map(t=>t.ch).join("")}(t,o))}(r.html,o.doc,i):(r.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?a.join("\n"):1===a.length?a[0]:a.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function N(t,e,n,l){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=l?t.href:null;return i=null===u?null:i&&i.href===u?i:r(++o,"link",u),a=e?.[c]?a??r(++o,"bold"):null,s=n?.[c]?s??r(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var C="application/x-efficient-markup",E=/^([0-9]{1,3})\. $/;function S(t,e){const n=t.split("\n"),r=l(t,e);let o=0,i=0;const a=r.map((t,e)=>{const l=!t.bullet&&null==t.number&&"- "===n[e],r=null!=t.number||t.bullet?null:E.exec(n[e]),a=t.bullet||l,s=r?r[1]:t.number??null,c=l||r?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,h={bullet:a,number:s,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,h});return{lines:a,text:a.map(t=>t.text).join("\n")}}function A(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const l=n[t];if(e<=l.vis+l.text.length||t===n.length-1)return[l,Math.max(0,Math.min(e-l.vis,l.text.length)),t]}return[n[0],0,0]}function B(t,e){const[n,l]=A(t,e);if(0===l)return n.src;let r=0;for(const t of n.chars){if(l<=r+t.ch.length)return t.at+(l-r);r+=t.ch.length}return n.src}function L(t,e){const[n,l]=A(t,e);let r=0;for(const t of n.chars){if(l===r)return t.at;r+=t.ch.length}return B(t,e)}function R(t,e){const{lines:n}=t;let l=n[0];for(const t of n)e>=t.start&&(l=t);let r=0;for(const t of l.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(r+=e-t.at);break}r+=t.ch.length}return l.vis+r}function W(t,e,n){return[R(t,e),R(t,n)]}function j(t,e,n){return e===n?[B(t,e),B(t,e)]:[L(t,e),B(t,n)]}function P(t,e){let n=0;for(let l=0;l<t.chars.length;l+=1){if(n>=e)return l;n+=t.chars[l].ch.length}return t.chars.length}function K(t,o,i,a,s){const c=S(t,o),[u,d,h]=A(c,Math.min(i,a)),[f,p,m]=A(c,Math.max(i,a)),g=P(u,d),b=P(f,p),k=u.chars.slice(0,g),v=f.chars.slice(b),y=i!==a&&u.chars[g]&&(h!==m||g<b)?u.chars[g].marks:function(t,e){const n=t.chars[e-1],l=t.chars[e],r=(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&&l?.marks.some(e=>e.id===t.id));return r(n.marks,e)}return l?r(l.marks,!1):[]}(u,g);let x=(w=c.lines,Math.max(0,...w.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var w;const D=t=>{let e;if(void 0!==s.markup){const t=x;e=l(s.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=(s.text??"").split("\n").map((e,l)=>(l>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"),r={bullet:u.bullet,number:u.number??null,chars:[...k,...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,...v]}}else r.chars.push(...v);return{lines:[...c.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),r,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},M=void 0!==s.markup?[null]:[(t=>{let e=t.filter(t=>!s.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of s.add??[]){if(e.some(e=>e.kind===t))continue;const n=r(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:r(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let T="",N="";for(const t of M){const l=D(t),r=e(l.lines).text;if(T=r,N=l.shown,n(l.lines,S(r,o).lines))break}return{text:T,caret:Math.min(i,a)+N.length}}function V(t,e,n,l){const r=S(t,e),[o,,i]=A(r,n);return n!==l||!o.bullet&&null==o.number||""!==o.text?K(t,e,n,l,{text:"\n"}):q(t,e,i,!1,n)}function q(t,n,l,r,o){const i=S(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===l?{bullet:r,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function F(t,n,l,r){const o=S(t,n),[i,a,s]=A(o,Math.min(l,r)),[c,u,d]=A(o,Math.max(l,r)),h=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},l)=>{const r=0===l?P(i,a):0,o=l===d-s?P(c,u):n.length;return{bullet:t,number:e,chars:n.slice(r,o)}});return e(h).text}function I(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const l=t.charCodeAt(e);return e+(l>=55296&&l<=56319?2:1)}function O(t){const{value:e,rules:n,multiline:l,inputType:r,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&r.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===r||"historyRedo"===r)return{kind:"history",dir:"historyUndo"===r?"undo":"redo"};if("formatBold"===r||"formatItalic"===r||"formatStrikeThrough"===r)return{kind:"format",style:"formatBold"===r?"bold":"formatItalic"===r?"italic":"strike"};if("insertParagraph"===r||"insertLineBreak"===r)return l?{kind:"edit",edit:V(e,n,i,a),range:s}:null;if(r.startsWith("insert")){if("insertTranspose"===r)return null;let c=t.data??"";if("insertFromDrop"===r||"insertFromPaste"===r){const r=T({html:t.html??void 0,text:c},{doc:t.doc,multiline:l,rules:n});return{kind:"edit",edit:K(e,n,i,a,{markup:r}),range:s}}return l||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:K(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(r.startsWith("delete")){const t=S(e,n),l=t.text;if(i===a){const o=r.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:q(e,n,c,!1,i),range:s};if(o?0===i:i===l.length)return null;o?i=I(l,i,-1):a=I(l,a,1)}return{kind:"type",edit:K(e,n,i,a,{text:""}),range:[i,a]}}return null}var z={sup:"sub",sub:"sup"};function U(t){const{value:e,rules:n,start:l,end:r,style:a,pending:s}=t,c=z[a];if(l===r){const t=o(e,l,r,n),i=s&&s.at===l?s:null,u=t.has(a),d=!!i?.add.includes(a)||!i?.drop.includes(a)&&u;let h=(i?.add??[]).filter(t=>t!==a),f=(i?.drop??[]).filter(t=>t!==a);return d&&u?f.push(a):d||u||h.push(a),!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:l}:null}}let u=e,d=l,h=r;if(c&&!o(u,d,h,n).has(a)&&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,a,n)}}var $=/^(block|list-item|flex|grid|table|flow-root)$/;function H(t){const e=t.ownerDocument.defaultView;return!!e&&$.test(e.getComputedStyle(t).display)}function X(t,e){const n=[],l=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;let o="",i=!1;const a=()=>{i&&(o+="\n",i=!1)},s=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&a(),l.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,r.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){l.set(t,o.length),r.set(t,o.length);continue}if("BR"===t.tagName){a(),l.set(t,o.length),o+="\n",r.set(t,o.length);continue}const u=H(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),l.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),r.set(t,o.length),u&&(i=!0)}};l.set(t,0),s(t),r.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(l.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?l.get(n[e])??r.get(t)??0:r.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const l=n[t],r=l.start+l.length;if(e<l.start)return[l.node,0];if(e<r||e===r&&(t===n.length-1||n[t+1].start>e))return 3===l.node.nodeType?[l.node,e-l.start]:[l.node,0]}const l=n[n.length-1];return l?3===l.node.nodeType?[l.node,l.length]:[l.node,0]:[t,0]}}}function Y(t){const e=t.element();if(!e)return null;let n=t.value;const l=t.rules;if(X(e,t.skip).text!==S(n,l).text)return null;const r=t.now??(()=>Date.now()),i=w();let p=e,m=!1,g=null,b=null,k=[t.caret[0],t.caret[1]],v=null,y=!1,x=!1;const D=()=>{x||t.onSelect?.()},M={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},N=()=>p.ownerDocument,E=()=>N().defaultView?.getSelection()??null,A=()=>{if(!b)return!0;nt();const e=X(p,t.skip);if(e.text!==S(n,l).text)return!1;const[r,o]=b,[i,a]=e.dom(r),[s,c]=e.dom(o);return y||N().activeElement===p||p.focus({preventScroll:!0}),E()?.setBaseAndExtent(i,a,s,c),k=b,B=b,b=null,D(),!0};let B=null;const L=()=>{if(!B)return!1;const t=E(),e=t?.anchorNode??null;return!(e&&e.isConnected&&p.contains(e))||e===p&&0===t.anchorOffset&&(0!==B[0]||0!==B[1])},R=()=>{b=B,A()},P=()=>{A(),N().activeElement===p&&L()&&R();const e=E();if(!(e&&e.anchorNode&&e.focusNode&&p.contains(e.anchorNode)&&p.contains(e.focusNode)))return k;const n=X(p,t.skip),l=n.at(e.anchorNode,e.anchorOffset),r=n.at(e.focusNode,e.focusOffset);return k=l<=r?[l,r]:[r,l],k},V=t=>{const e=N().defaultView;t<=0||!e?B=null:e.requestAnimationFrame(()=>{m||b||(nt(),N().activeElement===p?(L()&&(R(),D()),V(t-1)):B=null)})},q=(t,e)=>{b=[t,e];const n=t=>{if(m)return;if(A())return void V(3);const e=N().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},I=(e,l,o)=>{e.text!==n?(i.record({text:n,start:l[0],end:l[1]},o,r()),n=e.text,t.write(n),q(e.caret,e.caret),D()):q(e.caret,e.caret)},z=t=>j(S(n,l),t[0],t[1]),$=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",r()),n=e.text,t.write(n);const[a,s]=W(S(n,l),e.selectionStart,e.selectionEnd);q(a,s),D()},H=t=>{if(m)return;const e=P(),[r,o]=z(e),i=U({value:n,rules:l,start:r,end:o,style:t,pending:v});if("pending"===i.kind)return v=i.pending,void D();$(i.result,e)},Y=e=>{n=e.text,t.write(n),q(e.start,e.end)},Z=e=>{m||(m=!0,lt.removeEventListener("selectionchange",rt),et(p),t.end(e))},G=(t,e)=>{const r=P();!m&&r[0]!==r[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",S(n,l).text.slice(r[0],r[1])),t.clipboardData.setData(C,F(n,l,r[0],r[1])),e&&I(K(n,l,r[0],r[1],{text:""}),r,"edit"))},J=t=>t.preventDefault(),Q=()=>{t.remount?.()},_=[["keydown",e=>{if(m||e.isComposing)return;const l=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(l&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if("Enter"===e.key&&(!e.shiftKey||l))return e.preventDefault(),e.stopPropagation(),void Z("enter");if(l&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=P(),l={text:n,start:t[0],end:t[1]},r="y"===e.key||e.shiftKey?i.redo(l):i.undo(l);r&&Y(r)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;Z("escape")}}],["beforeinput",e=>{if(m)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const r=P(),o=X(p,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,s=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,c=O({value:n,rules:l,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:N(),sel:r,target:s,pending:v&&v.at===z(r)[0]?v:null});if(c){if("type"!==c.kind&&"edit"!==c.kind||(v=null),"history"===c.kind){const t={text:n,start:r[0],end:r[1]},e="undo"===c.dir?i.undo(t):i.redo(t);return void(e&&Y(e))}"format"!==c.kind?I(c.edit,c.range,c.kind):H(c.style)}}],["compositionstart",()=>{g=P()}],["compositionend",e=>{const o=g;if(g=null,!m&&o)if(e.data){const a=K(n,l,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",r()),n=a.text,t.write(n),Q(),q(a.caret,a.caret)}else Q(),q(o[0],o[0])}],["paste",e=>{if(m)return;e.preventDefault();const r=P(),o=e.clipboardData,i=o?.getData(C)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):T({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:N(),multiline:t.multiline,rules:l});I(K(n,l,r[0],r[1],{markup:a}),r,"edit")}],["copy",t=>G(t,!1)],["cut",t=>G(t,!0)],["drop",J],["dragstart",J],["blur",e=>{if(m||null!==g||y)return;const n=e.target,l=n.ownerDocument.defaultView,r=()=>{m||(n.isConnected&&n===t.element()?y||n.ownerDocument.activeElement===n||Z("blur"):q(k[0],k[1]))};l?.requestAnimationFrame?l.requestAnimationFrame(r):setTimeout(r,0)}],["focus",()=>{y=!1}]];function tt(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of _)t.addEventListener(e,n)}function et(t){for(const[e,n]of _)t.removeEventListener(e,n);null===M.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",M.contenteditable),null===M.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",M.spellcheck),t.removeAttribute("data-es-typing")}function nt(){const e=t.element();e&&e!==p&&(et(p),p=e,tt(p))}const lt=p.ownerDocument;function rt(){m||D()}return lt.addEventListener("selectionchange",rt),tt(p),p.focus({preventScroll:!0}),q(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=S(t,l).text.length,[r,o]=P();n=t,i.reset(),q(Math.min(r,e),Math.min(o,e))},stop(t="stop"){Z(t)},pressed(){let t;x=!0;try{t=P()}finally{x=!1}const[e,r]=z(t),i=o(n,e,r,l),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),l=v&&v.at===e?v:null;s[t]=!!l?.add.includes(t)||!l?.drop.includes(t)&&n}const c=v&&v.at===e&&void 0!==v.color?v:null;return{marks:s,list:a(n,e,r,l),selected:r>e,href:f(n,e,r)?.href??null,color:c?c.color??null:h(n,e,r,l)}},press:H,insert(t){if(m)return;y=!1;const e=P(),[l,r]=z(e),o=l+t.length;$({text:n.slice(0,l)+t+n.slice(r),selectionStart:o,selectionEnd:o},e),nt(),p.focus({preventScroll:!0})},hold(){m||(P(),y=!0)},release(){y=!1},resume(){m||(y=!1,nt(),p.focus({preventScroll:!0}),q(k[0],k[1]))},link(t){if(m)return;y=!1;const e=P(),[r,o]=z(e),i=null===t?u(n,r,o,l):d(n,r,o,t,l),a=i.text===n;$(i,e),nt(),p.focus({preventScroll:!0}),a&&q(e[0],e[1])},color(t){if(m)return;const e=P(),[r,o]=z(e);if(r===o){const e=v&&v.at===r?v:null;return v={add:e?.add??[],drop:e?.drop??[],color:t,at:r},void D()}$(c(n,r,o,t,l),e)},list(e){if(m||!t.multiline)return;const r=P(),[o,i]=z(r),c=a(n,o,i,l);$(s(n,o,i,c===e?null:e,l),r)}}}var Z=t=>t.preventDefault();function G(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function J({colors:t,current:e,words:n,onPick:l}){const r=null===e?null:e.startsWith("#")?e.toLowerCase():t.find(t=>t.name===e)?.value.toLowerCase()??null;/* @__PURE__ */
|
|
2
|
+
return v("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:t=>{"INPUT"!==t.target.tagName&&t.preventDefault()},children:[
|
|
3
|
+
/* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.theme}),
|
|
4
|
+
/* @__PURE__ */y("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */y(m,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */y(g,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:Z,onClick:()=>l(t.name)})},t.name))}),
|
|
5
|
+
/* @__PURE__ */y("span",{className:"es-copy-pop-label",children:n.any}),
|
|
6
|
+
/* @__PURE__ */y(b,{className:"es-copy-any",value:r??"",onChange:t=>{t!==e&&l(t)},label:n.title,dragWrites:"end"}),
|
|
7
|
+
/* @__PURE__ */y("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */y(k,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:Z,onClick:()=>l(null),children:n.remove})})]})}var Q=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function _({anchor:t,size:e,within:n,clip:l,parent:r,gap:o=8}){const i=Math.max(n.left,l.left),a=Math.min(n.right,l.right)-e.width,s=Q(t.left,i,a),c=l.bottom-(t.bottom+o),u=t.top-o-l.top,d=e.height>c&&(e.height<=u||u>c),h=d?t.top-o-e.height:t.bottom+o,f=t.left+Math.min((t.right-t.left)/2,10),p=Q(f-5-s,10,e.width-10-10);return{top:h-r.top,left:s-r.left,above:d,point:p}}var tt=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function et(t,e){const n=("function"==typeof t.getClientRects?[...t.getClientRects()]:[]).filter(t=>t.height>0);if(n.length>0){const e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():n[0];return e.height>0?tt(e):tt(n[0])}if(!e)return null;const l=e.getBoundingClientRect();return{left:l.left,top:l.top,right:l.left,bottom:l.bottom}}function nt(t){const e=t.ownerDocument,n=e.documentElement,l={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},r=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=r?.(o);if(!t||"visible"===t.overflowX&&"visible"===t.overflowY)continue;const e=o.getBoundingClientRect();if(0===e.width&&0===e.height)continue;const n=e.left+o.clientLeft,i=e.top+o.clientTop;l.left=Math.max(l.left,n),l.top=Math.max(l.top,i),l.right=Math.min(l.right,n+(o.clientWidth||e.width)),l.bottom=Math.min(l.bottom,i+(o.clientHeight||e.height))}return l}function lt(t){const e=t.offsetParent??t.parentElement;if(!e)return{left:0,top:0};const n=e.getBoundingClientRect();return{left:n.left+e.clientLeft-e.scrollLeft,top:n.top+e.clientTop-e.scrollTop}}function rt(t,e,n){const l=t.ownerDocument,r=l.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=r.nextNode();t;t=r.nextNode()){if(e<=t.data.length)return[t,e];e-=t.data.length,n=t}return n?[n,n.data.length]:null},i=o(e);r.currentNode=t;const a=o(n);if(!i||!a)return null;const s=l.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{J as ColorWindow,C as MARKUP_CLIPBOARD_TYPE,x as TYPING_BURST_MS,G as colorRunOf,w as createHistory,K as editVisible,U as markPress,F as markupOfRange,V as newLine,lt as offsetOrigin,T as pasteToMarkup,_ as placeWindow,O as richInput,S as richLayout,et as selectionBox,j as selectionToSource,W as selectionToVisible,q as setBullet,Y as startCanvasTyping,X as textMap,rt as textRange,B as toSource,L as toSourceStart,R as toVisible,nt as visibleArea};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{Inspector as t}from"./chunk-2SOOKBHH.js";import{EaselCanvas as r,useSelectedFields as i}from"./chunk-KE2CXEIK.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},j={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},w={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
|
|
2
|
+
return s(r,{height:"fill"})}function C(){const{id:n,fields:e,values:r,readOnly:o,onChange:u}=i();/* @__PURE__ */
|
|
3
|
+
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(t,{fields:e,values:r,onChange:u,readOnly:o,idPrefix:n})})}var P=o({});function B({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(P.Provider,{value:n,children:e})}function D(){return u(P)}function G(){return(D().useOwnerName??v)()}function I(){return(D().useDocumentLabel??g)()}function K(n,e,t,r){return(D().useBridges??h)(n,e,t,r)}function N(n){return(D().useStandaloneBridges??h)(n)}function x(n,e){(D().useDocumentPass??y)(n,e)}function T(){return D().blockRules??b}function A(){return D().blockLook??O}function E(){return D().devices??j}function F(){return D().leftView??w}function H(){return D().pinned??L}function R(){return D().saveSwitch??!0}function V(n){e(!0===D().pickFollowsSelection,n)}function W(){return D().storageNamespace||void 0}function Q(){return D().styleClipboard??null}function X(){return D().nodeKeys??!0}function Y(){return D().notify??null}function Z(){return D().Canvas??S}function q(){return D().CanvasHead??null}function z(){return D().canvasDrag??null}var J=o(null);function M({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(J.Provider,{value:n,children:e})}function U(){return u(J)}function $(){return D().Inspector??C}export{c as SELECTION_MODE,M as ScreenCanvasTargetProvider,B as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,A as useScreenBlockLook,T as useScreenBlockRules,K as useScreenBridges,z as useScreenCanvasDrag,Z as useScreenCanvasFrame,q as useScreenCanvasHead,U as useScreenCanvasTarget,E as useScreenDevices,I as useScreenDocumentLabel,x as useScreenDocumentPass,$ as useScreenInspectorPanel,F as useScreenLeftView,X as useScreenNodeKeys,Y as useScreenNotify,G as useScreenOwnerName,D as useScreenParts,V as useScreenPickFollowsSelection,H as useScreenPinned,R as useScreenSaveSwitch,W as useScreenStorageNamespace,Q as useScreenStyleClipboard,N as useStandaloneScreenBridges};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={less:"Less",more:"More",choose:"Choose",search:"Search",noMatches:"No matches",list:{item:"item",itemName:({noun:e,n:o})=>{return`${t=e,t?t[0].toUpperCase()+t.slice(1):t} ${o}`;var t},position:({n:e,total:o})=>`${e} of ${o}`,duplicate:"Duplicate",duplicateItem:({noun:e})=>`Duplicate ${e}`,deleteItem:({noun:e})=>`Delete ${e}`,add:({noun:e})=>`+ Add ${e}`,addHere:({noun:e})=>`Add ${e} here`,moveUp:"Move up",moveDown:"Move down",delete:"Delete",locked:"This one cannot be removed",moved:({n:e,total:o})=>`Moved to ${e} of ${o}`}};export{e as DEFAULT_FIELDS_WORDS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenDocument as n}from"./chunk-
|
|
1
|
+
import{useScreenDocument as n}from"./chunk-47JTYRQC.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{EditNotice as r}from"./chunk-IE55HNMA.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-CZYR5V77.js";import{ScreenChrome as e}from"./chunk-5R7FE4VT.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-47JTYRQC.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-VVPZMWJE.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var C=r(n),k=r(e);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
5
|
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function y({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function V({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),V=t(()=>s(!g),[g]),
|
|
7
|
-
/* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:V,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var N=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function V({config:r,parts:n,wrap:e=N}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:y}=a(),V=t(()=>s(!g),[g]),H=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:V,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(j,{onCancel:p,onDiscard:v,onSave:y})):/* @__PURE__ */u("div",{className:"sf-msg",children:H.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:H.waitingForAuthorization})}export{V as DocumentScreen,y as ScreenMount};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useScreenBlockRules as e}from"./chunk-
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-WP7AZDCV.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-KE2CXEIK.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-
|
|
1
|
+
import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-WP7AZDCV.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-VVPZMWJE.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
|
|
2
2
|
/* @__PURE__ */o("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(a,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
|
|
3
3
|
return o(n,{align:"start",triggerClassName:"sf-add-card",items:u,trigger:/* @__PURE__ */c(i,{children:[
|
|
4
4
|
/* @__PURE__ */o("span",{className:"sf-plus sf-plus--sm",children:"+"}),m.addBlockMenu]})})}export{l as AddBlockRow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var n=["none","upper","capitalize","lower"],e={none:"none",upper:"uppercase",capitalize:"capitalize",lower:"lowercase"};function i(e){return n.includes(e)}function t(n){return i(n)?e[n]:void 0}function a(i){return n.find(n=>e[n]===i)}var r=["font","color","size","weight","emphasis","lineSpacing","letterSpacing","paragraphSpacing","letterCase","largestSize"],o=["font","color","size","weight","lineSpacing","letterSpacing","paragraphSpacing","letterCase"],d=["heading","body"],s=7,l={heading:3,body:5},u={min:5,max:void 0,sliderMin:12,sliderMax:72,step:1,shiftStep:10,unit:"px"},c={size:u,weight:{min:100,max:900,sliderMin:300,sliderMax:900,step:100,shiftStep:100,unit:""},lineSpacing:{min:50,max:250,sliderMin:50,sliderMax:250,step:1,shiftStep:10,unit:"%"},letterSpacing:{min:-10,max:void 0,sliderMin:-5,sliderMax:10,step:.1,shiftStep:1,unit:"px"},paragraphSpacing:{min:0,max:void 0,sliderMin:0,sliderMax:48,step:1,shiftStep:10,unit:"px"},largestSize:u},f=(n,e)=>`${"heading"===n?"Heading":"Body"} ${e}`;function p(n=({kind:n,n:e})=>f(n,e)){return d.flatMap(e=>Array.from({length:l[e]},(i,t)=>({id:`${e}-${t+1}`,kind:e,name:n({kind:e,n:t+1}),values:{}})))}function m(n,e,i=s){return n.filter(n=>n.kind===e).length<i}function h(n,e){const i=new RegExp(`^${e}-([1-9]\\d*)$`).exec(n);return i?Number(i[1]):void 0}function g(n){const e=h(n.id,n.kind);return void 0!==e&&e<=l[n.kind]}function x(n,e,i={}){const{max:t=s,name:a=({kind:n,n:e})=>f(n,e),make:r}=i;if(!m(n,e,t))return null;const o=n.filter(n=>n.kind===e);let d=o.length+1;const l=new Set(n.map(n=>n.name));for(;l.has(a({kind:e,n:d}));)d+=1;const u=new Set(n.map(n=>n.id));let c=Math.max(d,...o.map(n=>(h(n.id,e)??0)+1));for(;u.has(`${e}-${c}`);)c+=1;const p=o.at(-1),g=r?r(e,d):{id:`${e}-${c}`,kind:e,name:a({kind:e,n:d}),values:{...p?.values??{}}},x=p?n.indexOf(p)+1:"heading"===e?0:n.length;return{styles:[...n.slice(0,x),g,...n.slice(x)],added:g}}function k(n,e,i={}){const{name:t=({kind:n,n:e})=>f(n,e)}=i,a=n.find(n=>n.id===e);if(!a||g(a))return null;const r=n.filter(n=>n.kind===a.kind),o=r.indexOf(a),d=/* @__PURE__ */new Map;return r.forEach((n,e)=>{e>o&&n.name===t({kind:n.kind,n:e+1})&&d.set(n,t({kind:n.kind,n:e}))}),{styles:n.filter(n=>n!==a).map(n=>d.has(n)?{...n,name:d.get(n)}:n),removed:a}}function v(n,e){const i=n.find(n=>n.id===e);if(i)return i;for(const i of d){const t=h(e,i);if(void 0===t)continue;let a;for(const e of n){const n=e.kind===i?h(e.id,i):void 0;void 0!==n&&n<t&&(!a||n>a.n)&&(a={n:n,style:e})}return a?.style}}function M(n,e,i){return n.map(n=>{if(n.id!==e)return n;const t={...n.values};for(const[n,e]of Object.entries(i))void 0===e?delete t[n]:t[n]=e;return{...n,values:t}})}function S(n){return Math.min(20,Math.max(12,Math.round(.5*n+6)))}function w(n,e){const i=e.weights;return[i.thin,i.extraLight,i.light,i.regular,i.medium,i.semibold,i.bold,i.extraBold,i.black][Math.min(8,Math.max(0,Math.round(n/100)-1))]}function z(n,e,i,t={}){const a=e.find(e=>e.value===n.font)?.label??n.font??"",r=void 0===n.size?t.autoSize?i.auto:"":i.px({n:n.size});return i.summary({font:a,size:r,weight:w(n.weight??400,i)})}export{o as CAMPAIGN_TEXT_STYLE_SETTINGS,n as TEXT_STYLE_CASES,e as TEXT_STYLE_CASE_CSS,l as TEXT_STYLE_DEFAULT_COUNT,d as TEXT_STYLE_KINDS,s as TEXT_STYLE_MAX,c as TEXT_STYLE_RANGES,r as TEXT_STYLE_SETTINGS,x as addTextStyle,m as canAddTextStyle,p as defaultTextStyles,z as describeTextStyle,g as isDefaultTextStyle,i as isTextStyleCase,k as removeTextStyle,v as resolveTextStyle,t as textStyleCaseCss,a as textStyleCaseOfCss,S as textStyleRowSize,M as updateTextStyle,w as weightWord};
|
package/dist/copy/copy.css
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* efficient-easel — the copy control's own chrome.
|
|
3
3
|
*
|
|
4
|
-
* Only the
|
|
5
|
-
* `efficient-easel/gold.css` and the
|
|
6
|
-
*
|
|
7
|
-
* there are two places a
|
|
4
|
+
* Only the frame, the windows and the line under the box are dressed here.
|
|
5
|
+
* The box inside it is `efficient-easel/gold.css` and the bar is the shell's
|
|
6
|
+
* `TextToolbar` (`efficient-shell/ui`, harness UI-24) — this sheet must never
|
|
7
|
+
* restate either, or there are two places a part can change.
|
|
8
8
|
*
|
|
9
9
|
* Declared on `.es-copy`, never on `:root`, for the reason gold.css gives: a
|
|
10
10
|
* sheet imported by an editor must not leak a variable into the page being
|
|
@@ -16,9 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
.es-copy {
|
|
18
18
|
--es-copy-gap: var(--es-space-8, 8px);
|
|
19
|
-
/* efficient-shell's IconButton at its default size, md (design v5, 0.94.0). */
|
|
20
|
-
--es-copy-mark-size: var(--control-height-md, 32px);
|
|
21
|
-
--es-copy-rule: var(--es-border, var(--line));
|
|
22
19
|
--es-copy-field-border: var(--es-field-border, var(--line-strong));
|
|
23
20
|
--es-copy-field-bg: var(--es-field-bg, var(--surface));
|
|
24
21
|
/** The field's inner inset. On the SURFACES, never on the box — see
|
|
@@ -36,85 +33,10 @@
|
|
|
36
33
|
--es-copy-radius: var(--radius-md);
|
|
37
34
|
|
|
38
35
|
display: block;
|
|
39
|
-
/* A container, so a host can query the box's own width.
|
|
40
|
-
`.es-copy-bar`: that would contain the very box whose children measure. */
|
|
36
|
+
/* A container, so a host can query the box's own width. */
|
|
41
37
|
container-type: inline-size;
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
/* — the bar — */
|
|
45
|
-
|
|
46
|
-
.es-copy-bar {
|
|
47
|
-
display: flex;
|
|
48
|
-
flex-wrap: wrap;
|
|
49
|
-
align-items: center;
|
|
50
|
-
gap: 2px;
|
|
51
|
-
margin-bottom: var(--es-copy-gap);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/*
|
|
55
|
-
* The direction sits on ITS OWN LINE, under the marks (0.94.0, design v5:
|
|
56
|
-
* "下面一行是对齐"). Until 0.93 it sat at the far end of the marks' row; seven
|
|
57
|
-
* 32px buttons leave no room beside them at any panel width, and a strip
|
|
58
|
-
* squeezed into the remainder is a strip drawn broken. The marks act on the
|
|
59
|
-
* SELECTION and this on the whole text, so a line of its own also says they
|
|
60
|
-
* are different kinds of thing.
|
|
61
|
-
*
|
|
62
|
-
* ⚠️ THE FLEX VALUES ARE NOT TASTE. THE STRIP IS 0px WIDE WITHOUT THEM.
|
|
63
|
-
*
|
|
64
|
-
* `.es-segs-fit` is `container-type: inline-size` + `flex: none` (panel.css).
|
|
65
|
-
* In a flex parent `flex: none` means "size to your own content", and size
|
|
66
|
-
* containment means there IS no content width to size to. Both declarations
|
|
67
|
-
* are right where they were written and they collide in any flex slot — which
|
|
68
|
-
* this is. `panel.css` carries the full account under card 66516 and the same
|
|
69
|
-
* exception for `.es-field-ctl`; it is not restated here, only obeyed.
|
|
70
|
-
*
|
|
71
|
-
* So the wrapper takes a basis from the bar, and hands one to the fit wrapper
|
|
72
|
-
* inside it. `min-width: 0` on both because a flex item's automatic minimum is
|
|
73
|
-
* its content size, which containment makes meaningless.
|
|
74
|
-
*/
|
|
75
|
-
.es-copy-bar-end {
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
flex: 1 1 100%;
|
|
79
|
-
min-width: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/* Not the whole line (design v14: the Segmented "does not fill a row"). A
|
|
83
|
-
FIXED basis, never `auto`: this wrapper is a size container, so `auto` is
|
|
84
|
-
its content width, which containment makes 0. */
|
|
85
|
-
.es-copy-bar-end > .es-segs-fit {
|
|
86
|
-
flex: 0 1 240px;
|
|
87
|
-
min-width: 0;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.es-copy-bar-split {
|
|
91
|
-
width: 1px;
|
|
92
|
-
align-self: stretch;
|
|
93
|
-
margin: 2px 4px;
|
|
94
|
-
background: var(--es-copy-rule);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/* A mark button is efficient-shell's IconButton (harness UI-24): its look, its
|
|
98
|
-
hover, its disabled fade and — since efficient-shell 4.164.0 — its pressed
|
|
99
|
-
look from `aria-pressed` are the kit's; this bar used to draw a copy of each.
|
|
100
|
-
What stays is its size in this bar, the room a letter needs and the letter
|
|
101
|
-
styling below. */
|
|
102
|
-
.es-copy-mark {
|
|
103
|
-
height: var(--es-copy-mark-size);
|
|
104
|
-
min-width: var(--es-copy-mark-size);
|
|
105
|
-
width: auto;
|
|
106
|
-
padding: 0 4px;
|
|
107
|
-
font-size: 11px;
|
|
108
|
-
line-height: 1;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/* The glyph looks like what it does. Safe here and NOT in the gold layer: a
|
|
112
|
-
button is not sitting over a caret, so a wider glyph moves nothing. A
|
|
113
|
-
drawing — the set's glyph or the host's own — gets none of it. */
|
|
114
|
-
.es-copy-mark.is-bold { font-weight: 700; }
|
|
115
|
-
.es-copy-mark.is-italic { font-style: italic; }
|
|
116
|
-
.es-copy-mark.is-strike { text-decoration: line-through; }
|
|
117
|
-
|
|
118
40
|
/* — the frame around the box — */
|
|
119
41
|
|
|
120
42
|
/*
|
|
@@ -338,35 +260,13 @@
|
|
|
338
260
|
margin-top: var(--es-space-12, 12px);
|
|
339
261
|
}
|
|
340
262
|
|
|
341
|
-
/* Words never break inside
|
|
342
|
-
moves to a line of its own, still at the right end. */
|
|
263
|
+
/* Words never break inside. */
|
|
343
264
|
.es-copy-marks-label {
|
|
344
|
-
font-size: 14px;
|
|
265
|
+
font-size: var(--text-sm, 14px);
|
|
345
266
|
white-space: nowrap;
|
|
346
267
|
color: var(--es-text-secondary, var(--ink));
|
|
347
268
|
}
|
|
348
269
|
|
|
349
|
-
/*
|
|
350
|
-
* CLEAR STYLE (owner ruling 2026-10-07, mockup
|
|
351
|
-
* https://claude.ai/artifact/GiyeV3xazepzArKGVkFM8T): a text button at the
|
|
352
|
-
* right end of the line under the box — beside Show marks, or alone under a
|
|
353
|
-
* one-line box (GG, 2026-10-07) — with the clear-marks glyph. Off until words
|
|
354
|
-
* are selected in the box.
|
|
355
|
-
*
|
|
356
|
-
* It is the shell's secondary Button, small (Lewis 2026-10-13: ghost is for
|
|
357
|
-
* toolbars and rows of icons; a lone text button is secondary; UI-24). The
|
|
358
|
-
* shell owns its look; this sheet only places it on the line.
|
|
359
|
-
*/
|
|
360
|
-
.es-copy-clear {
|
|
361
|
-
margin-left: auto;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
/* Off, it explains itself in the shell's Tooltip, whose wrapper is then the
|
|
365
|
-
line's last item: the wrapper takes the push to the end. */
|
|
366
|
-
.es-copy-marks > span:has(> .es-copy-clear) {
|
|
367
|
-
margin-left: auto;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
270
|
/* — the final toolbar (E5b, design final 2026-10-06) — */
|
|
371
271
|
|
|
372
272
|
/*
|
|
@@ -445,7 +345,7 @@
|
|
|
445
345
|
}
|
|
446
346
|
|
|
447
347
|
.es-copy-pop-label {
|
|
448
|
-
font-size: 12px;
|
|
348
|
+
font-size: var(--text-xs, 12px);
|
|
449
349
|
font-weight: 500;
|
|
450
350
|
color: var(--es-text-secondary, var(--ink));
|
|
451
351
|
}
|
package/dist/copy/index.d.ts
CHANGED
|
@@ -1,19 +1,49 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { c as CopyBoxProps, d as CopyCell, T as TextBoxHandle } from '../canvas-typing-CZ11Y5tb.js';
|
|
4
|
+
export { e as COPY_CELLS, b as CanvasTypingEnd, f as CanvasTypingOptions, g as CanvasTypingSession, h as ColorWindow, i as CopyBoxAlign, j as CopyBoxFooter, C as CopyBoxLastTool, k as CopyCase, l as CopyCellPreset, m as CopyCells, a as CopyThemeColor, M as MarkWriter, S as SelectionSource, n as TextAreaHandle, o as TextMap, p as ToolbarMark, q as colorRunOf, r as insertSelection, s as markSelection, t as startCanvasTyping, u as textMap } from '../canvas-typing-CZ11Y5tb.js';
|
|
5
|
+
import { MarkStyle, MarkupTool, InlineRule, MarkedLine, WrapResult } from 'efficient-shell/markup';
|
|
4
6
|
export { TextToolbar, TextToolbarProps } from 'efficient-shell/ui';
|
|
5
7
|
import { F as FieldOption } from '../types-Dkx1VAIQ.js';
|
|
6
|
-
import { a as CopyAlign } from '../words-
|
|
7
|
-
export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, C as CopyWords, f as copyAlignOptions } from '../words-
|
|
8
|
-
import {
|
|
8
|
+
import { a as CopyAlign } from '../words-notpwHR2.js';
|
|
9
|
+
export { b as COPY_ALIGNS, c as COPY_ALIGN_FIT, d as COPY_ALIGN_GLYPHS, e as COPY_ALIGN_LABELS, C as CopyWords, f as copyAlignOptions } from '../words-notpwHR2.js';
|
|
10
|
+
import { TextStyleCase } from '../text-styles/model.js';
|
|
9
11
|
import '../buckets-Tj-nkBpg.js';
|
|
12
|
+
import '../words-gIDCeRv3.js';
|
|
10
13
|
|
|
11
|
-
declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark,
|
|
14
|
+
declare function CopyBox({ value, onChange, onCommit, onCancel, multiline, placeholder, ariaLabel, className, readOnly, rules, tools, writeMark, align, actions, toolbar, barLabel, renderFooter, inputRef, barShows, richText, defaultShowMarks, colors, cells, letterCase, lastTool, }: CopyBoxProps): react.JSX.Element;
|
|
15
|
+
|
|
16
|
+
/** `'b'` → `Meta+B`, `'shift+x'` → `Meta+Shift+X` — the ARIA spelling of a
|
|
17
|
+
* shortcut.
|
|
18
|
+
* @deprecated The toolbar spells its own shortcuts. Removed in 12.0.0. */
|
|
19
|
+
declare function ariaShortcut(shortcut: string | undefined): string | undefined;
|
|
20
|
+
/** @deprecated Draw `TextToolbar` (`efficient-shell/ui`). Removed in 12.0.0. */
|
|
21
|
+
interface MarkBarProps {
|
|
22
|
+
/** The marks to offer: styles, or a host's descriptors (only `style` is read). */
|
|
23
|
+
tools: readonly MarkStyle[] | readonly MarkupTool[];
|
|
24
|
+
onApply: (style: MarkStyle) => void;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** One control of the host's, drawn in row 1's last cell. */
|
|
27
|
+
actions?: ReactNode;
|
|
28
|
+
/** Not drawn: the toolbar's alignment is a value. */
|
|
29
|
+
align?: ReactNode;
|
|
30
|
+
/** Not drawn: the drawings are the shell set's. */
|
|
31
|
+
glyphs?: Partial<Record<MarkStyle, ReactNode>>;
|
|
32
|
+
/** The toolbar's accessible name; "Formatting" (`EaselStrings.copy.formatting`) by default. */
|
|
33
|
+
ariaLabel?: string;
|
|
34
|
+
/** The marks the selection already wears. */
|
|
35
|
+
pressed?: Partial<Record<MarkStyle, boolean>>;
|
|
36
|
+
/** The style whose own window is open (`'link'` lights the link button). */
|
|
37
|
+
open?: MarkStyle | null;
|
|
38
|
+
}
|
|
39
|
+
/** @deprecated Draw `TextToolbar` (`efficient-shell/ui`). Removed in 12.0.0. */
|
|
40
|
+
declare function MarkBar({ tools, onApply, disabled, actions, ariaLabel, pressed, open }: MarkBarProps): react.JSX.Element;
|
|
12
41
|
|
|
13
42
|
/** Whether the lines are a list, and which kind. */
|
|
14
43
|
type TextList = 'none' | 'bullet' | 'number';
|
|
15
|
-
/** How the letters are drawn: as typed, all capitals, each word capitalized,
|
|
16
|
-
|
|
44
|
+
/** How the letters are drawn: as typed, all capitals, each word capitalized,
|
|
45
|
+
* all small. The text styles' own case (../text-styles/model), one list. */
|
|
46
|
+
type TextCase = TextStyleCase;
|
|
17
47
|
/** A strip row: the box's own answer (`''` = follows the style) and the style's. */
|
|
18
48
|
interface TextPartStrip<V extends string> {
|
|
19
49
|
value: V | '';
|
|
@@ -321,4 +351,4 @@ interface CaretEdit {
|
|
|
321
351
|
*/
|
|
322
352
|
declare function useCaretEdit({ target, onChange }: CaretEdit): (edit: (el: HTMLInputElement | HTMLTextAreaElement | null) => WrapResult) => void;
|
|
323
353
|
|
|
324
|
-
export { type CaretEdit, CopyAlign, CopyBox, CopyBoxProps, CopyCell, type History, MARKUP_CLIPBOARD_TYPE, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type Snapshot, TYPING_BURST_MS, TextBoxHandle, type TextCase, type TextList, TextPartPanel, type TextPartPanelProps, type TextPartStrip, createHistory, editVisible, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
|
|
354
|
+
export { type CaretEdit, CopyAlign, CopyBox, CopyBoxProps, CopyCell, type History, MARKUP_CLIPBOARD_TYPE, MarkBar, type MarkBarProps, type PasteData, type PasteOptions, RichBox, type RichBoxProps, type RichEdit, type RichHandle, type RichInputEvent, type RichInputResult, type RichInsert, type RichLayout, type RichLine, type RichPending, type Snapshot, TYPING_BURST_MS, TextBoxHandle, type TextCase, type TextList, TextPartPanel, type TextPartPanelProps, type TextPartStrip, ariaShortcut, createHistory, editVisible, markupOfRange, newLine, pasteToMarkup, richInput, richLayout, selectionToSource, selectionToVisible, setBullet, toSource, toSourceStart, toVisible, useCaretEdit };
|
package/dist/copy/index.js
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import{
|
|
2
|
-
return
|
|
3
|
-
/* @__PURE__ */
|
|
4
|
-
return
|
|
5
|
-
return
|
|
6
|
-
/* @__PURE__ */
|
|
7
|
-
/* @__PURE__ */
|
|
8
|
-
|
|
9
|
-
return
|
|
10
|
-
/* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */
|
|
12
|
-
/* @__PURE__ */
|
|
13
|
-
/* @__PURE__ */
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */
|
|
19
|
-
/* @__PURE__ */Oe(x,{label:d.italic,icon:/* @__PURE__ */Oe(pe,{}),children:/* @__PURE__ */Oe("div",{className:"es-tpp-font",children:m})}):null,o?.length?/* @__PURE__ */Oe(Ge,{cells:o,words:u.cells,readOnly:n}):null,s?/* @__PURE__ */Oe(st,{label:u.alignment,icon:/* @__PURE__ */Oe(he,{}),answers:Fe.filter(e=>!s.allow||s.allow.includes(e)),names:u.align,glyphs:Me,row:s,readOnly:n}):null,i?/* @__PURE__ */Oe(st,{label:d.list,icon:/* @__PURE__ */Oe(fe,{}),answers:rt,names:d.lists,glyphs:at,row:i,readOnly:n}):null,c?/* @__PURE__ */Oe(st,{label:d.capitalization,icon:/* @__PURE__ */Oe(me,{}),answers:lt,names:d.cases,glyphs:ot,row:c,readOnly:n}):null]})}export{Fe as COPY_ALIGNS,Re as COPY_ALIGN_FIT,Me as COPY_ALIGN_GLYPHS,Pe as COPY_ALIGN_LABELS,qe as COPY_CELLS,nt as CopyBox,Ge as CopyCells,Qe as MarkBar,Ie as RichBox,it as TextPartPanel,_e as ariaShortcut,Be as copyAlignOptions,Ve as insertSelection,He as markSelection,et as useCaretEdit};
|
|
1
|
+
import{TEXT_STYLE_CASES as e}from"../chunk-YHZSBL2N.js";import{FieldNumber as t}from"../chunk-2XMHLXMA.js";import{FieldSelect as n}from"../chunk-G3GWAP5R.js";import{SettingsSwitch as r,SettingsField as l,SettingsSegmented as o}from"../chunk-36LVP5WD.js";import"../chunk-WRFD4EXD.js";import{GoldTextInput as a}from"../chunk-H4UMY7QF.js";import{selectionToVisible as s,selectionToSource as c,richLayout as i,createHistory as u,colorRunOf as d,textRange as p,selectionBox as m,placeWindow as h,offsetOrigin as f,visibleArea as g,ColorWindow as y,markPress as v,pasteToMarkup as b,richInput as S,editVisible as k,MARKUP_CLIPBOARD_TYPE as x,markupOfRange as w}from"../chunk-WDQY6JMM.js";export{ColorWindow,MARKUP_CLIPBOARD_TYPE,TYPING_BURST_MS,colorRunOf,createHistory,editVisible,markupOfRange,newLine,pasteToMarkup,richInput,richLayout,selectionToSource,selectionToVisible,setBullet,startCanvasTyping,textMap,toSource,toSourceStart,toVisible}from"../chunk-WDQY6JMM.js";import{DEFAULT_COPY_WORDS as E}from"../chunk-33C6ALT5.js";import{useWords as C}from"../chunk-MFIRYGHW.js";import{TextToolbar as D,registerModalEscapeInterceptor as N,textToolbarRows as L,LinkPicker as O,Tooltip as T,IconButton as M}from"efficient-shell/ui";export{TextToolbar}from"efficient-shell/ui";import{useRef as R,useState as K,useLayoutEffect as P,useEffect as j,useId as F}from"react";import{RETIRED_MARKS as H,applyMark as $,marksIn as B,STANDARD_MARKUP as V,listIn as W,colorIn as z,spanFor as A,findLink as U,colorOver as Y,setList as I,unlinkAt as q,removeLink as G,linkOver as _,writeLink as Q}from"efficient-shell/markup";import{jsxs as X,jsx as J,Fragment as Z}from"react/jsx-runtime";import{ParagraphSpacingIcon as ee,LetterSpacingIcon as te,LineSpacingIcon as ne,TextSizeIcon as re,AlignJustifyIcon as le,AlignRightIcon as oe,AlignCenterIcon as ae,AlignLeftIcon as se,StylesIcon as ce,TypeIcon as ie,AlignmentIcon as ue,ListFormatIcon as de,CaseIcon as pe,ItalicIcon as me,NumberedListIcon as he,ListIcon as fe,ListNoneIcon as ge,CaseLowerIcon as ye,CaseCapitalizedIcon as ve,CaseUpperIcon as be,CaseNormalIcon as Se}from"efficient-shell/icons/efficient";function ke(e,t){const n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}}function xe(e,t,n,r=$){const{start:l,end:o}=ke(e,n);return r(e,l,o,t)}function we(e,t,n){const{start:r,end:l}=ke(e,n),o=r+t.length;return{text:e.slice(0,r)+t+e.slice(l),selectionStart:o,selectionEnd:o}}function Ee(e,t,n,r){switch(t){case"bold":return e.createElement("strong");case"italic":return e.createElement("em");case"strike":return e.createElement("s");case"underline":return e.createElement("u");case"sup":return e.createElement("sup");case"sub":return e.createElement("sub");case"color":{const t=e.createElement("span");return t.className="es-rich-color",r&&(t.dataset.color=r,t.title=r.startsWith("#")?r.toUpperCase():r,t.style.color=r.startsWith("#")?r:`var(--es-color-${r}, inherit)`),t}case"link":{const t=e.createElement("a");return t.className="es-rich-link",n&&(t.title=n),t}default:{const n=e.createElement("span");return n.className="highlight"===t||"accent"===t?"es-rich-emphasis":`es-rich-${t}`,n}}}function Ce(e,t,n,r){const l=e.layout.lines;if(n===t)return r>=e.lines.length?e.layout.text.length:l[r].vis;const o=e.lines.findIndex(e=>e===n||e.contains(n));if(-1===o)return 0;const a=t.ownerDocument.createRange();a.setStart(e.lines[o],0);try{a.setEnd(n,r)}catch{return l[o].vis}return l[o].vis+Math.min(a.toString().length,l[o].text.length)}function De(e,t){const n=e.layout.lines;let r=n.length-1;for(let e=0;e<n.length;e+=1)if(t<=n[e].vis+n[e].text.length){r=e;break}let l=Math.max(0,t-n[r].vis);const o=e.lines[r].ownerDocument.createTreeWalker(e.lines[r],4);let a=o.nextNode(),s=null;for(;a;){if(l<=a.data.length)return[a,l];l-=a.data.length,s=a,a=o.nextNode()}return s?[s,s.data.length]:[e.lines[r],0]}function Ne({value:e,rules:t,multiline:n,readOnly:r=!1,placeholder:l,ariaLabel:o,handle:a,onEdit:u,onSelect:d,onHistory:p,onFormat:m,pending:h,onCommit:f,onCancel:g}){const y=R(null),v=R(null),E=R(null),C=R(null),D=R(null),N=R(e),[L,O]=K(0),T=R({value:e,rules:t,multiline:n,readOnly:r,pending:h,onEdit:u,onHistory:p,onFormat:m});T.current={value:e,rules:t,multiline:n,readOnly:r,pending:h,onEdit:u,onHistory:p,onFormat:m};const M=()=>{const e=y.current,t=v.current,n=e?.ownerDocument.getSelection();if(!(e&&t&&n&&0!==n.rangeCount&&n.anchorNode&&e.contains(n.anchorNode)))return null;const r=Ce(t,e,n.anchorNode,n.anchorOffset),l=n.focusNode&&e.contains(n.focusNode)?Ce(t,e,n.focusNode,n.focusOffset):r;return r<=l?[r,l]:[l,r]},F=(e,t)=>{const n=y.current,r=v.current;if(!n||!r)return;const[l,o]=De(r,e),[a,s]=De(r,t);n.ownerDocument.getSelection()?.setBaseAndExtent(l,o,a,s)};a.current={getSource(){const e=M(),t=v.current;if(!e||!t)return null;const[n,r]=c(t.layout,e[0],e[1]);return{start:n,end:r}},setSource(e,t,n){C.current={text:n,src:[e,t]},O(e=>e+1)},focus(){y.current?.focus()},rangeOf(e,t){const n=y.current,r=v.current;if(!n||!r)return null;const[l,o]=s(r.layout,e,t),[a,c]=De(r,l),[i,u]=De(r,o),d=n.ownerDocument.createRange();return d.setStart(a,c),d.setEnd(i,u),d}},P(()=>{const n=y.current;if(!n||D.current)return;const r=C.current?null:M();v.current=function(e,t){const n=e.ownerDocument;e.replaceChildren();const r=t.lines.map(t=>{const r=n.createElement("div");r.className=null!=t.number?"es-rich-line is-numbered":t.bullet?"es-rich-line is-bullet":"es-rich-line",null!=t.number&&(r.dataset.number=t.number);const l=[],o=()=>l.length?l[l.length-1].el:r;let a=null;for(const e of t.chars){let t=0;for(;t<l.length&&t<e.marks.length&&l[t].id===e.marks[t].id;)t+=1;(l.length>t||e.marks.length>t)&&(a=null),l.length=t;for(let r=t;r<e.marks.length;r+=1){const t=Ee(n,e.marks[r].kind,e.marks[r].href,e.marks[r].color);o().appendChild(t),l.push({id:e.marks[r].id,el:t})}a||(a=n.createTextNode(""),o().appendChild(a)),a.data+=e.ch}return 0===t.chars.length&&r.appendChild(n.createElement("br")),e.appendChild(r),r});return{layout:t,lines:r}}(n,i(e,t)),E.current=e;const l=C.current;if(!l||l.text!==e)return void(r&&n.ownerDocument.activeElement===n&&F(r[0],Math.min(r[1],v.current.layout.text.length)));C.current=null;const o=v.current.layout,[a,c]=l.vis??s(o,l.src[0],l.src[1]);n.ownerDocument.activeElement!==n&&n.focus(),F(a,c)},[e,t,L]);const H=(e,t,n)=>{const r=v.current,[l,o]=c(r.layout,t[0],t[1]);C.current={text:e.text,vis:[e.caret,e.caret]},e.text!==T.current.value?T.current.onEdit(e.text,{start:l,end:o},n):O(e=>e+1)};j(()=>{const e=y.current;if(!e)return;const t=t=>{const{value:n,rules:r,multiline:l,readOnly:o,pending:a}=T.current;if("insertCompositionText"===t.inputType)return;if(t.preventDefault(),o)return;const s=v.current,c=M();if(!s||!c)return;const i="function"==typeof t.getTargetRanges?t.getTargetRanges()[0]:void 0,u=i&&!i.collapsed?[Ce(s,e,i.startContainer,i.startOffset),Ce(s,e,i.endContainer,i.endOffset)]:null,d=S({value:n,rules:r,multiline:l,inputType:t.inputType,data:t.data??t.dataTransfer?.getData("text/plain")??"",html:t.dataTransfer?.getData("text/html"),doc:e.ownerDocument,sel:c,target:u,pending:a});d&&("history"!==d.kind?"format"!==d.kind?H(d.edit,d.range,d.kind):T.current.onFormat(d.style):T.current.onHistory(d.dir))},n=()=>{D.current||O(e=>e+1)};return e.addEventListener("beforeinput",t),e.addEventListener("input",n),()=>{e.removeEventListener("beforeinput",t),e.removeEventListener("input",n)}},[]),j(()=>{const e=y.current;if(!e)return;const t=e.ownerDocument,n=()=>{const e=a.current?.getSource();e&&d(e)};return t.addEventListener("selectionchange",n),()=>t.removeEventListener("selectionchange",n)});const $=(n,l=!1)=>{const o=M();if(!o||o[0]===o[1])return;n.preventDefault();const a=v.current;n.clipboardData.setData("text/plain",a.layout.text.slice(o[0],o[1])),n.clipboardData.setData(x,w(e,t,o[0],o[1])),l&&!r&&H(k(e,t,o[0],o[1],{text:""}),o,"edit")};/* @__PURE__ */
|
|
2
|
+
return X("div",{className:"es-rich-wrap",children:[l&&""===e?/* @__PURE__ */J("div",{className:"es-rich-placeholder","aria-hidden":"true",children:l}):null,
|
|
3
|
+
/* @__PURE__ */J("div",{ref:y,className:`es-rich${n?" is-multiline":" is-single"}${r?" is-off":""}`,contentEditable:!r,suppressContentEditableWarning:!0,role:"textbox","aria-multiline":n,"aria-label":o,"aria-readonly":r||void 0,"aria-placeholder":l,tabIndex:r?-1:0,spellCheck:!0,onFocus:()=>{N.current=e},onBlur:()=>{e!==N.current&&f?.(e),N.current=e},onKeyDown:t=>{if("Escape"===t.key)return t.preventDefault(),g?.(N.current),void(N.current=e);"Enter"!==t.key||n||(t.preventDefault(),e!==N.current&&f?.(e),N.current=e)},onCompositionStart:()=>{const e=M()??[0,0];D.current={from:e[0],to:e[1]}},onCompositionEnd:e=>{const t=D.current;if(D.current=null,!t)return;const{value:n,rules:r,pending:l}=T.current;e.data?H(k(n,r,t.from,t.to,{text:e.data,add:l?.add,drop:l?.drop,color:l?.color}),[t.from,t.to],"type"):O(e=>e+1)},onCopy:e=>$(e),onCut:e=>$(e,!0),onPaste:l=>{if(l.preventDefault(),r)return;const o=M();if(!o)return;const a=l.clipboardData.getData(x),s=a?n?a:a.replace(/\s*\r?\n\s*/g," "):b({html:l.clipboardData.getData("text/html"),text:l.clipboardData.getData("text/plain")},{doc:l.currentTarget.ownerDocument,multiline:n,rules:t});H(k(e,t,o[0],o[1],{markup:s}),o,"edit")}})]})}var Le={fontSize:{key:"fontSize",nameKey:"fontSize",icon:/* @__PURE__ */J(re,{}),unit:"px",step:1,shiftStep:10,min:5},lineHeight:{key:"lineHeight",nameKey:"lineHeight",icon:/* @__PURE__ */J(ne,{}),unit:"%",step:1,shiftStep:10,min:50,max:250,scale:100},letterSpacing:{key:"letterSpacing",nameKey:"letterSpacing",icon:/* @__PURE__ */J(te,{}),unit:"px",step:.1,shiftStep:1,min:-10},paragraphSpacing:{key:"paragraphSpacing",nameKey:"paragraphSpacing",icon:/* @__PURE__ */J(ee,{}),unit:"px",step:1,shiftStep:10,min:0}};function Oe(e,t){return void 0===e?void 0:Number((e*t).toFixed(6))}function Te({cells:e,words:n,readOnly:r=!1}){const l=n??E.cells,o=F();/* @__PURE__ */
|
|
4
|
+
return J("div",{className:"es-copy-cells-fit",children:/* @__PURE__ */J("div",{className:"es-copy-cells",children:e.map(e=>{const n=e.scale??1,a=e.name??(e.nameKey?l[e.nameKey]:e.key),s=e.unit??"",c=e.step??1,i=`${o}-${e.key}`;/* @__PURE__ */
|
|
5
|
+
return X("div",{className:"es-copy-cell",children:[
|
|
6
|
+
/* @__PURE__ */J("label",{className:"es-field-label es-copy-cell-name",htmlFor:i,children:a}),
|
|
7
|
+
/* @__PURE__ */J(t,{id:i,value:Oe(e.value,n),styleValue:Oe(e.styleValue,n),onChange:t=>e.onChange(void 0===t?void 0:Number((t/n).toFixed(6))),min:e.min,max:e.max,step:c,shiftStep:e.shiftStep,icon:e.icon,unit:s||void 0,steppers:"compact",readOnly:r,ariaLabel:a,title:l.tip({name:a,step:c,unit:s})})]},e.key)})})})}function Me({target:e,onChange:t}){const n=R(null);return P(()=>{const t=n.current,r=e.current;t&&r&&r.value===t.text&&(n.current=null,r.focus(),r.setSelectionRange(t.start,t.end))}),r=>{const l=r(e.current);t(l.text),n.current={start:l.selectionStart,end:l.selectionEnd,text:l.text}}}var Re=/* @__PURE__ */new Set([...H,"clear"]);function Ke(e){if(!e)return;const t=e.split("+"),n=t.pop().toUpperCase();return["Meta",...t.map(e=>e[0].toUpperCase()+e.slice(1)),n].join("+")}function Pe({tools:e,onApply:t,disabled:n=!1,actions:r,ariaLabel:l,pressed:o,open:a=null}){const s=C("copy",E),c=("string"==typeof e[0]?e:e.map(e=>e.style)).filter(e=>!Re.has(e));/* @__PURE__ */
|
|
8
|
+
return J(D,{"aria-label":l??s.formatting,offered:new Set(c),pressed:o??{},onMark:e=>t(e),linkOpen:"link"===a,list:c.includes("bullet")||c.includes("number")?{pressed:null,onList:e=>t(e)}:void 0,last:r,disabled:n})}function je({value:e,onChange:t,onCommit:n,onCancel:l,multiline:o=!1,placeholder:s,ariaLabel:c,className:i,readOnly:S=!1,rules:k,tools:x=[],writeMark:w,align:T,actions:M,toolbar:H,barLabel:ee,renderFooter:te,inputRef:ne,barShows:re="always",richText:le=!0,defaultShowMarks:oe=!1,colors:ae,cells:se,letterCase:ce,lastTool:ie}){const ue=C("copy",E),de=R(null),pe=ne??de,[me,he]=K(!1),[fe,ge]=K(null),ye=R(u()).current,ve=R(null);j(()=>{const t=ve.current;t&&e===t.to?ve.current=null:t&&e===t.from||(ve.current=null,ye.reset())},[e,ye]);const be=n=>{ve.current={from:ve.current?.from??e,to:n},t(n)},Se=t=>({text:e,start:t?.selectionStart??fe?.start??e.length,end:t?.selectionEnd??fe?.end??e.length}),[ke,Ee]=K(oe),Ce=le&&!(o&&ke),De=R(null),Le=F(),[Oe,Ke]=K(null),[Pe,je]=K(!1),Fe=()=>{if(!Ce)return pe.current;const e=De.current?.getSource()??fe;return e?{selectionStart:e.start,selectionEnd:e.end}:null},He=Me({target:pe,onChange:be}),$e=e=>(ge({start:e.selectionStart,end:e.selectionEnd}),e),Be=(t,n)=>{if(!Ce)return void He(e=>(n&&ye.record(Se(e),"edit",Date.now()),$e(t(e))));const r=Fe(),l=$e(t(r));n&&ye.record(Se(r),"edit",Date.now()),Ke(null),l.text!==e&&be(l.text),De.current?.setSource(l.selectionStart,l.selectionEnd,l.text)},Ve=e=>Be(e,!0),We=e=>Be(t=>{const n=Se(t),r=ye[e](n);return r?{text:r.text,selectionStart:r.start,selectionEnd:r.end}:{text:n.text,selectionStart:n.start,selectionEnd:n.end}},!1),ze=R(null);P(()=>{const t=ze.current;t&&(ze.current=null,Ce?De.current?.setSource(t.start,t.end,e):(pe.current?.focus(),pe.current?.setSelectionRange(t.start,t.end),ge(t)))},[Ce]);const[Ae,Ue]=K(null),Ye=k??V,Ie=("string"==typeof x[0]?x:x.map(e=>e.style)).filter(e=>!Re.has(e)),qe={};if(fe){const t=B(e,fe.start,fe.end,Ye);for(const e of Ie){const n=t.has(e)||"highlight"===e&&t.has("accent");qe[e]=!!Oe?.add.includes(e)||!Oe?.drop.includes(e)&&n}qe.link=t.has("link")}const Ge=()=>{const t=Fe(),n=t?.selectionStart??e.length;return{start:n,end:t?.selectionEnd??n}},_e=t=>{if("link"!==t&&A(0,t)){const{start:n,end:r}=Ge();if(n===r&&!Ce)return void Ve(n=>xe(e,t,n,(e,t,n,r)=>$(e,t,n,r,Ye,ue.placeholders)));const l=v({value:e,rules:Ye,start:n,end:r,style:t,pending:Oe});return void("pending"===l.kind?Ke(l.pending):Ve(()=>l.result))}if("link"!==t){const n=w??((e,t,n,r)=>$(e,t,n,r,V,ue.placeholders));return void Ve(r=>xe(e,t,r,n))}const n=Fe(),r=n?.selectionStart??e.length,l=n?.selectionEnd??r;je(!1),Ue({start:r,end:l,link:U(e,r,l)})},Qe=Boolean(fe&&fe.start!==fe.end),Xe=fe?W(e,fe.start,fe.end,Ye):null,Je=fe?Oe&&void 0!==Oe.color&&Oe.at===fe.start?Oe.color:z(e,fe.start,fe.end,Ye):null,Ze=d(Je,ae),et=t=>{Ce?t?De.current?.setSource(t.start,t.end,e):De.current?.focus():(pe.current?.focus(),t&&pe.current?.setSelectionRange(t.start,t.end))},tt=()=>{const e=Ae;Ue(null),et(e?{start:e.start,end:e.end}:fe)},nt=()=>{const e=lt.current,t=Boolean(e&&e.querySelector(".es-copy-colors")?.contains(e.ownerDocument.activeElement));je(!1),t&&et(fe)},rt=R(nt);rt.current=nt,j(()=>{if(Pe)return N(e=>{const t=lt.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(rt.current(),!0)},()=>lt.current?.querySelector(".es-copy-colors"))},[Pe]);const lt=R(null),ot=Pe||null!==Ae;j(()=>{const e=lt.current;if(!ot||!e)return;const t=e.ownerDocument,n=()=>{je(!1),Ue(null)},r=t=>{e.contains(t.target)||n()};let l;const o=r=>{const o=r.relatedTarget;o?e.contains(o)||n():(clearTimeout(l),l=setTimeout(()=>{const r=t.activeElement;t.hasFocus()&&r&&r!==t.body&&!e.contains(r)&&n()},0))};return t.addEventListener("pointerdown",r,!0),e.addEventListener("focusout",o),()=>{clearTimeout(l),t.removeEventListener("pointerdown",r,!0),e.removeEventListener("focusout",o)}},[ot]);const at=Ae??(Pe?fe??{start:e.length,end:e.length}:null),st=R(()=>{});st.current=()=>{const e=lt.current,t=e?.querySelector(".rosh-tb-wrap > .es-copy-pop");if(!e||!t||!at)return;const n=Ce?null:e.querySelector(".es-gold-layer"),r=Ce?De.current?.rangeOf(at.start,at.end)??null:n?p(n,at.start,at.end):null,l=r?.endContainer,o=l?1===l.nodeType?l:l.parentElement:null,a=r?m(r,o?.closest(".es-rich-line, .es-gold-layer")??null):null;if(!a)return;const s=h({anchor:a,size:{width:t.offsetWidth,height:t.offsetHeight},within:e.getBoundingClientRect(),clip:g(e),parent:f(t)});t.style.top=`${s.top}px`,t.style.left=`${s.left}px`,t.style.setProperty("--es-pop-point",`${s.point}px`),t.dataset.side=s.above?"above":"below"},P(()=>{const e=lt.current;if(!ot||!e)return;const t=()=>st.current();t();const n=e.ownerDocument.defaultView;n?.addEventListener("resize",t);const r=e.querySelector(".rosh-tb-wrap > .es-copy-pop"),l=n?.ResizeObserver,o=l&&r?new l(t):null;return o&&r&&o.observe(r),()=>{n?.removeEventListener("resize",t),o?.disconnect()}},[ot,Pe,Ae,at?.start,at?.end,Ce]);const ct="always"===re||me||null!==Ae||Pe,it=ae&&ae.length>0?{run:Ze,open:Pe,onToggle:()=>{Ue(null),Pe?nt():je(!0)}}:void 0,ut=ct?ie?ie({className:"rosh-tb-btn",disabled:S,selected:Qe,keepCaret:e=>e.preventDefault(),insert:t=>Ve(n=>we(e,t,n))}):"classic"===H?M:void 0:void 0,dt=new Set(Ie),pt=T?{value:T.value,allow:T.allow,onChange:T.onChange,disabled:T.disabled}:void 0,mt={pressed:Xe,onList:t=>{const{start:n,end:r}=Ge(),l=W(e,n,r,Ye);Ve(()=>I(e,n,r,l===t?null:t,Ye))}},ht=L({offered:dt,color:it,last:ut,alignment:pt,list:mt,letterCase:ce});/* @__PURE__ */
|
|
9
|
+
return X("div",{ref:lt,className:"es-copy"+(i?` ${i}`:""),onFocus:()=>he(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||he(!1)},onKeyDown:e=>{const t=e.target===pe.current||Boolean(e.target.closest?.(".es-rich"));if(S||!t)return;if(e.altKey||e.metaKey===e.ctrlKey)return;const n=e.key.toLowerCase(),r="KeyZ"===e.code||"z"===n,l=("KeyY"===e.code||"y"===n)&&!e.shiftKey;if(r||l)return e.preventDefault(),e.stopPropagation(),void We(l||e.shiftKey?"redo":"undo");const o={b:"bold",i:"italic",u:"underline",k:"link"}[`${e.shiftKey?"shift+":""}${n}`];o&&Ie.includes(o)&&(e.preventDefault(),e.stopPropagation(),_e(o))},onPaste:t=>{const n=pe.current;if(S||!n||t.target!==n)return;t.preventDefault();const r=b({html:t.clipboardData.getData("text/html"),text:t.clipboardData.getData("text/plain")},{doc:n.ownerDocument,multiline:o,rules:Ye});Ve(t=>we(e,r,t))},style:ae&&ae.length>0?Object.fromEntries(ae.map(e=>[`--es-color-${e.name}`,e.value])):void 0,onSelect:()=>{const t=pe.current;t&&t.ownerDocument.activeElement===t&&ge({start:t.selectionStart??e.length,end:t.selectionEnd??e.length})},children:[ct&&(ht.words||ht.paragraph)?
|
|
10
|
+
/* @__PURE__ */J(D,{className:"es-copy-toolbar","aria-label":ee??ue.formatting,offered:dt,pressed:qe,onMark:e=>_e(e),color:it,linkOpen:null!==Ae,last:ut,alignment:pt,list:mt,letterCase:ce,disabled:S,windows:/* @__PURE__ */X(Z,{children:[Pe&&ae&&ae.length>0?/* @__PURE__ */J(y,{colors:ae,current:Je,words:ue.colors??E.colors,onPick:t=>{const{start:n,end:r}=Ge();if(n!==r)Ve(()=>Y(e,n,r,t,Ye));else{if(!Ce)return;Ke({add:Oe?.add??[],drop:Oe?.drop??[],color:t,at:n})}}}):null,Ae?Ae&&/* @__PURE__ */J(O,{className:"es-copy-link es-copy-pop",value:Ae.link?.href??"",onApply:t=>{const n=Ae;Ue(null),Ve(()=>Ce?_(e,n.start,n.end,t,Ye):Q(e,n.start,n.end,t))},onRemove:Ae.link?()=>{const t=Ae.link,n=Ae;Ue(null),t&&Ve(()=>Ce?q(e,n.start,n.end,Ye):G(e,t))}:void 0,onCancel:tt}):null]})}):null,se&&se.length>0?/* @__PURE__ */J(Te,{cells:se,words:ue.cells??E.cells,readOnly:S}):null,Ce?/* @__PURE__ */J(Ne,{value:e,rules:Ye,multiline:o,readOnly:S,placeholder:s,ariaLabel:c,handle:De,pending:Oe??void 0,onEdit:(t,n,r)=>{ye.record({text:e,start:n.start,end:n.end},r,Date.now()),Ke(null),be(t)},onSelect:e=>{ge(t=>t&&t.start===e.start&&t.end===e.end?t:e),!Oe||e.start===Oe.at&&e.end===Oe.at||Ke(null)},onHistory:We,onFormat:e=>{Ie.includes(e)&&_e(e)},onCommit:n,onCancel:l}):/* @__PURE__ */J(a,{value:e,onInput:e=>{ye.record(Se(null),"type",Date.now()),be(e)},onCommit:n,onCancel:l,multiline:o,placeholder:s,ariaLabel:c,rules:k,disabled:S,inputRef:pe,className:"es-copy-box"}),te?te({focused:me,insert:t=>Ve(n=>we(e,t,n))}):null,le&&o?
|
|
11
|
+
/* @__PURE__ */X("div",{className:"es-copy-marks",children:[
|
|
12
|
+
/* @__PURE__ */J(r,{checked:ke,onChange:()=>{const e=Fe();ze.current=e&&null!==e.selectionStart&&null!==e.selectionEnd?{start:e.selectionStart,end:e.selectionEnd}:fe,Ke(null),Ee(e=>!e)},ariaLabelledBy:Le,disabled:S}),
|
|
13
|
+
/* @__PURE__ */J("span",{id:Le,className:"es-copy-marks-label",children:ue.showMarks??"Show marks"})]}):null]})}var Fe=["left","center","right","justify"],He=E.align,$e={left:/* @__PURE__ */J(se,{}),center:/* @__PURE__ */J(ae,{}),right:/* @__PURE__ */J(oe,{}),justify:/* @__PURE__ */J(le,{})},Be={three:{labelsPx:94.5,widestLabelPx:39.94},four:{labelsPx:140,widestLabelPx:44}};function Ve(e,t=He){return Fe.filter(t=>e.includes(t)).map(e=>({id:e,label:t[e],icon:$e[e],title:t[e]}))}var We=["none","bullet","number"],ze=e,Ae={none:/* @__PURE__ */J(ge,{}),bullet:/* @__PURE__ */J(fe,{}),number:/* @__PURE__ */J(he,{})},Ue={none:/* @__PURE__ */J(Se,{}),upper:/* @__PURE__ */J(be,{}),capitalize:/* @__PURE__ */J(ve,{}),lower:/* @__PURE__ */J(ye,{})};function Ye({label:e,icon:t,answers:n,names:r,glyphs:a,row:s,readOnly:c}){const i=s.value||s.styleValue||"";/* @__PURE__ */
|
|
14
|
+
return J(l,{label:e,icon:t,children:/* @__PURE__ */J(o,{ariaLabel:e,value:i,disabled:c,onChange:e=>{c||s.onChange(function(e,t){return t===e.value||""===e.value&&t===e.styleValue?"":t}(s,e))},options:n.map(e=>({id:e,label:a[e],title:r[e]}))})})}function Ie({kept:e,keptHint:t,readOnly:r=!1,style:o,font:a,italic:s,cells:c,align:i,list:u,letterCase:d}){const p=C("copy",E),m={...E.panel,...p.panel},h=p.clearStyle??E.clearStyle,f=o&&!r?[o.onClearChanges&&{label:h,onSelect:o.onClearChanges},o.onEditStyles&&{label:m.editStyles,onSelect:o.onEditStyles},o.onUpdateStyle&&{label:m.updateStyle,onSelect:o.onUpdateStyle}].filter(e=>!!e):[],g=!!s&&(s.value??s.styleValue??!1),y=s?/* @__PURE__ */J(T,{content:m.italic,children:/* @__PURE__ */J(M,{size:"sm",variant:"ghost","aria-label":m.italic,"aria-pressed":g,disabled:r,onClick:()=>{if(r)return;const e=!g;s.onChange(e===(s.styleValue??!1)?void 0:e)},children:/* @__PURE__ */J(me,{})})}):null;/* @__PURE__ */
|
|
15
|
+
return X("div",{className:"es-tpp",children:[e?/* @__PURE__ */X("div",{className:"es-tpp-kept",children:[
|
|
16
|
+
/* @__PURE__ */J(je,{...e,readOnly:r||e.readOnly}),t?/* @__PURE__ */J("p",{className:"es-field-hint",children:t}):null]}):null,o?/* @__PURE__ */J(l,{label:m.style,icon:/* @__PURE__ */J(ce,{}),children:/* @__PURE__ */J(n,{ariaLabel:m.style,value:o.value,options:o.options,onChange:o.onChange,changed:o.changed,footer:f,readOnly:r})}):null,a?/* @__PURE__ */J(l,{label:m.font,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */X("div",{className:"es-tpp-font",children:[
|
|
17
|
+
/* @__PURE__ */J("div",{className:"es-tpp-font-select",children:/* @__PURE__ */J(n,{ariaLabel:m.font,value:a.value||void 0,placeholder:a.styleValue,options:a.options,onChange:a.onChange,searchable:a.searchable,readOnly:r})}),y]})}):y?
|
|
18
|
+
/* @__PURE__ */J(l,{label:m.italic,icon:/* @__PURE__ */J(ie,{}),children:/* @__PURE__ */J("div",{className:"es-tpp-font",children:y})}):null,c?.length?/* @__PURE__ */J(Te,{cells:c,words:p.cells,readOnly:r}):null,i?/* @__PURE__ */J(Ye,{label:p.alignment,icon:/* @__PURE__ */J(ue,{}),answers:Fe.filter(e=>!i.allow||i.allow.includes(e)),names:p.align,glyphs:$e,row:i,readOnly:r}):null,u?/* @__PURE__ */J(Ye,{label:m.list,icon:/* @__PURE__ */J(de,{}),answers:We,names:m.lists,glyphs:Ae,row:u,readOnly:r}):null,d?/* @__PURE__ */J(Ye,{label:m.capitalization,icon:/* @__PURE__ */J(pe,{}),answers:ze,names:m.cases,glyphs:Ue,row:d,readOnly:r}):null]})}export{Fe as COPY_ALIGNS,Be as COPY_ALIGN_FIT,$e as COPY_ALIGN_GLYPHS,He as COPY_ALIGN_LABELS,Le as COPY_CELLS,je as CopyBox,Te as CopyCells,Pe as MarkBar,Ne as RichBox,Ie as TextPartPanel,Ke as ariaShortcut,Ve as copyAlignOptions,we as insertSelection,xe as markSelection,Me as useCaretEdit};
|