scriviamo 1.0.1-beta.16 → 1.0.1-beta.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/dist/addons/scriviamo.attachments.js +1 -0
  3. package/dist/addons/scriviamo.attachments.min.js +1 -1
  4. package/dist/addons/scriviamo.callouts.js +1 -0
  5. package/dist/addons/scriviamo.callouts.min.js +2 -2
  6. package/dist/addons/scriviamo.diagrams.js +1 -0
  7. package/dist/addons/scriviamo.diagrams.min.js +1 -1
  8. package/dist/addons/scriviamo.forms.css +7 -0
  9. package/dist/addons/scriviamo.forms.js +38 -4
  10. package/dist/addons/scriviamo.forms.min.css +1 -1
  11. package/dist/addons/scriviamo.forms.min.js +4 -4
  12. package/dist/addons/scriviamo.gallery.css +15 -0
  13. package/dist/addons/scriviamo.gallery.js +6 -6
  14. package/dist/addons/scriviamo.gallery.min.css +1 -1
  15. package/dist/addons/scriviamo.gallery.min.js +1 -1
  16. package/dist/addons/scriviamo.map.css +6 -0
  17. package/dist/addons/scriviamo.map.js +32 -1
  18. package/dist/addons/scriviamo.map.min.css +1 -1
  19. package/dist/addons/scriviamo.map.min.js +1 -1
  20. package/dist/addons/scriviamo.math.js +1 -0
  21. package/dist/addons/scriviamo.math.min.js +3 -3
  22. package/dist/addons/scriviamo.media.js +30 -0
  23. package/dist/addons/scriviamo.media.min.js +1 -1
  24. package/dist/addons/scriviamo.outline.css +6 -0
  25. package/dist/addons/scriviamo.outline.min.css +1 -1
  26. package/dist/addons/scriviamo.rawcontent.js +1 -0
  27. package/dist/addons/scriviamo.rawcontent.min.js +1 -1
  28. package/dist/addons/scriviamo.steps.js +1 -0
  29. package/dist/addons/scriviamo.steps.min.js +1 -1
  30. package/dist/locales/scriviamo.forms.ar.json +2 -1
  31. package/dist/locales/scriviamo.forms.de.json +2 -1
  32. package/dist/locales/scriviamo.forms.es.json +2 -1
  33. package/dist/locales/scriviamo.forms.fr.json +2 -1
  34. package/dist/locales/scriviamo.forms.it.json +2 -1
  35. package/dist/locales/scriviamo.forms.ja.json +2 -1
  36. package/dist/locales/scriviamo.forms.ko.json +2 -1
  37. package/dist/locales/scriviamo.forms.pt-BR.json +2 -1
  38. package/dist/locales/scriviamo.forms.ru.json +2 -1
  39. package/dist/locales/scriviamo.forms.zh-CN.json +2 -1
  40. package/dist/locales/scriviamo.map.ar.json +2 -1
  41. package/dist/locales/scriviamo.map.de.json +2 -1
  42. package/dist/locales/scriviamo.map.es.json +2 -1
  43. package/dist/locales/scriviamo.map.fr.json +2 -1
  44. package/dist/locales/scriviamo.map.it.json +2 -1
  45. package/dist/locales/scriviamo.map.ja.json +2 -1
  46. package/dist/locales/scriviamo.map.ko.json +2 -1
  47. package/dist/locales/scriviamo.map.pt-BR.json +2 -1
  48. package/dist/locales/scriviamo.map.ru.json +2 -1
  49. package/dist/locales/scriviamo.map.zh-CN.json +2 -1
  50. package/dist/locales/scriviamo.media.ar.json +3 -1
  51. package/dist/locales/scriviamo.media.de.json +3 -1
  52. package/dist/locales/scriviamo.media.es.json +3 -1
  53. package/dist/locales/scriviamo.media.fr.json +3 -1
  54. package/dist/locales/scriviamo.media.it.json +3 -1
  55. package/dist/locales/scriviamo.media.ja.json +3 -1
  56. package/dist/locales/scriviamo.media.ko.json +3 -1
  57. package/dist/locales/scriviamo.media.pt-BR.json +3 -1
  58. package/dist/locales/scriviamo.media.ru.json +3 -1
  59. package/dist/locales/scriviamo.media.zh-CN.json +3 -1
  60. package/dist/scriviamo.css +24 -1
  61. package/dist/scriviamo.js +510 -25
  62. package/dist/scriviamo.min.css +1 -1
  63. package/dist/scriviamo.min.js +41 -41
  64. package/dist/types/addons/attachments/attachmentnode.d.ts +1 -0
  65. package/dist/types/addons/callouts/calloutnodes.d.ts +1 -0
  66. package/dist/types/addons/diagrams/diagramnode.d.ts +1 -0
  67. package/dist/types/addons/forms/formnodes.d.ts +18 -0
  68. package/dist/types/addons/gallery/gallerynode.d.ts +1 -0
  69. package/dist/types/addons/map/mapnode.d.ts +4 -1
  70. package/dist/types/addons/math/mathnode.d.ts +1 -0
  71. package/dist/types/addons/media/medianodes.d.ts +10 -0
  72. package/dist/types/addons/rawcontent/rawcontentnode.d.ts +1 -0
  73. package/dist/types/addons/steps/stepsnode.d.ts +1 -0
  74. package/dist/types/core.d.ts +8 -0
  75. package/dist/types/editor.d.ts +34 -3
  76. package/dist/types/internal.d.ts +1 -0
  77. package/dist/types/node.d.ts +31 -0
  78. package/dist/types/nodes/codeblocknode.d.ts +1 -0
  79. package/dist/types/nodes/dividernode.d.ts +1 -0
  80. package/dist/types/nodes/imagenode.d.ts +5 -0
  81. package/dist/types/nodes/listnode.d.ts +1 -0
  82. package/dist/types/nodes/mediaui.d.ts +7 -0
  83. package/dist/types/nodes/quotenode.d.ts +1 -0
  84. package/dist/types/nodes/tablenode.d.ts +1 -0
  85. package/dist/types/nodes/textnode.d.ts +7 -0
  86. package/dist/types/schema.d.ts +98 -0
  87. package/package.json +1 -1
package/README.md CHANGED
@@ -32,7 +32,7 @@ The add-ons in this package: `attachments`, `callouts`, `dates`, `diagrams`, `di
32
32
 
33
33
  Without a bundler, load the files under `scriviamo/dist/` with an import map that maps
34
34
  `scriviamo` to `dist/scriviamo.js`. They're also on jsDelivr:
35
- `https://cdn.jsdelivr.net/npm/scriviamo@1.0.1-beta.16/dist/scriviamo.js`.
35
+ `https://cdn.jsdelivr.net/npm/scriviamo@1.0.1-beta.17/dist/scriviamo.js`.
36
36
 
37
37
  Components for React, Vue, Angular and any framework: `scriviamo-react`, `scriviamo-vue`,
38
38
  `scriviamo-angular` and `scriviamo-element`, with inspector components for Scriviamo Pro's
@@ -31,6 +31,7 @@ var AttachmentNode = class _AttachmentNode extends Node {
31
31
  }
32
32
  static identifier = "attachment";
33
33
  static caption = "File";
34
+ static captionString = "TextAttachmentCaption";
34
35
  static icon = "bi bi-paperclip";
35
36
  static keywords = "attachment file download upload document pdf zip";
36
37
  /** Any file no other type takes. */
