@burger-editor/client 4.0.0-alpha.61 → 4.0.0-alpha.63

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/dist/client.js CHANGED
@@ -383,7 +383,7 @@ function kebabCase(str) {
383
383
  }
384
384
 
385
385
  /**
386
- * marked v17.0.2 - a markdown parser
386
+ * marked v17.0.3 - a markdown parser
387
387
  * Copyright (c) 2018-2026, MarkedJS. (MIT License)
388
388
  * Copyright (c) 2011-2018, Christopher Jeffrey. (MIT License)
389
389
  * https://github.com/markedjs/marked
@@ -451,7 +451,7 @@ ${this.parser.parse(e)}</blockquote>
451
451
  `}tablerow({text:e}){return `<tr>
452
452
  ${e}</tr>
453
453
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return (e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
454
- `}strong({tokens:e}){return `<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return `<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return `<code>${O(e,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=X(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+O(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=X(e);if(i===null)return O(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${O(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:O(e.text)}};var $=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return ""+e}image({text:e}){return ""+e}br(){return ""}checkbox({raw:e}){return e}};var b=class u{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new y,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $;}static parse(e,t){return new u(t).parse(e)}static parseInline(e,t){return new u(t).parseInline(e)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let s=r,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){t+=a||"";continue}}let i=r;switch(i.type){case "space":{t+=this.renderer.space(i);break}case "hr":{t+=this.renderer.hr(i);break}case "heading":{t+=this.renderer.heading(i);break}case "code":{t+=this.renderer.code(i);break}case "table":{t+=this.renderer.table(i);break}case "blockquote":{t+=this.renderer.blockquote(i);break}case "list":{t+=this.renderer.list(i);break}case "checkbox":{t+=this.renderer.checkbox(i);break}case "html":{t+=this.renderer.html(i);break}case "def":{t+=this.renderer.def(i);break}case "paragraph":{t+=this.renderer.paragraph(i);break}case "text":{t+=this.renderer.text(i);break}default:{let s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return t}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=a||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "checkbox":{n+=t.checkbox(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}};var P=class{options;block;constructor(e){this.options=e||T;}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?x.lex:x.lexInline}provideParser(){return this.block?b.parse:b.parseInline}};var B=class{defaults=M();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=y;TextRenderer=$;Lexer=x;Tokenizer=w;Hooks=P;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let a of s)n=n.concat(this.walkTokens(a.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let a=i[s].flat(1/0);n=n.concat(this.walkTokens(a,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===false&&(o=s.apply(this,a)),o}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new y(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,o=n.renderer[a],l=i[a];i[a]=(...p)=>{let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new w(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,o=n.tokenizer[a],l=i[a];i[a]=(...p)=>{let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new P;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,o=n.hooks[a],l=i[a];P.passThroughHooks.has(s)?i[a]=p=>{if(this.defaults.async&&P.passThroughHooksRespectAsync.has(s))return (async()=>{let d=await o.call(i,p);return l.call(i,d)})();let c=o.call(i,p);return l.call(i,c)}:i[a]=(...p)=>{if(this.defaults.async)return (async()=>{let d=await o.apply(i,p);return d===false&&(d=await l.apply(i,p)),d})();let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let o=[];return o.push(s.call(this,a)),i&&(o=o.concat(i.call(this,a))),o};}this.defaults={...this.defaults,...r};}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return (n,r)=>{let i={...r},s={...this.defaults,...i},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return (async()=>{let o=s.hooks?await s.hooks.preprocess(n):n,p=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(o,s),c=s.hooks?await s.hooks.processAllTokens(p):p;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(a);try{s.hooks&&(n=s.hooks.preprocess(n));let l=(s.hooks?s.hooks.provideLexer():e?x.lex:x.lexInline)(n,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let c=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
454
+ `}strong({tokens:e}){return `<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return `<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return `<code>${O(e,true)}</code>`}br(e){return "<br>"}del({tokens:e}){return `<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=X(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+O(t)+'"'),s+=">"+r+"</a>",s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=X(e);if(i===null)return O(n);e=i;let s=`<img src="${e}" alt="${O(n)}"`;return t&&(s+=` title="${O(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:O(e.text)}};var $=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return ""+e}image({text:e}){return ""+e}br(){return ""}checkbox({raw:e}){return e}};var b=class u{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new y,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $;}static parse(e,t){return new u(t).parse(e)}static parseInline(e,t){return new u(t).parseInline(e)}parse(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let s=r,a=this.options.extensions.renderers[s.type].call({parser:this},s);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(s.type)){t+=a||"";continue}}let i=r;switch(i.type){case "space":{t+=this.renderer.space(i);break}case "hr":{t+=this.renderer.hr(i);break}case "heading":{t+=this.renderer.heading(i);break}case "code":{t+=this.renderer.code(i);break}case "table":{t+=this.renderer.table(i);break}case "blockquote":{t+=this.renderer.blockquote(i);break}case "list":{t+=this.renderer.list(i);break}case "checkbox":{t+=this.renderer.checkbox(i);break}case "html":{t+=this.renderer.html(i);break}case "def":{t+=this.renderer.def(i);break}case "paragraph":{t+=this.renderer.paragraph(i);break}case "text":{t+=this.renderer.text(i);break}default:{let s='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(s),"";throw new Error(s)}}}return t}parseInline(e,t=this.renderer){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let a=this.options.extensions.renderers[i.type].call({parser:this},i);if(a!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=a||"";continue}}let s=i;switch(s.type){case "escape":{n+=t.text(s);break}case "html":{n+=t.html(s);break}case "link":{n+=t.link(s);break}case "image":{n+=t.image(s);break}case "checkbox":{n+=t.checkbox(s);break}case "strong":{n+=t.strong(s);break}case "em":{n+=t.em(s);break}case "codespan":{n+=t.codespan(s);break}case "br":{n+=t.br(s);break}case "del":{n+=t.del(s);break}case "text":{n+=t.text(s);break}default:{let a='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}};var P=class{options;block;constructor(e){this.options=e||T;}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?x.lex:x.lexInline}provideParser(){return this.block?b.parse:b.parseInline}};var B=class{defaults=M();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=y;TextRenderer=$;Lexer=x;Tokenizer=w;Hooks=P;constructor(...e){this.use(...e);}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case "table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,t));for(let s of i.rows)for(let a of s)n=n.concat(this.walkTokens(a.tokens,t));break}case "list":{let i=r;n=n.concat(this.walkTokens(i.items,t));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let a=i[s].flat(1/0);n=n.concat(this.walkTokens(a,t));}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)));}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||false,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=t.renderers[i.name];s?t.renderers[i.name]=function(...a){let o=i.renderer.apply(this,a);return o===false&&(o=s.apply(this,a)),o}:t.renderers[i.name]=i.renderer;}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=t[i.level];s?s.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]));}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens);}),r.extensions=t),n.renderer){let i=this.defaults.renderer||new y(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let a=s,o=n.renderer[a],l=i[a];i[a]=(...p)=>{let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new w(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let a=s,o=n.tokenizer[a],l=i[a];i[a]=(...p)=>{let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new P;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let a=s,o=n.hooks[a],l=i[a];P.passThroughHooks.has(s)?i[a]=p=>{if(this.defaults.async&&P.passThroughHooksRespectAsync.has(s))return (async()=>{let d=await o.call(i,p);return l.call(i,d)})();let c=o.call(i,p);return l.call(i,c)}:i[a]=(...p)=>{if(this.defaults.async)return (async()=>{let d=await o.apply(i,p);return d===false&&(d=await l.apply(i,p)),d})();let c=o.apply(i,p);return c===false&&(c=l.apply(i,p)),c};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(a){let o=[];return o.push(s.call(this,a)),i&&(o=o.concat(i.call(this,a))),o};}this.defaults={...this.defaults,...r};}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return (n,r)=>{let i={...r},s={...this.defaults,...i},a=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return (async()=>{let o=s.hooks?await s.hooks.preprocess(n):n,p=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(o,s),c=s.hooks?await s.hooks.processAllTokens(p):p;s.walkTokens&&await Promise.all(this.walkTokens(c,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(c,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(a);try{s.hooks&&(n=s.hooks.preprocess(n));let l=(s.hooks?s.hooks.provideLexer():e?x.lex:x.lexInline)(n,s);s.hooks&&(l=s.hooks.processAllTokens(l)),s.walkTokens&&this.walkTokens(l,s.walkTokens);let c=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(c=s.hooks.postprocess(c)),c}catch(o){return a(o)}}}onError(e,t){return n=>{if(n.message+=`
455
455
  Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+O(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var L=new B;function g(u,e){return L.parse(u,e)}g.options=g.setOptions=function(u){return L.setOptions(u),g.defaults=L.defaults,H(g.defaults),g};g.getDefaults=M;g.defaults=T;g.use=function(...u){return L.use(...u),g.defaults=L.defaults,H(g.defaults),g};g.walkTokens=function(u,e){return L.walkTokens(u,e)};g.parseInline=L.parseInline;g.Parser=b;g.parser=b.parse;g.Renderer=y;g.TextRenderer=$;g.Lexer=x;g.lexer=x.lex;g.Tokenizer=w;g.Hooks=P;g.parse=g;g.options;g.setOptions;g.use;g.walkTokens;g.parseInline;b.parse;x.lex;
456
456
 
457
457
  /*
@@ -2915,43 +2915,24 @@ class EditorUI {
2915
2915
  }
2916
2916
 
2917
2917
  class EditorDialog extends EditorUI {
2918
- #body = document.createElement('div');
2919
2918
  #cleanUpHooks = [];
2920
2919
  #createEditorComponent;
2921
- #dialog = document.createElement('dialog');
2920
+ #dialog;
2922
2921
  #el;
2923
- #footer = document.createElement('footer');
2924
- #form = document.createElement('form');
2922
+ #form;
2925
2923
  #onClosed;
2926
2924
  #onOpen;
2927
- constructor(name, el, settings, options) {
2928
- super(`${name}-dialog`, el);
2929
- this.#el = el;
2925
+ constructor(name, settings, options) {
2926
+ const shell = settings.createDialogShell
2927
+ ? settings.createDialogShell({ name, buttons: options.buttons })
2928
+ : createDefaultDialogShell(name, options);
2929
+ super(`${name}-dialog`, shell.containerElement);
2930
+ this.#el = shell.containerElement;
2931
+ this.#dialog = shell.dialogElement;
2932
+ this.#form = shell.formElement;
2930
2933
  this.#onClosed = settings.onClosed;
2931
2934
  this.#onOpen = settings.onOpen;
2932
2935
  this.#createEditorComponent = settings.createEditorComponent;
2933
- this.#form.noValidate = true;
2934
- this.#form.id = `${name}-dialog-form`;
2935
- this.#form.append(this.#el);
2936
- this.#body.append(this.#form);
2937
- if (options.buttons?.close) {
2938
- const button = document.createElement('button');
2939
- button.textContent = options.buttons.close;
2940
- button.type = 'button';
2941
- button.addEventListener('click', () => {
2942
- this.close();
2943
- });
2944
- this.#footer.append(button);
2945
- }
2946
- if (options.buttons?.complete) {
2947
- const button = document.createElement('button');
2948
- button.textContent = options.buttons.complete;
2949
- button.type = 'submit';
2950
- button.setAttribute('form', this.#form.id);
2951
- this.#footer.append(button);
2952
- }
2953
- this.#dialog.append(this.#body, this.#footer);
2954
- this.#form.method = 'dialog';
2955
2936
  this.#form.addEventListener('submit', (e) => {
2956
2937
  const submitter = this.#form.ownerDocument.activeElement;
2957
2938
  const cancel = this.onSubmit(e, submitter);
@@ -2965,8 +2946,6 @@ class EditorDialog extends EditorUI {
2965
2946
  return;
2966
2947
  });
2967
2948
  this.#sanitize(this.#el);
2968
- document.body.append(this.#dialog);
2969
- this.#dialog.classList.add('bge-dialog');
2970
2949
  this.#dialog.addEventListener('close', this.closed.bind(this));
2971
2950
  }
2972
2951
  clearTemplate() {
@@ -3068,12 +3047,58 @@ class EditorDialog extends EditorUI {
3068
3047
  }
3069
3048
  }
3070
3049
  }
3050
+ /**
3051
+ *
3052
+ * @param name
3053
+ * @param options
3054
+ */
3055
+ function createDefaultDialogShell(name, options) {
3056
+ const dialogId = `${name}-dialog`;
3057
+ const formId = `${name}-dialog-form`;
3058
+ const dialog = document.createElement('dialog');
3059
+ dialog.id = dialogId;
3060
+ dialog.classList.add('bge-dialog');
3061
+ dialog.setAttribute('closedby', 'any');
3062
+ const body = document.createElement('div');
3063
+ const form = document.createElement('form');
3064
+ form.noValidate = true;
3065
+ form.method = 'dialog';
3066
+ form.id = formId;
3067
+ const container = document.createElement('div');
3068
+ form.append(container);
3069
+ body.append(form);
3070
+ const footer = document.createElement('footer');
3071
+ if (options.buttons?.close) {
3072
+ const button = document.createElement('button');
3073
+ button.textContent = options.buttons.close;
3074
+ button.type = 'button';
3075
+ button.setAttribute('command', 'close');
3076
+ button.setAttribute('commandfor', dialogId);
3077
+ // Fallback for environments without Invoker Commands support
3078
+ button.addEventListener('click', () => dialog.close());
3079
+ footer.append(button);
3080
+ }
3081
+ if (options.buttons?.complete) {
3082
+ const button = document.createElement('button');
3083
+ button.textContent = options.buttons.complete;
3084
+ button.type = 'submit';
3085
+ button.setAttribute('form', formId);
3086
+ footer.append(button);
3087
+ }
3088
+ dialog.append(body, footer);
3089
+ document.body.append(dialog);
3090
+ return {
3091
+ dialogElement: dialog,
3092
+ containerElement: container,
3093
+ formElement: form,
3094
+ };
3095
+ }
3071
3096
 