@@ -1 +1 @@
1
- import{Editor as p,InspectorDefaults as g,InspectorEditors as d,InspectorItem as c,MediaUI as m,Node as T,Strings as x,ThemeColors as f,ToolbarItem as b,ToolbarItemKinds as S,ToolbarMenuItem as y,Utilities as a}from"scriviamo";var A={TextAttachmentCaption:"File",TextAttachmentToolbarTooltip:"Attach a File",TextAttachmentNameCaption:"File Name",TextDownloadAttachmentCaption:"Download",TextReplaceAttachmentCaption:"Replace",TextAttachmentAddressPrompt:"File address",TextAttachmentUploadingCaption:"Uploading\u2026",TextAttachmentUnavailableCaption:"This file couldn't be attached."};x.register(A);var w=[[/\.pdf$/i,"bi-file-earmark-pdf"],[/\.(docx?|odt|rtf|pages)$/i,"bi-file-earmark-word"],[/\.(xlsx?|ods|numbers|csv|tsv)$/i,"bi-file-earmark-spreadsheet"],[/\.(pptx?|odp|key)$/i,"bi-file-earmark-slides"],[/\.(zip|tar|gz|tgz|rar|7z|bz2|xz)$/i,"bi-file-earmark-zip"],[/\.(png|jpe?g|gif|webp|svg|heic|avif|bmp|tiff?)$/i,"bi-file-earmark-image"],[/\.(mp3|wav|m4a|aac|ogg|flac)$/i,"bi-file-earmark-music"],[/\.(mp4|mov|webm|mkv|avi)$/i,"bi-file-earmark-play"],[/\.(txt|md|markdown|log)$/i,"bi-file-earmark-text"],[/\.(js|ts|json|html?|css|xml|ya?ml|py|rb|php|java|c|cpp|h|cs|go|rs|swift|sh)$/i,"bi-file-earmark-code"]],u=class o extends T{static exportStyles(e,t){e.addRule(".attachment",`display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid ${p.themeCSS(t,f.border)}; border-radius: 8px`),e.addRule(".attachment a","font-weight: 600; text-decoration: none"),e.addRule(".attachment .attachment-size",`color: ${p.themeCSS(t,f.textMuted)}; font-size: 0.875em`)}static identifier="attachment";static caption="File";static icon="bi bi-paperclip";static keywords="attachment file download upload document pdf zip";static droppedFileTypes=["*"];static droppedFileImportPriority=-100;static importDroppedFile(e,t){let i=new o;return i.fileName=e.name||"",i.fileSize=e.size,i.mimeType=e.type||"",Promise.resolve().then(()=>i.loadFile(e)),i}static importElement(e,t){if(!/^(DIV|P)$/.test(e.tagName)||!e.classList.contains("attachment"))return;let i=e.querySelector("a[href]");if(!i)return;let s=new o;return s.setSource(i.getAttribute("href")||""),s.fileName=i.getAttribute("download")||(i.textContent||"").trim(),s.fileSize=Math.max(0,a.integer(i.dataset.size,0)),s.mimeType=i.getAttribute("type")||"",t.attach(s)}fileName="";fileSize=0;mimeType="";resourceData="";resourceURL="";uploadProgress=-1;get source(){return this.resourceData.length>0?this.resourceData:this.resourceURL}get hasResource(){return this.source.length>0}get displayName(){if(this.fileName.length>0)return this.fileName;if(this.resourceURL.length>0){let e=this.resourceURL.split(/[?#]/)[0],t=decodeURIComponent(e.substring(e.lastIndexOf("/")+1)||"");if(t.length>0)return t}return this.strings.TextAttachmentCaption}get fileIcon(){let e=this.displayName,t=w.find(([i])=>i.test(e));return`bi ${t?t[1]:"bi-file-earmark"}`}static formatSize(e){if(!(e>0))return"";let t=["bytes","KB","MB","GB","TB"],i=0,s=e;for(;s>=1024&&i<t.length-1;)s/=1024,i++;return i==0?`${e} bytes`:`${s<10?s.toFixed(1):Math.round(s)} ${t[i]}`}get details(){let e=this.displayName.includes(".")?this.displayName.substring(this.displayName.lastIndexOf(".")+1).toUpperCase():"";return[e.length>0&&e.length<=5?e:"",o.formatSize(this.fileSize)].filter(t=>t.length>0).join(" \xB7 ")}setSource(e){let t=(e||"").trim();if(t.toLowerCase().startsWith("data:")){this.resourceData=t,this.resourceURL="";let i=t.match(/^data:([^;,]+)/i);i&&this.mimeType.length==0&&(this.mimeType=i[1])}else this.resourceData="",this.resourceURL=t}async loadFile(e){this.uploadProgress=0,this.refresh();try{let t=this.editor?await this.editor.storeFile(e,"file",this,i=>{this.uploadProgress=i;let s=this.element?this.element.querySelector(".scv-attachment-progress > div"):null;s&&(s.style.width=`${Math.round(i*100)}%`)}):await m.readDataURI(e);this.uploadProgress=-1,this.willChange(),typeof e.name=="string"&&e.name.length>0&&(this.fileName=e.name),this.fileSize=e.size,this.mimeType=e.type||this.mimeType,this.setSource(t),this.refresh(),this.changed()}catch(t){this.uploadProgress=-1,this.refresh(),this.editor&&!(t instanceof DOMException&&t.name=="AbortError")&&this.editor.showMessage(this.editor.fileUploader?this.strings.TextUploadFailedMessage:this.strings.TextAttachmentUnavailableCaption,"danger")}}chooseFile(){m.pickFile("",e=>this.loadFile(e))}async enterURL(){if(!this.editor)return;let e=await this.editor.prompt(this.strings.TextAttachmentCaption,[{name:"url",label:this.strings.TextAttachmentAddressPrompt,value:this.resourceURL,type:"url",placeholder:"https://"}]);!e||String(e.url).trim().length==0||(this.willChange(),this.setSource(String(e.url)),this.fileSize=0,this.refresh(),this.changed())}download(){if(!this.hasResource)return;let e=a.element("a","",{href:this.source,download:this.displayName,rel:"noopener"});this.resourceData||(e.target="_blank"),document.body.append(e),e.click(),e.remove()}build(e){if(!this.hasResource&&this.uploadProgress<0){e.append(m.placeholder(this,o.icon,this.strings.TextAttachmentCaption,()=>this.chooseFile(),()=>this.enterURL()));return}let t=a.element("div","scv-attachment",{contenteditable:"false"}),i=a.element("i",`${this.fileIcon} scv-attachment-icon`,{"aria-hidden":"true"}),s=a.element("div","scv-attachment-text"),r=a.element("div","scv-attachment-name");r.textContent=this.displayName;let n=a.element("div","scv-attachment-details");if(n.textContent=this.uploadProgress>=0?this.strings.TextAttachmentUploadingCaption:this.details,s.append(r,n),this.uploadProgress>=0){let l=a.element("div","scv-attachment-progress",{role:"progressbar"}),h=a.element("div","");h.style.width=`${Math.round(this.uploadProgress*100)}%`,l.append(h),s.append(l)}if(t.append(i,s),this.hasResource){let l=a.element("button","btn btn-sm btn-outline-secondary scv-attachment-download",{type:"button",title:this.strings.TextDownloadAttachmentCaption,"aria-label":`${this.strings.TextDownloadAttachmentCaption} ${this.displayName}`});l.innerHTML='<i class="bi bi-download" aria-hidden="true"></i>',l.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),this.download()}),t.append(l)}e.append(t)}inspectorSections(){let e=this.strings,t=c.bound("filename",e.TextAttachmentNameCaption,d.text,r=>r.fileName,(r,n)=>r.fileName=String(n||"").trim());t.updatesLive=!1;let i=c.bound("localfile",e.TextLocalFileCaption,d.file,r=>r.resourceData.length>0?"data":"",(r,n)=>{typeof n=="string"&&n.startsWith("data:")&&r.setSource(n)}),s=c.bound("url",e.TextURLCaption,d.text,r=>r.resourceURL,(r,n)=>{let l=String(n||"").trim();l.length>0&&r.setSource(l)});return s.updatesLive=!1,[g.section("attachment",e.TextAttachmentCaption,[t,i,s])].concat(g.node(this,{appearance:!1,backgroundImage:!1}))}actions(){let e=new b("download",this.strings.TextDownloadAttachmentCaption,"bi bi-download");e.enabled=this.hasResource;let t=new b("replace",this.strings.TextReplaceAttachmentCaption,"bi bi-arrow-repeat",S.menu);return t.menuItems.push(new y("file",this.strings.TextChooseLocalFileCaption,"bi bi-folder2-open")),t.menuItems.push(new y("url",this.strings.TextEnterURLCaption,"bi bi-link-45deg")),[e,t]}performAction(e,t){return e.identifier=="download"?(this.download(),!0):e.identifier=="replace"&&t?(t.identifier=="file"&&this.chooseFile(),t.identifier=="url"&&this.enterURL(),!0):!1}toJSON(){let e=super.toJSON();return this.fileName.length>0&&(e.fileName=this.fileName),this.fileSize>0&&(e.fileSize=this.fileSize),this.mimeType.length>0&&(e.mimeType=this.mimeType),e.resourceURL=this.resourceURL,this.resourceData.length>0&&(e.resourceData=this.resourceData),e}fromJSON(e){if(!super.fromJSON(e))return!1;this.fileName=a.string(e.fileName),this.fileSize=Math.max(0,a.integer(e.fileSize,0)),this.mimeType=a.string(e.mimeType),this.resourceData="",this.resourceURL="";let t=a.string(e.resourceData).trim();return this.setSource(t.length>0?t:a.string(e.resourceURL)),!0}toHTML(){let e=o.formatSize(this.fileSize),t=this.mimeType.length>0?` type="${a.escapeAttribute(this.mimeType)}"`:"",i=this.fileSize>0?` data-size="${this.fileSize}"`:"";return`<div class="attachment" style="${this.htmlBackgroundCSS()}"><a href="${a.escapeAttribute(this.source)}" download="${a.escapeAttribute(this.displayName)}"${t}${i}>${a.escapeText(this.displayName)}</a>${e.length>0?` <span class="attachment-size">(${e})</span>`:""}</div>`}toMarkdown(){let e=o.formatSize(this.fileSize);return`[${this.displayName.replace(/([\[\]\\])/g,"\\$1")}](${this.source.replace(/ /g,"%20").replace(/\)/g,"%29")})${e.length>0?` (${e})`:""}`}toPlainText(){let e=o.formatSize(this.fileSize);return e.length>0?`${this.displayName} (${e})`:this.displayName}};p.registerNodeType(u,115);export{u as AttachmentNode};
1
+ import{Editor as p,InspectorDefaults as g,InspectorEditors as c,InspectorItem as d,MediaUI as m,Node as y,Strings as x,ThemeColors as f,ToolbarItem as b,ToolbarItemKinds as S,ToolbarMenuItem as T,Utilities as a}from"scriviamo";var A={TextAttachmentCaption:"File",TextAttachmentToolbarTooltip:"Attach a File",TextAttachmentNameCaption:"File Name",TextDownloadAttachmentCaption:"Download",TextReplaceAttachmentCaption:"Replace",TextAttachmentAddressPrompt:"File address",TextAttachmentUploadingCaption:"Uploading\u2026",TextAttachmentUnavailableCaption:"This file couldn't be attached."};x.register(A);var w=[[/\.pdf$/i,"bi-file-earmark-pdf"],[/\.(docx?|odt|rtf|pages)$/i,"bi-file-earmark-word"],[/\.(xlsx?|ods|numbers|csv|tsv)$/i,"bi-file-earmark-spreadsheet"],[/\.(pptx?|odp|key)$/i,"bi-file-earmark-slides"],[/\.(zip|tar|gz|tgz|rar|7z|bz2|xz)$/i,"bi-file-earmark-zip"],[/\.(png|jpe?g|gif|webp|svg|heic|avif|bmp|tiff?)$/i,"bi-file-earmark-image"],[/\.(mp3|wav|m4a|aac|ogg|flac)$/i,"bi-file-earmark-music"],[/\.(mp4|mov|webm|mkv|avi)$/i,"bi-file-earmark-play"],[/\.(txt|md|markdown|log)$/i,"bi-file-earmark-text"],[/\.(js|ts|json|html?|css|xml|ya?ml|py|rb|php|java|c|cpp|h|cs|go|rs|swift|sh)$/i,"bi-file-earmark-code"]],u=class o extends y{static exportStyles(e,t){e.addRule(".attachment",`display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid ${p.themeCSS(t,f.border)}; border-radius: 8px`),e.addRule(".attachment a","font-weight: 600; text-decoration: none"),e.addRule(".attachment .attachment-size",`color: ${p.themeCSS(t,f.textMuted)}; font-size: 0.875em`)}static identifier="attachment";static caption="File";static captionString="TextAttachmentCaption";static icon="bi bi-paperclip";static keywords="attachment file download upload document pdf zip";static droppedFileTypes=["*"];static droppedFileImportPriority=-100;static importDroppedFile(e,t){let i=new o;return i.fileName=e.name||"",i.fileSize=e.size,i.mimeType=e.type||"",Promise.resolve().then(()=>i.loadFile(e)),i}static importElement(e,t){if(!/^(DIV|P)$/.test(e.tagName)||!e.classList.contains("attachment"))return;let i=e.querySelector("a[href]");if(!i)return;let s=new o;return s.setSource(i.getAttribute("href")||""),s.fileName=i.getAttribute("download")||(i.textContent||"").trim(),s.fileSize=Math.max(0,a.integer(i.dataset.size,0)),s.mimeType=i.getAttribute("type")||"",t.attach(s)}fileName="";fileSize=0;mimeType="";resourceData="";resourceURL="";uploadProgress=-1;get source(){return this.resourceData.length>0?this.resourceData:this.resourceURL}get hasResource(){return this.source.length>0}get displayName(){if(this.fileName.length>0)return this.fileName;if(this.resourceURL.length>0){let e=this.resourceURL.split(/[?#]/)[0],t=decodeURIComponent(e.substring(e.lastIndexOf("/")+1)||"");if(t.length>0)return t}return this.strings.TextAttachmentCaption}get fileIcon(){let e=this.displayName,t=w.find(([i])=>i.test(e));return`bi ${t?t[1]:"bi-file-earmark"}`}static formatSize(e){if(!(e>0))return"";let t=["bytes","KB","MB","GB","TB"],i=0,s=e;for(;s>=1024&&i<t.length-1;)s/=1024,i++;return i==0?`${e} bytes`:`${s<10?s.toFixed(1):Math.round(s)} ${t[i]}`}get details(){let e=this.displayName.includes(".")?this.displayName.substring(this.displayName.lastIndexOf(".")+1).toUpperCase():"";return[e.length>0&&e.length<=5?e:"",o.formatSize(this.fileSize)].filter(t=>t.length>0).join(" \xB7 ")}setSource(e){let t=(e||"").trim();if(t.toLowerCase().startsWith("data:")){this.resourceData=t,this.resourceURL="";let i=t.match(/^data:([^;,]+)/i);i&&this.mimeType.length==0&&(this.mimeType=i[1])}else this.resourceData="",this.resourceURL=t}async loadFile(e){this.uploadProgress=0,this.refresh();try{let t=this.editor?await this.editor.storeFile(e,"file",this,i=>{this.uploadProgress=i;let s=this.element?this.element.querySelector(".scv-attachment-progress > div"):null;s&&(s.style.width=`${Math.round(i*100)}%`)}):await m.readDataURI(e);this.uploadProgress=-1,this.willChange(),typeof e.name=="string"&&e.name.length>0&&(this.fileName=e.name),this.fileSize=e.size,this.mimeType=e.type||this.mimeType,this.setSource(t),this.refresh(),this.changed()}catch(t){this.uploadProgress=-1,this.refresh(),this.editor&&!(t instanceof DOMException&&t.name=="AbortError")&&this.editor.showMessage(this.editor.fileUploader?this.strings.TextUploadFailedMessage:this.strings.TextAttachmentUnavailableCaption,"danger")}}chooseFile(){m.pickFile("",e=>this.loadFile(e))}async enterURL(){if(!this.editor)return;let e=await this.editor.prompt(this.strings.TextAttachmentCaption,[{name:"url",label:this.strings.TextAttachmentAddressPrompt,value:this.resourceURL,type:"url",placeholder:"https://"}]);!e||String(e.url).trim().length==0||(this.willChange(),this.setSource(String(e.url)),this.fileSize=0,this.refresh(),this.changed())}download(){if(!this.hasResource)return;let e=a.element("a","",{href:this.source,download:this.displayName,rel:"noopener"});this.resourceData||(e.target="_blank"),document.body.append(e),e.click(),e.remove()}build(e){if(!this.hasResource&&this.uploadProgress<0){e.append(m.placeholder(this,o.icon,this.strings.TextAttachmentCaption,()=>this.chooseFile(),()=>this.enterURL()));return}let t=a.element("div","scv-attachment",{contenteditable:"false"}),i=a.element("i",`${this.fileIcon} scv-attachment-icon`,{"aria-hidden":"true"}),s=a.element("div","scv-attachment-text"),r=a.element("div","scv-attachment-name");r.textContent=this.displayName;let n=a.element("div","scv-attachment-details");if(n.textContent=this.uploadProgress>=0?this.strings.TextAttachmentUploadingCaption:this.details,s.append(r,n),this.uploadProgress>=0){let l=a.element("div","scv-attachment-progress",{role:"progressbar"}),h=a.element("div","");h.style.width=`${Math.round(this.uploadProgress*100)}%`,l.append(h),s.append(l)}if(t.append(i,s),this.hasResource){let l=a.element("button","btn btn-sm btn-outline-secondary scv-attachment-download",{type:"button",title:this.strings.TextDownloadAttachmentCaption,"aria-label":`${this.strings.TextDownloadAttachmentCaption} ${this.displayName}`});l.innerHTML='<i class="bi bi-download" aria-hidden="true"></i>',l.addEventListener("click",h=>{h.preventDefault(),h.stopPropagation(),this.download()}),t.append(l)}e.append(t)}inspectorSections(){let e=this.strings,t=d.bound("filename",e.TextAttachmentNameCaption,c.text,r=>r.fileName,(r,n)=>r.fileName=String(n||"").trim());t.updatesLive=!1;let i=d.bound("localfile",e.TextLocalFileCaption,c.file,r=>r.resourceData.length>0?"data":"",(r,n)=>{typeof n=="string"&&n.startsWith("data:")&&r.setSource(n)}),s=d.bound("url",e.TextURLCaption,c.text,r=>r.resourceURL,(r,n)=>{let l=String(n||"").trim();l.length>0&&r.setSource(l)});return s.updatesLive=!1,[g.section("attachment",e.TextAttachmentCaption,[t,i,s])].concat(g.node(this,{appearance:!1,backgroundImage:!1}))}actions(){let e=new b("download",this.strings.TextDownloadAttachmentCaption,"bi bi-download");e.enabled=this.hasResource;let t=new b("replace",this.strings.TextReplaceAttachmentCaption,"bi bi-arrow-repeat",S.menu);return t.menuItems.push(new T("file",this.strings.TextChooseLocalFileCaption,"bi bi-folder2-open")),t.menuItems.push(new T("url",this.strings.TextEnterURLCaption,"bi bi-link-45deg")),[e,t]}performAction(e,t){return e.identifier=="download"?(this.download(),!0):e.identifier=="replace"&&t?(t.identifier=="file"&&this.chooseFile(),t.identifier=="url"&&this.enterURL(),!0):!1}toJSON(){let e=super.toJSON();return this.fileName.length>0&&(e.fileName=this.fileName),this.fileSize>0&&(e.fileSize=this.fileSize),this.mimeType.length>0&&(e.mimeType=this.mimeType),e.resourceURL=this.resourceURL,this.resourceData.length>0&&(e.resourceData=this.resourceData),e}fromJSON(e){if(!super.fromJSON(e))return!1;this.fileName=a.string(e.fileName),this.fileSize=Math.max(0,a.integer(e.fileSize,0)),this.mimeType=a.string(e.mimeType),this.resourceData="",this.resourceURL="";let t=a.string(e.resourceData).trim();return this.setSource(t.length>0?t:a.string(e.resourceURL)),!0}toHTML(){let e=o.formatSize(this.fileSize),t=this.mimeType.length>0?` type="${a.escapeAttribute(this.mimeType)}"`:"",i=this.fileSize>0?` data-size="${this.fileSize}"`:"";return`<div class="attachment" style="${this.htmlBackgroundCSS()}"><a href="${a.escapeAttribute(this.source)}" download="${a.escapeAttribute(this.displayName)}"${t}${i}>${a.escapeText(this.displayName)}</a>${e.length>0?` <span class="attachment-size">(${e})</span>`:""}</div>`}toMarkdown(){let e=o.formatSize(this.fileSize);return`[${this.displayName.replace(/([\[\]\\])/g,"\\$1")}](${this.source.replace(/ /g,"%20").replace(/\)/g,"%29")})${e.length>0?` (${e})`:""}`}toPlainText(){let e=o.formatSize(this.fileSize);return e.length>0?`${this.displayName} (${e})`:this.displayName}};p.registerNodeType(u,115);export{u as AttachmentNode};
@@ -27,6 +27,7 @@ var AlertNode = class _AlertNode extends TextNode {
27
27
  }
28
28
  static identifier = "alert";
29
29
  static caption = "Alert";
30
+ static captionString = "TextAlertInspectorCaption";
30
31
  static icon = "bi bi-exclamation-triangle";
31
32
  static keywords = "callout note tip warning caution info danger success";
32
33
  static typeNames = ["info", "success", "warning", "danger"];
@@ -1,3 +1,3 @@
1
- import{Editor as i,InspectorDefaults as p,InspectorItem as g,Strings as T,TextHost as h,TextHostModes as u,TextNode as d,ThemeColors as s,ToolbarItem as m,ToolbarItemKinds as y,ToolbarMenuItem as x,Utilities as l}from"scriviamo";var C={TextAlertInspectorCaption:"Alert",TextInfoCaption:"Info",TextSuccessCaption:"Success",TextWarningCaption:"Warning",TextDangerCaption:"Danger",TextAddAlertCaption:"Add Alert",TextAlertTypeCaption:"Alert Type"};T.register(C);var f=(r=>(r[r.info=0]="info",r[r.success=1]="success",r[r.warning=2]="warning",r[r.danger=3]="danger",r))(f||{}),o=class a extends d{static exportStyles(e,t){super.exportStyles(e,t),e.addRule(".alert",`padding: 16px; border-inline-start: 4px solid ${i.themeCSS(t,s.information)}; background: ${i.themeCSS(t,s.information,220)}`),e.addRule(".alert-success",`border-inline-start-color: ${i.themeCSS(t,s.success)}; background: ${i.themeCSS(t,s.success,220)}`),e.addRule(".alert-warning",`border-inline-start-color: ${i.themeCSS(t,s.warning)}; background: ${i.themeCSS(t,s.warning,220)}`),e.addRule(".alert-danger",`border-inline-start-color: ${i.themeCSS(t,s.danger)}; background: ${i.themeCSS(t,s.danger,220)}`)}static identifier="alert";static caption="Alert";static icon="bi bi-exclamation-triangle";static keywords="callout note tip warning caution info danger success";static typeNames=["info","success","warning","danger"];static typeIcons=["bi bi-info-circle-fill","bi bi-check-circle-fill","bi bi-exclamation-triangle-fill","bi bi-x-octagon-fill"];static blockKinds(e,t){return[["alert:0",e.TextAlertInspectorCaption,"bi bi-info-circle"]]}static fromBlockContent(e,t,n){e.alertType=t;let r=super.fromBlockContent(e,t,n);return r[0].alertType=t,r}static importElement(e,t){if(e.tagName!="BLOCKQUOTE"&&e.tagName!="ASIDE")return;let n=(e.className||"").match(/alert-(info|success|warning|danger)/);if(!n)return;let r=new a;return r.alertType=a.typeNames.indexOf(n[1]),r.content=t.trimmed(t.richText(Array.from(e.childNodes))),r.content.alertType=a.typeNames.indexOf(n[1]),t.attach(r)}get blockKind(){return`alert:${this.alertType}`}convertBlock(e,t){return e!="alert"||this.alertType==t?super.convertBlock(e,t):(this.alertType=t,[this])}inspectorSections(){let e=this.strings,t=g.menu("alerttype",e.TextTypeCaption,[[e.TextInfoCaption,0],[e.TextSuccessCaption,1],[e.TextWarningCaption,2],[e.TextDangerCaption,3]],n=>n.alertType,(n,r)=>n.alertType=r);return t.setDefaultValue(0),[p.section("alert",e.TextAlertInspectorCaption,[t])].concat(p.text(this))}get alertType(){return l.clamp(this.content.alertType,0,3)}set alertType(e){this.content.alertType=l.clamp(e,0,3)}get placeholderText(){return this.typeCaption(this.alertType)}typeCaption(e){return[this.strings.TextInfoCaption,this.strings.TextSuccessCaption,this.strings.TextWarningCaption,this.strings.TextDangerCaption][e]}build(e){let t=l.element("div",`alert alert-${a.typeNames[this.alertType]} scv-alert mb-0`,{role:"note"});e.append(t);let n=l.element("i",`${a.typeIcons[this.alertType]} scv-alert-icon`,{contenteditable:"false"});t.append(n);let r=l.element("div","scv-alert-text");t.append(r);let c=this.addHost(new h(this,this.content,r,u.inline));c.placeholder=this.placeholderText,this.applyTextAppearance(r),c.render()}actions(){let e=new m("alerttype",this.typeCaption(this.alertType),a.typeIcons[this.alertType],y.menu,this.strings.TextAlertInspectorCaption);e.alwaysShowCaption=!0;for(let t=0;t<=3;t++){let n=new x(String(t),this.typeCaption(t),a.typeIcons[t]);n.checked=t==this.alertType,e.menuItems.push(n)}return[e]}performAction(e,t){return e.identifier=="alerttype"&&t?(this.willChange(),this.alertType=Number(t.identifier),this.refresh(),this.changed(),!0):!1}createFollowingNode(){return new d}toHTML(){return`<aside class="alert alert-${a.typeNames[this.alertType]}" style="${this.htmlBackgroundCSS()}${this.htmlTextAlignmentCSS()}${this.htmlLineHeightCSS()}">${this.content.htmlText()}</aside>`}toMarkdown(){let e=this.content.markdownText().replace(/\r/g,"").split(`
1
+ import{Editor as i,InspectorDefaults as p,InspectorItem as g,Strings as T,TextHost as h,TextHostModes as u,TextNode as d,ThemeColors as s,ToolbarItem as m,ToolbarItemKinds as y,ToolbarMenuItem as x,Utilities as o}from"scriviamo";var C={TextAlertInspectorCaption:"Alert",TextInfoCaption:"Info",TextSuccessCaption:"Success",TextWarningCaption:"Warning",TextDangerCaption:"Danger",TextAddAlertCaption:"Add Alert",TextAlertTypeCaption:"Alert Type"};T.register(C);var f=(r=>(r[r.info=0]="info",r[r.success=1]="success",r[r.warning=2]="warning",r[r.danger=3]="danger",r))(f||{}),l=class a extends d{static exportStyles(e,t){super.exportStyles(e,t),e.addRule(".alert",`padding: 16px; border-inline-start: 4px solid ${i.themeCSS(t,s.information)}; background: ${i.themeCSS(t,s.information,220)}`),e.addRule(".alert-success",`border-inline-start-color: ${i.themeCSS(t,s.success)}; background: ${i.themeCSS(t,s.success,220)}`),e.addRule(".alert-warning",`border-inline-start-color: ${i.themeCSS(t,s.warning)}; background: ${i.themeCSS(t,s.warning,220)}`),e.addRule(".alert-danger",`border-inline-start-color: ${i.themeCSS(t,s.danger)}; background: ${i.themeCSS(t,s.danger,220)}`)}static identifier="alert";static caption="Alert";static captionString="TextAlertInspectorCaption";static icon="bi bi-exclamation-triangle";static keywords="callout note tip warning caution info danger success";static typeNames=["info","success","warning","danger"];static typeIcons=["bi bi-info-circle-fill","bi bi-check-circle-fill","bi bi-exclamation-triangle-fill","bi bi-x-octagon-fill"];static blockKinds(e,t){return[["alert:0",e.TextAlertInspectorCaption,"bi bi-info-circle"]]}static fromBlockContent(e,t,n){e.alertType=t;let r=super.fromBlockContent(e,t,n);return r[0].alertType=t,r}static importElement(e,t){if(e.tagName!="BLOCKQUOTE"&&e.tagName!="ASIDE")return;let n=(e.className||"").match(/alert-(info|success|warning|danger)/);if(!n)return;let r=new a;return r.alertType=a.typeNames.indexOf(n[1]),r.content=t.trimmed(t.richText(Array.from(e.childNodes))),r.content.alertType=a.typeNames.indexOf(n[1]),t.attach(r)}get blockKind(){return`alert:${this.alertType}`}convertBlock(e,t){return e!="alert"||this.alertType==t?super.convertBlock(e,t):(this.alertType=t,[this])}inspectorSections(){let e=this.strings,t=g.menu("alerttype",e.TextTypeCaption,[[e.TextInfoCaption,0],[e.TextSuccessCaption,1],[e.TextWarningCaption,2],[e.TextDangerCaption,3]],n=>n.alertType,(n,r)=>n.alertType=r);return t.setDefaultValue(0),[p.section("alert",e.TextAlertInspectorCaption,[t])].concat(p.text(this))}get alertType(){return o.clamp(this.content.alertType,0,3)}set alertType(e){this.content.alertType=o.clamp(e,0,3)}get placeholderText(){return this.typeCaption(this.alertType)}typeCaption(e){return[this.strings.TextInfoCaption,this.strings.TextSuccessCaption,this.strings.TextWarningCaption,this.strings.TextDangerCaption][e]}build(e){let t=o.element("div",`alert alert-${a.typeNames[this.alertType]} scv-alert mb-0`,{role:"note"});e.append(t);let n=o.element("i",`${a.typeIcons[this.alertType]} scv-alert-icon`,{contenteditable:"false"});t.append(n);let r=o.element("div","scv-alert-text");t.append(r);let c=this.addHost(new h(this,this.content,r,u.inline));c.placeholder=this.placeholderText,this.applyTextAppearance(r),c.render()}actions(){let e=new m("alerttype",this.typeCaption(this.alertType),a.typeIcons[this.alertType],y.menu,this.strings.TextAlertInspectorCaption);e.alwaysShowCaption=!0;for(let t=0;t<=3;t++){let n=new x(String(t),this.typeCaption(t),a.typeIcons[t]);n.checked=t==this.alertType,e.menuItems.push(n)}return[e]}performAction(e,t){return e.identifier=="alerttype"&&t?(this.willChange(),this.alertType=Number(t.identifier),this.refresh(),this.changed(),!0):!1}createFollowingNode(){return new d}toHTML(){return`<aside class="alert alert-${a.typeNames[this.alertType]}" style="${this.htmlBackgroundCSS()}${this.htmlTextAlignmentCSS()}${this.htmlLineHeightCSS()}">${this.content.htmlText()}</aside>`}toMarkdown(){let e=this.content.markdownText().replace(/\r/g,"").split(`
2
2
  `);return e.unshift(["[!NOTE]","[!TIP]","[!WARNING]","[!CAUTION]"][this.alertType]),this.markdownWithBackground(e.map(t=>`> ${t}`).join(`
3
- `))}};i.registerNodeType(o,50);export{o as AlertNode,f as AlertTypes};
3
+ `))}};i.registerNodeType(l,50);export{l as AlertNode,f as AlertTypes};
@@ -102,6 +102,7 @@ var DiagramNode = class _DiagramNode extends CodeBlockNode {
102
102
  }
103
103
  static identifier = "diagram";
104
104
  static caption = "Diagram";
105
+ static captionString = "TextDiagramCaption";
105
106
  static icon = "bi bi-diagram-3";
106
107
  static keywords = "mermaid flowchart chart graph sequence gantt";
107
108
  // Higher than code blocks, so <pre><code class="language-mermaid"> becomes a diagram.
@@ -1,3 +1,3 @@
1
- import{CodeBlockNode as h,Editor as p,InspectorDefaults as c,InspectorEditors as f,InspectorItem as g,RichText as l,Strings as T,Utilities as d}from"scriviamo";var v={TextDiagramCaption:"Diagram",TextDiagramSourceCaption:"Mermaid",TextDiagramRedrawCaption:"Redraw",TextDiagramPlaceholder:"A Mermaid diagram, such as: graph LR; A --> B",TextDiagramLoadingCaption:"Drawing the diagram\u2026",TextDiagramUnavailableMessage:"The diagram renderer couldn't be loaded."};T.register(v);var o=class e{static moduleURL="https://cdn.jsdelivr.net/npm/mermaid@11.4.1/dist/mermaid.esm.min.mjs";static settings={securityLevel:"strict"};static themes={light:"default",dark:"dark"};static#t=null;static#r=null;static#e="";static#i=0;static use(t){e.#t=t&&typeof t.render=="function"?t:null,e.#r=null,e.#e=""}static get mermaid(){if(!e.#t){let t=globalThis.mermaid;t&&typeof t.render=="function"&&(e.#t=t)}return e.#t}static load(){if(e.mermaid)return Promise.resolve(e.mermaid);if(!e.#r){let t=e.moduleURL;e.#r=import(t).then(r=>{let i=r.default||r;return e.#t=i,i},r=>{throw e.#r=null,r})}return e.#r}static async render(t,r=!1){let i=await e.load(),a=String(e.settings.theme||(r?e.themes.dark:e.themes.light));e.#e!=a&&typeof i.initialize=="function"&&(i.initialize({startOnLoad:!1,...e.settings,theme:a}),e.#e=a);let s=`scv-diagram-${++e.#i}`;try{let n=await i.render(s,t);return String(n&&typeof n=="object"?n.svg:n||"")}finally{typeof document<"u"&&document.getElementById(`d${s}`)?.remove()}}},u=class e{static#t=new Set;static#r=null;static watch(t){e.#t.add(t),!(e.#r||typeof MutationObserver>"u"||typeof document>"u")&&(e.#r=new MutationObserver(()=>e.#e()),e.#r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-bs-theme"],subtree:!0}))}static#e(){for(let t of Array.from(e.#t))t.isShown?t.drawnForOtherTheme&&t.redraw():e.#t.delete(t)}},m=class e extends h{static exportStyles(t,r){super.exportStyles(t,r),t.addRule("figure.diagram","margin: 1em 0; overflow-x: auto; text-align: center"),t.addRule("figure.diagram svg","max-width: 100%; height: auto")}static identifier="diagram";static caption="Diagram";static icon="bi bi-diagram-3";static keywords="mermaid flowchart chart graph sequence gantt";static importPriority=50;static markdownShortcuts=[{pattern:/^```mermaid$/}];static create(t){return new e}static importElement(t,r){let i=null;if(t.tagName=="PRE"){let s=t.querySelector("code");/(^|\s)mermaid(\s|$)/.test(t.className||"")?i=t.textContent||"":s&&/(^|\s)language-mermaid(\s|$)/.test(s.className||"")&&(i=s.textContent||"")}else t.hasAttribute("data-mermaid")&&(i=t.getAttribute("data-mermaid"));if(i===null)return;let a=new e;return a.content=new l(i.replace(/\n$/,"")),r.attach(a)}#t=null;#r=null;#e=null;#i=0;get isShown(){return!!this.#t&&this.#t.isConnected}get drawnForOtherTheme(){return!!this.#t&&!!this.#e&&this.#e.dark!=this.#s(this.#t)}#s(t){return(this.editor&&this.editor.element||t).closest("[data-bs-theme]")?.getAttribute("data-bs-theme")=="dark"}get source(){return this.content.text}set source(t){this.content=new l(String(t||""))}get svg(){return this.#e&&this.#e.source==this.source.trim()?this.#e.svg:""}get typeName(){return this.strings.TextDiagramCaption}get placeholderText(){return this.strings.TextDiagramPlaceholder}inspectorSections(){let t=this.strings,r=g.bound("source",t.TextDiagramSourceCaption,f.multilineText,a=>a.content.text,(a,s)=>a.content=new l(String(s||""))),i=g.actionItem("redraw","",t.TextDiagramRedrawCaption,a=>a.redraw());return[c.section("diagram",t.TextDiagramCaption,[r,i])].concat(c.node(this))}build(t){super.build(t),t.querySelector(".scv-code")?.classList.add("scv-diagram-source");let r=t.querySelector(".scv-code-language");r&&(r.value=this.strings.TextDiagramSourceCaption,r.readOnly=!0,r.removeAttribute("list")),this.#t=d.element("div","scv-diagram-output",{contenteditable:"false"}),t.prepend(this.#t),t.classList.add("scv-diagram"),u.watch(this),this.#a()}textChanged(t){super.textChanged(t),this.#r!==null&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.#a()},400)}redraw(){return this.#a()}async#a(){let t=this.#t;if(!t)return;let r=this.source.trim(),i=++this.#i;if(t.parentElement?.classList.toggle("scv-diagram-empty",r.length==0),r.length==0){t.replaceChildren();return}let a=this.#s(t);if(this.#e&&this.#e.source==r&&this.#e.dark==a){t.innerHTML=this.#e.svg,t.className="scv-diagram-output";return}!o.mermaid&&t.childElementCount==0&&(t.textContent=this.strings.TextDiagramLoadingCaption,t.className="scv-diagram-output scv-diagram-pending");try{let s=await o.render(r,a);if(i!=this.#i||this.#t!==t)return;this.#e={source:r,svg:s,dark:a},t.innerHTML=s,t.className="scv-diagram-output"}catch(s){if(i!=this.#i||this.#t!==t)return;let n=!!o.mermaid;t.textContent=n?String(s?.message||s).trim():this.strings.TextDiagramUnavailableMessage,t.className="scv-diagram-output scv-diagram-error"}}fromJSON(t){return super.fromJSON(t)?(this.language="",!0):!1}toJSON(){let t=super.toJSON();return delete t.language,t}toHTML(){let t=this.source.trim(),r=this.htmlBackgroundCSS(),i=r.length>0?` style="${r}"`:"",a=this.svg;return a.length>0?`<figure class="diagram" data-mermaid="${d.escapeAttribute(t)}"${i}>${a}</figure>`:`<pre class="mermaid"${i}>${d.escapeText(t)}</pre>`}toMarkdown(){let t=this.source.trim(),r=2;for(let a of t.match(/`+/g)||[])r=Math.max(r,a.length);let i="`".repeat(r+1);return this.markdownWithBackground(`${i}mermaid
1
+ import{CodeBlockNode as h,Editor as p,InspectorDefaults as c,InspectorEditors as f,InspectorItem as g,RichText as l,Strings as T,Utilities as d}from"scriviamo";var v={TextDiagramCaption:"Diagram",TextDiagramSourceCaption:"Mermaid",TextDiagramRedrawCaption:"Redraw",TextDiagramPlaceholder:"A Mermaid diagram, such as: graph LR; A --> B",TextDiagramLoadingCaption:"Drawing the diagram\u2026",TextDiagramUnavailableMessage:"The diagram renderer couldn't be loaded."};T.register(v);var o=class e{static moduleURL="https://cdn.jsdelivr.net/npm/mermaid@11.4.1/dist/mermaid.esm.min.mjs";static settings={securityLevel:"strict"};static themes={light:"default",dark:"dark"};static#t=null;static#r=null;static#e="";static#i=0;static use(t){e.#t=t&&typeof t.render=="function"?t:null,e.#r=null,e.#e=""}static get mermaid(){if(!e.#t){let t=globalThis.mermaid;t&&typeof t.render=="function"&&(e.#t=t)}return e.#t}static load(){if(e.mermaid)return Promise.resolve(e.mermaid);if(!e.#r){let t=e.moduleURL;e.#r=import(t).then(r=>{let i=r.default||r;return e.#t=i,i},r=>{throw e.#r=null,r})}return e.#r}static async render(t,r=!1){let i=await e.load(),a=String(e.settings.theme||(r?e.themes.dark:e.themes.light));e.#e!=a&&typeof i.initialize=="function"&&(i.initialize({startOnLoad:!1,...e.settings,theme:a}),e.#e=a);let s=`scv-diagram-${++e.#i}`;try{let n=await i.render(s,t);return String(n&&typeof n=="object"?n.svg:n||"")}finally{typeof document<"u"&&document.getElementById(`d${s}`)?.remove()}}},u=class e{static#t=new Set;static#r=null;static watch(t){e.#t.add(t),!(e.#r||typeof MutationObserver>"u"||typeof document>"u")&&(e.#r=new MutationObserver(()=>e.#e()),e.#r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-bs-theme"],subtree:!0}))}static#e(){for(let t of Array.from(e.#t))t.isShown?t.drawnForOtherTheme&&t.redraw():e.#t.delete(t)}},m=class e extends h{static exportStyles(t,r){super.exportStyles(t,r),t.addRule("figure.diagram","margin: 1em 0; overflow-x: auto; text-align: center"),t.addRule("figure.diagram svg","max-width: 100%; height: auto")}static identifier="diagram";static caption="Diagram";static captionString="TextDiagramCaption";static icon="bi bi-diagram-3";static keywords="mermaid flowchart chart graph sequence gantt";static importPriority=50;static markdownShortcuts=[{pattern:/^```mermaid$/}];static create(t){return new e}static importElement(t,r){let i=null;if(t.tagName=="PRE"){let s=t.querySelector("code");/(^|\s)mermaid(\s|$)/.test(t.className||"")?i=t.textContent||"":s&&/(^|\s)language-mermaid(\s|$)/.test(s.className||"")&&(i=s.textContent||"")}else t.hasAttribute("data-mermaid")&&(i=t.getAttribute("data-mermaid"));if(i===null)return;let a=new e;return a.content=new l(i.replace(/\n$/,"")),r.attach(a)}#t=null;#r=null;#e=null;#i=0;get isShown(){return!!this.#t&&this.#t.isConnected}get drawnForOtherTheme(){return!!this.#t&&!!this.#e&&this.#e.dark!=this.#s(this.#t)}#s(t){return(this.editor&&this.editor.element||t).closest("[data-bs-theme]")?.getAttribute("data-bs-theme")=="dark"}get source(){return this.content.text}set source(t){this.content=new l(String(t||""))}get svg(){return this.#e&&this.#e.source==this.source.trim()?this.#e.svg:""}get typeName(){return this.strings.TextDiagramCaption}get placeholderText(){return this.strings.TextDiagramPlaceholder}inspectorSections(){let t=this.strings,r=g.bound("source",t.TextDiagramSourceCaption,f.multilineText,a=>a.content.text,(a,s)=>a.content=new l(String(s||""))),i=g.actionItem("redraw","",t.TextDiagramRedrawCaption,a=>a.redraw());return[c.section("diagram",t.TextDiagramCaption,[r,i])].concat(c.node(this))}build(t){super.build(t),t.querySelector(".scv-code")?.classList.add("scv-diagram-source");let r=t.querySelector(".scv-code-language");r&&(r.value=this.strings.TextDiagramSourceCaption,r.readOnly=!0,r.removeAttribute("list")),this.#t=d.element("div","scv-diagram-output",{contenteditable:"false"}),t.prepend(this.#t),t.classList.add("scv-diagram"),u.watch(this),this.#a()}textChanged(t){super.textChanged(t),this.#r!==null&&clearTimeout(this.#r),this.#r=setTimeout(()=>{this.#r=null,this.#a()},400)}redraw(){return this.#a()}async#a(){let t=this.#t;if(!t)return;let r=this.source.trim(),i=++this.#i;if(t.parentElement?.classList.toggle("scv-diagram-empty",r.length==0),r.length==0){t.replaceChildren();return}let a=this.#s(t);if(this.#e&&this.#e.source==r&&this.#e.dark==a){t.innerHTML=this.#e.svg,t.className="scv-diagram-output";return}!o.mermaid&&t.childElementCount==0&&(t.textContent=this.strings.TextDiagramLoadingCaption,t.className="scv-diagram-output scv-diagram-pending");try{let s=await o.render(r,a);if(i!=this.#i||this.#t!==t)return;this.#e={source:r,svg:s,dark:a},t.innerHTML=s,t.className="scv-diagram-output"}catch(s){if(i!=this.#i||this.#t!==t)return;let n=!!o.mermaid;t.textContent=n?String(s?.message||s).trim():this.strings.TextDiagramUnavailableMessage,t.className="scv-diagram-output scv-diagram-error"}}fromJSON(t){return super.fromJSON(t)?(this.language="",!0):!1}toJSON(){let t=super.toJSON();return delete t.language,t}toHTML(){let t=this.source.trim(),r=this.htmlBackgroundCSS(),i=r.length>0?` style="${r}"`:"",a=this.svg;return a.length>0?`<figure class="diagram" data-mermaid="${d.escapeAttribute(t)}"${i}>${a}</figure>`:`<pre class="mermaid"${i}>${d.escapeText(t)}</pre>`}toMarkdown(){let t=this.source.trim(),r=2;for(let a of t.match(/`+/g)||[])r=Math.max(r,a.length);let i="`".repeat(r+1);return this.markdownWithBackground(`${i}mermaid
2
2
  ${t}
3
3
  ${i}`)}toPlainText(){return this.source}};p.registerNodeType(m,67);export{m as DiagramNode,o as DiagramRenderer};
@@ -163,3 +163,10 @@
163
163
  margin: 0;
164
164
  font-weight: 500;
165
165
  }
166
+
167
+ /* A button or checkbox is only as wide as its content, so Alignment moves it along the line. */
168
+ .scv-node[data-type="button"] > .scv-node-body,
169
+ .scv-node[data-type="checkbox"] > .scv-node-body {
170
+ width: fit-content;
171
+ max-width: 100%;
172
+ }
@@ -385,6 +385,14 @@ var FormControlNode = class extends TextNode {
385
385
  super.applyAppearance(wrapper, body);
386
386
  wrapper.classList.toggle("scv-control-disabled", this.disabled);
387
387
  }
388
+ /**
389
+ * CSS that moves a control only as wide as its content, such as a button, to the middle or end
390
+ * of the line, as Alignment asks; empty at the start. Margins alone don't move an inline control.
391
+ */
392
+ htmlAlignmentCSS() {
393
+ let css = this.htmlBackgroundCSS();
394
+ return /margin-left:auto|margin-inline-start:auto/.test(css) ? "display:block;width:fit-content;max-width:100%;" : "";
395
+ }
388
396
  htmlFormAttributes(includeID = true, includeStyle = true) {
389
397
  let result = "";
390
398
  if (includeID && this.id.length > 0)
@@ -455,6 +463,7 @@ var TextFieldTypes = /* @__PURE__ */ ((TextFieldTypes2) => {
455
463
  var TextFieldNode = class _TextFieldNode extends FormControlNode {
456
464
  static identifier = "textfield";
457
465
  static caption = "Text Field";
466
+ static captionString = "TextTextFieldCaption";
458
467
  static icon = "bi bi-input-cursor-text";
459
468
  static keywords = "form input field textbox email password number date";
460
469
  static importElement(element, importer) {
@@ -721,6 +730,7 @@ var TextFieldNode = class _TextFieldNode extends FormControlNode {
721
730
  var TextAreaNode = class _TextAreaNode extends TextFieldNode {
722
731
  static identifier = "textarea";
723
732
  static caption = "Text Area";
733
+ static captionString = "TextAreaCaption";
724
734
  static icon = "bi bi-textarea-resize";
725
735
  static keywords = "form input multiline comments message";
726
736
  static importElement(element, importer) {
@@ -813,6 +823,7 @@ var TextAreaNode = class _TextAreaNode extends TextFieldNode {
813
823
  var LabelNode = class _LabelNode extends TextNode {
814
824
  static identifier = "label";
815
825
  static caption = "Label";
826
+ static captionString = "TextLabelCaption";
816
827
  static icon = "bi bi-tag";
817
828
  static keywords = "form caption";
818
829
  static importElement(element, importer) {
@@ -877,6 +888,7 @@ var LabelNode = class _LabelNode extends TextNode {
877
888
  var CheckboxNode = class _CheckboxNode extends FormControlNode {
878
889
  static identifier = "checkbox";
879
890
  static caption = "Checkbox";
891
+ static captionString = "TextCheckboxCaption";
880
892
  static icon = "bi bi-check2-square";
881
893
  static keywords = "form toggle tick option agree";
882
894
  /** A checkbox input, or a label holding one, whose other content becomes the caption. */
@@ -1000,8 +1012,17 @@ var CheckboxNode = class _CheckboxNode extends FormControlNode {
1000
1012
  this.value = Utilities.string(data.value);
1001
1013
  return true;
1002
1014
  }
1015
+ // Only as wide as its caption, so it moves with Alignment rather than aligning its text.
1016
+ get canAlignBlock() {
1017
+ return true;
1018
+ }
1019
+ get alignsText() {
1020
+ return false;
1021
+ }
1003
1022
  toHTML() {
1004
- let result = `<input${this.htmlFormAttributes()} type="checkbox"`;
1023
+ let captioned = this.captionText.length > 0;
1024
+ let style = this.htmlAlignmentCSS() + this.htmlBackgroundCSS();
1025
+ let result = `<input${this.htmlFormAttributes(true, false)}${!captioned && style.length > 0 ? ` style="${Utilities.escapeAttribute(style)}"` : ""} type="checkbox"`;
1005
1026
  if (this.checked)
1006
1027
  result += " checked";
1007
1028
  if (this.required)
@@ -1009,9 +1030,9 @@ var CheckboxNode = class _CheckboxNode extends FormControlNode {
1009
1030
  if (this.value.length > 0 && this.value != "on")
1010
1031
  result += ` value="${Utilities.escapeAttribute(this.value)}"`;
1011
1032
  result += ">";
1012
- if (this.captionText.length == 0)
1033
+ if (!captioned)
1013
1034
  return result;
1014
- return `<label>${result}${this.content.htmlText()}</label>`;
1035
+ return `<label${style.length > 0 ? ` style="${Utilities.escapeAttribute(style)}"` : ""}>${result}${this.content.htmlText()}</label>`;
1015
1036
  }
1016
1037
  toPlainText() {
1017
1038
  return `${this.checked ? "[x]" : "[ ]"} ${this.captionText}`;
@@ -1026,6 +1047,7 @@ var ButtonTypes = /* @__PURE__ */ ((ButtonTypes2) => {
1026
1047
  var ButtonNode = class _ButtonNode extends FormControlNode {
1027
1048
  static identifier = "button";
1028
1049
  static caption = "Button";
1050
+ static captionString = "TextButtonCaption";
1029
1051
  static icon = "bi bi-hand-index";
1030
1052
  static keywords = "form submit reset action";
1031
1053
  static importElement(element, importer) {
@@ -1167,8 +1189,16 @@ var ButtonNode = class _ButtonNode extends FormControlNode {
1167
1189
  this.buttonType = Utilities.clamp(Utilities.integer(data.buttonType, 0), 0, 2);
1168
1190
  return true;
1169
1191
  }
1192
+ // Only as wide as its caption, so it moves with Alignment rather than aligning its text.
1193
+ get canAlignBlock() {
1194
+ return true;
1195
+ }
1196
+ get alignsText() {
1197
+ return false;
1198
+ }
1170
1199
  toHTML() {
1171
- let attributes = `${this.htmlFormAttributes()} type="${_ButtonNode.typeNames[this.buttonType]}"`;
1200
+ let style = this.htmlAlignmentCSS() + this.htmlBackgroundCSS();
1201
+ let attributes = `${this.htmlFormAttributes(true, false)}${style.length > 0 ? ` style="${Utilities.escapeAttribute(style)}"` : ""} type="${_ButtonNode.typeNames[this.buttonType]}"`;
1172
1202
  if (this.value.length > 0)
1173
1203
  attributes += ` value="${Utilities.escapeAttribute(this.value)}"`;
1174
1204
  let pairs = [["command", this.command], ["commandfor", this.commandFor], ["formaction", this.formAction], ["formenctype", this.formEnctype], ["formmethod", this.formMethod], ["formtarget", this.formTarget], ["popovertarget", this.popoverTarget], ["popovertargetaction", this.popoverTargetAction]];
@@ -1184,6 +1214,7 @@ var ButtonNode = class _ButtonNode extends FormControlNode {
1184
1214
  var DropdownNode = class _DropdownNode extends FormControlNode {
1185
1215
  static identifier = "select";
1186
1216
  static caption = "Dropdown";
1217
+ static captionString = "TextDropdownCaption";
1187
1218
  static icon = "bi bi-menu-button-wide";
1188
1219
  static keywords = "form select choice combobox list";
1189
1220
  static importElement(element, importer) {
@@ -1361,6 +1392,7 @@ var RadioGroupNode = class _RadioGroupNode extends DropdownNode {
1361
1392
  }
1362
1393
  static identifier = "radiogroup";
1363
1394
  static caption = "Radio Group";
1395
+ static captionString = "TextRadioGroupCaption";
1364
1396
  static icon = "bi bi-ui-radios";
1365
1397
  static keywords = "form radio choice option fieldset";
1366
1398
  static importElement(element, importer) {
@@ -1607,6 +1639,7 @@ var RadioGroupNode = class _RadioGroupNode extends DropdownNode {
1607
1639
  var DatalistNode = class _DatalistNode extends Node {
1608
1640
  static identifier = "datalist";
1609
1641
  static caption = "Datalist";
1642
+ static captionString = "TextDatalistCaption";
1610
1643
  static icon = "bi bi-card-list";
1611
1644
  static keywords = "form suggestions autocomplete options";
1612
1645
  static importElement(element, importer) {
@@ -1728,6 +1761,7 @@ var FormNode = class _FormNode extends TableNode {
1728
1761
  }
1729
1762
  static identifier = "form";
1730
1763
  static caption = "Form";
1764
+ static captionString = "TextFormCaption";
1731
1765
  static icon = "bi bi-ui-checks-grid";
1732
1766
  static keywords = "form fields controls submit";
1733
1767
  static importElement(element, importer) {
@@ -1 +1 @@
1
- .scv-form{position:relative;padding:26px 14px 12px;border:1px dashed var(--scv-border);border-radius:8px}.scv-form-badge{position:absolute;top:4px;inset-inline-start:10px;color:var(--scv-muted);user-select:none}.scv-form>.scv-cell-text:empty,.scv-form>.scv-cell-text.scv-empty:not(:focus){min-height:0;height:0;overflow:hidden}.scv-form>.scv-cell-children{margin-top:0}.scv-readonly .scv-form{border-color:transparent}.scv-field{position:relative;display:flex;align-items:flex-start;gap:8px;cursor:text}.scv-field-text{flex:1 1 auto;min-width:0;min-height:1.5em;white-space:pre-wrap}.scv-field-badge{flex:0 0 auto;font-size:.7em;line-height:2.1;color:var(--scv-muted);text-transform:uppercase;letter-spacing:.04em;user-select:none}.scv-field-area .scv-field-text{align-self:stretch}.scv-select,.scv-listbox{cursor:default;user-select:none}.scv-listbox{padding:4px}.scv-listbox-option{padding:2px 8px;border-radius:4px}.scv-listbox-option.active{background-color:var(--scv-accent-soft)}.scv-check-control,.scv-radio-option{display:flex;align-items:flex-start;gap:.5em;min-height:1.5em;padding-inline-start:0;margin:0}.scv-check-control .form-check-input,.scv-radio-option .form-check-input{float:none;margin:.25em 0 0;cursor:pointer}.scv-check-caption,.scv-radio-option .form-check-label{flex:1 1 auto;min-width:0}.scv-radiogroup{margin:0;padding:0;border:0}.scv-radiogroup-legend{float:none;width:auto;margin-bottom:4px;font-size:1em;font-weight:600}.scv-radiogroup-options{display:flex;flex-direction:column;gap:4px}.scv-radiogroup-horizontal .scv-radiogroup-options{flex-direction:row;flex-wrap:wrap;gap:4px 20px}.scv-button-control{min-width:4em;cursor:text}.scv-button-control.scv-text{min-height:0}.scv-datalist{padding:8px 12px;border:1px dashed var(--scv-border);border-radius:6px;user-select:none}.scv-datalist-title{margin-bottom:6px;color:var(--scv-muted)}.scv-datalist-options{display:flex;flex-wrap:wrap;gap:4px}.scv-control-disabled>.scv-node-body{opacity:.55}.scv-node-label label{display:block;margin:0;font-weight:500}
1
+ .scv-form{position:relative;padding:26px 14px 12px;border:1px dashed var(--scv-border);border-radius:8px}.scv-form-badge{position:absolute;top:4px;inset-inline-start:10px;color:var(--scv-muted);user-select:none}.scv-form>.scv-cell-text:empty,.scv-form>.scv-cell-text.scv-empty:not(:focus){min-height:0;height:0;overflow:hidden}.scv-form>.scv-cell-children{margin-top:0}.scv-readonly .scv-form{border-color:transparent}.scv-field{position:relative;display:flex;align-items:flex-start;gap:8px;cursor:text}.scv-field-text{flex:1 1 auto;min-width:0;min-height:1.5em;white-space:pre-wrap}.scv-field-badge{flex:0 0 auto;font-size:.7em;line-height:2.1;color:var(--scv-muted);text-transform:uppercase;letter-spacing:.04em;user-select:none}.scv-field-area .scv-field-text{align-self:stretch}.scv-select,.scv-listbox{cursor:default;user-select:none}.scv-listbox{padding:4px}.scv-listbox-option{padding:2px 8px;border-radius:4px}.scv-listbox-option.active{background-color:var(--scv-accent-soft)}.scv-check-control,.scv-radio-option{display:flex;align-items:flex-start;gap:.5em;min-height:1.5em;padding-inline-start:0;margin:0}.scv-check-control .form-check-input,.scv-radio-option .form-check-input{float:none;margin:.25em 0 0;cursor:pointer}.scv-check-caption,.scv-radio-option .form-check-label{flex:1 1 auto;min-width:0}.scv-radiogroup{margin:0;padding:0;border:0}.scv-radiogroup-legend{float:none;width:auto;margin-bottom:4px;font-size:1em;font-weight:600}.scv-radiogroup-options{display:flex;flex-direction:column;gap:4px}.scv-radiogroup-horizontal .scv-radiogroup-options{flex-direction:row;flex-wrap:wrap;gap:4px 20px}.scv-button-control{min-width:4em;cursor:text}.scv-button-control.scv-text{min-height:0}.scv-datalist{padding:8px 12px;border:1px dashed var(--scv-border);border-radius:6px;user-select:none}.scv-datalist-title{margin-bottom:6px;color:var(--scv-muted)}.scv-datalist-options{display:flex;flex-wrap:wrap;gap:4px}.scv-control-disabled>.scv-node-body{opacity:.55}.scv-node-label label{display:block;margin:0;font-weight:500}.scv-node[data-type=button]>.scv-node-body,.scv-node[data-type=checkbox]>.scv-node-body{width:fit-content;max-width:100%}