3072
3097
  class BlockCatalogDialog extends EditorDialog {
3073
3098
  catalog;
3074
3099
  #addBlock;
3075
3100
  constructor(catalog, settings) {
3076
- super('catalog', document.createElement('div'), settings, {
3101
+ super('catalog', settings, {
3077
3102
  buttons: {
3078
3103
  close: 'キャンセル',
3079
3104
  },
@@ -3098,7 +3123,7 @@ class BlockOptionsDialog extends EditorDialog {
3098
3123
  #getCurrentBlock;
3099
3124
  #onChangeBlock;
3100
3125
  constructor(settings) {
3101
- super('options', document.createElement('div'), settings, {
3126
+ super('options', settings, {
3102
3127
  buttons: {
3103
3128
  close: 'キャンセル',
3104
3129
  complete: '決定',
@@ -3296,13 +3321,15 @@ function comparePriority(a, b) {
3296
3321
 
3297
3322
  /**
3298
3323
  * Get all custom properties from document
3299
- * @param scope
3300
- * @param containerType
3324
+ * @param scope - Document to scan for CSS custom properties
3325
+ * @param containerType - Container type to filter container-scoped properties (prefixed with `_`)
3326
+ * @returns Categorized map of custom properties grouped by property name
3301
3327
  */
3302
3328
  function getCustomProperties(scope, containerType) {
3303
3329
  const categories = new Map();
3304
3330
  const defaultValues = new Map();
3305
- searchCustomProperty(scope, (cssProperty, value, layers) => {
3331
+ const nestedDefaultValues = new Map();
3332
+ searchCustomProperty(scope, (cssProperty, value, layers, isNested) => {
3306
3333
  if (!cssProperty.startsWith(BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX)) {
3307
3334
  return;
3308
3335
  }
@@ -3338,8 +3365,12 @@ function getCustomProperties(scope, containerType) {
3338
3365
  isDefault: true,
3339
3366
  priority: layers.map((layer) => layer.priority),
3340
3367
  };
3341
- const currentDefaultValue = defaultValues.get(propName);
3342
- defaultValues.set(propName, currentDefaultValue
3368
+ // Direct selectors take precedence over nested selectors for default.
3369
+ // Nested selectors (e.g. `.parent [data-bge-container]`) are context-specific
3370
+ // overrides; they are used as fallback when no direct selector defines a default.
3371
+ const targetMap = isNested ? nestedDefaultValues : defaultValues;
3372
+ const currentDefaultValue = targetMap.get(propName);
3373
+ targetMap.set(propName, currentDefaultValue
3343
3374
  ? compareCustomPropertyByLayerPriority(currentDefaultValue, newDefaultValue)
3344
3375
  : newDefaultValue);
3345
3376
  }
@@ -3356,6 +3387,19 @@ function getCustomProperties(scope, containerType) {
3356
3387
  }
3357
3388
  }
3358
3389
  }
3390
+ // Merge nested defaults: use nested default when no direct default exists,
3391
+ // or when the nested default has higher cascade layer priority.
3392
+ for (const [category, nestedProperty] of nestedDefaultValues.entries()) {
3393
+ const directProperty = defaultValues.get(category);
3394
+ if (directProperty) {
3395
+ // Compare by layer priority; on equal priority, direct selector wins
3396
+ const winner = compareCustomPropertyByLayerPriority(nestedProperty, directProperty);
3397
+ defaultValues.set(category, winner);
3398
+ }
3399
+ else {
3400
+ defaultValues.set(category, nestedProperty);
3401
+ }
3402
+ }
3359
3403
  for (const [category, property] of defaultValues.entries()) {
3360
3404
  const currentMap = categories.get(category);
3361
3405
  if (!currentMap) {
@@ -3371,9 +3415,10 @@ function getCustomProperties(scope, containerType) {
3371
3415
  return categories;
3372
3416
  }
3373
3417
  /**
3374
- *
3375
- * @param scope
3376
- * @param property
3418
+ * Get a single custom property value from document
3419
+ * @param scope - Document to scan for CSS custom properties
3420
+ * @param property - Property name or pattern to match against
3421
+ * @returns The property value with the highest cascade priority, or `null` if not found
3377
3422
  */
3378
3423
  function getCustomProperty(scope, property) {
3379
3424
  let resultValue = null;
@@ -3455,9 +3500,9 @@ function collectGlobalTopLevelLayerOrder(scope) {
3455
3500
  /**
3456
3501
  * Get all CSSStyleRule from CSSRule array recursively
3457
3502
  * @param rules - CSSRule array
3458
- * @param layers
3459
- * @param scope - Document
3460
- * @param scopeRoot
3503
+ * @param layers - Accumulated layer priority chain from parent rules
3504
+ * @param scope - Document providing CSSOM constructors
3505
+ * @param scopeRoot - Selector from enclosing `@scope` rule, if any
3461
3506
  * @param topLevelLayerOrder - Global layer order from collectGlobalTopLevelLayerOrder (top-level calls only)
3462
3507
  * @returns CSSStyleRule array
3463
3508
  */
@@ -3528,9 +3573,9 @@ function getStyleRules(rules, layers, scope, scopeRoot = null, topLevelLayerOrde
3528
3573
  return styleRules;
3529
3574
  }
3530
3575
  /**
3531
- *
3532
- * @param scope
3533
- * @param found
3576
+ * Search all stylesheets for custom properties on the block option scope selector
3577
+ * @param scope - Document to scan
3578
+ * @param found - Callback invoked for each custom property found
3534
3579
  */
3535
3580
  function searchCustomProperty(scope, found) {
3536
3581
  const globalLayerOrder = collectGlobalTopLevelLayerOrder(scope);
@@ -3538,15 +3583,18 @@ function searchCustomProperty(scope, found) {
3538
3583
  try {
3539
3584
  const styleRules = getStyleRules(styleSheet.cssRules, [], scope, null, globalLayerOrder);
3540
3585
  for (const cssRule of styleRules) {
3541
- const selector = cssRule.rule.selectorText.trim().replace(/^&/, '').trim();
3586
+ const rawSelector = cssRule.rule.selectorText.trim();
3587
+ const selector = rawSelector.replace(/^&/, '').trim();
3542
3588
  if (selector === BLOCK_OPTION_SCOPE_SELECTOR ||
3543
3589
  (selector === ':scope' && cssRule.scopeRoot === BLOCK_OPTION_SCOPE_SELECTOR)) {
3590
+ // Detect nested selectors: `& [data-bge-container]` has a parent context
3591
+ const isNested = rawSelector !== selector;
3544
3592
  for (const cssProperty of cssRule.rule.style) {
3545
3593
  if (!cssProperty.startsWith('--')) {
3546
3594
  continue;
3547
3595
  }
3548
3596
  const value = cssRule.rule.style.getPropertyValue(cssProperty);
3549
- found(cssProperty, value, cssRule.layers);
3597
+ found(cssProperty, value, cssRule.layers, isNested);
3550
3598
  }
3551
3599
  }
3552
3600
  }
@@ -3561,7 +3609,8 @@ function searchCustomProperty(scope, found) {
3561
3609
  }
3562
3610
  /**
3563
3611
  * Get repeat-min-inline-size variant definitions from document
3564
- * @param scope
3612
+ * @param scope - Document to scan for `--bge-repeat-min-inline-size` variants
3613
+ * @returns Category containing variant properties, or `null` if no variants found
3565
3614
  */
3566
3615
  function getRepeatMinInlineSizeVariants(scope) {
3567
3616
  const PREFIX = '--bge-repeat-min-inline-size';
@@ -3612,8 +3661,8 @@ function getRepeatMinInlineSizeVariants(scope) {
3612
3661
  * - レイヤーの数が少ないほど優先度が高い
3613
3662
  * - レイヤーの数が同じ場合は、レイヤーの優先度の値が小さいほど優先度が高い
3614
3663
  * - 全てのレイヤーの優先度が同じ場合は、bを返す
3615
- * @param a
3616
- * @param b
3664
+ * @param a - First candidate property
3665
+ * @param b - Second candidate property (wins on equal priority)
3617
3666
  */
3618
3667
  function compareCustomPropertyByLayerPriority(a, b) {
3619
3668
  const result = comparePriority(a.priority, b.priority);
@@ -3623,124 +3672,6 @@ function compareCustomPropertyByLayerPriority(a, b) {
3623
3672
  return b;
3624
3673
  }
3625
3674
 
3626
- const getCSSPropertyAsNumberCache = new Map();
3627
- /**
3628
- *
3629
- * @param el
3630
- * @param property
3631
- */
3632
- function getCSSPropertyAsNumber(el, property) {
3633
- const value = window.getComputedStyle(el).getPropertyValue(property);
3634
- if (value === '') {
3635
- return 0;
3636
- }
3637
- const cached = getCSSPropertyAsNumberCache.get(value);
3638
- if (cached !== undefined) {
3639
- return cached;
3640
- }
3641
- const i_or_nan = Number.parseInt(value, 10);
3642
- const result = Number.isNaN(i_or_nan) ? 0 : i_or_nan;
3643
- getCSSPropertyAsNumberCache.set(value, result);
3644
- return result;
3645
- }
3646
-
3647
- class BlockMenu extends EditorUI {
3648
- #engine;
3649
- #mouseX = 0;
3650
- #mouseY = 0;
3651
- #raf = 0;
3652
- constructor(engine, el, create) {
3653
- super('block-menu', el, {
3654
- stylesheet: `
3655
- [data-bge-component='block-menu'] {
3656
- position: absolute;
3657
- z-index: 2147483647;
3658
- pointer-events: none;
3659
- }
3660
- `,
3661
- });
3662
- create(this.el);
3663
- this.#engine = engine;
3664
- const update = () => {
3665
- cancelAnimationFrame(this.#raf);
3666
- if (engine.isProcessed) {
3667
- this.hide();
3668
- return;
3669
- }
3670
- this.#raf = requestAnimationFrame(() => {
3671
- this.#updatePosition();
3672
- });
3673
- };
3674
- this.el.ownerDocument.body.addEventListener('mousemove', (e) => {
3675
- this.#mouseX = e.pageX;
3676
- this.#mouseY = e.pageY;
3677
- update();
3678
- });
3679
- globalThis.addEventListener('resize', this.hide.bind(this));
3680
- this.el.ownerDocument.body.addEventListener('mouseleave', this.hide.bind(this));
3681
- this.el.ownerDocument.addEventListener('mouseleave', this.hide.bind(this));
3682
- this.el.ownerDocument.defaultView?.addEventListener('mouseleave', this.hide.bind(this));
3683
- const observer = new MutationObserver((mutations) => {
3684
- for (const mutation of mutations) {
3685
- for (const node of mutation.addedNodes) {
3686
- if (!(node instanceof HTMLElement)) {
3687
- continue;
3688
- }
3689
- const images = node.querySelectorAll('img');
3690
- for (const img of images) {
3691
- img.addEventListener('load', update, { once: true });
3692
- img.addEventListener('error', update, { once: true });
3693
- img.addEventListener('abort', update, { once: true });
3694
- }
3695
- }
3696
- }
3697
- });
3698
- observer.observe(this.el.ownerDocument, { childList: true, subtree: true });
3699
- engine.el.addEventListener('bge:saved', update);
3700
- }
3701
- #getSelectedBlock() {
3702
- const $blocks = [
3703
- ...this.el.ownerDocument.body.querySelectorAll('[data-bge-container]'),
3704
- ];
3705
- for (const $block of $blocks) {
3706
- const rect = $block.getBoundingClientRect();
3707
- const marginBlockEnd = getCSSPropertyAsNumber($block, 'margin-block-end');
3708
- const onMouse = rect.left <= this.#mouseX &&
3709
- this.#mouseX <= rect.right &&
3710
- rect.top <= this.#mouseY &&
3711
- this.#mouseY <= rect.bottom + marginBlockEnd;
3712
- if (onMouse) {
3713
- const block = BurgerBlock.getBlock($block);
3714
- return { block, rect, marginBlockEnd };
3715
- }
3716
- }
3717
- return null;
3718
- }
3719
- #updatePosition() {
3720
- const selected = this.#getSelectedBlock();
3721
- if (!selected) {
3722
- this.hide();
3723
- return;
3724
- }
3725
- this.show();
3726
- const { block, rect, marginBlockEnd } = selected;
3727
- this.#engine.componentObserver.notify('select-block', {
3728
- block,
3729
- width: rect.width,
3730
- height: rect.height,
3731
- x: rect.left,
3732
- y: rect.top,
3733
- marginBlockEnd,
3734
- });
3735
- }
3736
- hide() {
3737
- super.hide();
3738
- this.#mouseX = 0;
3739
- this.#mouseY = 0;
3740
- this.#engine.clearCurrentBlock();
3741
- }
3742
- }
3743
-
3744
3675
  class InitialInsertionButton extends EditorUI {
3745
3676
  #afterInsert;
3746
3677
  #engine;
@@ -3849,46 +3780,74 @@ class EditableArea extends EditorUI {
3849
3780
  get isVisualMode() {
3850
3781
  return this.#isVisualMode;
3851
3782
  }
3852
- constructor(type, initialContent, engine, createBlockMenu, stylesheets = [], classList = []) {
3853
- const viewNode = document.createElement('div');
3854
- super(`${type}-editable-area`, viewNode);
3783
+ constructor(type, initialContent, engine, createBlockMenu, createInitialInsertionButton, stylesheets = [], classList = [], createShell) {
3784
+ const shell = createShell
3785
+ ? createShell({ type, initialContent, stylesheets, classList })
3786
+ : createDefaultEditableAreaShell(initialContent, classList);
3787
+ super(`${type}-editable-area`, shell.viewNode);
3855
3788
  this.type = type;
3856
3789
  this.#engine = engine;
3857
- this.#engine.viewArea.append(viewNode);
3858
- this.#sourceTextarea = document.createElement('textarea');
3859
- this.#sourceTextarea.spellcheck = false;
3860
- viewNode.append(this.#sourceTextarea);
3861
- this.#frameElement = document.createElement('iframe');
3862
- this.#frameElement.setAttribute('width', '100%;');
3863
- this.#frameElement.setAttribute('scrolling', 'no');
3864
- viewNode.append(this.#frameElement);
3790
+ this.#engine.viewArea.append(shell.viewNode);
3791
+ this.#sourceTextarea = shell.sourceTextarea;
3792
+ this.#frameElement = shell.frameElement;
3793
+ this.#containerElement = shell.containerElement;
3865
3794
  if (!this.#frameElement.contentWindow) {
3866
3795
  throw new Error('Impossible error: The contentWindow of created iframe is null.');
3867
3796
  }
3868
- this.#frameElement.contentWindow.document.open();
3869
- this.#frameElement.contentWindow.document.close();
3797
+ const frameDoc = this.#frameElement.contentWindow.document;
3798
+ frameDoc.open();
3799
+ frameDoc.close();
3870
3800
  for (const { path, id } of stylesheets) {
3871
- appendStylesheetTo(this.#frameElement.contentWindow.document, path, id);
3872
- }
3873
- this.#frameElement.contentWindow.document.body.setAttribute('style', 'margin: 0; border: 0;');
3874
- this.#containerElement =
3875
- this.#frameElement.contentWindow.document.createElement('div');
3876
- this.#containerElement.id = CONTENT_ID;
3877
- this.#containerElement.style.setProperty('padding', `${CONTAINER_PADDING}px`, 'important');
3878
- this.#containerElement.style.setProperty('overflow', 'hidden', 'important');
3879
- this.#containerElement.style.setProperty('margin', '0', 'important');
3880
- this.#containerElement.style.setProperty('box-sizing', 'border-box', 'important');
3881
- this.#containerElement.classList.add(...classList);
3882
- this.#containerElement.innerHTML = initialContent;
3883
- this.#containerElement.dataset.bgeComponent = 'editable-area';
3884
- this.blockMenu = new BlockMenu(this.#engine, this.#frameElement.contentWindow.document.createElement('div'), (el) => createBlockMenu(el, engine));
3801
+ appendStylesheetTo(frameDoc, path, id);
3802
+ }
3803
+ frameDoc.body.setAttribute('style', 'margin: 0; border: 0;');
3804
+ const blockMenuEl = frameDoc.createElement('div');
3805
+ blockMenuEl.dataset.bgeComponent = 'block-menu';
3806
+ const blockMenuStylesheetUrl = createStylesheet(`[data-bge-component='block-menu'] {
3807
+ position: absolute;
3808
+ z-index: 2147483647;
3809
+ pointer-events: none;
3810
+ }`, CSS_LAYER.ui);
3811
+ appendStylesheetTo(frameDoc, blockMenuStylesheetUrl, `block-menu-${CSS_LAYER.ui}`);
3812
+ const { hide: blockMenuHide } = createBlockMenu(blockMenuEl, engine);
3813
+ this.blockMenu = {
3814
+ el: blockMenuEl,
3815
+ hide: () => {
3816
+ blockMenuEl.hidden = true;
3817
+ blockMenuHide();
3818
+ },
3819
+ };
3885
3820
  this.insertionPoint = new InsertionPoint(this.#engine);
3886
- this.#insertionButton = new InitialInsertionButton(this.insertionPoint, this.#engine, () => this.#engine.blockCatalogDialog.open());
3887
- const els = this.#frameElement.contentWindow.document.createDocumentFragment();
3821
+ const onInsert = () => {
3822
+ if (this.#engine.isProcessed) {
3823
+ return;
3824
+ }
3825
+ this.#insertionButton.hide();
3826
+ this.insertionPoint.set(null, false);
3827
+ this.#engine.blockCatalogDialog.open();
3828
+ };
3829
+ if (createInitialInsertionButton) {
3830
+ const buttonEl = frameDoc.createElement('div');
3831
+ buttonEl.dataset.bgeComponent = 'initial-insertion';
3832
+ createInitialInsertionButton(buttonEl, onInsert);
3833
+ this.#insertionButton = {
3834
+ el: buttonEl,
3835
+ show: () => {
3836
+ buttonEl.hidden = false;
3837
+ },
3838
+ hide: () => {
3839
+ buttonEl.hidden = true;
3840
+ },
3841
+ };
3842
+ }
3843
+ else {
3844
+ this.#insertionButton = new InitialInsertionButton(this.insertionPoint, this.#engine, () => this.#engine.blockCatalogDialog.open());
3845
+ }
3846
+ const els = frameDoc.createDocumentFragment();
3888
3847
  els.append(this.blockMenu.el);
3889
3848
  els.append(this.#insertionButton.el);
3890
3849
  els.append(this.#containerElement);
3891
- this.#frameElement.contentWindow.document.body.append(els);
3850
+ frameDoc.body.append(els);
3892
3851
  window.addEventListener('resize', this.#setHeightTrigger.bind(this), true);
3893
3852
  // eslint-disable-next-line no-restricted-syntax
3894
3853
  window.addEventListener('DOMContentLoaded', this.#setHeightTrigger.bind(this), false);
@@ -3896,7 +3855,7 @@ class EditableArea extends EditorUI {
3896
3855
  this.#frameElement.contentWindow.addEventListener('resize', this.#setHeightTrigger.bind(this), true);
3897
3856
  // eslint-disable-next-line no-restricted-syntax
3898
3857
  this.#frameElement.contentWindow.addEventListener('DOMContentLoaded', this.#setHeightTrigger.bind(this), false);
3899
- this.#frameElement.contentWindow.document.addEventListener('load', this.#setHeightTrigger.bind(this), true);
3858
+ frameDoc.addEventListener('load', this.#setHeightTrigger.bind(this), true);
3900
3859
  this.#sourceTextarea.addEventListener('blur', this.#saveSource.bind(this), false);
3901
3860
  }
3902
3861
  async copyTo(editableArea) {
@@ -3987,12 +3946,42 @@ class EditableArea extends EditorUI {
3987
3946
  this.#sourceTextarea.hidden = !!visualMode;
3988
3947
  this.#sourceTextarea.disabled = !!visualMode;
3989
3948
  }
3990
- static async new(type, initialContent, engine, createBlockMenu, stylesheets, classList) {
3991
- const editableArea = new EditableArea(type, initialContent, engine, createBlockMenu, stylesheets, classList);
3949
+ static async new(type, initialContent, engine, createBlockMenu, createInitialInsertionButton, stylesheets, classList, createShell) {
3950
+ const editableArea = new EditableArea(type, initialContent, engine, createBlockMenu, createInitialInsertionButton, stylesheets, classList, createShell);
3992
3951
  await editableArea.#init();
3993
3952
  return editableArea;
3994
3953
  }
3995
3954
  }
3955
+ /**
3956
+ *
3957
+ * @param initialContent
3958
+ * @param classList
3959
+ */
3960
+ function createDefaultEditableAreaShell(initialContent, classList) {
3961
+ const viewNode = document.createElement('div');
3962
+ const sourceTextarea = document.createElement('textarea');
3963
+ sourceTextarea.spellcheck = false;
3964
+ viewNode.append(sourceTextarea);
3965
+ const frameElement = document.createElement('iframe');
3966
+ frameElement.setAttribute('width', '100%;');
3967
+ frameElement.setAttribute('scrolling', 'no');
3968
+ viewNode.append(frameElement);
3969
+ const containerElement = document.createElement('div');
3970
+ containerElement.id = CONTENT_ID;
3971
+ containerElement.style.setProperty('padding', `${CONTAINER_PADDING}px`, 'important');
3972
+ containerElement.style.setProperty('overflow', 'hidden', 'important');
3973
+ containerElement.style.setProperty('margin', '0', 'important');
3974
+ containerElement.style.setProperty('box-sizing', 'border-box', 'important');
3975
+ containerElement.classList.add(...classList);
3976
+ containerElement.innerHTML = initialContent;
3977
+ containerElement.dataset.bgeComponent = 'editable-area';
3978
+ return {
3979
+ viewNode,
3980
+ frameElement,
3981
+ sourceTextarea,
3982
+ containerElement,
3983
+ };
3984
+ }
3996
3985
 
3997
3986
  /**
3998
3987
  *
@@ -4219,7 +4208,7 @@ class ItemEditorDialog extends EditorDialog {
4219
4208
  return this.#componentObserver();
4220
4209
  }
4221
4210
  constructor(settings) {
4222
- super('item-editor', document.createElement('div'), settings, {
4211
+ super('item-editor', settings, {
4223
4212
  buttons: {
4224
4213
  close: 'キャンセル',
4225
4214
  complete: '決定',
@@ -4513,6 +4502,7 @@ class BurgerEditorEngine {
4513
4502
  }
4514
4503
  return;
4515
4504
  },
4505
+ createDialogShell: options.dialogShell,
4516
4506
  };
4517
4507
  this.blockCatalogDialog = new BlockCatalogDialog(options.catalog, {
4518
4508
  ...dialogSettings,
@@ -4776,13 +4766,13 @@ class BurgerEditorEngine {
4776
4766
  // @ts-ignore force assign to readonly property
4777
4767
  engine.#main =
4778
4768
  //
4779
- await EditableArea.new('main', mainInitialContent, engine, options.blockMenu, stylesheets, options.config.classList);
4769
+ await EditableArea.new('main', mainInitialContent, engine, options.blockMenu, options.initialInsertionButton, stylesheets, options.config.classList, options.editableAreaShell);
4780
4770
  const draftInitialContent = typeof options.initialContents === 'string' ? null : options.initialContents.draft;
4781
4771
  // @ts-ignore force assign to readonly property
4782
4772
  engine.#draft =
4783
4773
  draftInitialContent == null
4784
4774
  ? null
4785
- : await EditableArea.new('draft', draftInitialContent, engine, options.blockMenu, stylesheets, options.config.classList);
4775
+ : await EditableArea.new('draft', draftInitialContent, engine, options.blockMenu, options.initialInsertionButton, stylesheets, options.config.classList, options.editableAreaShell);
4786
4776
  engine.#current = engine.#main;
4787
4777
  engine.showMain();
4788
4778
  engine.save();
@@ -4799,6 +4789,50 @@ class BurgerEditorEngine {
4799
4789
  }
4800
4790
  }
4801
4791
 
4792
+ const getCSSPropertyAsNumberCache = new Map();
4793
+ /**
4794
+ *
4795
+ * @param el
4796
+ * @param property
4797
+ */
4798
+ function getCSSPropertyAsNumber(el, property) {
4799
+ const value = window.getComputedStyle(el).getPropertyValue(property);
4800
+ if (value === '') {
4801
+ return 0;
4802
+ }
4803
+ const cached = getCSSPropertyAsNumberCache.get(value);
4804
+ if (cached !== undefined) {
4805
+ return cached;
4806
+ }
4807
+ const i_or_nan = Number.parseInt(value, 10);
4808
+ const result = Number.isNaN(i_or_nan) ? 0 : i_or_nan;
4809
+ getCSSPropertyAsNumberCache.set(value, result);
4810
+ return result;
4811
+ }
4812
+
4813
+ /**
4814
+ *
4815
+ * @param doc
4816
+ * @param x
4817
+ * @param y
4818
+ */
4819
+ function getBlockAtPosition(doc, x, y) {
4820
+ const blocks = doc.body.querySelectorAll('[data-bge-container]');
4821
+ for (const $block of blocks) {
4822
+ const rect = $block.getBoundingClientRect();
4823
+ const marginBlockEnd = getCSSPropertyAsNumber($block, 'margin-block-end');
4824
+ const onMouse = rect.left <= x &&
4825
+ x <= rect.right &&
4826
+ rect.top <= y &&
4827
+ y <= rect.bottom + marginBlockEnd;
4828
+ if (onMouse) {
4829
+ const block = BurgerBlock.getBlock($block);
4830
+ return { block, rect, marginBlockEnd };
4831
+ }
4832
+ }
4833
+ return null;
4834
+ }
4835
+
4802
4836
  const IconAlignBoxCenterStretch = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-align-box-center-stretch\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M3 19v-14a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2\" />\n <path d=\"M11 17h2\" />\n <path d=\"M9 12h6\" />\n <path d=\"M10 7h4\" />\n</svg>";
4803
4837
 
4804
4838
  const IconAlignCenter = "<svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-align-center\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M4 6l16 0\" />\n <path d=\"M8 12l8 0\" />\n <path d=\"M6 18l12 0\" />\n</svg>";
@@ -19777,6 +19811,9 @@ function getAttributesFromExtensions(extensions) {
19777
19811
  keepOnSplit: true,
19778
19812
  isRequired: false
19779
19813
  };
19814
+ const nodeExtensionTypes = nodeExtensions.filter((ext) => ext.name !== "text").map((ext) => ext.name);
19815
+ const markExtensionTypes = markExtensions.map((ext) => ext.name);
19816
+ const allExtensionTypes = [...nodeExtensionTypes, ...markExtensionTypes];
19780
19817
  extensions.forEach((extension) => {
19781
19818
  const context = {
19782
19819
  name: extension.name,
@@ -19794,7 +19831,19 @@ function getAttributesFromExtensions(extensions) {
19794
19831
  }
19795
19832
  const globalAttributes = addGlobalAttributes();
19796
19833
  globalAttributes.forEach((globalAttribute) => {
19797
- globalAttribute.types.forEach((type) => {
19834
+ let resolvedTypes;
19835
+ if (Array.isArray(globalAttribute.types)) {
19836
+ resolvedTypes = globalAttribute.types;
19837
+ } else if (globalAttribute.types === "*") {
19838
+ resolvedTypes = allExtensionTypes;
19839
+ } else if (globalAttribute.types === "nodes") {
19840
+ resolvedTypes = nodeExtensionTypes;
19841
+ } else if (globalAttribute.types === "marks") {
19842
+ resolvedTypes = markExtensionTypes;
19843
+ } else {
19844
+ resolvedTypes = [];
19845
+ }
19846
+ resolvedTypes.forEach((type) => {
19798
19847
  Object.entries(globalAttribute.attributes).forEach(([name, attribute]) => {
19799
19848
  extensionAttributes.push({
19800
19849
  type,
@@ -20334,6 +20383,9 @@ function isMarkActive(state, typeOrName, attributes = {}) {
20334
20383
  const from = $from.pos;
20335
20384
  const to = $to.pos;
20336
20385
  state.doc.nodesBetween(from, to, (node, pos) => {
20386
+ if (type && node.inlineContent && !node.type.allowsMarkType(type)) {
20387
+ return false;
20388
+ }
20337
20389
  if (!node.isText && !node.marks.length) {
20338
20390
  return;
20339
20391
  }
@@ -21894,6 +21946,39 @@ var ExtensionManager = class {
21894
21946
  };
21895
21947
  }, baseDispatch);
21896
21948
  }
21949
+ /**
21950
+ * Get the composed transformPastedHTML function from all extensions.
21951
+ * @param baseTransform The base transform function (e.g. from the editor props)
21952
+ * @returns A composed transform function that chains all extension transforms
21953
+ */
21954
+ transformPastedHTML(baseTransform) {
21955
+ const { editor } = this;
21956
+ const extensions = sortExtensions([...this.extensions]);
21957
+ return extensions.reduce(
21958
+ (transform, extension) => {
21959
+ const context = {
21960
+ name: extension.name,
21961
+ options: extension.options,
21962
+ storage: this.editor.extensionStorage[extension.name],
21963
+ editor,
21964
+ type: getSchemaTypeByName(extension.name, this.schema)
21965
+ };
21966
+ const extensionTransform = getExtensionField(
21967
+ extension,
21968
+ "transformPastedHTML",
21969
+ context
21970
+ );
21971
+ if (!extensionTransform) {
21972
+ return transform;
21973
+ }
21974
+ return (html, view) => {
21975
+ const transformedHtml = transform(html, view);
21976
+ return extensionTransform.call(context, transformedHtml);
21977
+ };
21978
+ },
21979
+ baseTransform || ((html) => html)
21980
+ );
21981
+ }
21897
21982
  get markViews() {
21898
21983
  const { editor } = this;
21899
21984
  const { markExtensions } = splitExtensions(this.extensions);
@@ -22889,7 +22974,7 @@ var Editor = class extends EventEmitter {
22889
22974
  return this.options.editable && this.view && this.view.editable;
22890
22975
  }
22891
22976
  /**
22892
- * Returns the editor state.
22977
+ * Returns the editor view.
22893
22978
  */
22894
22979
  get view() {
22895
22980
  if (this.editorView) {
@@ -23057,6 +23142,8 @@ var Editor = class extends EventEmitter {
23057
23142
  const { editorProps, enableExtensionDispatchTransaction } = this.options;
23058
23143
  const baseDispatch = editorProps.dispatchTransaction || this.dispatchTransaction.bind(this);
23059
23144
  const dispatch = enableExtensionDispatchTransaction ? this.extensionManager.dispatchTransaction(baseDispatch) : baseDispatch;
23145
+ const baseTransformPastedHTML = editorProps.transformPastedHTML;
23146
+ const transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML);
23060
23147
  this.editorView = new EditorView(element, {
23061
23148
  ...editorProps,
23062
23149
  attributes: {
@@ -23065,6 +23152,7 @@ var Editor = class extends EventEmitter {
23065
23152
  ...editorProps == null ? void 0 : editorProps.attributes
23066
23153
  },
23067
23154
  dispatchTransaction: dispatch,
23155
+ transformPastedHTML,
23068
23156
  state: this.editorState,
23069
23157
  markViews: this.extensionManager.markViews,
23070
23158
  nodeViews: this.extensionManager.nodeViews
@@ -34703,18 +34791,6 @@ if (typeof window !== 'undefined') {
34703
34791
  ((window.__svelte ??= {}).v ??= new Set()).add(PUBLIC_VERSION);
34704
34792
  }
34705
34793
 
34706
- /** True if experimental.async=true */
34707
- /** True if we're not certain that we only have Svelte 5 code in the compilation */
34708
- let legacy_mode_flag = false;
34709
- /** True if $inspect.trace is used */
34710
- let tracing_mode_flag = false;
34711
-
34712
- function enable_legacy_mode_flag() {
34713
- legacy_mode_flag = true;
34714
- }
34715
-
34716
- enable_legacy_mode_flag();
34717
-
34718
34794
  const EACH_ITEM_REACTIVE = 1;
34719
34795
  const EACH_INDEX_REACTIVE = 1 << 1;
34720
34796
  /** See EachBlock interface metadata.is_controlled for an explanation what this is */
@@ -34735,6 +34811,7 @@ const UNINITIALIZED = Symbol();
34735
34811
 
34736
34812
  const NAMESPACE_HTML = 'http://www.w3.org/1999/xhtml';
34737
34813
  const NAMESPACE_SVG = 'http://www.w3.org/2000/svg';
34814
+ const NAMESPACE_MATHML = 'http://www.w3.org/1998/Math/MathML';
34738
34815
 
34739
34816
  const ATTACHMENT_KEY = '@attach';
34740
34817
 
@@ -34900,21 +34977,10 @@ const STALE_REACTION = new (class StaleReactionError extends Error {
34900
34977
  message = 'The reaction that called `getAbortSignal()` was re-run or destroyed';
34901
34978
  })();
34902
34979
 
34903
- const IS_XHTML = /* @__PURE__ */ globalThis.document?.contentType?.includes('xml') ?? false;
34904
-
34905
- /* This file is generated by scripts/process-messages/index.js. Do not edit! */
34906
-
34907
-
34908
- /**
34909
- * `%name%(...)` can only be used during component initialisation
34910
- * @param {string} name
34911
- * @returns {never}
34912
- */
34913
- function lifecycle_outside_component(name) {
34914
- {
34915
- throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
34916
- }
34917
- }
34980
+ const IS_XHTML =
34981
+ // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
34982
+ !!globalThis.document?.contentType &&
34983
+ /* @__PURE__ */ globalThis.document.contentType.includes('xml');
34918
34984
 
34919
34985
  /* This file is generated by scripts/process-messages/index.js. Do not edit! */
34920
34986
 
@@ -35079,6 +35145,16 @@ function safe_equals(value) {
35079
35145
  return !safe_not_equal(value, this.v);
35080
35146
  }
35081
35147
 
35148
+ /** True if experimental.async=true */
35149
+ /** True if we're not certain that we only have Svelte 5 code in the compilation */
35150
+ let legacy_mode_flag = false;
35151
+ /** True if $inspect.trace is used */
35152
+ let tracing_mode_flag = false;
35153
+
35154
+ function enable_legacy_mode_flag() {
35155
+ legacy_mode_flag = true;
35156
+ }
35157
+
35082
35158
  /** @import { ComponentContext, DevStackEntry, Effect } from '#client' */
35083
35159
 
35084
35160
  /** @type {ComponentContext | null} */
@@ -35295,7 +35371,6 @@ function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
35295
35371
 
35296
35372
  /** @import { Fork } from 'svelte' */
35297
35373
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
35298
- /** @import { Boundary } from '../dom/blocks/boundary' */
35299
35374
 
35300
35375
  /** @type {Set<Batch>} */
35301
35376
  const batches = new Set();
@@ -35325,12 +35400,17 @@ let queued_root_effects = [];
35325
35400
  /** @type {Effect | null} */
35326
35401
  let last_scheduled_effect = null;
35327
35402
 
35328
- let is_flushing = false;
35329
35403
  let is_flushing_sync = false;
35330
35404
 
35331
- class Batch {
35332
- committed = false;
35405
+ /**
35406
+ * During traversal, this is an array. Newly created effects are (if not immediately
35407
+ * executed) pushed to this array, rather than going through the scheduling
35408
+ * rigamarole that would cause another turn of the flush loop.
35409
+ * @type {Effect[] | null}
35410
+ */
35411
+ let collected_effects = null;
35333
35412
 
35413
+ class Batch {
35334
35414
  /**
35335
35415
  * The current values of any sources that are updated in this batch
35336
35416
  * They keys of this map are identical to `this.#previous`
@@ -35348,7 +35428,7 @@ class Batch {
35348
35428
  /**
35349
35429
  * When the batch is committed (and the DOM is updated), we need to remove old branches
35350
35430
  * and append new ones by calling the functions added inside (if/each/key/etc) blocks
35351
- * @type {Set<() => void>}
35431
+ * @type {Set<(batch: Batch) => void>}
35352
35432
  */
35353
35433
  #commit_callbacks = new Set();
35354
35434
 
@@ -35400,7 +35480,7 @@ class Batch {
35400
35480
 
35401
35481
  #decrement_queued = false;
35402
35482
 
35403
- is_deferred() {
35483
+ #is_deferred() {
35404
35484
  return this.is_fork || this.#blocking_pending > 0;
35405
35485
  }
35406
35486
 
@@ -35446,7 +35526,7 @@ class Batch {
35446
35526
  this.apply();
35447
35527
 
35448
35528
  /** @type {Effect[]} */
35449
- var effects = [];
35529
+ var effects = (collected_effects = []);
35450
35530
 
35451
35531
  /** @type {Effect[]} */
35452
35532
  var render_effects = [];
@@ -35460,7 +35540,9 @@ class Batch {
35460
35540
  // log_inconsistent_branches(root);
35461
35541
  }
35462
35542
 
35463
- if (this.is_deferred()) {
35543
+ collected_effects = null;
35544
+
35545
+ if (this.#is_deferred()) {
35464
35546
  this.#defer_effects(render_effects);
35465
35547
  this.#defer_effects(effects);
35466
35548
 
@@ -35468,22 +35550,26 @@ class Batch {
35468
35550
  reset_branch(e, t);
35469
35551
  }
35470
35552
  } else {
35553
+ // If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
35554
+ // newly updated sources, which could lead to infinite loops when effects run over and over again.
35555
+ previous_batch = this;
35556
+ current_batch = null;
35557
+
35471
35558
  // append/remove branches
35472
- for (const fn of this.#commit_callbacks) fn();
35559
+ for (const fn of this.#commit_callbacks) fn(this);
35473
35560
  this.#commit_callbacks.clear();
35474
35561
 
35475
35562
  if (this.#pending === 0) {
35476
35563
  this.#commit();
35477
35564
  }
35478
35565
 
35479
- // If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
35480
- // newly updated sources, which could lead to infinite loops when effects run over and over again.
35481
- previous_batch = this;
35482
- current_batch = null;
35483
-
35484
35566
  flush_queued_effects(render_effects);
35485
35567
  flush_queued_effects(effects);
35486
35568
 
35569
+ // Clear effects. Those that are still needed will be rescheduled through unskipping the skipped branches.
35570
+ this.#dirty_effects.clear();
35571
+ this.#maybe_dirty_effects.clear();
35572
+
35487
35573
  previous_batch = null;
35488
35574
 
35489
35575
  this.#deferred?.resolve();
@@ -35504,9 +35590,6 @@ class Batch {
35504
35590
 
35505
35591
  var effect = root.first;
35506
35592
 
35507
- /** @type {Effect | null} */
35508
- var pending_boundary = null;
35509
-
35510
35593
  while (effect !== null) {
35511
35594
  var flags = effect.f;
35512
35595
  var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
@@ -35517,11 +35600,6 @@ class Batch {
35517
35600
  if (!skip && effect.fn !== null) {
35518
35601
  if (is_branch) {
35519
35602
  effect.f ^= CLEAN;
35520
- } else if (
35521
- pending_boundary !== null &&
35522
- (flags & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0
35523
- ) {
35524
- /** @type {Boundary} */ (pending_boundary.b).defer_effect(effect);
35525
35603
  } else if ((flags & EFFECT) !== 0) {
35526
35604
  effects.push(effect);
35527
35605
  } else if (is_dirty(effect)) {
@@ -35537,16 +35615,15 @@ class Batch {
35537
35615
  }
35538
35616
  }
35539
35617
 
35540
- var parent = effect.parent;
35541
- effect = effect.next;
35618
+ while (effect !== null) {
35619
+ var next = effect.next;
35542
35620
 
35543
- while (effect === null && parent !== null) {
35544
- if (parent === pending_boundary) {
35545
- pending_boundary = null;
35621
+ if (next !== null) {
35622
+ effect = next;
35623
+ break;
35546
35624
  }
35547
35625
 
35548
- effect = parent.next;
35549
- parent = parent.parent;
35626
+ effect = effect.parent;
35550
35627
  }
35551
35628
  }
35552
35629
  }
@@ -35593,17 +35670,16 @@ class Batch {
35593
35670
  }
35594
35671
 
35595
35672
  flush() {
35596
- this.activate();
35597
-
35598
35673
  if (queued_root_effects.length > 0) {
35674
+ current_batch = this;
35599
35675
  flush_effects();
35676
+ } else if (this.#pending === 0 && !this.is_fork) {
35677
+ // append/remove branches
35678
+ for (const fn of this.#commit_callbacks) fn(this);
35679
+ this.#commit_callbacks.clear();
35600
35680
 
35601
- if (current_batch !== null && current_batch !== this) {
35602
- // this can happen if a new batch was created during `flush_effects()`
35603
- return;
35604
- }
35605
- } else if (this.#pending === 0) {
35606
- this.process([]); // TODO this feels awkward
35681
+ this.#commit();
35682
+ this.#deferred?.resolve();
35607
35683
  }
35608
35684
 
35609
35685
  this.deactivate();
@@ -35622,6 +35698,7 @@ class Batch {
35622
35698
  if (batches.size > 1) {
35623
35699
  this.previous.clear();
35624
35700
 
35701
+ var previous_batch = current_batch;
35625
35702
  var previous_batch_values = batch_values;
35626
35703
  var is_earlier = true;
35627
35704
 
@@ -35685,11 +35762,11 @@ class Batch {
35685
35762
  }
35686
35763
  }
35687
35764
 
35688
- current_batch = null;
35765
+ current_batch = previous_batch;
35689
35766
  batch_values = previous_batch_values;
35690
35767
  }
35691
35768
 
35692
- this.committed = true;
35769
+ this.#skipped_branches.clear();
35693
35770
  batches.delete(this);
35694
35771
  }
35695
35772
 
@@ -35716,7 +35793,7 @@ class Batch {
35716
35793
  queue_micro_task(() => {
35717
35794
  this.#decrement_queued = false;
35718
35795
 
35719
- if (!this.is_deferred()) {
35796
+ if (!this.#is_deferred()) {
35720
35797
  // we only reschedule previously-deferred effects if we expect
35721
35798
  // to be able to run them after processing the batch
35722
35799
  this.revive();
@@ -35743,7 +35820,7 @@ class Batch {
35743
35820
  this.flush();
35744
35821
  }
35745
35822
 
35746
- /** @param {() => void} fn */
35823
+ /** @param {(batch: Batch) => void} fn */
35747
35824
  oncommit(fn) {
35748
35825
  this.#commit_callbacks.add(fn);
35749
35826
  }
@@ -35822,8 +35899,6 @@ function flushSync(fn) {
35822
35899
  }
35823
35900
 
35824
35901
  function flush_effects() {
35825
- is_flushing = true;
35826
-
35827
35902
  var source_stacks = null;
35828
35903
 
35829
35904
  try {
@@ -35846,8 +35921,8 @@ function flush_effects() {
35846
35921
  } finally {
35847
35922
  queued_root_effects = [];
35848
35923
 
35849
- is_flushing = false;
35850
35924
  last_scheduled_effect = null;
35925
+ collected_effects = null;
35851
35926
  }
35852
35927
  }
35853
35928
 
@@ -36001,6 +36076,19 @@ function depends_on(reaction, sources, checked) {
36001
36076
  function schedule_effect(signal) {
36002
36077
  var effect = (last_scheduled_effect = signal);
36003
36078
 
36079
+ var boundary = effect.b;
36080
+
36081
+ // defer render effects inside a pending boundary
36082
+ // TODO the `REACTION_RAN` check is only necessary because of legacy `$:` effects AFAICT — we can remove later
36083
+ if (
36084
+ boundary?.is_pending &&
36085
+ (signal.f & (EFFECT | RENDER_EFFECT | MANAGED_EFFECT)) !== 0 &&
36086
+ (signal.f & REACTION_RAN) === 0
36087
+ ) {
36088
+ boundary.defer_effect(signal);
36089
+ return;
36090
+ }
36091
+
36004
36092
  while (effect.parent !== null) {
36005
36093
  effect = effect.parent;
36006
36094
  var flags = effect.f;
@@ -36008,17 +36096,21 @@ function schedule_effect(signal) {
36008
36096
  // if the effect is being scheduled because a parent (each/await/etc) block
36009
36097
  // updated an internal source, or because a branch is being unskipped,
36010
36098
  // bail out or we'll cause a second flush
36011
- if (
36012
- is_flushing &&
36013
- effect === active_effect &&
36014
- (flags & BLOCK_EFFECT) !== 0 &&
36015
- (flags & HEAD_EFFECT) === 0
36016
- ) {
36017
- return;
36099
+ if (collected_effects !== null && effect === active_effect) {
36100
+ // in sync mode, render effects run during traversal. in an extreme edge case
36101
+ // they can be made dirty after they have already been visited, in which
36102
+ // case we shouldn't bail out
36103
+ if ((signal.f & RENDER_EFFECT) === 0) {
36104
+ return;
36105
+ }
36018
36106
  }
36019
36107
 
36020
36108
  if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
36021
- if ((flags & CLEAN) === 0) return;
36109
+ if ((flags & CLEAN) === 0) {
36110
+ // branch is already dirty, bail
36111
+ return;
36112
+ }
36113
+
36022
36114
  effect.f ^= CLEAN;
36023
36115
  }
36024
36116
  }
@@ -36149,16 +36241,17 @@ function createSubscriber(start) {
36149
36241
  * }} BoundaryProps
36150
36242
  */
36151
36243
 
36152
- var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED | BOUNDARY_EFFECT;
36244
+ var flags = EFFECT_TRANSPARENT | EFFECT_PRESERVED;
36153
36245
 
36154
36246
  /**
36155
36247
  * @param {TemplateNode} node
36156
36248
  * @param {BoundaryProps} props
36157
36249
  * @param {((anchor: Node) => void)} children
36250
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
36158
36251
  * @returns {void}
36159
36252
  */
36160
- function boundary(node, props, children) {
36161
- new Boundary(node, props, children);
36253
+ function boundary(node, props, children, transform_error) {
36254
+ new Boundary(node, props, children, transform_error);
36162
36255
  }
36163
36256
 
36164
36257
  class Boundary {
@@ -36167,6 +36260,13 @@ class Boundary {
36167
36260
 
36168
36261
  is_pending = false;
36169
36262
 
36263
+ /**
36264
+ * API-level transformError transform function. Transforms errors before they reach the `failed` snippet.
36265
+ * Inherited from parent boundary, or defaults to identity.
36266
+ * @type {(error: unknown) => unknown}
36267
+ */
36268
+ transform_error;
36269
+
36170
36270
  /** @type {TemplateNode} */
36171
36271
  #anchor;
36172
36272
 
@@ -36194,15 +36294,10 @@ class Boundary {
36194
36294
  /** @type {DocumentFragment | null} */
36195
36295
  #offscreen_fragment = null;
36196
36296
 
36197
- /** @type {TemplateNode | null} */
36198
- #pending_anchor = null;
36199
-
36200
36297
  #local_pending_count = 0;
36201
36298
  #pending_count = 0;
36202
36299
  #pending_count_update_queued = false;
36203
36300
 
36204
- #is_creating_fallback = false;
36205
-
36206
36301
  /** @type {Set<Effect>} */
36207
36302
  #dirty_effects = new Set();
36208
36303
 
@@ -36230,38 +36325,30 @@ class Boundary {
36230
36325
  * @param {TemplateNode} node
36231
36326
  * @param {BoundaryProps} props
36232
36327
  * @param {((anchor: Node) => void)} children
36328
+ * @param {((error: unknown) => unknown) | undefined} [transform_error]
36233
36329
  */
36234
- constructor(node, props, children) {
36330
+ constructor(node, props, children, transform_error) {
36235
36331
  this.#anchor = node;
36236
36332
  this.#props = props;
36237
- this.#children = children;
36238
36333
 
36239
- this.parent = /** @type {Effect} */ (active_effect).b;
36334
+ this.#children = (anchor) => {
36335
+ var effect = /** @type {Effect} */ (active_effect);
36240
36336
 
36241
- this.is_pending = !!this.#props.pending;
36337
+ effect.b = this;
36338
+ effect.f |= BOUNDARY_EFFECT;
36242
36339
 
36243
- this.#effect = block(() => {
36244
- /** @type {Effect} */ (active_effect).b = this;
36340
+ children(anchor);
36341
+ };
36245
36342
 
36246
- {
36247
- var anchor = this.#get_anchor();
36343
+ this.parent = /** @type {Effect} */ (active_effect).b;
36248
36344
 
36249
- try {
36250
- this.#main_effect = branch(() => children(anchor));
36251
- } catch (error) {
36252
- this.error(error);
36253
- }
36345
+ // Inherit transform_error from parent boundary, or use the provided one, or default to identity
36346
+ this.transform_error = transform_error ?? this.parent?.transform_error ?? ((e) => e);
36254
36347
 
36255
- if (this.#pending_count > 0) {
36256
- this.#show_pending_snippet();
36257
- } else {
36258
- this.is_pending = false;
36259
- }
36348
+ this.#effect = block(() => {
36349
+ {
36350
+ this.#render();
36260
36351
  }
36261
-
36262
- return () => {
36263
- this.#pending_anchor?.remove();
36264
- };
36265
36352
  }, flags);
36266
36353
  }
36267
36354
 
@@ -36273,43 +36360,95 @@ class Boundary {
36273
36360
  }
36274
36361
  }
36275
36362
 
36363
+ /**
36364
+ * @param {unknown} error The deserialized error from the server's hydration comment
36365
+ */
36366
+ #hydrate_failed_content(error) {
36367
+ const failed = this.#props.failed;
36368
+ if (!failed) return;
36369
+
36370
+ this.#failed_effect = branch(() => {
36371
+ failed(
36372
+ this.#anchor,
36373
+ () => error,
36374
+ () => () => {}
36375
+ );
36376
+ });
36377
+ }
36378
+
36276
36379
  #hydrate_pending_content() {
36277
36380
  const pending = this.#props.pending;
36278
36381
  if (!pending) return;
36279
36382
 
36383
+ this.is_pending = true;
36280
36384
  this.#pending_effect = branch(() => pending(this.#anchor));
36281
36385
 
36282
36386
  queue_micro_task(() => {
36283
- var anchor = this.#get_anchor();
36387
+ var fragment = (this.#offscreen_fragment = document.createDocumentFragment());
36388
+ var anchor = create_text();
36389
+
36390
+ fragment.append(anchor);
36284
36391
 
36285
36392
  this.#main_effect = this.#run(() => {
36286
36393
  Batch.ensure();
36287
36394
  return branch(() => this.#children(anchor));
36288
36395
  });
36289
36396
 
36290
- if (this.#pending_count > 0) {
36291
- this.#show_pending_snippet();
36292
- } else {
36397
+ if (this.#pending_count === 0) {
36398
+ this.#anchor.before(fragment);
36399
+ this.#offscreen_fragment = null;
36400
+
36293
36401
  pause_effect(/** @type {Effect} */ (this.#pending_effect), () => {
36294
36402
  this.#pending_effect = null;
36295
36403
  });
36296
36404
 
36297
- this.is_pending = false;
36405
+ this.#resolve();
36298
36406
  }
36299
36407
  });
36300
36408
  }
36301
36409
 
36302
- #get_anchor() {
36303
- var anchor = this.#anchor;
36410
+ #render() {
36411
+ try {
36412
+ this.is_pending = this.has_pending_snippet();
36413
+ this.#pending_count = 0;
36414
+ this.#local_pending_count = 0;
36415
+
36416
+ this.#main_effect = branch(() => {
36417
+ this.#children(this.#anchor);
36418
+ });
36304
36419
 
36305
- if (this.is_pending) {
36306
- this.#pending_anchor = create_text();
36307
- this.#anchor.before(this.#pending_anchor);
36420
+ if (this.#pending_count > 0) {
36421
+ var fragment = (this.#offscreen_fragment = document.createDocumentFragment());
36422
+ move_effect(this.#main_effect, fragment);
36308
36423
 
36309
- anchor = this.#pending_anchor;
36424
+ const pending = /** @type {(anchor: Node) => void} */ (this.#props.pending);
36425
+ this.#pending_effect = branch(() => pending(this.#anchor));
36426
+ } else {
36427
+ this.#resolve();
36428
+ }
36429
+ } catch (error) {
36430
+ this.error(error);
36431
+ }
36432
+ }
36433
+
36434
+ #resolve() {
36435
+ this.is_pending = false;
36436
+
36437
+ // any effects that were previously deferred should be rescheduled —
36438
+ // after the next traversal (which will happen immediately, due to the
36439
+ // same update that brought us here) the effects will be flushed
36440
+ for (const e of this.#dirty_effects) {
36441
+ set_signal_status(e, DIRTY);
36442
+ schedule_effect(e);
36443
+ }
36444
+
36445
+ for (const e of this.#maybe_dirty_effects) {
36446
+ set_signal_status(e, MAYBE_DIRTY);
36447
+ schedule_effect(e);
36310
36448
  }
36311
36449
 
36312
- return anchor;
36450
+ this.#dirty_effects.clear();
36451
+ this.#maybe_dirty_effects.clear();
36313
36452
  }
36314
36453
 
36315
36454
  /**
@@ -36333,7 +36472,8 @@ class Boundary {
36333
36472
  }
36334
36473
 
36335
36474
  /**
36336
- * @param {() => Effect | null} fn
36475
+ * @template T
36476
+ * @param {() => T} fn
36337
36477
  */
36338
36478
  #run(fn) {
36339
36479
  var previous_effect = active_effect;
@@ -36356,20 +36496,6 @@ class Boundary {
36356
36496
  }
36357
36497
  }
36358
36498
 
36359
- #show_pending_snippet() {
36360
- const pending = /** @type {(anchor: Node) => void} */ (this.#props.pending);
36361
-
36362
- if (this.#main_effect !== null) {
36363
- this.#offscreen_fragment = document.createDocumentFragment();
36364
- this.#offscreen_fragment.append(/** @type {TemplateNode} */ (this.#pending_anchor));
36365
- move_effect(this.#main_effect, this.#offscreen_fragment);
36366
- }
36367
-
36368
- if (this.#pending_effect === null) {
36369
- this.#pending_effect = branch(() => pending(this.#anchor));
36370
- }
36371
- }
36372
-
36373
36499
  /**
36374
36500
  * Updates the pending count associated with the currently visible pending snippet,
36375
36501
  * if any, such that we can replace the snippet with content once work is done
@@ -36388,24 +36514,7 @@ class Boundary {
36388
36514
  this.#pending_count += d;
36389
36515
 
36390
36516
  if (this.#pending_count === 0) {
36391
- this.is_pending = false;
36392
-
36393
- // any effects that were encountered and deferred during traversal
36394
- // should be rescheduled — after the next traversal (which will happen
36395
- // immediately, due to the same update that brought us here)
36396
- // the effects will be flushed
36397
- for (const e of this.#dirty_effects) {
36398
- set_signal_status(e, DIRTY);
36399
- schedule_effect(e);
36400
- }
36401
-
36402
- for (const e of this.#maybe_dirty_effects) {
36403
- set_signal_status(e, MAYBE_DIRTY);
36404
- schedule_effect(e);
36405
- }
36406
-
36407
- this.#dirty_effects.clear();
36408
- this.#maybe_dirty_effects.clear();
36517
+ this.#resolve();
36409
36518
 
36410
36519
  if (this.#pending_effect) {
36411
36520
  pause_effect(this.#pending_effect, () => {
@@ -36454,7 +36563,7 @@ class Boundary {
36454
36563
 
36455
36564
  // If we have nothing to capture the error, or if we hit an error while
36456
36565
  // rendering the fallback, re-throw for another boundary to handle
36457
- if (this.#is_creating_fallback || (!onerror && !failed)) {
36566
+ if (!onerror && !failed) {
36458
36567
  throw error;
36459
36568
  }
36460
36569
 
@@ -36488,37 +36597,25 @@ class Boundary {
36488
36597
  svelte_boundary_reset_onerror();
36489
36598
  }
36490
36599
 
36491
- // If the failure happened while flushing effects, current_batch can be null
36492
- Batch.ensure();
36493
-
36494
- this.#local_pending_count = 0;
36495
-
36496
36600
  if (this.#failed_effect !== null) {
36497
36601
  pause_effect(this.#failed_effect, () => {
36498
36602
  this.#failed_effect = null;
36499
36603
  });
36500
36604
  }
36501
36605
 
36502
- // we intentionally do not try to find the nearest pending boundary. If this boundary has one, we'll render it on reset
36503
- // but it would be really weird to show the parent's boundary on a child reset.
36504
- this.is_pending = this.has_pending_snippet();
36606
+ this.#run(() => {
36607
+ // If the failure happened while flushing effects, current_batch can be null
36608
+ Batch.ensure();
36505
36609
 
36506
- this.#main_effect = this.#run(() => {
36507
- this.#is_creating_fallback = false;
36508
- return branch(() => this.#children(this.#anchor));
36610
+ this.#render();
36509
36611
  });
36510
-
36511
- if (this.#pending_count > 0) {
36512
- this.#show_pending_snippet();
36513
- } else {
36514
- this.is_pending = false;
36515
- }
36516
36612
  };
36517
36613
 
36518
- queue_micro_task(() => {
36614
+ /** @param {unknown} transformed_error */
36615
+ const handle_error_result = (transformed_error) => {
36519
36616
  try {
36520
36617
  calling_on_error = true;
36521
- onerror?.(error, reset);
36618
+ onerror?.(transformed_error, reset);
36522
36619
  calling_on_error = false;
36523
36620
  } catch (error) {
36524
36621
  invoke_error_boundary(error, this.#effect && this.#effect.parent);
@@ -36527,24 +36624,56 @@ class Boundary {
36527
36624
  if (failed) {
36528
36625
  this.#failed_effect = this.#run(() => {
36529
36626
  Batch.ensure();
36530
- this.#is_creating_fallback = true;
36531
36627
 
36532
36628
  try {
36533
36629
  return branch(() => {
36630
+ // errors in `failed` snippets cause the boundary to error again
36631
+ // TODO Svelte 6: revisit this decision, most likely better to go to parent boundary instead
36632
+ var effect = /** @type {Effect} */ (active_effect);
36633
+
36634
+ effect.b = this;
36635
+ effect.f |= BOUNDARY_EFFECT;
36636
+
36534
36637
  failed(
36535
36638
  this.#anchor,
36536
- () => error,
36639
+ () => transformed_error,
36537
36640
  () => reset
36538
36641
  );
36539
36642
  });
36540
36643
  } catch (error) {
36541
36644
  invoke_error_boundary(error, /** @type {Effect} */ (this.#effect.parent));
36542
36645
  return null;
36543
- } finally {
36544
- this.#is_creating_fallback = false;
36545
36646
  }
36546
36647
  });
36547
36648
  }
36649
+ };
36650
+
36651
+ queue_micro_task(() => {
36652
+ // Run the error through the API-level transformError transform (e.g. SvelteKit's handleError)
36653
+ /** @type {unknown} */
36654
+ var result;
36655
+ try {
36656
+ result = this.transform_error(error);
36657
+ } catch (e) {
36658
+ invoke_error_boundary(e, this.#effect && this.#effect.parent);
36659
+ return;
36660
+ }
36661
+
36662
+ if (
36663
+ result !== null &&
36664
+ typeof result === 'object' &&
36665
+ typeof (/** @type {any} */ (result).then) === 'function'
36666
+ ) {
36667
+ // transformError returned a Promise — wait for it
36668
+ /** @type {any} */ (result).then(
36669
+ handle_error_result,
36670
+ /** @param {unknown} e */
36671
+ (e) => invoke_error_boundary(e, this.#effect && this.#effect.parent)
36672
+ );
36673
+ } else {
36674
+ // Synchronous result — handle immediately
36675
+ handle_error_result(result);
36676
+ }
36548
36677
  });
36549
36678
  }
36550
36679
  }
@@ -36567,8 +36696,6 @@ function flatten(blockers, sync, async, fn) {
36567
36696
  fn(sync.map(d));
36568
36697
  return;
36569
36698
  }
36570
-
36571
- var batch = current_batch;
36572
36699
  var parent = /** @type {Effect} */ (active_effect);
36573
36700
 
36574
36701
  var restore = capture();
@@ -36591,7 +36718,6 @@ function flatten(blockers, sync, async, fn) {
36591
36718
  }
36592
36719
  }
36593
36720
 
36594
- batch?.deactivate();
36595
36721
  unset_context();
36596
36722
  }
36597
36723
 
@@ -36635,10 +36761,25 @@ function capture() {
36635
36761
  };
36636
36762
  }
36637
36763
 
36638
- function unset_context() {
36764
+ function unset_context(deactivate_batch = true) {
36639
36765
  set_active_effect(null);
36640
36766
  set_active_reaction(null);
36641
36767
  set_component_context(null);
36768
+ if (deactivate_batch) current_batch?.deactivate();
36769
+ }
36770
+
36771
+ function increment_pending() {
36772
+ var boundary = /** @type {Boundary} */ (/** @type {Effect} */ (active_effect).b);
36773
+ var batch = /** @type {Batch} */ (current_batch);
36774
+ var blocking = boundary.is_rendered();
36775
+
36776
+ boundary.update_pending_count(1);
36777
+ batch.increment(blocking);
36778
+
36779
+ return () => {
36780
+ boundary.update_pending_count(-1);
36781
+ batch.decrement(blocking);
36782
+ };
36642
36783
  }
36643
36784
 
36644
36785
  /** @import { Derived, Effect, Source } from '#client' */
@@ -36697,8 +36838,6 @@ function async_derived(fn, label, location) {
36697
36838
  async_derived_orphan();
36698
36839
  }
36699
36840
 
36700
- var boundary = /** @type {Boundary} */ (parent.b);
36701
-
36702
36841
  var promise = /** @type {Promise<V>} */ (/** @type {unknown} */ (undefined));
36703
36842
  var signal = source(/** @type {V} */ (UNINITIALIZED));
36704
36843
 
@@ -36718,17 +36857,7 @@ function async_derived(fn, label, location) {
36718
36857
  // If this code is changed at some point, make sure to still access the then property
36719
36858
  // of fn() to read any signals it might access, so that we track them as dependencies.
36720
36859
  // We call `unset_context` to undo any `save` calls that happen inside `fn()`
36721
- Promise.resolve(fn())
36722
- .then(d.resolve, d.reject)
36723
- .then(() => {
36724
- if (batch === current_batch && batch.committed) {
36725
- // if the batch was rejected as stale, we need to cleanup
36726
- // after any `$.save(...)` calls inside `fn()`
36727
- batch.deactivate();
36728
- }
36729
-
36730
- unset_context();
36731
- });
36860
+ Promise.resolve(fn()).then(d.resolve, d.reject).finally(unset_context);
36732
36861
  } catch (error) {
36733
36862
  d.reject(error);
36734
36863
  unset_context();
@@ -36737,10 +36866,7 @@ function async_derived(fn, label, location) {
36737
36866
  var batch = /** @type {Batch} */ (current_batch);
36738
36867
 
36739
36868
  if (should_suspend) {
36740
- var blocking = boundary.is_rendered();
36741
-
36742
- boundary.update_pending_count(1);
36743
- batch.increment(blocking);
36869
+ var decrement_pending = increment_pending();
36744
36870
 
36745
36871
  deferreds.get(batch)?.reject(STALE_REACTION);
36746
36872
  deferreds.delete(batch); // delete to ensure correct order in Map iteration below
@@ -36777,9 +36903,8 @@ function async_derived(fn, label, location) {
36777
36903
  }
36778
36904
  }
36779
36905
 
36780
- if (should_suspend) {
36781
- boundary.update_pending_count(-1);
36782
- batch.decrement(blocking);
36906
+ if (decrement_pending) {
36907
+ decrement_pending();
36783
36908
  }
36784
36909
  };
36785
36910
 
@@ -37046,19 +37171,6 @@ function mutable_source(initial_value, immutable = false, trackable = true) {
37046
37171
  return s;
37047
37172
  }
37048
37173
 
37049
- /**
37050
- * @template V
37051
- * @param {Value<V>} source
37052
- * @param {V} value
37053
- */
37054
- function mutate(source, value) {
37055
- set(
37056
- source,
37057
- untrack(() => get(source))
37058
- );
37059
- return value;
37060
- }
37061
-
37062
37174
  /**
37063
37175
  * @template V
37064
37176
  * @param {Source<V>} source
@@ -37827,10 +37939,9 @@ function push_effect(effect, parent_effect) {
37827
37939
  /**
37828
37940
  * @param {number} type
37829
37941
  * @param {null | (() => void | (() => void))} fn
37830
- * @param {boolean} sync
37831
37942
  * @returns {Effect}
37832
37943
  */
37833
- function create_effect(type, fn, sync) {
37944
+ function create_effect(type, fn) {
37834
37945
  var parent = active_effect;
37835
37946
 
37836
37947
  if (parent !== null && (parent.f & INERT) !== 0) {
@@ -37855,34 +37966,39 @@ function create_effect(type, fn, sync) {
37855
37966
  ac: null
37856
37967
  };
37857
37968
 
37858
- if (sync) {
37969
+ /** @type {Effect | null} */
37970
+ var e = effect;
37971
+
37972
+ if ((type & EFFECT) !== 0) {
37973
+ if (collected_effects !== null) {
37974
+ // created during traversal — collect and run afterwards
37975
+ collected_effects.push(effect);
37976
+ } else {
37977
+ // schedule for later
37978
+ schedule_effect(effect);
37979
+ }
37980
+ } else if (fn !== null) {
37859
37981
  try {
37860
37982
  update_effect(effect);
37861
37983
  } catch (e) {
37862
37984
  destroy_effect(effect);
37863
37985
  throw e;
37864
37986
  }
37865
- } else if (fn !== null) {
37866
- schedule_effect(effect);
37867
- }
37868
37987
 
37869
- /** @type {Effect | null} */
37870
- var e = effect;
37871
-
37872
- // if an effect has already ran and doesn't need to be kept in the tree
37873
- // (because it won't re-run, has no DOM, and has no teardown etc)
37874
- // then we skip it and go to its child (if any)
37875
- if (
37876
- sync &&
37877
- e.deps === null &&
37878
- e.teardown === null &&
37879
- e.nodes === null &&
37880
- e.first === e.last && // either `null`, or a singular child
37881
- (e.f & EFFECT_PRESERVED) === 0
37882
- ) {
37883
- e = e.first;
37884
- if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
37885
- e.f |= EFFECT_TRANSPARENT;
37988
+ // if an effect doesn't need to be kept in the tree (because it
37989
+ // won't re-run, has no DOM, and has no teardown etc)
37990
+ // then we skip it and go to its child (if any)
37991
+ if (
37992
+ e.deps === null &&
37993
+ e.teardown === null &&
37994
+ e.nodes === null &&
37995
+ e.first === e.last && // either `null`, or a singular child
37996
+ (e.f & EFFECT_PRESERVED) === 0
37997
+ ) {
37998
+ e = e.first;
37999
+ if ((type & BLOCK_EFFECT) !== 0 && (type & EFFECT_TRANSPARENT) !== 0 && e !== null) {
38000
+ e.f |= EFFECT_TRANSPARENT;
38001
+ }
37886
38002
  }
37887
38003
  }
37888
38004
 
@@ -37919,7 +38035,7 @@ function effect_tracking() {
37919
38035
  * @param {() => void} fn
37920
38036
  */
37921
38037
  function teardown(fn) {
37922
- const effect = create_effect(RENDER_EFFECT, null, false);
38038
+ const effect = create_effect(RENDER_EFFECT, null);
37923
38039
  set_signal_status(effect, CLEAN);
37924
38040
  effect.teardown = fn;
37925
38041
  return effect;
@@ -37951,7 +38067,7 @@ function user_effect(fn) {
37951
38067
  * @param {() => void | (() => void)} fn
37952
38068
  */
37953
38069
  function create_user_effect(fn) {
37954
- return create_effect(EFFECT | USER_EFFECT, fn, false);
38070
+ return create_effect(EFFECT | USER_EFFECT, fn);
37955
38071
  }
37956
38072
 
37957
38073
  /**
@@ -37961,7 +38077,7 @@ function create_user_effect(fn) {
37961
38077
  */
37962
38078
  function user_pre_effect(fn) {
37963
38079
  validate_effect();
37964
- return create_effect(RENDER_EFFECT | USER_EFFECT, fn, true);
38080
+ return create_effect(RENDER_EFFECT | USER_EFFECT, fn);
37965
38081
  }
37966
38082
 
37967
38083
  /**
@@ -37971,7 +38087,7 @@ function user_pre_effect(fn) {
37971
38087
  */
37972
38088
  function component_root(fn) {
37973
38089
  Batch.ensure();
37974
- const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn, true);
38090
+ const effect = create_effect(ROOT_EFFECT | EFFECT_PRESERVED, fn);
37975
38091
 
37976
38092
  return (options = {}) => {
37977
38093
  return new Promise((fulfil) => {
@@ -37993,57 +38109,7 @@ function component_root(fn) {
37993
38109
  * @returns {Effect}
37994
38110
  */
37995
38111
  function effect(fn) {
37996
- return create_effect(EFFECT, fn, false);
37997
- }
37998
-
37999
- /**
38000
- * Internal representation of `$: ..`
38001
- * @param {() => any} deps
38002
- * @param {() => void | (() => void)} fn
38003
- */
38004
- function legacy_pre_effect(deps, fn) {
38005
- var context = /** @type {ComponentContextLegacy} */ (component_context);
38006
-
38007
- /** @type {{ effect: null | Effect, ran: boolean, deps: () => any }} */
38008
- var token = { effect: null, ran: false, deps };
38009
-
38010
- context.l.$.push(token);
38011
-
38012
- token.effect = render_effect(() => {
38013
- deps();
38014
-
38015
- // If this legacy pre effect has already run before the end of the reset, then
38016
- // bail out to emulate the same behavior.
38017
- if (token.ran) return;
38018
-
38019
- token.ran = true;
38020
- untrack(fn);
38021
- });
38022
- }
38023
-
38024
- function legacy_pre_effect_reset() {
38025
- var context = /** @type {ComponentContextLegacy} */ (component_context);
38026
-
38027
- render_effect(() => {
38028
- // Run dirty `$:` statements
38029
- for (var token of context.l.$) {
38030
- token.deps();
38031
-
38032
- var effect = token.effect;
38033
-
38034
- // If the effect is CLEAN, then make it MAYBE_DIRTY. This ensures we traverse through
38035
- // the effects dependencies and correctly ensure each dependency is up-to-date.
38036
- if ((effect.f & CLEAN) !== 0 && effect.deps !== null) {
38037
- set_signal_status(effect, MAYBE_DIRTY);
38038
- }
38039
-
38040
- if (is_dirty(effect)) {
38041
- update_effect(effect);
38042
- }
38043
-
38044
- token.ran = false;
38045
- }
38046
- });
38112
+ return create_effect(EFFECT, fn);
38047
38113
  }
38048
38114
 
38049
38115
  /**
@@ -38051,7 +38117,7 @@ function legacy_pre_effect_reset() {
38051
38117
  * @returns {Effect}
38052
38118
  */
38053
38119
  function async_effect(fn) {
38054
- return create_effect(ASYNC | EFFECT_PRESERVED, fn, true);
38120
+ return create_effect(ASYNC | EFFECT_PRESERVED, fn);
38055
38121
  }
38056
38122
 
38057
38123
  /**
@@ -38059,7 +38125,7 @@ function async_effect(fn) {
38059
38125
  * @returns {Effect}
38060
38126
  */
38061
38127
  function render_effect(fn, flags = 0) {
38062
- return create_effect(RENDER_EFFECT | flags, fn, true);
38128
+ return create_effect(RENDER_EFFECT | flags, fn);
38063
38129
  }
38064
38130
 
38065
38131
  /**
@@ -38070,7 +38136,7 @@ function render_effect(fn, flags = 0) {
38070
38136
  */
38071
38137
  function template_effect(fn, sync = [], async = [], blockers = []) {
38072
38138
  flatten(blockers, sync, async, (values) => {
38073
- create_effect(RENDER_EFFECT, () => fn(...values.map(get)), true);
38139
+ create_effect(RENDER_EFFECT, () => fn(...values.map(get)));
38074
38140
  });
38075
38141
  }
38076
38142
 
@@ -38079,7 +38145,7 @@ function template_effect(fn, sync = [], async = [], blockers = []) {
38079
38145
  * @param {number} flags
38080
38146
  */
38081
38147
  function block(fn, flags = 0) {
38082
- var effect = create_effect(BLOCK_EFFECT | flags, fn, true);
38148
+ var effect = create_effect(BLOCK_EFFECT | flags, fn);
38083
38149
  return effect;
38084
38150
  }
38085
38151
 
@@ -38088,7 +38154,7 @@ function block(fn, flags = 0) {
38088
38154
  * @param {number} flags
38089
38155
  */
38090
38156
  function managed(fn, flags = 0) {
38091
- var effect = create_effect(MANAGED_EFFECT | flags, fn, true);
38157
+ var effect = create_effect(MANAGED_EFFECT | flags, fn);
38092
38158
  return effect;
38093
38159
  }
38094
38160
 
@@ -38096,7 +38162,7 @@ function managed(fn, flags = 0) {
38096
38162
  * @param {(() => void)} fn
38097
38163
  */
38098
38164
  function branch(fn) {
38099
- return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn, true);
38165
+ return create_effect(BRANCH_EFFECT | EFFECT_PRESERVED, fn);
38100
38166
  }
38101
38167
 
38102
38168
  /**
@@ -38388,51 +38454,6 @@ function move_effect(effect, fragment) {
38388
38454
  }
38389
38455
  }
38390
38456
 
38391
- /** @import { Value } from '#client' */
38392
-
38393
- /**
38394
- * @type {Set<Value> | null}
38395
- * @deprecated
38396
- */
38397
- let captured_signals = null;
38398
-
38399
- /**
38400
- * Capture an array of all the signals that are read when `fn` is called
38401
- * @template T
38402
- * @param {() => T} fn
38403
- */
38404
- function capture_signals(fn) {
38405
- var previous_captured_signals = captured_signals;
38406
-
38407
- try {
38408
- captured_signals = new Set();
38409
-
38410
- untrack(fn);
38411
-
38412
- if (previous_captured_signals !== null) {
38413
- for (var signal of captured_signals) {
38414
- previous_captured_signals.add(signal);
38415
- }
38416
- }
38417
-
38418
- return captured_signals;
38419
- } finally {
38420
- captured_signals = previous_captured_signals;
38421
- }
38422
- }
38423
-
38424
- /**
38425
- * Invokes a function and captures all signals that are read during the invocation,
38426
- * then invalidates them.
38427
- * @param {() => any} fn
38428
- * @deprecated
38429
- */
38430
- function invalidate_inner_signals(fn) {
38431
- for (var signal of capture_signals(fn)) {
38432
- internal_set(signal, signal.v);
38433
- }
38434
- }
38435
-
38436
38457
  /** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
38437
38458
 
38438
38459
  let is_updating_effect = false;
@@ -38860,8 +38881,6 @@ function get(signal) {
38860
38881
  var flags = signal.f;
38861
38882
  var is_derived = (flags & DERIVED) !== 0;
38862
38883
 
38863
- captured_signals?.add(signal);
38864
-
38865
38884
  // Register the dependency on the current reaction signal.
38866
38885
  if (active_reaction !== null && !untracking) {
38867
38886
  // if we're in a derived that is being read inside an _async_ derived,
@@ -39104,96 +39123,9 @@ function deep_read(value, visited = new Set()) {
39104
39123
  }
39105
39124
 
39106
39125
  /**
39107
- * @param {string} name
39108
- */
39109
- function is_capture_event(name) {
39110
- return name.endsWith('capture') && name !== 'gotpointercapture' && name !== 'lostpointercapture';
39111
- }
39112
-
39113
- /** List of Element events that will be delegated */
39114
- const DELEGATED_EVENTS = [
39115
- 'beforeinput',
39116
- 'click',
39117
- 'change',
39118
- 'dblclick',
39119
- 'contextmenu',
39120
- 'focusin',
39121
- 'focusout',
39122
- 'input',
39123
- 'keydown',
39124
- 'keyup',
39125
- 'mousedown',
39126
- 'mousemove',
39127
- 'mouseout',
39128
- 'mouseover',
39129
- 'mouseup',
39130
- 'pointerdown',
39131
- 'pointermove',
39132
- 'pointerout',
39133
- 'pointerover',
39134
- 'pointerup',
39135
- 'touchend',
39136
- 'touchmove',
39137
- 'touchstart'
39138
- ];
39139
-
39140
- /**
39141
- * Returns `true` if `event_name` is a delegated event
39142
- * @param {string} event_name
39126
+ * Used on elements, as a map of event type -> event handler,
39127
+ * and on events themselves to track which element handled an event
39143
39128
  */
39144
- function can_delegate_event(event_name) {
39145
- return DELEGATED_EVENTS.includes(event_name);
39146
- }
39147
-
39148
- /**
39149
- * @type {Record<string, string>}
39150
- * List of attribute names that should be aliased to their property names
39151
- * because they behave differently between setting them as an attribute and
39152
- * setting them as a property.
39153
- */
39154
- const ATTRIBUTE_ALIASES = {
39155
- // no `class: 'className'` because we handle that separately
39156
- formnovalidate: 'formNoValidate',
39157
- ismap: 'isMap',
39158
- nomodule: 'noModule',
39159
- playsinline: 'playsInline',
39160
- readonly: 'readOnly',
39161
- defaultvalue: 'defaultValue',
39162
- defaultchecked: 'defaultChecked',
39163
- srcobject: 'srcObject',
39164
- novalidate: 'noValidate',
39165
- allowfullscreen: 'allowFullscreen',
39166
- disablepictureinpicture: 'disablePictureInPicture',
39167
- disableremoteplayback: 'disableRemotePlayback'
39168
- };
39169
-
39170
- /**
39171
- * @param {string} name
39172
- */
39173
- function normalize_attribute(name) {
39174
- name = name.toLowerCase();
39175
- return ATTRIBUTE_ALIASES[name] ?? name;
39176
- }
39177
-
39178
- /**
39179
- * Subset of delegated events which should be passive by default.
39180
- * These two are already passive via browser defaults on window, document and body.
39181
- * But since
39182
- * - we're delegating them
39183
- * - they happen often
39184
- * - they apply to mobile which is generally less performant
39185
- * we're marking them as passive by default for other elements, too.
39186
- */
39187
- const PASSIVE_EVENTS = ['touchstart', 'touchmove'];
39188
-
39189
- /**
39190
- * Returns `true` if `name` is a passive event
39191
- * @param {string} name
39192
- */
39193
- function is_passive_event(name) {
39194
- return PASSIVE_EVENTS.includes(name);
39195
- }
39196
-
39197
39129
  const event_symbol = Symbol('events');
39198
39130
 
39199
39131
  /** @type {Set<string>} */
@@ -39317,8 +39249,8 @@ function handle_event_propagation(event) {
39317
39249
  last_propagated_event = event;
39318
39250
 
39319
39251
  // composedPath contains list of nodes the event has propagated through.
39320
- // We check __root to skip all nodes below it in case this is a
39321
- // parent of the __root node, which indicates that there's nested
39252
+ // We check `event_symbol` to skip all nodes below it in case this is a
39253
+ // parent of the `event_symbol` node, which indicates that there's nested
39322
39254
  // mounted apps. In this case we don't want to trigger events multiple times.
39323
39255
  var path_idx = 0;
39324
39256
 
@@ -39326,7 +39258,7 @@ function handle_event_propagation(event) {
39326
39258
  // without it the variable will be DCE'd and things will
39327
39259
  // fail mysteriously in Firefox
39328
39260
  // @ts-expect-error is added below
39329
- var handled_at = last_propagated_event === event && event.__root;
39261
+ var handled_at = last_propagated_event === event && event[event_symbol];
39330
39262
 
39331
39263
  if (handled_at) {
39332
39264
  var at_idx = path.indexOf(handled_at);
@@ -39338,7 +39270,7 @@ function handle_event_propagation(event) {
39338
39270
  // -> ignore, but set handle_at to document/window so that we're resetting the event
39339
39271
  // chain in case someone manually dispatches the same event object again.
39340
39272
  // @ts-expect-error
39341
- event.__root = handler_element;
39273
+ event[event_symbol] = handler_element;
39342
39274
  return;
39343
39275
  }
39344
39276
 
@@ -39438,7 +39370,7 @@ function handle_event_propagation(event) {
39438
39370
  }
39439
39371
  } finally {
39440
39372
  // @ts-expect-error is used above
39441
- event.__root = handler_element;
39373
+ event[event_symbol] = handler_element;
39442
39374
  // @ts-ignore remove proxy on currentTarget
39443
39375
  delete event.currentTarget;
39444
39376
  set_active_reaction(previous_reaction);
@@ -39446,18 +39378,15 @@ function handle_event_propagation(event) {
39446
39378
  }
39447
39379
  }
39448
39380
 
39449
- /** @import {} from 'trusted-types' */
39450
-
39451
-
39452
- const policy = /* @__PURE__ */ globalThis?.window?.trustedTypes?.createPolicy(
39453
- 'svelte-trusted-html',
39454
- {
39381
+ const policy =
39382
+ // We gotta write it like this because after downleveling the pure comment may end up in the wrong location
39383
+ globalThis?.window?.trustedTypes &&
39384
+ /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy('svelte-trusted-html', {
39455
39385
  /** @param {string} html */
39456
39386
  createHTML: (html) => {
39457
39387
  return html;
39458
39388
  }
39459
- }
39460
- );
39389
+ });
39461
39390
 
39462
39391
  /** @param {string} html */
39463
39392
  function create_trusted_html(html) {
@@ -39466,12 +39395,10 @@ function create_trusted_html(html) {
39466
39395
 
39467
39396
  /**
39468
39397
  * @param {string} html
39469
- * @param {boolean} trusted
39470
39398
  */
39471
- function create_fragment_from_html(html, trusted = false) {
39399
+ function create_fragment_from_html(html) {
39472
39400
  var elem = create_element('template');
39473
- html = html.replaceAll('<!>', '<!---->'); // XHTML compliance
39474
- elem.innerHTML = trusted ? create_trusted_html(html) : html;
39401
+ elem.innerHTML = create_trusted_html(html.replaceAll('<!>', '<!---->')); // XHTML compliance
39475
39402
  return elem.content;
39476
39403
  }
39477
39404
 
@@ -39511,7 +39438,7 @@ function from_html(content, flags) {
39511
39438
  return () => {
39512
39439
 
39513
39440
  if (node === undefined) {
39514
- node = create_fragment_from_html(has_start ? content : '<!>' + content, true);
39441
+ node = create_fragment_from_html(has_start ? content : '<!>' + content);
39515
39442
  if (!is_fragment) node = /** @type {TemplateNode} */ (get_first_child(node));
39516
39443
  }
39517
39444
 
@@ -39553,7 +39480,7 @@ function from_namespace(content, flags, ns = 'svg') {
39553
39480
  return () => {
39554
39481
 
39555
39482
  if (!node) {
39556
- var fragment = /** @type {DocumentFragment} */ (create_fragment_from_html(wrapped, true));
39483
+ var fragment = /** @type {DocumentFragment} */ (create_fragment_from_html(wrapped));
39557
39484
  var root = /** @type {Element} */ (get_first_child(fragment));
39558
39485
 
39559
39486
  {
@@ -39635,6 +39562,97 @@ function props_id() {
39635
39562
  return `c${window.__svelte.uid++}`;
39636
39563
  }
39637
39564
 
39565
+ /**
39566
+ * @param {string} name
39567
+ */
39568
+ function is_capture_event(name) {
39569
+ return name.endsWith('capture') && name !== 'gotpointercapture' && name !== 'lostpointercapture';
39570
+ }
39571
+
39572
+ /** List of Element events that will be delegated */
39573
+ const DELEGATED_EVENTS = [
39574
+ 'beforeinput',
39575
+ 'click',
39576
+ 'change',
39577
+ 'dblclick',
39578
+ 'contextmenu',
39579
+ 'focusin',
39580
+ 'focusout',
39581
+ 'input',
39582
+ 'keydown',
39583
+ 'keyup',
39584
+ 'mousedown',
39585
+ 'mousemove',
39586
+ 'mouseout',
39587
+ 'mouseover',
39588
+ 'mouseup',
39589
+ 'pointerdown',
39590
+ 'pointermove',
39591
+ 'pointerout',
39592
+ 'pointerover',
39593
+ 'pointerup',
39594
+ 'touchend',
39595
+ 'touchmove',
39596
+ 'touchstart'
39597
+ ];
39598
+
39599
+ /**
39600
+ * Returns `true` if `event_name` is a delegated event
39601
+ * @param {string} event_name
39602
+ */
39603
+ function can_delegate_event(event_name) {
39604
+ return DELEGATED_EVENTS.includes(event_name);
39605
+ }
39606
+
39607
+ /**
39608
+ * @type {Record<string, string>}
39609
+ * List of attribute names that should be aliased to their property names
39610
+ * because they behave differently between setting them as an attribute and
39611
+ * setting them as a property.
39612
+ */
39613
+ const ATTRIBUTE_ALIASES = {
39614
+ // no `class: 'className'` because we handle that separately
39615
+ formnovalidate: 'formNoValidate',
39616
+ ismap: 'isMap',
39617
+ nomodule: 'noModule',
39618
+ playsinline: 'playsInline',
39619
+ readonly: 'readOnly',
39620
+ defaultvalue: 'defaultValue',
39621
+ defaultchecked: 'defaultChecked',
39622
+ srcobject: 'srcObject',
39623
+ novalidate: 'noValidate',
39624
+ allowfullscreen: 'allowFullscreen',
39625
+ disablepictureinpicture: 'disablePictureInPicture',
39626
+ disableremoteplayback: 'disableRemotePlayback'
39627
+ };
39628
+
39629
+ /**
39630
+ * @param {string} name
39631
+ */
39632
+ function normalize_attribute(name) {
39633
+ name = name.toLowerCase();
39634
+ return ATTRIBUTE_ALIASES[name] ?? name;
39635
+ }
39636
+
39637
+ /**
39638
+ * Subset of delegated events which should be passive by default.
39639
+ * These two are already passive via browser defaults on window, document and body.
39640
+ * But since
39641
+ * - we're delegating them
39642
+ * - they happen often
39643
+ * - they apply to mobile which is generally less performant
39644
+ * we're marking them as passive by default for other elements, too.
39645
+ */
39646
+ const PASSIVE_EVENTS = ['touchstart', 'touchmove'];
39647
+
39648
+ /**
39649
+ * Returns `true` if `name` is a passive event
39650
+ * @param {string} name
39651
+ */
39652
+ function is_passive_event(name) {
39653
+ return PASSIVE_EVENTS.includes(name);
39654
+ }
39655
+
39638
39656
  /** @import { ComponentContext, Effect, EffectNodes, TemplateNode } from '#client' */
39639
39657
  /** @import { Component, ComponentType, SvelteComponent, MountOptions } from '../../index.js' */
39640
39658
 
@@ -39645,12 +39663,12 @@ function props_id() {
39645
39663
  */
39646
39664
  function set_text(text, value) {
39647
39665
  // For objects, we apply string coercion (which might make things like $state array references in the template reactive) before diffing
39648
- var str = value == null ? '' : typeof value === 'object' ? value + '' : value;
39666
+ var str = value == null ? '' : typeof value === 'object' ? `${value}` : value;
39649
39667
  // @ts-expect-error
39650
39668
  if (str !== (text.__t ??= text.nodeValue)) {
39651
39669
  // @ts-expect-error
39652
39670
  text.__t = str;
39653
- text.nodeValue = str + '';
39671
+ text.nodeValue = `${str}`;
39654
39672
  }
39655
39673
  }
39656
39674
 
@@ -39677,51 +39695,12 @@ const listeners = new Map();
39677
39695
  * @param {MountOptions} options
39678
39696
  * @returns {Exports}
39679
39697
  */
39680
- function _mount(Component, { target, anchor, props = {}, events, context, intro = true }) {
39698
+ function _mount(
39699
+ Component,
39700
+ { target, anchor, props = {}, events, context, intro = true, transformError }
39701
+ ) {
39681
39702
  init_operations();
39682
39703
 
39683
- /** @type {Set<string>} */
39684
- var registered_events = new Set();
39685
-
39686
- /** @param {Array<string>} events */
39687
- var event_handle = (events) => {
39688
- for (var i = 0; i < events.length; i++) {
39689
- var event_name = events[i];
39690
-
39691
- if (registered_events.has(event_name)) continue;
39692
- registered_events.add(event_name);
39693
-
39694
- var passive = is_passive_event(event_name);
39695
-
39696
- // Add the event listener to both the container and the document.
39697
- // The container listener ensures we catch events from within in case
39698
- // the outer content stops propagation of the event.
39699
- //
39700
- // The document listener ensures we catch events that originate from elements that were
39701
- // manually moved outside of the container (e.g. via manual portals).
39702
- for (const node of [target, document]) {
39703
- var counts = listeners.get(node);
39704
-
39705
- if (counts === undefined) {
39706
- counts = new Map();
39707
- listeners.set(node, counts);
39708
- }
39709
-
39710
- var count = counts.get(event_name);
39711
-
39712
- if (count === undefined) {
39713
- node.addEventListener(event_name, handle_event_propagation, { passive });
39714
- counts.set(event_name, 1);
39715
- } else {
39716
- counts.set(event_name, count + 1);
39717
- }
39718
- }
39719
- }
39720
- };
39721
-
39722
- event_handle(array_from(all_registered_events));
39723
- root_event_handles.add(event_handle);
39724
-
39725
39704
  /** @type {Exports} */
39726
39705
  // @ts-expect-error will be defined because the render effect runs synchronously
39727
39706
  var component = undefined;
@@ -39747,9 +39726,53 @@ function _mount(Component, { target, anchor, props = {}, events, context, intro
39747
39726
  component = Component(anchor_node, props) || {};
39748
39727
 
39749
39728
  pop();
39750
- }
39729
+ },
39730
+ transformError
39751
39731
  );
39752
39732
 
39733
+ // Setup event delegation _after_ component is mounted - if an error would happen during mount, it would otherwise not be cleaned up
39734
+ /** @type {Set<string>} */
39735
+ var registered_events = new Set();
39736
+
39737
+ /** @param {Array<string>} events */
39738
+ var event_handle = (events) => {
39739
+ for (var i = 0; i < events.length; i++) {
39740
+ var event_name = events[i];
39741
+
39742
+ if (registered_events.has(event_name)) continue;
39743
+ registered_events.add(event_name);
39744
+
39745
+ var passive = is_passive_event(event_name);
39746
+
39747
+ // Add the event listener to both the container and the document.
39748
+ // The container listener ensures we catch events from within in case
39749
+ // the outer content stops propagation of the event.
39750
+ //
39751
+ // The document listener ensures we catch events that originate from elements that were
39752
+ // manually moved outside of the container (e.g. via manual portals).
39753
+ for (const node of [target, document]) {
39754
+ var counts = listeners.get(node);
39755
+
39756
+ if (counts === undefined) {
39757
+ counts = new Map();
39758
+ listeners.set(node, counts);
39759
+ }
39760
+
39761
+ var count = counts.get(event_name);
39762
+
39763
+ if (count === undefined) {
39764
+ node.addEventListener(event_name, handle_event_propagation, { passive });
39765
+ counts.set(event_name, 1);
39766
+ } else {
39767
+ counts.set(event_name, count + 1);
39768
+ }
39769
+ }
39770
+ }
39771
+ };
39772
+
39773
+ event_handle(array_from(all_registered_events));
39774
+ root_event_handles.add(event_handle);
39775
+
39753
39776
  return () => {
39754
39777
  for (var event_name of registered_events) {
39755
39778
  for (const node of [target, document]) {
@@ -39878,9 +39901,10 @@ class BranchManager {
39878
39901
  this.#transition = transition;
39879
39902
  }
39880
39903
 
39881
- #commit = () => {
39882
- var batch = /** @type {Batch} */ (current_batch);
39883
-
39904
+ /**
39905
+ * @param {Batch} batch
39906
+ */
39907
+ #commit = (batch) => {
39884
39908
  // if this batch was made obsolete, bail
39885
39909
  if (!this.#batches.has(batch)) return;
39886
39910
 
@@ -40028,7 +40052,7 @@ class BranchManager {
40028
40052
  batch.ondiscard(this.#discard);
40029
40053
  } else {
40030
40054
 
40031
- this.#commit();
40055
+ this.#commit(batch);
40032
40056
  }
40033
40057
  }
40034
40058
  }
@@ -40054,48 +40078,6 @@ function snippet(node, get_snippet, ...args) {
40054
40078
  }, EFFECT_TRANSPARENT);
40055
40079
  }
40056
40080
 
40057
- /** @import { ComponentContext, ComponentContextLegacy } from '#client' */
40058
- /** @import { EventDispatcher } from './index.js' */
40059
- /** @import { NotFunction } from './internal/types.js' */
40060
-
40061
- /**
40062
- * `onMount`, like [`$effect`](https://svelte.dev/docs/svelte/$effect), schedules a function to run as soon as the component has been mounted to the DOM.
40063
- * Unlike `$effect`, the provided function only runs once.
40064
- *
40065
- * It must be called during the component's initialisation (but doesn't need to live _inside_ the component;
40066
- * it can be called from an external module). If a function is returned _synchronously_ from `onMount`,
40067
- * it will be called when the component is unmounted.
40068
- *
40069
- * `onMount` functions do not run during [server-side rendering](https://svelte.dev/docs/svelte/svelte-server#render).
40070
- *
40071
- * @template T
40072
- * @param {() => NotFunction<T> | Promise<NotFunction<T>> | (() => any)} fn
40073
- * @returns {void}
40074
- */
40075
- function onMount(fn) {
40076
- if (component_context === null) {
40077
- lifecycle_outside_component();
40078
- }
40079
-
40080
- if (legacy_mode_flag && component_context.l !== null) {
40081
- init_update_callbacks(component_context).m.push(fn);
40082
- } else {
40083
- user_effect(() => {
40084
- const cleanup = untrack(fn);
40085
- if (typeof cleanup === 'function') return /** @type {() => void} */ (cleanup);
40086
- });
40087
- }
40088
- }
40089
-
40090
- /**
40091
- * Legacy-mode: Init callbacks object for onMount/beforeUpdate/afterUpdate
40092
- * @param {ComponentContext} context
40093
- */
40094
- function init_update_callbacks(context) {
40095
- var l = /** @type {ComponentContextLegacy} */ (context).l;
40096
- return (l.u ??= { a: [], b: [], m: [] });
40097
- }
40098
-
40099
40081
  /** @import { TemplateNode } from '#client' */
40100
40082
 
40101
40083
  /**
@@ -40723,10 +40705,11 @@ function link(state, prev, next) {
40723
40705
  }
40724
40706
 
40725
40707
  /** @import { Effect, TemplateNode } from '#client' */
40708
+ /** @import {} from 'trusted-types' */
40726
40709
 
40727
40710
  /**
40728
40711
  * @param {Element | Text | Comment} node
40729
- * @param {() => string} get_value
40712
+ * @param {() => string | TrustedHTML} get_value
40730
40713
  * @param {boolean} [svg]
40731
40714
  * @param {boolean} [mathml]
40732
40715
  * @param {boolean} [skip_warning]
@@ -40735,6 +40718,7 @@ function link(state, prev, next) {
40735
40718
  function html(node, get_value, svg = false, mathml = false, skip_warning = false) {
40736
40719
  var anchor = node;
40737
40720
 
40721
+ /** @type {string | TrustedHTML} */
40738
40722
  var value = '';
40739
40723
 
40740
40724
  template_effect(() => {
@@ -40751,18 +40735,18 @@ function html(node, get_value, svg = false, mathml = false, skip_warning = false
40751
40735
 
40752
40736
  if (value === '') return;
40753
40737
 
40754
- var html = value + '';
40755
- if (svg) html = `<svg>${html}</svg>`;
40756
- else if (mathml) html = `<math>${html}</math>`;
40757
-
40758
40738
  // Don't use create_fragment_with_script_from_html here because that would mean script tags are executed.
40759
40739
  // @html is basically `.innerHTML = ...` and that doesn't execute scripts either due to security reasons.
40760
- /** @type {DocumentFragment | Element} */
40761
- var node = create_fragment_from_html(html);
40740
+ // Use a <template>, <svg>, or <math> wrapper depending on context. If value is a TrustedHTML object,
40741
+ // it will be assigned directly to innerHTML without coercion — this allows {@html policy.createHTML(...)} to work.
40742
+ var ns = svg ? NAMESPACE_SVG : mathml ? NAMESPACE_MATHML : undefined;
40743
+ var wrapper = /** @type {HTMLTemplateElement | SVGElement | MathMLElement} */ (
40744
+ create_element(svg ? 'svg' : mathml ? 'math' : 'template', ns)
40745
+ );
40746
+ wrapper.innerHTML = /** @type {any} */ (value);
40762
40747
 
40763
- if (svg || mathml) {
40764
- node = /** @type {Element} */ (get_first_child(node));
40765
- }
40748
+ /** @type {DocumentFragment | Element} */
40749
+ var node = svg || mathml ? wrapper : /** @type {HTMLTemplateElement} */ (wrapper).content;
40766
40750
 
40767
40751
  assign_nodes(
40768
40752
  /** @type {TemplateNode} */ (get_first_child(node)),
@@ -40929,7 +40913,7 @@ function to_class(value, hash, directives) {
40929
40913
  }
40930
40914
 
40931
40915
  if (directives) {
40932
- for (var key in directives) {
40916
+ for (var key of Object.keys(directives)) {
40933
40917
  if (directives[key]) {
40934
40918
  classname = classname ? classname + ' ' + key : key;
40935
40919
  } else if (classname.length) {
@@ -40964,7 +40948,7 @@ function append_styles(styles, important = false) {
40964
40948
  var separator = important ? ' !important;' : ';';
40965
40949
  var css = '';
40966
40950
 
40967
- for (var key in styles) {
40951
+ for (var key of Object.keys(styles)) {
40968
40952
  var value = styles[key];
40969
40953
  if (value != null && value !== '') {
40970
40954
  css += ' ' + key + ': ' + value + separator;
@@ -42280,6 +42264,8 @@ function prop(props, key, flags, fallback) {
42280
42264
  );
42281
42265
  }
42282
42266
 
42267
+ enable_legacy_mode_flag();
42268
+
42283
42269
  const defaultAttributes = {
42284
42270
  outline: {
42285
42271
  xmlns: 'http://www.w3.org/2000/svg',
@@ -42395,29 +42381,25 @@ function Clipboard($$anchor, $$props) {
42395
42381
  }));
42396
42382
  }
42397
42383
 
42398
- var root_1$6 = from_html(`<div class="paste-section svelte-1hna6ki"><button type="button" class="paste-button svelte-1hna6ki"><!> <span class="svelte-1hna6ki">クリップボードから貼り付け</span></button></div>`);
42399
- var root_5$4 = from_html(`<img alt="" loading="lazy" class="svelte-1hna6ki"/>`);
42384
+ var root_1$7 = from_html(`<div class="paste-section svelte-1hna6ki"><button type="button" class="paste-button svelte-1hna6ki"><!> <span class="svelte-1hna6ki">クリップボードから貼り付け</span></button></div>`);
42385
+ var root_5$3 = from_html(`<img alt="" loading="lazy" class="svelte-1hna6ki"/>`);
42400
42386
  var root_4$4 = from_html(`<figure class="svelte-1hna6ki"><div class="img svelte-1hna6ki"><!></div> <figcaption class="svelte-1hna6ki"> </figcaption></figure>`);
42401
42387
  var root_3$4 = from_html(`<dd class="svelte-1hna6ki"><button type="button" class="svelte-1hna6ki"><!></button></dd>`);
42402
42388
  var root_2$5 = from_html(`<dt class="svelte-1hna6ki"> </dt> <div class="svelte-1hna6ki"></div>`, 1);
42403
42389
  var root$a = from_html(`<div class="block-catalog"><!> <dl class="svelte-1hna6ki"></dl></div>`);
42404
42390
 
42405
42391
  function Block_catalog($$anchor, $$props) {
42406
- push($$props, false);
42407
-
42408
- let engine = prop($$props, 'engine', 8);
42409
- let hasCopiedBlock = mutable_source(false);
42392
+ push($$props, true);
42410
42393
 
42411
- // コンポーネント初期化時にsessionStorageをチェック
42412
- set(hasCopiedBlock, !!sessionStorage.getItem(engine().storageKey.blockClipboard));
42394
+ const hasCopiedBlock = !!sessionStorage.getItem($$props.engine.storageKey.blockClipboard);
42413
42395
 
42414
42396
  /**
42415
42397
  *
42416
42398
  * @param blockData
42417
42399
  */
42418
42400
  function addBlock(blockData) {
42419
- engine().blockCatalogDialog.close();
42420
- engine().addBlock(blockData);
42401
+ $$props.engine.blockCatalogDialog.close();
42402
+ $$props.engine.addBlock(blockData);
42421
42403
  }
42422
42404
 
42423
42405
  /**
@@ -42425,7 +42407,7 @@ function Block_catalog($$anchor, $$props) {
42425
42407
  */
42426
42408
  async function pasteBlock() {
42427
42409
  // 1. sessionStorageから取得
42428
- const jsonString = sessionStorage.getItem(engine().storageKey.blockClipboard);
42410
+ const jsonString = sessionStorage.getItem($$props.engine.storageKey.blockClipboard);
42429
42411
 
42430
42412
  if (!jsonString) {
42431
42413
  alert('クリップボードにブロックデータがありません。');
@@ -42448,133 +42430,107 @@ function Block_catalog($$anchor, $$props) {
42448
42430
  }
42449
42431
 
42450
42432
  // 3. ダイアログを閉じる
42451
- engine().blockCatalogDialog.close();
42433
+ $$props.engine.blockCatalogDialog.close();
42452
42434
 
42453
42435
  // 4. ブロックを追加(既存のaddBlock関数と同じ)
42454
- await engine().addBlock(blockData);
42436
+ await $$props.engine.addBlock(blockData);
42455
42437
 
42456
42438
  // 5. sessionStorageをクリア
42457
- sessionStorage.removeItem(engine().storageKey.blockClipboard);
42439
+ sessionStorage.removeItem($$props.engine.storageKey.blockClipboard);
42458
42440
  }
42459
42441
 
42460
- init();
42461
-
42462
42442
  var div = root$a();
42463
42443
  var node = child(div);
42464
42444
 
42465
42445
  {
42466
42446
  var consequent = ($$anchor) => {
42467
- var div_1 = root_1$6();
42447
+ var div_1 = root_1$7();
42468
42448
  var button = child(div_1);
42469
42449
  var node_1 = child(button);
42470
42450
 
42471
42451
  Clipboard(node_1, {});
42472
- event('click', button, pasteBlock);
42452
+ delegated('click', button, pasteBlock);
42473
42453
  append($$anchor, div_1);
42474
42454
  };
42475
42455
 
42476
42456
  if_block(node, ($$render) => {
42477
- if (get(hasCopiedBlock)) $$render(consequent);
42457
+ if (hasCopiedBlock) $$render(consequent);
42478
42458
  });
42479
42459
  }
42480
42460
 
42481
42461
  var dl = sibling(node, 2);
42482
42462
 
42483
- each(
42484
- dl,
42485
- 5,
42486
- () => (
42487
- deep_read_state(engine()),
42488
- untrack(() => engine().blockCatalogDialog.catalog)
42489
- ),
42490
- ([category, blocks]) => category,
42491
- ($$anchor, $$item) => {
42492
- var $$array = user_derived(() => to_array(get($$item), 2));
42493
- let category = () => get($$array)[0];
42494
- let blocks = () => get($$array)[1];
42495
- var fragment = root_2$5();
42496
- var dt = first_child(fragment);
42497
- var text$1 = child(dt);
42498
-
42499
- var div_2 = sibling(dt, 2);
42500
-
42501
- each(div_2, 5, blocks, (blockInfo) => category() + blockInfo.label + blockInfo.definition.name, ($$anchor, blockInfo) => {
42502
- var dd = root_3$4();
42503
- var button_1 = child(dd);
42504
- var node_2 = child(button_1);
42463
+ each(dl, 21, () => $$props.engine.blockCatalogDialog.catalog, ([category, blocks]) => category, ($$anchor, $$item) => {
42464
+ var $$array = user_derived(() => to_array(get($$item), 2));
42465
+ let category = () => get($$array)[0];
42466
+ let blocks = () => get($$array)[1];
42467
+ var fragment = root_2$5();
42468
+ var dt = first_child(fragment);
42469
+ var text$1 = child(dt);
42505
42470
 
42506
- {
42507
- var consequent_3 = ($$anchor) => {
42508
- var figure = root_4$4();
42509
- var div_3 = child(figure);
42510
- var node_3 = child(div_3);
42511
-
42512
- {
42513
- var consequent_1 = ($$anchor) => {
42514
- var img = root_5$4();
42515
-
42516
- template_effect(() => set_attribute(img, 'src', (
42517
- get(blockInfo),
42518
- untrack(() => get(blockInfo).definition.img)
42519
- )));
42520
-
42521
- append($$anchor, img);
42522
- };
42523
-
42524
- var consequent_2 = ($$anchor) => {
42525
- var fragment_1 = comment();
42526
- var node_4 = first_child(fragment_1);
42527
-
42528
- html(node_4, () => (
42529
- get(blockInfo),
42530
- untrack(() => get(blockInfo).definition.svg)
42531
- ));
42532
-
42533
- append($$anchor, fragment_1);
42534
- };
42535
-
42536
- if_block(node_3, ($$render) => {
42537
- if ((
42538
- get(blockInfo),
42539
- untrack(() => get(blockInfo).definition.img)
42540
- )) $$render(consequent_1); else if ((
42541
- get(blockInfo),
42542
- untrack(() => get(blockInfo).definition.svg)
42543
- )) $$render(consequent_2, 1);
42544
- });
42545
- }
42471
+ var div_2 = sibling(dt, 2);
42546
42472
 
42547
- var figcaption = sibling(div_3, 2);
42548
- var text_1 = child(figcaption);
42549
- template_effect(() => set_text(text_1, (get(blockInfo), untrack(() => get(blockInfo).label))));
42550
- append($$anchor, figure);
42551
- };
42473
+ each(div_2, 21, blocks, (blockInfo) => category() + blockInfo.label + blockInfo.definition.name, ($$anchor, blockInfo) => {
42474
+ var dd = root_3$4();
42475
+ var button_1 = child(dd);
42476
+ var node_2 = child(button_1);
42552
42477
 
42553
- var alternate = ($$anchor) => {
42554
- var text_2 = text();
42478
+ {
42479
+ var consequent_3 = ($$anchor) => {
42480
+ var figure = root_4$4();
42481
+ var div_3 = child(figure);
42482
+ var node_3 = child(div_3);
42555
42483
 
42556
- template_effect(() => set_text(text_2, (get(blockInfo), untrack(() => get(blockInfo).label))));
42557
- append($$anchor, text_2);
42558
- };
42484
+ {
42485
+ var consequent_1 = ($$anchor) => {
42486
+ var img = root_5$3();
42559
42487
 
42560
- if_block(node_2, ($$render) => {
42561
- if ((
42562
- get(blockInfo),
42563
- untrack(() => get(blockInfo).definition.img || get(blockInfo).definition.svg)
42564
- )) $$render(consequent_3); else $$render(alternate, false);
42565
- });
42566
- }
42567
- event('click', button_1, () => addBlock(get(blockInfo).definition));
42568
- append($$anchor, dd);
42569
- });
42570
- template_effect(() => set_text(text$1, category()));
42571
- append($$anchor, fragment);
42572
- }
42573
- );
42488
+ template_effect(() => set_attribute(img, 'src', get(blockInfo).definition.img));
42489
+ append($$anchor, img);
42490
+ };
42491
+
42492
+ var consequent_2 = ($$anchor) => {
42493
+ var fragment_1 = comment();
42494
+ var node_4 = first_child(fragment_1);
42495
+
42496
+ html(node_4, () => get(blockInfo).definition.svg);
42497
+ append($$anchor, fragment_1);
42498
+ };
42499
+
42500
+ if_block(node_3, ($$render) => {
42501
+ if (get(blockInfo).definition.img) $$render(consequent_1); else if (get(blockInfo).definition.svg) $$render(consequent_2, 1);
42502
+ });
42503
+ }
42504
+
42505
+ var figcaption = sibling(div_3, 2);
42506
+ var text_1 = child(figcaption);
42507
+ template_effect(() => set_text(text_1, get(blockInfo).label));
42508
+ append($$anchor, figure);
42509
+ };
42510
+
42511
+ var alternate = ($$anchor) => {
42512
+ var text_2 = text();
42513
+
42514
+ template_effect(() => set_text(text_2, get(blockInfo).label));
42515
+ append($$anchor, text_2);
42516
+ };
42517
+
42518
+ if_block(node_2, ($$render) => {
42519
+ if (get(blockInfo).definition.img || get(blockInfo).definition.svg) $$render(consequent_3); else $$render(alternate, false);
42520
+ });
42521
+ }
42522
+ delegated('click', button_1, () => addBlock(get(blockInfo).definition));
42523
+ append($$anchor, dd);
42524
+ });
42525
+ template_effect(() => set_text(text$1, category()));
42526
+ append($$anchor, fragment);
42527
+ });
42574
42528
  append($$anchor, div);
42575
42529
  pop();
42576
42530
  }
42577
42531
 
42532
+ delegate(['click']);
42533
+
42578
42534
  function Arrow_big_down_line($$anchor, $$props) {
42579
42535
  const $$sanitized_props = legacy_rest_props($$props, ['children', '$$slots', '$$events', '$$legacy']);
42580
42536
 
@@ -42974,34 +42930,142 @@ async function replaceElement(elA, elB, duration = 600) {
42974
42930
  }
42975
42931
  }
42976
42932
 
42977
- var root_5$3 = from_html(`<!> <!>`, 1);
42978
- var root$8 = from_html(`<div class="bge-menu-base svelte-1fv4q6w"><div class="bge-menu svelte-1fv4q6w"><div class="bge-move-group svelte-1fv4q6w"><!> <!></div> <div class="bge-standard-group svelte-1fv4q6w"><!> <!> <!> <!> <!> <!></div></div> <div class="bge-menu-margin svelte-1fv4q6w"><span class="svelte-1fv4q6w"> </span></div></div>`);
42933
+ var root_6$2 = from_html(`<!> <!>`, 1);
42934
+ var root_1$6 = from_html(`<div class="bge-menu-base svelte-1fv4q6w"><div class="bge-menu svelte-1fv4q6w"><div class="bge-move-group svelte-1fv4q6w"><!> <!></div> <div class="bge-standard-group svelte-1fv4q6w"><!> <!> <!> <!> <!> <!></div></div> <div class="bge-menu-margin svelte-1fv4q6w"><span class="svelte-1fv4q6w"> </span></div></div>`);
42979
42935
 
42980
42936
  function Block_menu($$anchor, $$props) {
42981
- push($$props, false);
42937
+ push($$props, true);
42982
42938
 
42983
- const isMutable = mutable_source();
42984
- let engine = prop($$props, 'engine', 12);
42985
- let currentBlock = mutable_source(null);
42986
- let _width = mutable_source(0);
42987
- let _height = mutable_source(0);
42988
- let _x = mutable_source(0);
42989
- let _y = mutable_source(0);
42990
- let _marginBlockEnd = mutable_source(0);
42991
- let marginBlockEndValue = mutable_source('0px');
42939
+ const engine = prop($$props, 'engine', 7);
42940
+ let currentBlock = state(null);
42941
+ let visible = state(false);
42942
+ const isMutable = user_derived(() => get(currentBlock)?.isMutable());
42943
+ let _width = state(0);
42944
+ let _height = state(0);
42945
+ let _x = state(0);
42946
+ let _y = state(0);
42947
+ let _marginBlockEnd = state(0);
42948
+ let marginBlockEndValue = state('0px');
42992
42949
 
42993
42950
  engine().blockOptionsDialog.onChangeBlock((block) => {
42994
- set(currentBlock, block);
42951
+ set(currentBlock, block, true);
42995
42952
  });
42996
42953
 
42997
- engine().componentObserver.on('select-block', ({ block, width, height, x, y, marginBlockEnd }) => {
42998
- set(currentBlock, block);
42999
- set(_width, width);
43000
- set(_height, height);
43001
- set(_x, x);
43002
- set(_y, y);
43003
- set(_marginBlockEnd, marginBlockEnd);
43004
- set(marginBlockEndValue, window.getComputedStyle(block.el).getPropertyValue('--bge-block-margin'));
42954
+ /**
42955
+ *
42956
+ */
42957
+ function hide() {
42958
+ set(visible, false);
42959
+ set(currentBlock, null);
42960
+ $$props.onHide();
42961
+ }
42962
+
42963
+ let mouseX = 0;
42964
+ let mouseY = 0;
42965
+ let raf = 0;
42966
+
42967
+ /**
42968
+ *
42969
+ */
42970
+ function updatePosition() {
42971
+ const doc = $$props.container.ownerDocument;
42972
+ const selected = getBlockAtPosition(doc, mouseX, mouseY);
42973
+
42974
+ if (!selected) {
42975
+ hide();
42976
+
42977
+ return;
42978
+ }
42979
+
42980
+ set(visible, true);
42981
+
42982
+ const { block, rect, marginBlockEnd } = selected;
42983
+
42984
+ set(currentBlock, block, true);
42985
+ set(_width, rect.width, true);
42986
+ set(_height, rect.height, true);
42987
+ set(_x, rect.left, true);
42988
+ set(_y, rect.top, true);
42989
+ set(_marginBlockEnd, marginBlockEnd, true);
42990
+ set(marginBlockEndValue, window.getComputedStyle(block.el).getPropertyValue('--bge-block-margin'), true);
42991
+
42992
+ engine().componentObserver.notify('select-block', {
42993
+ block,
42994
+ width: rect.width,
42995
+ height: rect.height,
42996
+ x: rect.left,
42997
+ y: rect.top,
42998
+ marginBlockEnd
42999
+ });
43000
+ }
43001
+
43002
+ /**
43003
+ *
43004
+ */
43005
+ function scheduleUpdate() {
43006
+ cancelAnimationFrame(raf);
43007
+
43008
+ if (engine().isProcessed) {
43009
+ hide();
43010
+
43011
+ return;
43012
+ }
43013
+
43014
+ raf = requestAnimationFrame(() => {
43015
+ updatePosition();
43016
+ });
43017
+ }
43018
+
43019
+ user_effect(() => {
43020
+ const doc = $$props.container.ownerDocument;
43021
+ const body = doc.body;
43022
+ const win = doc.defaultView;
43023
+
43024
+ const onMouseMove = (e) => {
43025
+ mouseX = e.pageX;
43026
+ mouseY = e.pageY;
43027
+ scheduleUpdate();
43028
+ };
43029
+
43030
+ const onHideEvent = () => hide();
43031
+
43032
+ body.addEventListener('mousemove', onMouseMove);
43033
+ body.addEventListener('mouseleave', onHideEvent);
43034
+ doc.addEventListener('mouseleave', onHideEvent);
43035
+ win?.addEventListener('mouseleave', onHideEvent);
43036
+ globalThis.addEventListener('resize', onHideEvent);
43037
+ engine().el.addEventListener('bge:saved', scheduleUpdate);
43038
+
43039
+ const observer = new MutationObserver((mutations) => {
43040
+ for (const mutation of mutations) {
43041
+ for (const node of mutation.addedNodes) {
43042
+ if (!(node instanceof HTMLElement)) {
43043
+ continue;
43044
+ }
43045
+
43046
+ const images = node.querySelectorAll('img');
43047
+
43048
+ for (const img of images) {
43049
+ img.addEventListener('load', scheduleUpdate, { once: true });
43050
+ img.addEventListener('error', scheduleUpdate, { once: true });
43051
+ img.addEventListener('abort', scheduleUpdate, { once: true });
43052
+ }
43053
+ }
43054
+ }
43055
+ });
43056
+
43057
+ observer.observe(doc, { childList: true, subtree: true });
43058
+
43059
+ return () => {
43060
+ body.removeEventListener('mousemove', onMouseMove);
43061
+ body.removeEventListener('mouseleave', onHideEvent);
43062
+ doc.removeEventListener('mouseleave', onHideEvent);
43063
+ win?.removeEventListener('mouseleave', onHideEvent);
43064
+ globalThis.removeEventListener('resize', onHideEvent);
43065
+ engine().el.removeEventListener('bge:saved', scheduleUpdate);
43066
+ observer.disconnect();
43067
+ cancelAnimationFrame(raf);
43068
+ };
43005
43069
  });
43006
43070
 
43007
43071
  /**
@@ -43033,24 +43097,24 @@ function Block_menu($$anchor, $$props) {
43033
43097
  return;
43034
43098
  }
43035
43099
 
43036
- let $from;
43037
- let $to;
43100
+ let fromEl;
43101
+ let toEl;
43038
43102
 
43039
43103
  if (toTop) {
43040
- $from = get(currentBlock).el.previousElementSibling;
43041
- $to = get(currentBlock).el;
43104
+ fromEl = get(currentBlock).el.previousElementSibling;
43105
+ toEl = get(currentBlock).el;
43042
43106
  } else {
43043
- $from = get(currentBlock).el;
43044
- $to = get(currentBlock).el.nextElementSibling;
43107
+ fromEl = get(currentBlock).el;
43108
+ toEl = get(currentBlock).el.nextElementSibling;
43045
43109
  }
43046
43110
 
43047
- if (!$from || !$to) {
43111
+ if (!fromEl || !toEl) {
43048
43112
  return;
43049
43113
  }
43050
43114
 
43051
- engine(engine().isProcessed = true, true);
43052
- await replaceElement($from, $to);
43053
- engine(engine().isProcessed = false, true);
43115
+ engine().isProcessed = true;
43116
+ await replaceElement(fromEl, toEl);
43117
+ engine().isProcessed = false;
43054
43118
  engine().save();
43055
43119
  }
43056
43120
 
@@ -43066,11 +43130,11 @@ function Block_menu($$anchor, $$props) {
43066
43130
  return;
43067
43131
  }
43068
43132
 
43069
- engine(engine().isProcessed = true, true);
43133
+ engine().isProcessed = true;
43070
43134
  await Promise.resolve();
43071
43135
  get(currentBlock).remove();
43072
43136
  set(currentBlock, null);
43073
- engine(engine().isProcessed = false, true);
43137
+ engine().isProcessed = false;
43074
43138
  engine().save();
43075
43139
  }
43076
43140
 
@@ -43111,127 +43175,133 @@ function Block_menu($$anchor, $$props) {
43111
43175
  alert('ブロックをコピーしました。\nブロックの追加ボタンからペースト(貼り付け)することができます。');
43112
43176
  }
43113
43177
 
43114
- legacy_pre_effect(() => (get(currentBlock)), () => {
43115
- set(isMutable, get(currentBlock)?.isMutable());
43116
- });
43117
-
43118
- legacy_pre_effect_reset();
43119
- init();
43120
-
43121
- var div = root$8();
43122
- var div_1 = child(div);
43123
- var div_2 = child(div_1);
43124
- var node = child(div_2);
43125
-
43126
- Block_menu_button(node, {
43127
- label: 'ひとつ上へ移動',
43128
- action: () => move(true),
43129
- children: ($$anchor, $$slotProps) => {
43130
- Arrow_big_up_line($$anchor, {});
43131
- }});
43132
-
43133
- var node_1 = sibling(node, 2);
43134
-
43135
- Block_menu_button(node_1, {
43136
- label: 'ひとつ下へ移動',
43137
- action: () => move(false),
43138
- children: ($$anchor, $$slotProps) => {
43139
- Arrow_big_down_line($$anchor, {});
43140
- }});
43178
+ var fragment = comment();
43179
+ var node_1 = first_child(fragment);
43141
43180
 
43142
- var div_3 = sibling(div_2, 2);
43143
- var node_2 = child(div_3);
43181
+ {
43182
+ var consequent_1 = ($$anchor) => {
43183
+ var div = root_1$6();
43184
+ var div_1 = child(div);
43185
+ var div_2 = child(div_1);
43186
+ var node_2 = child(div_2);
43187
+
43188
+ Block_menu_button(node_2, {
43189
+ label: 'ひとつ上へ移動',
43190
+ action: () => move(true),
43191
+ children: ($$anchor, $$slotProps) => {
43192
+ Arrow_big_up_line($$anchor, {});
43193
+ }});
43144
43194
 
43145
- Block_menu_button(node_2, {
43146
- label: '上にブロックを追加',
43147
- action: () => insert(true),
43148
- children: ($$anchor, $$slotProps) => {
43149
- Row_insert_top($$anchor, {});
43150
- }});
43195
+ var node_3 = sibling(node_2, 2);
43151
43196
 
43152
- var node_3 = sibling(node_2, 2);
43197
+ Block_menu_button(node_3, {
43198
+ label: 'ひとつ下へ移動',
43199
+ action: () => move(false),
43200
+ children: ($$anchor, $$slotProps) => {
43201
+ Arrow_big_down_line($$anchor, {});
43202
+ }});
43153
43203
 
43154
- Block_menu_button(node_3, {
43155
- label: '下にブロックを追加',
43156
- action: () => insert(false),
43157
- children: ($$anchor, $$slotProps) => {
43158
- Row_insert_bottom($$anchor, {});
43159
- }});
43204
+ var div_3 = sibling(div_2, 2);
43205
+ var node_4 = child(div_3);
43160
43206
 
43161
- var node_4 = sibling(node_3, 2);
43207
+ Block_menu_button(node_4, {
43208
+ label: '上にブロックを追加',
43209
+ action: () => insert(true),
43210
+ children: ($$anchor, $$slotProps) => {
43211
+ Row_insert_top($$anchor, {});
43212
+ }});
43162
43213
 
43163
- {
43164
- var consequent = ($$anchor) => {
43165
- var fragment_4 = root_5$3();
43166
- var node_5 = first_child(fragment_4);
43214
+ var node_5 = sibling(node_4, 2);
43167
43215
 
43168
43216
  Block_menu_button(node_5, {
43169
- label: 'ブロック内に要素を追加',
43170
- action: () => updateGridItems(1),
43217
+ label: '下にブロックを追加',
43218
+ action: () => insert(false),
43171
43219
  children: ($$anchor, $$slotProps) => {
43172
- Layout_grid_add($$anchor, {});
43220
+ Row_insert_bottom($$anchor, {});
43173
43221
  }});
43174
43222
 
43175
43223
  var node_6 = sibling(node_5, 2);
43176
43224
 
43177
- Block_menu_button(node_6, {
43178
- label: 'ブロック内の要素を削除',
43179
- action: () => updateGridItems(-1),
43180
- children: ($$anchor, $$slotProps) => {
43181
- Layout_grid_remove($$anchor, {});
43182
- }});
43183
-
43184
- append($$anchor, fragment_4);
43185
- };
43225
+ {
43226
+ var consequent = ($$anchor) => {
43227
+ var fragment_5 = root_6$2();
43228
+ var node_7 = first_child(fragment_5);
43229
+
43230
+ Block_menu_button(node_7, {
43231
+ label: 'ブロック内に要素を追加',
43232
+ action: () => updateGridItems(1),
43233
+ children: ($$anchor, $$slotProps) => {
43234
+ Layout_grid_add($$anchor, {});
43235
+ }});
43236
+
43237
+ var node_8 = sibling(node_7, 2);
43238
+
43239
+ Block_menu_button(node_8, {
43240
+ label: 'ブロック内の要素を削除',
43241
+ action: () => updateGridItems(-1),
43242
+ children: ($$anchor, $$slotProps) => {
43243
+ Layout_grid_remove($$anchor, {});
43244
+ }});
43245
+
43246
+ append($$anchor, fragment_5);
43247
+ };
43186
43248
 
43187
- if_block(node_4, ($$render) => {
43188
- if (get(isMutable)) $$render(consequent);
43189
- });
43190
- }
43249
+ if_block(node_6, ($$render) => {
43250
+ if (get(isMutable)) $$render(consequent);
43251
+ });
43252
+ }
43191
43253
 
43192
- var node_7 = sibling(node_4, 2);
43254
+ var node_9 = sibling(node_6, 2);
43193
43255
 
43194
- Block_menu_button(node_7, {
43195
- label: 'オプション設定',
43196
- action: () => openConfig(),
43197
- children: ($$anchor, $$slotProps) => {
43198
- Settings($$anchor, {});
43199
- }});
43256
+ Block_menu_button(node_9, {
43257
+ label: 'オプション設定',
43258
+ action: () => openConfig(),
43259
+ children: ($$anchor, $$slotProps) => {
43260
+ Settings($$anchor, {});
43261
+ }});
43200
43262
 
43201
- var node_8 = sibling(node_7, 2);
43263
+ var node_10 = sibling(node_9, 2);
43202
43264
 
43203
- Block_menu_button(node_8, {
43204
- label: 'ブロックをコピー',
43205
- action: () => copy(),
43206
- children: ($$anchor, $$slotProps) => {
43207
- Clipboard_plus($$anchor, {});
43208
- }});
43265
+ Block_menu_button(node_10, {
43266
+ label: 'ブロックをコピー',
43267
+ action: () => copy(),
43268
+ children: ($$anchor, $$slotProps) => {
43269
+ Clipboard_plus($$anchor, {});
43270
+ }});
43209
43271
 
43210
- var node_9 = sibling(node_8, 2);
43272
+ var node_11 = sibling(node_10, 2);
43211
43273
 
43212
- Block_menu_button(node_9, {
43213
- label: 'ブロックを削除',
43214
- action: () => remove(),
43215
- children: ($$anchor, $$slotProps) => {
43216
- Trash($$anchor, {});
43217
- }});
43274
+ Block_menu_button(node_11, {
43275
+ label: 'ブロックを削除',
43276
+ action: () => remove(),
43277
+ children: ($$anchor, $$slotProps) => {
43278
+ Trash($$anchor, {});
43279
+ }});
43218
43280
 
43219
- var div_4 = sibling(div_1, 2);
43220
- var span = child(div_4);
43221
- var text = child(span);
43281
+ var div_4 = sibling(div_1, 2);
43282
+ var span = child(div_4);
43283
+ var text = child(span);
43222
43284
 
43223
- template_effect(() => {
43224
- set_style(div, `
43285
+ template_effect(() => {
43286
+ set_style(div, `
43225
43287
  --width:${get(_width)}px;
43226
43288
  --height:${get(_height)}px;
43227
43289
  --x:${get(_x)}px;
43228
43290
  --y:${get(_y)}px;
43229
43291
  --margin-block-end:${get(_marginBlockEnd) ?? '0'}px`);
43230
43292
 
43231
- set_text(text, `余白: ${get(marginBlockEndValue) ?? ''} (${get(_marginBlockEnd) ?? ''}px)`);
43232
- });
43293
+ set_text(text, `余白: ${get(marginBlockEndValue) ?? ''} (${get(_marginBlockEnd) ?? ''}px)`);
43294
+ });
43233
43295
 
43234
- append($$anchor, div);
43296
+ append($$anchor, div);
43297
+ };
43298
+
43299
+ if_block(node_1, ($$render) => {
43300
+ if (get(visible)) $$render(consequent_1);
43301
+ });
43302
+ }
43303
+
43304
+ append($$anchor, fragment);
43235
43305
  pop();
43236
43306
  }
43237
43307
 
@@ -43249,7 +43319,7 @@ var root_1$5 = from_html(`<fieldset><legend>コンテナ特性</legend> <!> <!>
43249
43319
  var root_15 = from_html(`<option> </option>`);
43250
43320
  var root_14 = from_html(`<label><span> </span> <select></select></label>`);
43251
43321
  var root_13 = from_html(`<fieldset><legend>ブロックのスタイル拡張</legend> <!></fieldset>`);
43252
- var root$7 = from_html(`<!> <!> <label><span>独自class設定</span> <input type="text" name="bge-options-classes" aria-describedby="block-option-classes-desc"/></label> <small id="block-option-classes-desc">複数指定する場合はスペース(空白文字)で区切ってください。</small> <label><span>ID設定: <code>bge-</code></span> <input name="bge-options-id" type="text" aria-describedby="block-option-id-desc"/></label> <small id="block-option-id-desc">アンカーリンク用のID属性を設定します。実際のIDは<code>bge-</code>が自動的に先頭に付加されます。</small>`, 1);
43322
+ var root$8 = from_html(`<!> <!> <label><span>独自class設定</span> <input type="text" name="bge-options-classes" aria-describedby="block-option-classes-desc"/></label> <small id="block-option-classes-desc">複数指定する場合はスペース(空白文字)で区切ってください。</small> <label><span>ID設定: <code>bge-</code></span> <input name="bge-options-id" type="text" aria-describedby="block-option-id-desc"/></label> <small id="block-option-id-desc">アンカーリンク用のID属性を設定します。実際のIDは<code>bge-</code>が自動的に先頭に付加されます。</small>`, 1);
43253
43323
 
43254
43324
  function Block_options($$anchor, $$props) {
43255
43325
  push($$props, true);
@@ -43313,7 +43383,7 @@ function Block_options($$anchor, $$props) {
43313
43383
  set(currentFrameSemantics, newSemantics, true);
43314
43384
  }
43315
43385
 
43316
- var fragment = root$7();
43386
+ var fragment = root$8();
43317
43387
  var node = first_child(fragment);
43318
43388
 
43319
43389
  {
@@ -43681,30 +43751,27 @@ var root_1$4 = from_html(`<span class="svelte-17zpf86">ソース表示</span>`);
43681
43751
  var root_2$3 = from_html(`<span class="svelte-17zpf86">ソース表示</span>`);
43682
43752
  var root_3$2 = from_html(`<button type="button" class="svelte-17zpf86">本稿を下書きにコピー</button>`);
43683
43753
  var root_4$2 = from_html(`<button type="button" class="svelte-17zpf86">下書きを本稿にコピー</button>`);
43684
- var root$6 = from_html(`<div class="draft-btn svelte-17zpf86"><div class="draft-tab-btn svelte-17zpf86"><button type="button" class="svelte-17zpf86">本稿モード <!></button> <button type="button" class="svelte-17zpf86">下書きモード <!></button></div> <div class="draft-copy-btn svelte-17zpf86"><!></div></div>`);
43754
+ var root$7 = from_html(`<div class="draft-btn svelte-17zpf86"><div class="draft-tab-btn svelte-17zpf86"><button type="button" class="svelte-17zpf86">本稿モード <!></button> <button type="button" class="svelte-17zpf86">下書きモード <!></button></div> <div class="draft-copy-btn svelte-17zpf86"><!></div></div>`);
43685
43755
 
43686
43756
  function Draft_switcher($$anchor, $$props) {
43687
- push($$props, false);
43688
-
43689
- let engine = prop($$props, 'engine', 8);
43690
- let isMain = mutable_source();
43691
- let isVisualMode = mutable_source();
43757
+ push($$props, true);
43692
43758
 
43693
- onMount(update);
43759
+ let isMain = state($$props.engine.content.type === 'main');
43760
+ let isVisualMode = state(proxy($$props.engine.content.isVisualMode));
43694
43761
 
43695
43762
  /**
43696
43763
  *
43697
43764
  */
43698
43765
  function update() {
43699
- set(isMain, engine().content.type === 'main');
43700
- set(isVisualMode, engine().content.isVisualMode);
43766
+ set(isMain, $$props.engine.content.type === 'main');
43767
+ set(isVisualMode, $$props.engine.content.isVisualMode, true);
43701
43768
  }
43702
43769
 
43703
43770
  /**
43704
43771
  *
43705
43772
  */
43706
43773
  function onClickMain() {
43707
- engine().showMain();
43774
+ $$props.engine.showMain();
43708
43775
  update();
43709
43776
  }
43710
43777
 
@@ -43712,7 +43779,7 @@ function Draft_switcher($$anchor, $$props) {
43712
43779
  *
43713
43780
  */
43714
43781
  function onClickDraft() {
43715
- engine().showDraft();
43782
+ $$props.engine.showDraft();
43716
43783
  update();
43717
43784
  }
43718
43785
 
@@ -43720,7 +43787,7 @@ function Draft_switcher($$anchor, $$props) {
43720
43787
  *
43721
43788
  */
43722
43789
  async function onClickDraftToMain() {
43723
- if (await engine().draftToMain(() => confirm('下書き内容を本稿へ上書きしてもよろしいですか?'))) {
43790
+ if (await $$props.engine.draftToMain(() => confirm('下書き内容を本稿へ上書きしてもよろしいですか?'))) {
43724
43791
  onClickMain();
43725
43792
  }
43726
43793
  }
@@ -43729,7 +43796,7 @@ function Draft_switcher($$anchor, $$props) {
43729
43796
  *
43730
43797
  */
43731
43798
  async function onClickMainToDraft() {
43732
- if (await engine().mainToDraft(() => confirm('本稿内容を下書きへ上書きしてもよろしいですか?'))) {
43799
+ if (await $$props.engine.mainToDraft(() => confirm('本稿内容を下書きへ上書きしてもよろしいですか?'))) {
43733
43800
  onClickDraft();
43734
43801
  }
43735
43802
  }
@@ -43738,7 +43805,7 @@ function Draft_switcher($$anchor, $$props) {
43738
43805
  *
43739
43806
  */
43740
43807
  function toggleDisplayMode() {
43741
- engine().content.toggleDisplayMode();
43808
+ $$props.engine.content.toggleDisplayMode();
43742
43809
  update();
43743
43810
  }
43744
43811
 
@@ -43751,7 +43818,7 @@ function Draft_switcher($$anchor, $$props) {
43751
43818
  return;
43752
43819
  }
43753
43820
 
43754
- engine().showMain();
43821
+ $$props.engine.showMain();
43755
43822
  toggleDisplayMode();
43756
43823
  }
43757
43824
 
@@ -43764,13 +43831,11 @@ function Draft_switcher($$anchor, $$props) {
43764
43831
  return;
43765
43832
  }
43766
43833
 
43767
- engine().showDraft();
43834
+ $$props.engine.showDraft();
43768
43835
  toggleDisplayMode();
43769
43836
  }
43770
43837
 
43771
- init();
43772
-
43773
- var div = root$6();
43838
+ var div = root$7();
43774
43839
  var div_1 = child(div);
43775
43840
  var button = child(div_1);
43776
43841
  var node = sibling(child(button));
@@ -43809,14 +43874,14 @@ function Draft_switcher($$anchor, $$props) {
43809
43874
  var consequent_2 = ($$anchor) => {
43810
43875
  var button_2 = root_3$2();
43811
43876
 
43812
- event('click', button_2, onClickMainToDraft);
43877
+ delegated('click', button_2, onClickMainToDraft);
43813
43878
  append($$anchor, button_2);
43814
43879
  };
43815
43880
 
43816
43881
  var alternate = ($$anchor) => {
43817
43882
  var button_3 = root_4$2();
43818
43883
 
43819
- event('click', button_3, onClickDraftToMain);
43884
+ delegated('click', button_3, onClickDraftToMain);
43820
43885
  append($$anchor, button_3);
43821
43886
  };
43822
43887
 
@@ -43830,14 +43895,16 @@ function Draft_switcher($$anchor, $$props) {
43830
43895
  set_attribute(button_1, 'aria-pressed', !get(isMain));
43831
43896
  });
43832
43897
 
43833
- event('click', button, onClickMain);
43834
- event('dblclick', button, onDblClickMain);
43835
- event('click', button_1, onClickDraft);
43836
- event('dblclick', button_1, onDblClickDraft);
43898
+ delegated('click', button, onClickMain);
43899
+ delegated('dblclick', button, onDblClickMain);
43900
+ delegated('click', button_1, onClickDraft);
43901
+ delegated('dblclick', button_1, onDblClickDraft);
43837
43902
  append($$anchor, div);
43838
43903
  pop();
43839
43904
  }
43840
43905
 
43906
+ delegate(['click', 'dblclick']);
43907
+
43841
43908
  function File($$anchor, $$props) {
43842
43909
  const $$sanitized_props = legacy_rest_props($$props, ['children', '$$slots', '$$events', '$$legacy']);
43843
43910
 
@@ -44094,25 +44161,21 @@ function getExt(src) {
44094
44161
 
44095
44162
  var root_1$3 = from_html(`<img alt="画像のプレビュー" loading="lazy" class="svelte-by6cmj"/>`);
44096
44163
  var root_2$2 = from_html(`<video playsinline="" class="svelte-by6cmj"><source/> <track kind="captions" src=""/> <!></video>`, 2);
44097
- var root$5 = from_html(`<span data-bge-editor-ui-component="thumbnail" class="svelte-by6cmj"><!></span>`);
44164
+ var root$6 = from_html(`<span data-bge-editor-ui-component="thumbnail" class="svelte-by6cmj"><!></span>`);
44098
44165
 
44099
44166
  function Thumbnail($$anchor, $$props) {
44100
- push($$props, false);
44101
-
44102
- let src = prop($$props, 'src', 8);
44103
- let isLoaded = mutable_source(false);
44104
- const file = getExt(src());
44105
-
44106
- init();
44167
+ push($$props, true);
44107
44168
 
44108
- var span = root$5();
44169
+ let isLoaded = state(false);
44170
+ const file = getExt($$props.src);
44171
+ var span = root$6();
44109
44172
  var node = child(span);
44110
44173
 
44111
44174
  {
44112
44175
  var consequent = ($$anchor) => {
44113
44176
  var img = root_1$3();
44114
44177
 
44115
- template_effect(() => set_attribute(img, 'src', src()));
44178
+ template_effect(() => set_attribute(img, 'src', $$props.src));
44116
44179
  event('load', img, () => set(isLoaded, true));
44117
44180
  append($$anchor, img);
44118
44181
  };
@@ -44128,8 +44191,8 @@ function Thumbnail($$anchor, $$props) {
44128
44191
  Video(node_1, {});
44129
44192
 
44130
44193
  template_effect(() => {
44131
- set_attribute(source, 'src', src());
44132
- set_attribute(source, 'type', (untrack(() => `video/${file.ext}`)));
44194
+ set_attribute(source, 'src', $$props.src);
44195
+ set_attribute(source, 'type', `video/${file.ext}`);
44133
44196
  });
44134
44197
 
44135
44198
  append($$anchor, video);
@@ -44160,7 +44223,7 @@ function Thumbnail($$anchor, $$props) {
44160
44223
  };
44161
44224
 
44162
44225
  if_block(node, ($$render) => {
44163
- if ((untrack(() => file.isImage))) $$render(consequent); else if ((untrack(() => file.isVideo))) $$render(consequent_1, 1); else if ((untrack(() => file.isAudio))) $$render(consequent_2, 2); else if ((untrack(() => file.isDoc))) $$render(consequent_3, 3); else if ((untrack(() => file.isPpt))) $$render(consequent_4, 4); else if ((untrack(() => file.isXls))) $$render(consequent_5, 5); else if ((untrack(() => file.isPdf))) $$render(consequent_6, 6); else $$render(alternate, false);
44226
+ if (file.isImage) $$render(consequent); else if (file.isVideo) $$render(consequent_1, 1); else if (file.isAudio) $$render(consequent_2, 2); else if (file.isDoc) $$render(consequent_3, 3); else if (file.isPpt) $$render(consequent_4, 4); else if (file.isXls) $$render(consequent_5, 5); else if (file.isPdf) $$render(consequent_6, 6); else $$render(alternate, false);
44164
44227
  });
44165
44228
  }
44166
44229
  template_effect(() => set_attribute(span, 'data-loaded', get(isLoaded)));
@@ -44174,10 +44237,10 @@ var root_5$1 = from_html(`<span class="svelte-6hu200">アップロード中... <
44174
44237
  var root_6$1 = from_html(`<span class="attr svelte-6hu200"><span class="svelte-6hu200">ID</span><span class="svelte-6hu200"><!></span> <span class="svelte-6hu200">名称</span><span class="svelte-6hu200"><!></span> <span class="svelte-6hu200">更新</span><span class="svelte-6hu200"> </span> <span class="svelte-6hu200">サイズ</span><span class="svelte-6hu200"> </span></span>`);
44175
44238
  var root_7$1 = from_html(`<button class="delete svelte-6hu200" type="button">削除</button>`);
44176
44239
  var root_4$1 = from_html(`<li class="svelte-6hu200"><button class="file svelte-6hu200" type="button"><span class="thumbnail svelte-6hu200"><!></span> <!></button> <!></li>`);
44177
- var root$4 = from_html(`<div class="ctrl svelte-6hu200"><div class="pagination svelte-6hu200"><button type="button" class="svelte-6hu200">前へ</button> <div class="page svelte-6hu200"><span><input type="number" min="1" aria-label="ページ番号"/></span> <span>/</span> <span> </span></div> <button type="button" class="svelte-6hu200">次へ</button></div> <input type="search" placeholder="検索"/></div> <ul class="list svelte-6hu200"></ul>`, 1);
44240
+ var root$5 = from_html(`<div class="ctrl svelte-6hu200"><div class="pagination svelte-6hu200"><button type="button" class="svelte-6hu200">前へ</button> <div class="page svelte-6hu200"><span><input type="number" min="1" aria-label="ページ番号"/></span> <span>/</span> <span> </span></div> <button type="button" class="svelte-6hu200">次へ</button></div> <input type="search" placeholder="検索"/></div> <ul class="list svelte-6hu200"></ul>`, 1);
44178
44241
 
44179
44242
  function File_list($$anchor, $$props) {
44180
- push($$props, false);
44243
+ push($$props, true);
44181
44244
 
44182
44245
  const // On initial mount
44183
44246
  /**
@@ -44201,7 +44264,7 @@ function File_list($$anchor, $$props) {
44201
44264
  var fragment = comment();
44202
44265
  var node = first_child(fragment);
44203
44266
 
44204
- each(node, 3, chars, (char, i) => char + i, ($$anchor, char, i) => {
44267
+ each(node, 19, chars, (char, i) => char + i, ($$anchor, char, i) => {
44205
44268
  var fragment_1 = root_2$1();
44206
44269
  var node_1 = first_child(fragment_1);
44207
44270
 
@@ -44227,43 +44290,45 @@ function File_list($$anchor, $$props) {
44227
44290
  append($$anchor, fragment);
44228
44291
  };
44229
44292
 
44230
- let engine = prop($$props, 'engine', 8);
44231
- let fileType = prop($$props, 'fileType', 8);
44232
- const getFileList = engine().serverAPI.getFileList;
44233
- const deleteFile = engine().serverAPI.deleteFile;
44234
- let fileList = mutable_source([]);
44235
- let selectedPath = mutable_source('');
44236
- let searchWord = mutable_source('');
44237
- let currentPage = mutable_source(0);
44238
- let totalPage = mutable_source(1);
44239
- let uploaded = mutable_source(0);
44240
- let total = mutable_source(100);
44293
+ const getFileList = $$props.engine.serverAPI.getFileList;
44294
+ const deleteFile = $$props.engine.serverAPI.deleteFile;
44295
+ let fileList = state(proxy([]));
44296
+ let selectedPath = state('');
44297
+ let searchWord = state('');
44298
+ let currentPage = state(0);
44299
+ let totalPage = state(1);
44300
+ let uploaded = state(0);
44301
+ let total = state(100);
44241
44302
  let requestDebounce = -1;
44242
44303
 
44243
- engine().componentObserver.on('file-select', async ({ path, isMounted }) => {
44244
- set(selectedPath, path);
44304
+ $$props.engine.componentObserver.on('file-select', async ({ path, isMounted }) => {
44305
+ set(selectedPath, path, true);
44245
44306
 
44246
44307
  if (!isMounted && // On initial mount
44247
44308
  getFileList) {
44248
- const result = await getFileList(fileType(), { filter: '', page: 0, selected: get(selectedPath) });
44309
+ const result = await getFileList($$props.fileType, { filter: '', page: 0, selected: get(selectedPath) });
44249
44310
 
44250
- set(fileList, result.data);
44251
- set(currentPage, result.pagination.current);
44252
- set(totalPage, result.pagination.total);
44311
+ set(fileList, result.data, true);
44312
+ set(currentPage, result.pagination.current, true);
44313
+ set(totalPage, result.pagination.total, true);
44253
44314
  }
44254
44315
 
44255
44316
  if (path.startsWith('blob:')) {
44256
- set(fileList, [
44257
- {
44258
- fileId: '',
44259
- name: '',
44260
- size: 0,
44261
- timestamp: Date.now(),
44262
- url: path,
44263
- sizes: {}
44264
- },
44265
- ...get(fileList).filter((file) => !file.url.startsWith('blob:'))
44266
- ]);
44317
+ set(
44318
+ fileList,
44319
+ [
44320
+ {
44321
+ fileId: '',
44322
+ name: '',
44323
+ size: 0,
44324
+ timestamp: Date.now(),
44325
+ url: path,
44326
+ sizes: {}
44327
+ },
44328
+ ...get(fileList).filter((file) => !file.url.startsWith('blob:'))
44329
+ ],
44330
+ true
44331
+ );
44267
44332
  }
44268
44333
 
44269
44334
  const selectedButton = await awaitUntilFound(() => document.querySelector(`button[aria-pressed="true"]:has(img[src="${path}"])`));
@@ -44273,15 +44338,15 @@ function File_list($$anchor, $$props) {
44273
44338
  }
44274
44339
  });
44275
44340
 
44276
- engine().componentObserver.on('file-upload-progress', (progress) => {
44341
+ $$props.engine.componentObserver.on('file-upload-progress', (progress) => {
44277
44342
  if (progress.blob === get(selectedPath)) {
44278
- set(uploaded, progress.uploaded);
44279
- set(total, progress.total);
44343
+ set(uploaded, progress.uploaded, true);
44344
+ set(total, progress.total, true);
44280
44345
  }
44281
44346
  });
44282
44347
 
44283
- engine().componentObserver.on('file-listup', ({ data }) => {
44284
- set(fileList, data);
44348
+ $$props.engine.componentObserver.on('file-listup', ({ data }) => {
44349
+ set(fileList, data, true);
44285
44350
  });
44286
44351
 
44287
44352
  /**
@@ -44295,17 +44360,17 @@ function File_list($$anchor, $$props) {
44295
44360
  return;
44296
44361
  }
44297
44362
 
44298
- set(currentPage, page);
44363
+ set(currentPage, page, true);
44299
44364
  window.clearTimeout(requestDebounce);
44300
44365
 
44301
44366
  requestDebounce = window.setTimeout(
44302
44367
  async () => {
44303
- const result = await getFileList?.(fileType(), { page });
44368
+ const result = await getFileList?.($$props.fileType, { page });
44304
44369
 
44305
44370
  if (result) {
44306
- set(fileList, result.data);
44307
- set(currentPage, result.pagination.current);
44308
- set(totalPage, result.pagination.total);
44371
+ set(fileList, result.data, true);
44372
+ set(currentPage, result.pagination.current, true);
44373
+ set(totalPage, result.pagination.total, true);
44309
44374
  }
44310
44375
  },
44311
44376
  100
@@ -44321,17 +44386,17 @@ function File_list($$anchor, $$props) {
44321
44386
  return;
44322
44387
  }
44323
44388
 
44324
- set(searchWord, value);
44389
+ set(searchWord, value, true);
44325
44390
  window.clearTimeout(requestDebounce);
44326
44391
 
44327
44392
  requestDebounce = window.setTimeout(
44328
44393
  async () => {
44329
- const result = await getFileList?.(fileType(), { filter: get(searchWord) });
44394
+ const result = await getFileList?.($$props.fileType, { filter: get(searchWord) });
44330
44395
 
44331
44396
  if (result) {
44332
- set(fileList, result.data);
44333
- set(currentPage, result.pagination.current);
44334
- set(totalPage, result.pagination.total);
44397
+ set(fileList, result.data, true);
44398
+ set(currentPage, result.pagination.current, true);
44399
+ set(totalPage, result.pagination.total, true);
44335
44400
  }
44336
44401
  },
44337
44402
  300
@@ -44344,7 +44409,7 @@ function File_list($$anchor, $$props) {
44344
44409
  * @param fileSize
44345
44410
  */
44346
44411
  function selectFile(path, fileSize) {
44347
- engine().componentObserver.notify('file-select', { path, fileSize, isEmpty: false, isMounted: true });
44412
+ $$props.engine.componentObserver.notify('file-select', { path, fileSize, isEmpty: false, isMounted: true });
44348
44413
  }
44349
44414
 
44350
44415
  /**
@@ -44365,9 +44430,7 @@ function File_list($$anchor, $$props) {
44365
44430
  return awaitUntilFound(callback);
44366
44431
  }
44367
44432
 
44368
- init();
44369
-
44370
- var fragment_2 = root$4();
44433
+ var fragment_2 = root$5();
44371
44434
  var div = first_child(fragment_2);
44372
44435
  var div_1 = child(div);
44373
44436
  var button = child(div_1);
@@ -44384,7 +44447,7 @@ function File_list($$anchor, $$props) {
44384
44447
 
44385
44448
  var ul = sibling(div, 2);
44386
44449
 
44387
- each(ul, 5, () => get(fileList), (file) => file.url, ($$anchor, file) => {
44450
+ each(ul, 21, () => get(fileList), (file) => file.url, ($$anchor, file) => {
44388
44451
  var li = root_4$1();
44389
44452
  var button_2 = child(li);
44390
44453
  var span_2 = child(button_2);
@@ -44392,7 +44455,7 @@ function File_list($$anchor, $$props) {
44392
44455
 
44393
44456
  Thumbnail(node_2, {
44394
44457
  get src() {
44395
- return (get(file), untrack(() => get(file).url));
44458
+ return get(file).url;
44396
44459
  }
44397
44460
  });
44398
44461
 
@@ -44403,22 +44466,11 @@ function File_list($$anchor, $$props) {
44403
44466
  var span_3 = root_5$1();
44404
44467
  var span_4 = sibling(child(span_3));
44405
44468
  var text_3 = child(span_4);
44406
-
44407
- template_effect(($0) => set_text(text_3, `${$0 ?? ''}%`), [
44408
- () => (
44409
- get(uploaded),
44410
- get(total),
44411
- untrack(() => Math.floor(get(uploaded) / get(total) * 100))
44412
- )
44413
- ]);
44414
-
44469
+ template_effect(($0) => set_text(text_3, `${$0 ?? ''}%`), [() => Math.floor(get(uploaded) / get(total) * 100)]);
44415
44470
  append($$anchor, span_3);
44416
44471
  };
44417
44472
 
44418
- var d = user_derived(() => (
44419
- get(file),
44420
- untrack(() => get(file).url.startsWith('blob:'))
44421
- ));
44473
+ var d = user_derived(() => get(file).url.startsWith('blob:'));
44422
44474
 
44423
44475
  var alternate = ($$anchor) => {
44424
44476
  var span_5 = root_6$1();
@@ -44426,11 +44478,7 @@ function File_list($$anchor, $$props) {
44426
44478
  var node_4 = child(span_6);
44427
44479
 
44428
44480
  {
44429
- let $0 = derived_safe_equal(() => (
44430
- get(file),
44431
- get(searchWord),
44432
- untrack(() => get(file).fileId.split(get(searchWord)))
44433
- ));
44481
+ let $0 = user_derived(() => get(file).fileId.split(get(searchWord)));
44434
44482
 
44435
44483
  marked(node_4, () => get($0));
44436
44484
  }
@@ -44439,11 +44487,7 @@ function File_list($$anchor, $$props) {
44439
44487
  var node_5 = child(span_7);
44440
44488
 
44441
44489
  {
44442
- let $0 = derived_safe_equal(() => (
44443
- get(file),
44444
- get(searchWord),
44445
- untrack(() => get(file).name.split(get(searchWord)))
44446
- ));
44490
+ let $0 = user_derived(() => get(file).name.split(get(searchWord)));
44447
44491
 
44448
44492
  marked(node_5, () => get($0));
44449
44493
  }
@@ -44460,17 +44504,8 @@ function File_list($$anchor, $$props) {
44460
44504
  set_text(text_5, $1);
44461
44505
  },
44462
44506
  [
44463
- () => (
44464
- deep_read_state(formatDate),
44465
- get(file),
44466
- untrack(() => formatDate(get(file).timestamp / 1000, 'YYYY-MM-DD HH:mm'))
44467
- ),
44468
-
44469
- () => (
44470
- deep_read_state(formatByteSize),
44471
- get(file),
44472
- untrack(() => formatByteSize(get(file).size))
44473
- )
44507
+ () => formatDate(get(file).timestamp / 1000, 'YYYY-MM-DD HH:mm'),
44508
+ () => formatByteSize(get(file).size)
44474
44509
  ]
44475
44510
  );
44476
44511
 
@@ -44488,27 +44523,18 @@ function File_list($$anchor, $$props) {
44488
44523
  var consequent_2 = ($$anchor) => {
44489
44524
  var button_3 = root_7$1();
44490
44525
 
44491
- event('click', button_3, () => deleteFile('image', get(file).url));
44526
+ delegated('click', button_3, () => deleteFile('image', get(file).url));
44492
44527
  append($$anchor, button_3);
44493
44528
  };
44494
44529
 
44495
- var d_1 = user_derived(() => (
44496
- get(file),
44497
- untrack(() => !get(file).url.startsWith('blob:') && deleteFile)
44498
- ));
44530
+ var d_1 = user_derived(() => !get(file).url.startsWith('blob:') && deleteFile);
44499
44531
 
44500
44532
  if_block(node_6, ($$render) => {
44501
44533
  if (get(d_1)) $$render(consequent_2);
44502
44534
  });
44503
44535
  }
44504
-
44505
- template_effect(() => set_attribute(button_2, 'aria-pressed', (
44506
- get(file),
44507
- get(selectedPath),
44508
- untrack(() => get(file).url === get(selectedPath))
44509
- )));
44510
-
44511
- event('click', button_2, () => selectFile(get(file).url, get(file).size));
44536
+ template_effect(() => set_attribute(button_2, 'aria-pressed', get(file).url === get(selectedPath)));
44537
+ delegated('click', button_2, () => selectFile(get(file).url, get(file).size));
44512
44538
  append($$anchor, li);
44513
44539
  });
44514
44540
 
@@ -44521,36 +44547,36 @@ function File_list($$anchor, $$props) {
44521
44547
  set_value(input_1, get(searchWord));
44522
44548
  });
44523
44549
 
44524
- event('click', button, () => paginate(get(currentPage) - 1));
44525
- event('change', input, (e) => paginate(e.currentTarget.valueAsNumber - 1));
44526
- event('click', button_1, () => paginate(get(currentPage) + 1));
44527
- event('input', input_1, (e) => search(e.currentTarget.value));
44550
+ delegated('click', button, () => paginate(get(currentPage) - 1));
44551
+ delegated('change', input, (e) => paginate(e.currentTarget.valueAsNumber - 1));
44552
+ delegated('click', button_1, () => paginate(get(currentPage) + 1));
44553
+ delegated('input', input_1, (e) => search(e.currentTarget.value));
44528
44554
  append($$anchor, fragment_2);
44529
44555
  pop();
44530
44556
  }
44531
44557
 
44532
- var root$3 = from_html(`<div><input type="file" class="svelte-uefuli"/> <button type="button">ファイルを追加アップロードする</button></div>`);
44558
+ delegate(['click', 'change', 'input']);
44559
+
44560
+ var root$4 = from_html(`<div><input type="file" class="svelte-uefuli"/> <button type="button">ファイルを追加アップロードする</button></div>`);
44533
44561
 
44534
44562
  function File_uploader($$anchor, $$props) {
44535
- push($$props, false);
44563
+ push($$props, true);
44536
44564
 
44537
- let engine = prop($$props, 'engine', 8);
44538
- let fileType = prop($$props, 'fileType', 8);
44539
- const accept = fileType() === 'image' ? 'image/*' : '*';
44540
- let inputFile = mutable_source();
44565
+ const accept = $$props.fileType === 'image' ? 'image/*' : '*';
44566
+ let inputFile;
44541
44567
 
44542
44568
  /**
44543
44569
  *
44544
44570
  */
44545
44571
  function openFile() {
44546
- get(inputFile).click();
44572
+ inputFile.click();
44547
44573
  }
44548
44574
 
44549
44575
  /**
44550
44576
  *
44551
44577
  */
44552
44578
  async function stageFile() {
44553
- const file = get(inputFile).files?.[0];
44579
+ const file = inputFile.files?.[0];
44554
44580
 
44555
44581
  if (!file) {
44556
44582
  return;
@@ -44558,40 +44584,54 @@ function File_uploader($$anchor, $$props) {
44558
44584
 
44559
44585
  const path = URL.createObjectURL(file);
44560
44586
 
44561
- engine().componentObserver.notify('file-select', { path, fileSize: file.size, isEmpty: false });
44587
+ $$props.engine.componentObserver.notify('file-select', { path, fileSize: file.size, isEmpty: false });
44562
44588
 
44563
- const res = await engine().serverAPI.postFile?.(fileType(), file, (uploaded, total) => {
44564
- engine().componentObserver.notify('file-upload-progress', { blob: path, uploaded, total });
44589
+ const res = await $$props.engine.serverAPI.postFile?.($$props.fileType, file, (uploaded, total) => {
44590
+ $$props.engine.componentObserver.notify('file-upload-progress', { blob: path, uploaded, total });
44565
44591
  });
44566
44592
 
44567
44593
  if (!res) {
44568
44594
  throw new Error(`Failed to upload file: ${file.name}`);
44569
44595
  }
44570
44596
 
44571
- engine().componentObserver.notify('file-listup', { fileType: fileType(), data: [res.uploaded] });
44597
+ $$props.engine.componentObserver.notify('file-listup', { fileType: $$props.fileType, data: [res.uploaded] });
44572
44598
 
44573
- engine().componentObserver.notify('file-select', {
44599
+ $$props.engine.componentObserver.notify('file-select', {
44574
44600
  path: res.uploaded.url,
44575
44601
  fileSize: res.uploaded.size,
44576
44602
  isEmpty: false
44577
44603
  });
44578
44604
  }
44579
44605
 
44580
- init();
44581
-
44582
- var div = root$3();
44606
+ var div = root$4();
44583
44607
  var input = child(div);
44584
44608
 
44585
- bind_this(input, ($$value) => set(inputFile, $$value), () => get(inputFile));
44609
+ bind_this(input, ($$value) => inputFile = $$value, () => inputFile);
44586
44610
 
44587
44611
  var button = sibling(input, 2);
44588
44612
  template_effect(() => set_attribute(input, 'accept', accept));
44589
- event('change', input, stageFile);
44590
- event('click', button, openFile);
44613
+ delegated('change', input, stageFile);
44614
+ delegated('click', button, openFile);
44591
44615
  append($$anchor, div);
44592
44616
  pop();
44593
44617
  }
44594
44618
 
44619
+ delegate(['change', 'click']);
44620
+
44621
+ var root$3 = from_html(`<button class="insert_after" type="button">下に要素を追加</button>`);
44622
+
44623
+ function Initial_insertion_button($$anchor, $$props) {
44624
+ var button = root$3();
44625
+
44626
+ delegated('click', button, function (...$$args) {
44627
+ $$props.onInsert?.apply(this, $$args);
44628
+ });
44629
+
44630
+ append($$anchor, button);
44631
+ }
44632
+
44633
+ delegate(['click']);
44634
+
44595
44635
  var root_1$2 = from_html(`<img alt="画像プレビュー" class="svelte-1sdkkhr"/>`);
44596
44636
  var root_2 = from_html(`<video controls="" playsinline="" class="svelte-1sdkkhr"><source/> <track kind="captions" src=""/></video>`, 2);
44597
44637
  var root_3 = from_html(`<audio controls="" class="svelte-1sdkkhr"><source/> <track kind="metadata" src=""/></audio>`);
@@ -44604,36 +44644,31 @@ var root_9 = from_html(`<li class="dimension svelte-1sdkkhr"> </li>`);
44604
44644
  var root$2 = from_html(`<div><div><!> <!></div> <ul class="svelte-1sdkkhr"><!> <!></ul></div>`);
44605
44645
 
44606
44646
  function Preview($$anchor, $$props) {
44607
- push($$props, false);
44647
+ push($$props, true);
44608
44648
 
44609
- const isUploadingMode = mutable_source();
44610
- let engine = prop($$props, 'engine', 8);
44611
- let selectedPath = mutable_source('');
44612
- let width = mutable_source(Number.NaN);
44613
- let height = mutable_source(Number.NaN);
44614
- let file = mutable_source(null);
44615
- let uploaded = mutable_source(0);
44616
- let total = mutable_source(100);
44617
-
44618
- engine().componentObserver.on('file-select', ({ path }) => {
44619
- set(selectedPath, path);
44620
- set(file, getExt(path));
44649
+ let selectedPath = state('');
44650
+ let width = state(proxy(Number.NaN));
44651
+ let height = state(proxy(Number.NaN));
44652
+ let file = state(null);
44653
+ let uploaded = state(0);
44654
+ let total = state(100);
44655
+ const isUploadingMode = user_derived(() => get(selectedPath).startsWith('blob:'));
44656
+
44657
+ $$props.engine.componentObserver.on('file-select', ({ path }) => {
44658
+ set(selectedPath, path, true);
44659
+ set(file, getExt(path), true);
44621
44660
  });
44622
44661
 
44623
- engine().componentObserver.on('file-upload-progress', (progress) => {
44662
+ $$props.engine.componentObserver.on('file-upload-progress', (progress) => {
44624
44663
  if (progress.blob === get(selectedPath)) {
44625
- set(uploaded, progress.uploaded);
44626
- set(total, progress.total);
44664
+ set(uploaded, progress.uploaded, true);
44665
+ set(total, progress.total, true);
44627
44666
  }
44628
44667
  });
44629
44668
 
44630
- legacy_pre_effect(() => (get(selectedPath)), () => {
44631
- set(isUploadingMode, get(selectedPath).startsWith('blob:'));
44632
- });
44633
-
44634
- legacy_pre_effect(() => (get(file), get(selectedPath)), () => {
44635
- set(width, Number.NaN);
44636
- set(height, Number.NaN);
44669
+ user_effect(() => {
44670
+ set(width, Number.NaN, true);
44671
+ set(height, Number.NaN, true);
44637
44672
 
44638
44673
  if (get(file)?.isImage) {
44639
44674
  const image = new Image();
@@ -44643,8 +44678,8 @@ function Preview($$anchor, $$props) {
44643
44678
  image.addEventListener(
44644
44679
  'load',
44645
44680
  () => {
44646
- set(width, image.naturalWidth);
44647
- set(height, image.naturalHeight);
44681
+ set(width, image.naturalWidth, true);
44682
+ set(height, image.naturalHeight, true);
44648
44683
  },
44649
44684
  { once: true }
44650
44685
  );
@@ -44656,17 +44691,14 @@ function Preview($$anchor, $$props) {
44656
44691
  video.addEventListener(
44657
44692
  'loadedmetadata',
44658
44693
  () => {
44659
- set(width, video.videoWidth);
44660
- set(height, video.videoHeight);
44694
+ set(width, video.videoWidth, true);
44695
+ set(height, video.videoHeight, true);
44661
44696
  },
44662
44697
  { once: true }
44663
44698
  );
44664
44699
  }
44665
44700
  });
44666
44701
 
44667
- legacy_pre_effect_reset();
44668
- init();
44669
-
44670
44702
  var div = root$2();
44671
44703
  var div_1 = child(div);
44672
44704
  let classes;
@@ -44686,7 +44718,7 @@ function Preview($$anchor, $$props) {
44686
44718
 
44687
44719
  template_effect(() => {
44688
44720
  set_attribute(source, 'src', get(selectedPath));
44689
- set_attribute(source, 'type', (get(file), untrack(() => `video/${get(file).ext}`)));
44721
+ set_attribute(source, 'type', `video/${get(file).ext}`);
44690
44722
  });
44691
44723
 
44692
44724
  append($$anchor, video_1);
@@ -44698,7 +44730,7 @@ function Preview($$anchor, $$props) {
44698
44730
 
44699
44731
  template_effect(() => {
44700
44732
  set_attribute(source_1, 'src', get(selectedPath));
44701
- set_attribute(source_1, 'type', (get(file), untrack(() => `audio/${get(file).ext}`)));
44733
+ set_attribute(source_1, 'type', `audio/${get(file).ext}`);
44702
44734
  });
44703
44735
 
44704
44736
  append($$anchor, audio);
@@ -44709,13 +44741,8 @@ function Preview($$anchor, $$props) {
44709
44741
 
44710
44742
  template_effect(() => {
44711
44743
  set_attribute(object, 'data', get(selectedPath));
44712
-
44713
- set_attribute(object, 'type', (
44714
- get(file),
44715
- untrack(() => `application/${get(file).ext}`)
44716
- ));
44717
-
44718
- set_attribute(object, 'title', (get(file), untrack(() => `${get(file).ext}ファイルのプレビュー`)));
44744
+ set_attribute(object, 'type', `application/${get(file).ext}`);
44745
+ set_attribute(object, 'title', `${get(file).ext}ファイルのプレビュー`);
44719
44746
  });
44720
44747
 
44721
44748
  append($$anchor, object);
@@ -44728,10 +44755,7 @@ function Preview($$anchor, $$props) {
44728
44755
  };
44729
44756
 
44730
44757
  if_block(node, ($$render) => {
44731
- if ((get(file), untrack(() => get(file)?.isImage))) $$render(consequent); else if ((get(file), untrack(() => get(file)?.isVideo))) $$render(consequent_1, 1); else if ((get(file), untrack(() => get(file)?.isAudio))) $$render(consequent_2, 2); else if ((
44732
- get(file),
44733
- untrack(() => get(file)?.isDoc || get(file)?.isPpt || get(file)?.isXls || get(file)?.isPdf)
44734
- )) $$render(consequent_3, 3); else $$render(alternate, false);
44758
+ if (get(file)?.isImage) $$render(consequent); else if (get(file)?.isVideo) $$render(consequent_1, 1); else if (get(file)?.isAudio) $$render(consequent_2, 2); else if (get(file)?.isDoc || get(file)?.isPpt || get(file)?.isXls || get(file)?.isPdf) $$render(consequent_3, 3); else $$render(alternate, false);
44735
44759
  });
44736
44760
  }
44737
44761
 
@@ -44759,15 +44783,7 @@ function Preview($$anchor, $$props) {
44759
44783
  var li = root_7();
44760
44784
  var span = sibling(child(li), 2);
44761
44785
  var text = child(span);
44762
-
44763
- template_effect(($0) => set_text(text, `${$0 ?? ''}% (${get(uploaded) ?? ''}/${get(total) ?? ''})`), [
44764
- () => (
44765
- get(uploaded),
44766
- get(total),
44767
- untrack(() => Math.round(get(uploaded) / get(total) * 100))
44768
- )
44769
- ]);
44770
-
44786
+ template_effect(($0) => set_text(text, `${$0 ?? ''}% (${get(uploaded) ?? ''}/${get(total) ?? ''})`), [() => Math.round(get(uploaded) / get(total) * 100)]);
44771
44787
  append($$anchor, li);
44772
44788
  };
44773
44789
 
@@ -44799,11 +44815,7 @@ function Preview($$anchor, $$props) {
44799
44815
  append($$anchor, li_2);
44800
44816
  };
44801
44817
 
44802
- var d = user_derived(() => (
44803
- get(width),
44804
- get(height),
44805
- untrack(() => !Number.isNaN(get(width)) && !Number.isNaN(get(height)))
44806
- ));
44818
+ var d = user_derived(() => !Number.isNaN(get(width)) && !Number.isNaN(get(height)));
44807
44819
 
44808
44820
  if_block(node_3, ($$render) => {
44809
44821
  if (get(d)) $$render(consequent_6);
@@ -44855,15 +44867,14 @@ var root_1$1 = from_html(`<div class="row svelte-sj6f65"><div class="th"><textar
44855
44867
  var root$1 = from_html(`<div class="table svelte-sj6f65"></div>`);
44856
44868
 
44857
44869
  function Table_editor($$anchor, $$props) {
44858
- push($$props, false);
44870
+ push($$props, true);
44859
44871
 
44860
- let engine = prop($$props, 'engine', 8);
44861
- let table = mutable_source([]);
44872
+ let table = state(proxy([]));
44862
44873
 
44863
- engine().componentObserver.on('open-editor', ({ data }) => {
44874
+ $$props.engine.componentObserver.on('open-editor', ({ data }) => {
44864
44875
  const { th, td } = data;
44865
44876
 
44866
- set(table, th.map((th, i) => [th, td[i] ?? '']));
44877
+ set(table, th.map((th, i) => [th, td[i] ?? '']), true);
44867
44878
  updateDataEl();
44868
44879
  });
44869
44880
 
@@ -44872,7 +44883,7 @@ function Table_editor($$anchor, $$props) {
44872
44883
  * @param index
44873
44884
  */
44874
44885
  function add(index) {
44875
- set(table, get(table).toSpliced(index + 1, 0, ['', '']));
44886
+ set(table, get(table).toSpliced(index + 1, 0, ['', '']), true);
44876
44887
  updateDataEl();
44877
44888
  }
44878
44889
 
@@ -44881,7 +44892,7 @@ function Table_editor($$anchor, $$props) {
44881
44892
  * @param index
44882
44893
  */
44883
44894
  function remove(index) {
44884
- set(table, get(table).toSpliced(index, 1));
44895
+ set(table, get(table).toSpliced(index, 1), true);
44885
44896
  updateDataEl();
44886
44897
  }
44887
44898
 
@@ -44891,11 +44902,11 @@ function Table_editor($$anchor, $$props) {
44891
44902
  * @param to
44892
44903
  */
44893
44904
  function move(from, to) {
44894
- const $from = get(table)[from];
44895
- const $to = get(table)[to];
44905
+ const fromRow = get(table)[from];
44906
+ const toRow = get(table)[to];
44896
44907
 
44897
- set(table, get(table).toSpliced(from, 1, $to));
44898
- set(table, get(table).toSpliced(to, 1, $from));
44908
+ set(table, get(table).toSpliced(from, 1, toRow), true);
44909
+ set(table, get(table).toSpliced(to, 1, fromRow), true);
44899
44910
  updateDataEl();
44900
44911
  }
44901
44912
 
@@ -44905,7 +44916,7 @@ function Table_editor($$anchor, $$props) {
44905
44916
  * based on the provided logic or parameters.
44906
44917
  */
44907
44918
  function updateDataEl() {
44908
- const dataEl = engine().itemEditorDialog.find('[name=bge]');
44919
+ const dataEl = $$props.engine.itemEditorDialog.find('[name=bge]');
44909
44920
 
44910
44921
  if (!dataEl) {
44911
44922
  throw new Error('dataEl not found');
@@ -44919,11 +44930,9 @@ function Table_editor($$anchor, $$props) {
44919
44930
  dataEl.value = JSON.stringify(data);
44920
44931
  }
44921
44932
 
44922
- init();
44923
-
44924
44933
  var div = root$1();
44925
44934
 
44926
- each(div, 5, () => get(table), index, ($$anchor, row, i) => {
44935
+ each(div, 21, () => get(table), index, ($$anchor, row, i) => {
44927
44936
  var div_1 = root_1$1();
44928
44937
  var div_2 = child(div_1);
44929
44938
  var textarea = child(div_2);
@@ -44956,28 +44965,14 @@ function Table_editor($$anchor, $$props) {
44956
44965
  Arrows_transfer_down(node_2, { class: 'icon' });
44957
44966
 
44958
44967
  template_effect(() => {
44959
- button_1.disabled = (get(table), untrack(() => get(table).length === 1));
44960
-
44961
- button_2.disabled = (
44962
- get(table),
44963
- untrack(() => i === get(table).length - 1)
44964
- );
44968
+ button_1.disabled = get(table).length === 1;
44969
+ button_2.disabled = i === get(table).length - 1;
44965
44970
  });
44966
44971
 
44967
44972
  delegated('input', textarea, updateDataEl);
44968
-
44969
- bind_value(textarea, () => get(row)[0], ($$value) => (
44970
- get(row)[0] = $$value,
44971
- invalidate_inner_signals(() => (get(table)))
44972
- ));
44973
-
44973
+ bind_value(textarea, () => get(row)[0], ($$value) => (get(row)[0] = $$value));
44974
44974
  delegated('input', textarea_1, updateDataEl);
44975
-
44976
- bind_value(textarea_1, () => get(row)[1], ($$value) => (
44977
- get(row)[1] = $$value,
44978
- invalidate_inner_signals(() => (get(table)))
44979
- ));
44980
-
44975
+ bind_value(textarea_1, () => get(row)[1], ($$value) => (get(row)[1] = $$value));
44981
44976
  delegated('click', button, () => add(i));
44982
44977
  delegated('click', button_1, () => remove(i));
44983
44978
  delegated('click', button_2, () => move(i, i + 1));
@@ -44993,18 +44988,16 @@ var root_1 = from_html(`<button type="button" role="tab" class="svelte-ruvo7f">
44993
44988
  var root = from_html(`<div role="tablist" class="svelte-ruvo7f"></div>`);
44994
44989
 
44995
44990
  function Tabs($$anchor, $$props) {
44996
- push($$props, false);
44991
+ push($$props, true);
44997
44992
 
44998
- let engine = prop($$props, 'engine', 8);
44999
- let contentId = prop($$props, 'contentId', 8);
45000
- const refs = mutable_source([]);
44993
+ const refs = [];
45001
44994
  let tabPanel = null;
45002
44995
  const length = 2;
45003
- let currentIndex = mutable_source(0);
44996
+ let currentIndex = state(0);
45004
44997
 
45005
- engine().componentObserver.on('select-tab-in-item-editor', ({ index }) => {
45006
- set(currentIndex, index);
45007
- get(refs)[get(currentIndex)]?.focus();
44998
+ $$props.engine.componentObserver.on('select-tab-in-item-editor', ({ index }) => {
44999
+ set(currentIndex, index, true);
45000
+ refs[get(currentIndex)]?.focus();
45008
45001
  });
45009
45002
 
45010
45003
  const onKeyDown = (event) => {
@@ -45034,42 +45027,38 @@ function Tabs($$anchor, $$props) {
45034
45027
  * @param index
45035
45028
  */
45036
45029
  function update(index) {
45037
- set(currentIndex, index);
45038
- get(refs)[get(currentIndex)]?.focus();
45039
- engine().componentObserver.notify('select-tab-in-item-editor', { index: get(currentIndex) });
45030
+ set(currentIndex, index, true);
45031
+ refs[get(currentIndex)]?.focus();
45032
+ $$props.engine.componentObserver.notify('select-tab-in-item-editor', { index: get(currentIndex) });
45040
45033
  tabPanel?.setAttribute('aria-label', createLabel(get(currentIndex)));
45041
45034
  }
45042
45035
 
45043
- onMount(() => {
45044
- tabPanel = document.getElementById(contentId());
45036
+ user_effect(() => {
45037
+ tabPanel = document.getElementById($$props.contentId);
45045
45038
 
45046
45039
  if (!tabPanel) {
45047
45040
  throw new Error('Tab panel not found');
45048
45041
  }
45049
45042
  });
45050
45043
 
45051
- init();
45052
-
45053
45044
  var div = root();
45054
45045
 
45055
- each(div, 5, () => (untrack(() => Array.from({ length }, (_, index) => index))), (index) => index, ($$anchor, index) => {
45046
+ each(div, 20, () => Array.from({ length }, (_, index) => index), (index) => index, ($$anchor, index) => {
45056
45047
  var button = root_1();
45057
45048
  var text = child(button);
45058
- bind_this(button, ($$value, index) => mutate(refs, get(refs)[index] = $$value), (index) => get(refs)?.[index], () => [get(index)]);
45049
+ bind_this(button, ($$value, index) => refs[index] = $$value, (index) => refs?.[index], () => [index]);
45059
45050
 
45060
45051
  template_effect(
45061
45052
  ($0) => {
45062
- set_attribute(button, 'aria-controls', contentId());
45063
- set_attribute(button, 'aria-selected', get(currentIndex) === get(index));
45064
- set_attribute(button, 'tabindex', get(currentIndex) === get(index) ? 0 : -1);
45053
+ set_attribute(button, 'aria-controls', $$props.contentId);
45054
+ set_attribute(button, 'aria-selected', get(currentIndex) === index);
45055
+ set_attribute(button, 'tabindex', get(currentIndex) === index ? 0 : -1);
45065
45056
  set_text(text, $0);
45066
45057
  },
45067
- [
45068
- () => (get(index), untrack(() => createLabel(get(index))))
45069
- ]
45058
+ [() => createLabel(index)]
45070
45059
  );
45071
45060
 
45072
- delegated('click', button, () => onClick(get(index)));
45061
+ delegated('click', button, () => onClick(index));
45073
45062
  delegated('keydown', button, onKeyDown);
45074
45063
  append($$anchor, button);
45075
45064
  });
@@ -45116,7 +45105,7 @@ function parseConfig(config) {
45116
45105
  }
45117
45106
  }
45118
45107
 
45119
- const version = "4.0.0-alpha.60";
45108
+ const version = "4.0.0-alpha.62";
45120
45109
  function attachDraftSwitcher(engine) {
45121
45110
  if (engine.hasDraft()) {
45122
45111
  const container = document.createElement("div");
@@ -45134,13 +45123,27 @@ function attachDraftSwitcher(engine) {
45134
45123
  async function createBurgerEditorClient(options) {
45135
45124
  const engine = await BurgerEditorEngine.new({
45136
45125
  ...options,
45137
- blockMenu: (el, engine2) => {
45138
- return svelteMount(Block_menu, {
45139
- target: el,
45126
+ initialInsertionButton: (container, onInsert) => {
45127
+ return svelteMount(Initial_insertion_button, {
45128
+ target: container,
45129
+ props: {
45130
+ onInsert
45131
+ }
45132
+ });
45133
+ },
45134
+ blockMenu: (container, engine2) => {
45135
+ const { cleanUp } = svelteMount(Block_menu, {
45136
+ target: container,
45140
45137
  props: {
45141
- engine: engine2
45138
+ engine: engine2,
45139
+ container,
45140
+ onHide: () => engine2.clearCurrentBlock()
45142
45141
  }
45143
45142
  });
45143
+ return {
45144
+ hide: () => engine2.clearCurrentBlock(),
45145
+ cleanUp
45146
+ };
45144
45147
  },
45145
45148
  ui: {
45146
45149
  blockCatalog: (el, engine2) => {