@burger-editor/client 4.0.0-alpha.25 → 4.0.0-alpha.27
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 +692 -636
- package/dist/client.js.map +1 -1
- package/package.json +10 -10
package/dist/client.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param el
|
|
4
|
+
* @param frameSemantics
|
|
5
|
+
*/
|
|
6
|
+
function changeFrameSemantics(el, frameSemantics) {
|
|
7
|
+
const containerFrame = el.querySelector('[data-bge-container-frame]');
|
|
8
|
+
if (!containerFrame) {
|
|
9
|
+
throw new Error('Container frame not found');
|
|
10
|
+
}
|
|
11
|
+
// Determine target elements
|
|
12
|
+
const frameTagName = frameSemantics === 'div' ? 'div' : frameSemantics;
|
|
13
|
+
const groupTagName = frameSemantics === 'div' ? 'div' : 'li';
|
|
14
|
+
// Create new container frame element
|
|
15
|
+
const newFrame = document.createElement(frameTagName);
|
|
16
|
+
copyAttributes(containerFrame, newFrame);
|
|
17
|
+
// Transform groups
|
|
18
|
+
const groups = containerFrame.querySelectorAll('[data-bge-group]');
|
|
19
|
+
for (const group of groups) {
|
|
20
|
+
const newGroup = document.createElement(groupTagName);
|
|
21
|
+
copyAttributes(group, newGroup);
|
|
22
|
+
// Move all child content
|
|
23
|
+
while (group.firstChild) {
|
|
24
|
+
newGroup.append(group.firstChild);
|
|
25
|
+
}
|
|
26
|
+
newFrame.append(newGroup);
|
|
27
|
+
}
|
|
28
|
+
// Replace old frame with new frame
|
|
29
|
+
containerFrame.parentNode?.replaceChild(newFrame, containerFrame);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Copy all attributes from source to target element
|
|
33
|
+
* @param source - Source element
|
|
34
|
+
* @param target - Target element
|
|
35
|
+
*/
|
|
36
|
+
function copyAttributes(source, target) {
|
|
37
|
+
for (const attr of source.attributes) {
|
|
38
|
+
target.setAttribute(attr.name, attr.value);
|
|
39
|
+
}
|
|
40
|
+
if (source.className) {
|
|
41
|
+
// Copy classes
|
|
42
|
+
target.className = source.className;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
1
46
|
const CSS_LAYER = {
|
|
2
47
|
base: 'bge-component-bases',
|
|
3
48
|
components: 'bge-components',
|
|
@@ -33,7 +78,9 @@ function sanitizeAttrs(el) {
|
|
|
33
78
|
function sanitizeStyle(el) {
|
|
34
79
|
const customProperties = [];
|
|
35
80
|
const style = el.style;
|
|
36
|
-
|
|
81
|
+
// JSDOM's CSSStyleDeclaration does not have Symbol.iterator
|
|
82
|
+
const properties = typeof el.style[Symbol.iterator] === 'function' ? style : Object.keys(style);
|
|
83
|
+
for (const property of properties) {
|
|
37
84
|
if (property.startsWith(BLOCK_OPTION_CSS_CUSTOM_PROPERTY_PREFIX)) {
|
|
38
85
|
customProperties.push([property, style.getPropertyValue(property)]);
|
|
39
86
|
}
|
|
@@ -140,6 +187,7 @@ async function createPlainStructuredBlockElement(data, createItemElement) {
|
|
|
140
187
|
container.append(frame);
|
|
141
188
|
const itemElements = await createItemElements(data.items, createItemElement);
|
|
142
189
|
frame.append(...itemElements);
|
|
190
|
+
changeFrameSemantics(container, data.containerProps.frameSemantics ?? 'div');
|
|
143
191
|
return container;
|
|
144
192
|
}
|
|
145
193
|
/**
|
|
@@ -311,7 +359,7 @@ function kebabCase(str) {
|
|
|
311
359
|
}
|
|
312
360
|
|
|
313
361
|
/**
|
|
314
|
-
* marked v16.
|
|
362
|
+
* marked v16.4.0 - a markdown parser
|
|
315
363
|
* Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed)
|
|
316
364
|
* https://github.com/markedjs/marked
|
|
317
365
|
*/
|
|
@@ -321,32 +369,32 @@ function kebabCase(str) {
|
|
|
321
369
|
* The code in this file is generated from files in ./src/
|
|
322
370
|
*/
|
|
323
371
|
|
|
324
|
-
function L(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var
|
|
325
|
-
]`).replace("lheading",
|
|
372
|
+
function L(){return {async:false,breaks:false,extensions:null,gfm:true,hooks:null,pedantic:false,renderer:null,silent:false,tokenizer:null,walkTokens:null}}var T=L();function G(u){T=u;}var I={exec:()=>null};function d(u,e=""){let t=typeof u=="string"?u:u.source,n={replace:(r,i)=>{let s=typeof i=="string"?i:i.source;return s=s.replace(m.caret,"$1"),t=t.replace(r,s),n},getRegex:()=>new RegExp(t,e)};return n}var m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:u=>new RegExp(`^( {0,3}${u})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}#`),htmlBeginRegex:u=>new RegExp(`^ {0,${Math.min(3,u-1)}}<(?:[a-z].*>|!--)`,"i")},be=/^(?:[ \t]*(?:\n|$))+/,Re=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Te=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,E=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie$2=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=d(ie$2).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),we=d(ie$2).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),j=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ye=/^[^\n]+/,Q=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Pe=d(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Se=d(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),v="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",U=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,$e=d("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",U).replace("tag",v).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ae=d(j).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),_e=d(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ae).getRegex(),K={blockquote:_e,code:Re,def:Pe,fences:Te,heading:Oe,hr:E,html:$e,lheading:oe,list:Se,newline:be,paragraph:ae,table:I,text:ye},re$1=d("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Le={...K,lheading:we,table:re$1,paragraph:d(j).replace("hr",E).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re$1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex()},Me={...K,html:d(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",U).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:d(j).replace("hr",E).replace("heading",` *#{1,6} *[^
|
|
373
|
+
]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},ze=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ae=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,le=/^( {2,}|\\)\n(?!\s*$)/,Ie=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,D=/[\p{P}\p{S}]/u,W=/[\s\p{P}\p{S}]/u,ue=/[^\s\p{P}\p{S}]/u,Ee=d(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,W).getRegex(),pe=/(?!~)[\p{P}\p{S}]/u,Ce=/(?!~)[\s\p{P}\p{S}]/u,Be=/(?:[^\s\p{P}\p{S}]|~)/u,qe=/\[(?:[^\[\]`]|`[^`]*?`)*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)|`[^`]*?`|<(?! )[^<>]*?>/g,ce=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ve=d(ce,"u").replace(/punct/g,D).getRegex(),De=d(ce,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",He=d(he,"gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ze=d(he,"gu").replace(/notPunctSpace/g,Be).replace(/punctSpace/g,Ce).replace(/punct/g,pe).getRegex(),Ge=d("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ue).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ne=d(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),Fe=d(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),je=d(U).replace("(?:-->|$)","-->").getRegex(),Qe=d("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Ue=d(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),de=d(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",Q).getRegex(),ke=d(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q).getRegex(),Ke=d("reflink|nolink(?!\\()","g").replace("reflink",de).replace("nolink",ke).getRegex(),se=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:I,anyPunctuation:Ne,autolink:Fe,blockSkip:qe,br:le,code:Ae,del:I,emStrongLDelim:ve,emStrongRDelimAst:He,emStrongRDelimUnd:Ge,escape:ze,link:Ue,nolink:ke,punctuation:Ee,reflink:de,reflinkSearch:Ke,tag:Qe,text:Ie,url:I},We={...X,link:d(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:d(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},N={...X,emStrongRDelimAst:Ze,emStrongLDelim:De,url:d(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",se).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:d(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",se).getRegex()},Xe={...N,br:d(le).replace("{2,}","*").getRegex(),text:d(N.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},C={normal:K,gfm:Le,pedantic:Me},M={normal:X,gfm:N,breaks:Xe,pedantic:We};var Je={"&":"&","<":"<",">":">",'"':""","'":"'"},ge=u=>Je[u];function w(u,e){if(e){if(m.escapeTest.test(u))return u.replace(m.escapeReplace,ge)}else if(m.escapeTestNoEncode.test(u))return u.replace(m.escapeReplaceNoEncode,ge);return u}function J(u){try{u=encodeURI(u).replace(m.percentDecode,"%");}catch{return null}return u}function V(u,e){let t=u.replace(m.findPipe,(i,s,o)=>{let a=false,l=s;for(;--l>=0&&o[l]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function z(u,e,t){let n=u.length;if(n===0)return "";let r=0;for(;r<n;){let i=u.charAt(n-r-1);if(i===e&&true)r++;else break}return u.slice(0,n-r)}function fe(u,e){if(u.indexOf(e[1])===-1)return -1;let t=0;for(let n=0;n<u.length;n++)if(u[n]==="\\")n++;else if(u[n]===e[0])t++;else if(u[n]===e[1]&&(t--,t<0))return n;return t>0?-2:-1}function me(u,e,t,n,r){let i=e.href,s=e.title||null,o=u[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=true;let a={type:u[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:s,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=false,a}function Ve(u,e,t){let n=u.match(t.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
|
|
326
374
|
`).map(i=>{let s=i.match(t.other.beginningSpace);if(s===null)return i;let[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(`
|
|
327
|
-
`)}var y=class{options;rules;lexer;constructor(e){this.options=e||
|
|
328
|
-
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=
|
|
375
|
+
`)}var y=class{options;rules;lexer;constructor(e){this.options=e||T;}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return {type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return {type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:z(n,`
|
|
376
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],r=Ve(n,t[3]||"",this.rules);return {type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:r}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let r=z(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim());}return {type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return {type:"hr",raw:z(t[0],`
|
|
329
377
|
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=z(t[0],`
|
|
330
378
|
`).split(`
|
|
331
|
-
`),r="",i="",s=[];for(;n.length>0;){let o=false,a=[],
|
|
332
|
-
`),c
|
|
379
|
+
`),r="",i="",s=[];for(;n.length>0;){let o=false,a=[],l;for(l=0;l<n.length;l++)if(this.rules.other.blockquoteStart.test(n[l]))a.push(n[l]),o=true;else if(!o)a.push(n[l]);else break;n=n.slice(l);let c=a.join(`
|
|
380
|
+
`),p=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
333
381
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
334
|
-
${
|
|
335
|
-
${
|
|
382
|
+
${c}`:c,i=i?`${i}
|
|
383
|
+
${p}`:p;let g=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.blockTokens(p,s,true),this.lexer.state.top=g,n.length===0)break;let h=s.at(-1);if(h?.type==="code")break;if(h?.type==="blockquote"){let R=h,f=R.raw+`
|
|
336
384
|
`+n.join(`
|
|
337
|
-
`),
|
|
385
|
+
`),O=this.blockquote(f);s[s.length-1]=O,r=r.substring(0,r.length-R.raw.length)+O.raw,i=i.substring(0,i.length-R.text.length)+O.text;break}else if(h?.type==="list"){let R=h,f=R.raw+`
|
|
338
386
|
`+n.join(`
|
|
339
|
-
`),
|
|
340
|
-
`);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=false;for(;e;){let
|
|
341
|
-
`,1)[0].replace(this.rules.other.listReplaceTabs,H=>" ".repeat(3*H.length)),
|
|
342
|
-
`,1)[0],
|
|
343
|
-
`,e=e.substring(
|
|
344
|
-
`,1)[0],A;if(
|
|
345
|
-
`+A.slice(
|
|
346
|
-
`+
|
|
347
|
-
`,e=e.substring(Z.length+1),
|
|
348
|
-
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:true,align:s.align[o]});for(let o of i)s.rows.push(V(o,s.header.length).map((a,
|
|
349
|
-
`?t[1].slice(0,-1):t[1];return {type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return {type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return {type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return !this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=z(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=
|
|
387
|
+
`),O=this.list(f);s[s.length-1]=O,r=r.substring(0,r.length-h.raw.length)+O.raw,i=i.substring(0,i.length-R.raw.length)+O.raw,n=f.substring(s.at(-1).raw.length).split(`
|
|
388
|
+
`);continue}}return {type:"blockquote",raw:r,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:false,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=false;for(;e;){let l=false,c="",p="";if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let g=t[2].split(`
|
|
389
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,H=>" ".repeat(3*H.length)),h=e.split(`
|
|
390
|
+
`,1)[0],R=!g.trim(),f=0;if(this.options.pedantic?(f=2,p=g.trimStart()):R?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,p=g.slice(f),f+=t[1].length),R&&this.rules.other.blankLine.test(h)&&(c+=h+`
|
|
391
|
+
`,e=e.substring(h.length+1),l=true),!l){let H=this.rules.other.nextBulletRegex(f),ee=this.rules.other.hrRegex(f),te=this.rules.other.fencesBeginRegex(f),ne=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f);for(;e;){let Z=e.split(`
|
|
392
|
+
`,1)[0],A;if(h=Z,this.options.pedantic?(h=h.replace(this.rules.other.listReplaceNesting," "),A=h):A=h.replace(this.rules.other.tabCharGlobal," "),te.test(h)||ne.test(h)||xe.test(h)||H.test(h)||ee.test(h))break;if(A.search(this.rules.other.nonSpaceChar)>=f||!h.trim())p+=`
|
|
393
|
+
`+A.slice(f);else {if(R||g.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||te.test(g)||ne.test(g)||ee.test(g))break;p+=`
|
|
394
|
+
`+h;}!R&&!h.trim()&&(R=true),c+=Z+`
|
|
395
|
+
`,e=e.substring(Z.length+1),g=A.slice(f);}}i.loose||(o?i.loose=true:this.rules.other.doubleBlankLine.test(c)&&(o=true));let O=null,Y;this.options.gfm&&(O=this.rules.other.listIsTask.exec(p),O&&(Y=O[0]!=="[ ] ",p=p.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:c,task:!!O,checked:Y,loose:false,text:p,tokens:[]}),i.raw+=c;}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let l=0;l<i.items.length;l++)if(this.lexer.state.top=false,i.items[l].tokens=this.lexer.blockTokens(i.items[l].text,[]),!i.loose){let c=i.items[l].tokens.filter(g=>g.type==="space"),p=c.length>0&&c.some(g=>this.rules.other.anyLine.test(g.raw));i.loose=p;}if(i.loose)for(let l=0;l<i.items.length;l++)i.items[l].loose=true;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return {type:"html",block:true,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return {type:"def",tag:n,raw:t[0],href:r,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=V(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
396
|
+
`):[],s={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:true,align:s.align[o]});for(let o of i)s.rows.push(V(o,s.header.length).map((a,l)=>({text:a,tokens:this.lexer.inline(a),header:false,align:s.align[l]})));return s}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return {type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
|
|
397
|
+
`?t[1].slice(0,-1):t[1];return {type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return {type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return {type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return !this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=true:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=false),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=true:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=false),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:false,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=z(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else {let s=fe(t[2],"()");if(s===-2)return;if(s>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+s;t[2]=t[2].substring(0,s),t[0]=t[0].substring(0,a).trim(),t[3]="";}}let r=t[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3]);}else i=t[3]?t[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),me(t,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return {type:"text",raw:s,text:s}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let s=[...r[0]].length-1,o,a,l=s,c=0,p=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(p.lastIndex=0,t=t.slice(-1*e.length+s);(r=p.exec(t))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(a=[...o].length,r[3]||r[4]){l+=a;continue}else if((r[5]||r[6])&&s%3&&!((s+a)%3)){c+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+c);let g=[...r[0]][0].length,h=e.slice(0,s+r.index+g+a);if(Math.min(s,a)%2){let f=h.slice(1,-1);return {type:"em",raw:h,text:f,tokens:this.lexer.inlineTokens(f)}}let R=h.slice(2,-2);return {type:"strong",raw:h,text:R,tokens:this.lexer.inlineTokens(R)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return {type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return {type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,r;return t[2]==="@"?(n=t[1],r="mailto:"+n):(n=t[1],r=n),{type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,r;if(t[2]==="@")n=t[0],r="mailto:"+n;else {let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?r="http://"+t[0]:r=t[0];}return {type:"link",raw:t[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return {type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class u{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||T,this.options.tokenizer=this.options.tokenizer||new y,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:false,inRawBlock:false,top:true};let t={other:m,block:C.normal,inline:M.normal};this.options.pedantic?(t.block=C.pedantic,t.inline=M.pedantic):this.options.gfm&&(t.block=C.gfm,this.options.breaks?t.inline=M.breaks:t.inline=M.gfm),this.tokenizer.rules=t;}static get rules(){return {block:C,inline:M}}static lex(e,t){return new u(t).lex(e)}static lexInline(e,t){return new u(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,`
|
|
350
398
|
`),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let n=this.inlineQueue[t];this.inlineTokens(n.src,n.tokens);}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=false){for(this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(s=>(r=s.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),true):false))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let s=t.at(-1);r.raw.length===1&&s!==void 0?s.raw+=`
|
|
351
399
|
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
352
400
|
`)?"":`
|
|
@@ -354,13 +402,13 @@ ${c}`:c;let f=this.lexer.state.top;if(this.lexer.state.top=true,this.lexer.block
|
|
|
354
402
|
`+r.text,this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="paragraph"||s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
355
403
|
`)?"":`
|
|
356
404
|
`)+r.raw,s.text+=`
|
|
357
|
-
`+r.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let s=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(
|
|
405
|
+
`+r.raw,this.inlineQueue.at(-1).src=s.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let s=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(l=>{a=l.call({lexer:this},o),typeof a=="number"&&a>=0&&(s=Math.min(s,a));}),s<1/0&&s>=0&&(i=e.substring(0,s+1));}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let s=t.at(-1);n&&s?.type==="paragraph"?(s.raw+=(s.raw.endsWith(`
|
|
358
406
|
`)?"":`
|
|
359
407
|
`)+r.raw,s.text+=`
|
|
360
408
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let s=t.at(-1);s?.type==="text"?(s.raw+=(s.raw.endsWith(`
|
|
361
409
|
`)?"":`
|
|
362
410
|
`)+r.raw,s.text+=`
|
|
363
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=false,s="";for(;e;){i||(s=""),i=false;let o;if(this.options.extensions?.inline?.some(
|
|
411
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=s.text):t.push(r);continue}if(e){let s="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(s);break}else throw new Error(s)}}return this.state.top=true,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex));}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=false,s="";for(;e;){i||(s=""),i=false;let o;if(this.options.extensions?.inline?.some(l=>(o=l.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),true):false))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let l=t.at(-1);o.type==="text"&&l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,s)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let l=1/0,c=e.slice(1),p;this.options.extensions.startInline.forEach(g=>{p=g.call({lexer:this},c),typeof p=="number"&&p>=0&&(l=Math.min(l,p));}),l<1/0&&l>=0&&(a=e.substring(0,l+1));}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(s=o.raw.slice(-1)),i=true;let l=t.at(-1);l?.type==="text"?(l.raw+=o.raw,l.text+=o.text):t.push(o);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return t}};var P=class{options;parser;constructor(e){this.options=e||T;}space(e){return ""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+`
|
|
364
412
|
`;return r?'<pre><code class="language-'+w(r)+'">'+(n?i:w(i,true))+`</code></pre>
|
|
365
413
|
`:"<pre><code>"+(n?i:w(i,true))+`</code></pre>
|
|
366
414
|
`}blockquote({tokens:e}){return `<blockquote>
|
|
@@ -378,9 +426,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
378
426
|
`}tablerow({text:e}){return `<tr>
|
|
379
427
|
${e}</tr>
|
|
380
428
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return (e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
381
|
-
`}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>${w(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=J(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+w(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=J(e);if(i===null)return w(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${w(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:w(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 ""}};var
|
|
382
|
-
`+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:true}]}):n+=a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}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 o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";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 "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 o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var S=class{options;block;constructor(e){this.options=e||
|
|
383
|
-
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+w(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var _=new B;function
|
|
429
|
+
`}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>${w(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=J(e);if(i===null)return r;e=i;let s='<a href="'+e+'"';return t&&(s+=' title="'+w(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=J(e);if(i===null)return w(n);e=i;let s=`<img src="${e}" alt="${n}"`;return t&&(s+=` title="${w(t)}"`),s+=">",s}text(e){return "tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:w(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 ""}};var b=class u{options;renderer;textRenderer;constructor(e){this.options=e||T,this.options.renderer=this.options.renderer||new P,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,t=true){let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,a=this.options.extensions.renderers[o.type].call({parser:this},o);if(a!==false||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=a||"";continue}}let s=i;switch(s.type){case "space":{n+=this.renderer.space(s);continue}case "hr":{n+=this.renderer.hr(s);continue}case "heading":{n+=this.renderer.heading(s);continue}case "code":{n+=this.renderer.code(s);continue}case "table":{n+=this.renderer.table(s);continue}case "blockquote":{n+=this.renderer.blockquote(s);continue}case "list":{n+=this.renderer.list(s);continue}case "html":{n+=this.renderer.html(s);continue}case "def":{n+=this.renderer.def(s);continue}case "paragraph":{n+=this.renderer.paragraph(s);continue}case "text":{let o=s,a=this.renderer.text(o);for(;r+1<e.length&&e[r+1].type==="text";)o=e[++r],a+=`
|
|
430
|
+
`+this.renderer.text(o);t?n+=this.renderer.paragraph({type:"paragraph",raw:a,text:a,tokens:[{type:"text",raw:a,text:a,escaped:true}]}):n+=a;continue}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}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 o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==false||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){n+=o||"";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 "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 o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}};var S=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=L();options=this.setOptions;parse=this.parseMarkdown(true);parseInline=this.parseMarkdown(false);Parser=b;Renderer=P;TextRenderer=$;Lexer=x;Tokenizer=y;Hooks=S;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 o of s)n=n.concat(this.walkTokens(o.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 o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,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(...o){let a=i.renderer.apply(this,o);return a===false&&(a=s.apply(this,o)),a}: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 P(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 o=s,a=n.renderer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p||""};}r.renderer=i;}if(n.tokenizer){let i=this.defaults.tokenizer||new y(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 o=s,a=n.tokenizer[o],l=i[o];i[o]=(...c)=>{let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.tokenizer=i;}if(n.hooks){let i=this.defaults.hooks||new S;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 o=s,a=n.hooks[o],l=i[o];S.passThroughHooks.has(s)?i[o]=c=>{if(this.defaults.async&&S.passThroughHooksRespectAsync.has(s))return (async()=>{let g=await a.call(i,c);return l.call(i,g)})();let p=a.call(i,c);return l.call(i,p)}:i[o]=(...c)=>{if(this.defaults.async)return (async()=>{let g=await a.apply(i,c);return g===false&&(g=await l.apply(i,c)),g})();let p=a.apply(i,c);return p===false&&(p=l.apply(i,c)),p};}r.hooks=i;}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let a=[];return a.push(s.call(this,o)),i&&(a=a.concat(i.call(this,o))),a};}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},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===true&&i.async===false)return o(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 o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(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 a=s.hooks?await s.hooks.preprocess(n):n,c=await(s.hooks?await s.hooks.provideLexer():e?x.lex:x.lexInline)(a,s),p=s.hooks?await s.hooks.processAllTokens(c):c;s.walkTokens&&await Promise.all(this.walkTokens(p,s.walkTokens));let h=await(s.hooks?await s.hooks.provideParser():e?b.parse:b.parseInline)(p,s);return s.hooks?await s.hooks.postprocess(h):h})().catch(o);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 p=(s.hooks?s.hooks.provideParser():e?b.parse:b.parseInline)(l,s);return s.hooks&&(p=s.hooks.postprocess(p)),p}catch(a){return o(a)}}}onError(e,t){return n=>{if(n.message+=`
|
|
431
|
+
Please report this to https://github.com/markedjs/marked.`,e){let r="<p>An error occurred:</p><pre>"+w(n.message+"",true)+"</pre>";return t?Promise.resolve(r):r}if(t)return Promise.reject(n);throw n}}};var _=new B;function k(u,e){return _.parse(u,e)}k.options=k.setOptions=function(u){return _.setOptions(u),k.defaults=_.defaults,G(k.defaults),k};k.getDefaults=L;k.defaults=T;k.use=function(...u){return _.use(...u),k.defaults=_.defaults,G(k.defaults),k};k.walkTokens=function(u,e){return _.walkTokens(u,e)};k.parseInline=_.parseInline;k.Parser=b;k.parser=b.parse;k.Renderer=P;k.TextRenderer=$;k.Lexer=x;k.lexer=x.lex;k.Tokenizer=y;k.Hooks=S;k.parse=k;k.options;k.setOptions;k.use;k.walkTokens;k.parseInline;b.parse;x.lex;
|
|
384
432
|
|
|
385
433
|
/*
|
|
386
434
|
* Set up window for Node.js
|
|
@@ -501,18 +549,6 @@ function formatByteSize(byteSize, digits = 2, autoFormat = true) {
|
|
|
501
549
|
function formatDate(timestamp, format) {
|
|
502
550
|
return dayjs.unix(timestamp).format(format);
|
|
503
551
|
}
|
|
504
|
-
/**
|
|
505
|
-
*
|
|
506
|
-
* @param html
|
|
507
|
-
*/
|
|
508
|
-
function strToDOM(html) {
|
|
509
|
-
const doc = new DOMParser().parseFromString(html, 'text/html');
|
|
510
|
-
const el = doc.body.firstElementChild;
|
|
511
|
-
if (!el || !(el instanceof HTMLElement)) {
|
|
512
|
-
throw new Error(`Element not found: ${html}`);
|
|
513
|
-
}
|
|
514
|
-
return el;
|
|
515
|
-
}
|
|
516
552
|
|
|
517
553
|
const cache = new Map();
|
|
518
554
|
/**
|
|
@@ -2517,6 +2553,10 @@ function requireIdentifiers () {
|
|
|
2517
2553
|
|
|
2518
2554
|
const numeric = /^[0-9]+$/;
|
|
2519
2555
|
const compareIdentifiers = (a, b) => {
|
|
2556
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
2557
|
+
return a === b ? 0 : a < b ? -1 : 1
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2520
2560
|
const anum = numeric.test(a);
|
|
2521
2561
|
const bnum = numeric.test(b);
|
|
2522
2562
|
|
|
@@ -2659,11 +2699,25 @@ function requireSemver$1 () {
|
|
|
2659
2699
|
other = new SemVer(other, this.options);
|
|
2660
2700
|
}
|
|
2661
2701
|
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2702
|
+
if (this.major < other.major) {
|
|
2703
|
+
return -1
|
|
2704
|
+
}
|
|
2705
|
+
if (this.major > other.major) {
|
|
2706
|
+
return 1
|
|
2707
|
+
}
|
|
2708
|
+
if (this.minor < other.minor) {
|
|
2709
|
+
return -1
|
|
2710
|
+
}
|
|
2711
|
+
if (this.minor > other.minor) {
|
|
2712
|
+
return 1
|
|
2713
|
+
}
|
|
2714
|
+
if (this.patch < other.patch) {
|
|
2715
|
+
return -1
|
|
2716
|
+
}
|
|
2717
|
+
if (this.patch > other.patch) {
|
|
2718
|
+
return 1
|
|
2719
|
+
}
|
|
2720
|
+
return 0
|
|
2667
2721
|
}
|
|
2668
2722
|
|
|
2669
2723
|
comparePre (other) {
|
|
@@ -3684,6 +3738,7 @@ function requireRange () {
|
|
|
3684
3738
|
// already replaced the hyphen ranges
|
|
3685
3739
|
// turn into a set of JUST comparators.
|
|
3686
3740
|
const parseComparator = (comp, options) => {
|
|
3741
|
+
comp = comp.replace(re[t.BUILD], '');
|
|
3687
3742
|
debug('comp', comp, options);
|
|
3688
3743
|
comp = replaceCarets(comp, options);
|
|
3689
3744
|
debug('caret', comp);
|
|
@@ -4887,6 +4942,405 @@ function requireSemver () {
|
|
|
4887
4942
|
var semverExports = requireSemver();
|
|
4888
4943
|
const semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
4889
4944
|
|
|
4945
|
+
/**
|
|
4946
|
+
* テンプレート文字列のプレースホルダーを設定値で置換する
|
|
4947
|
+
* @param template
|
|
4948
|
+
* @param config
|
|
4949
|
+
*/
|
|
4950
|
+
function replacePlaceholders(template, config) {
|
|
4951
|
+
return template
|
|
4952
|
+
.replaceAll('%sampleImagePath%', config.sampleImagePath)
|
|
4953
|
+
.replaceAll('%sampleFilePath%', config.sampleFilePath)
|
|
4954
|
+
.replaceAll('%googleMapsApiKey%', config.googleMapsApiKey ?? '');
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
/**
|
|
4958
|
+
*
|
|
4959
|
+
* @param html
|
|
4960
|
+
* @param data
|
|
4961
|
+
*/
|
|
4962
|
+
function dataToHtml(html, data) {
|
|
4963
|
+
return frozenPatty(html, {
|
|
4964
|
+
attr: 'bge',
|
|
4965
|
+
typeConvert: true,
|
|
4966
|
+
valueFilter,
|
|
4967
|
+
})
|
|
4968
|
+
.merge(data)
|
|
4969
|
+
.toHTML();
|
|
4970
|
+
}
|
|
4971
|
+
|
|
4972
|
+
class ItemEditorService {
|
|
4973
|
+
#beforeChange;
|
|
4974
|
+
#beforeOpen;
|
|
4975
|
+
#data;
|
|
4976
|
+
#isDisable;
|
|
4977
|
+
#item;
|
|
4978
|
+
#migrate;
|
|
4979
|
+
#migrateElement;
|
|
4980
|
+
#onSubmit;
|
|
4981
|
+
#open;
|
|
4982
|
+
get item() {
|
|
4983
|
+
return this.#item;
|
|
4984
|
+
}
|
|
4985
|
+
constructor(item, seed) {
|
|
4986
|
+
this.#item = item;
|
|
4987
|
+
const options = seed.editorOptions ?? {};
|
|
4988
|
+
if (options.beforeOpen) {
|
|
4989
|
+
this.#beforeOpen = options.beforeOpen;
|
|
4990
|
+
}
|
|
4991
|
+
if (options.open) {
|
|
4992
|
+
this.#open = options.open;
|
|
4993
|
+
}
|
|
4994
|
+
if (options.beforeChange) {
|
|
4995
|
+
this.#beforeChange = options.beforeChange;
|
|
4996
|
+
}
|
|
4997
|
+
if (options.onSubmit) {
|
|
4998
|
+
this.#onSubmit = options.onSubmit;
|
|
4999
|
+
}
|
|
5000
|
+
if (options.migrate) {
|
|
5001
|
+
this.#migrate = options.migrate;
|
|
5002
|
+
}
|
|
5003
|
+
if (options.migrateElement) {
|
|
5004
|
+
this.#migrateElement = options.migrateElement;
|
|
5005
|
+
}
|
|
5006
|
+
if (options.isDisable) {
|
|
5007
|
+
this.#isDisable = options.isDisable;
|
|
5008
|
+
}
|
|
5009
|
+
this.#data = options.customData;
|
|
5010
|
+
}
|
|
5011
|
+
async beforeChange(newValues, editor) {
|
|
5012
|
+
if (this.#beforeChange) {
|
|
5013
|
+
return this.#beforeChange(newValues, editor);
|
|
5014
|
+
}
|
|
5015
|
+
return newValues;
|
|
5016
|
+
}
|
|
5017
|
+
beforeOpen(data, editor) {
|
|
5018
|
+
if (this.#beforeOpen) {
|
|
5019
|
+
return this.#beforeOpen(data, editor);
|
|
5020
|
+
}
|
|
5021
|
+
return data;
|
|
5022
|
+
}
|
|
5023
|
+
getData(customProperty) {
|
|
5024
|
+
return this.#data?.[customProperty] ?? null;
|
|
5025
|
+
}
|
|
5026
|
+
isDisable(item) {
|
|
5027
|
+
return this.#isDisable?.(item) ?? '';
|
|
5028
|
+
}
|
|
5029
|
+
migrate(item) {
|
|
5030
|
+
return this.#migrate ? this.#migrate(item) : item.export();
|
|
5031
|
+
}
|
|
5032
|
+
async migrateElement(data, item) {
|
|
5033
|
+
await this.#migrateElement?.(data, item);
|
|
5034
|
+
}
|
|
5035
|
+
onSubmit(e, submitter) {
|
|
5036
|
+
return this.#onSubmit?.(e, submitter);
|
|
5037
|
+
}
|
|
5038
|
+
async open(data, editor) {
|
|
5039
|
+
await this.#open?.(data, editor);
|
|
5040
|
+
}
|
|
5041
|
+
setData(customProperty, value) {
|
|
5042
|
+
if (!this.#data) {
|
|
5043
|
+
return;
|
|
5044
|
+
}
|
|
5045
|
+
this.#data[customProperty] = value;
|
|
5046
|
+
}
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5049
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5050
|
+
const elMap = new WeakMap();
|
|
5051
|
+
let Item$1 = class Item {
|
|
5052
|
+
editor;
|
|
5053
|
+
name;
|
|
5054
|
+
#el;
|
|
5055
|
+
#engine;
|
|
5056
|
+
#service;
|
|
5057
|
+
#version;
|
|
5058
|
+
get el() {
|
|
5059
|
+
return this.#el;
|
|
5060
|
+
}
|
|
5061
|
+
get version() {
|
|
5062
|
+
return this.#version;
|
|
5063
|
+
}
|
|
5064
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
5065
|
+
constructor(engine, seed, el) {
|
|
5066
|
+
elMap.set(el, this);
|
|
5067
|
+
this.#el = el;
|
|
5068
|
+
this.#el.addEventListener('click', (e) => {
|
|
5069
|
+
e.preventDefault();
|
|
5070
|
+
e.stopPropagation();
|
|
5071
|
+
void this.#openEditor();
|
|
5072
|
+
});
|
|
5073
|
+
this.#engine = engine;
|
|
5074
|
+
this.name = seed.name;
|
|
5075
|
+
this.#version = seed.version;
|
|
5076
|
+
this.#service = new ItemEditorService(this, seed);
|
|
5077
|
+
this.editor = engine.itemEditorDialog;
|
|
5078
|
+
}
|
|
5079
|
+
export() {
|
|
5080
|
+
return dataFromHtml(this.el.innerHTML);
|
|
5081
|
+
}
|
|
5082
|
+
async import(newData, fromDialogChanges = false) {
|
|
5083
|
+
const currentData = this.export();
|
|
5084
|
+
let data = {
|
|
5085
|
+
...currentData,
|
|
5086
|
+
...newData,
|
|
5087
|
+
};
|
|
5088
|
+
if (fromDialogChanges) {
|
|
5089
|
+
data = await this.#service.beforeChange(data, this.editor);
|
|
5090
|
+
}
|
|
5091
|
+
this.el.innerHTML = dataToHtml(this.el.innerHTML, data);
|
|
5092
|
+
if (this.#isOld(this.#engine.items)) {
|
|
5093
|
+
await this.#service.migrateElement(data, this);
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5096
|
+
isDisable() {
|
|
5097
|
+
return this.#service.isDisable(this);
|
|
5098
|
+
}
|
|
5099
|
+
#isOld(currentItems) {
|
|
5100
|
+
const originVersion = currentItems.get(this.name)?.version ?? '0.0.0';
|
|
5101
|
+
const isOld = semver.lt(this.#version, originVersion);
|
|
5102
|
+
return isOld;
|
|
5103
|
+
}
|
|
5104
|
+
async #openEditor() {
|
|
5105
|
+
await this.editor.open(this.#service);
|
|
5106
|
+
}
|
|
5107
|
+
static async create(engine, name, initData = {}) {
|
|
5108
|
+
const seed = engine.items.get(name);
|
|
5109
|
+
if (!seed) {
|
|
5110
|
+
throw new Error(`Item seed not found: ${name}`);
|
|
5111
|
+
}
|
|
5112
|
+
const version = seed.version;
|
|
5113
|
+
const wrapper = document.createElement('div');
|
|
5114
|
+
wrapper.dataset.bgi = name;
|
|
5115
|
+
wrapper.dataset.bgiVer = version;
|
|
5116
|
+
wrapper.innerHTML = replacePlaceholders(seed.template, engine.config);
|
|
5117
|
+
const item = new Item(engine, seed, wrapper);
|
|
5118
|
+
await item.import(initData);
|
|
5119
|
+
return item;
|
|
5120
|
+
}
|
|
5121
|
+
static rebind(engine, el) {
|
|
5122
|
+
const name = el.dataset.bgi;
|
|
5123
|
+
if (!name) {
|
|
5124
|
+
throw new Error('data-bgi not found');
|
|
5125
|
+
}
|
|
5126
|
+
const seed = engine.items.get(name);
|
|
5127
|
+
if (!seed) {
|
|
5128
|
+
throw new Error(`Item seed not found: ${name}`);
|
|
5129
|
+
}
|
|
5130
|
+
const item = new Item(engine, seed, el);
|
|
5131
|
+
return item;
|
|
5132
|
+
}
|
|
5133
|
+
static getInstance(el) {
|
|
5134
|
+
return elMap.get(el);
|
|
5135
|
+
}
|
|
5136
|
+
};
|
|
5137
|
+
|
|
5138
|
+
/**
|
|
5139
|
+
* グリッドアイテムを追加または削除する
|
|
5140
|
+
* @param $items - 子要素の配列
|
|
5141
|
+
* @param engine - BurgerEditorEngineインスタンス
|
|
5142
|
+
* @param addOrRemove - 1: 追加, -1: 削除
|
|
5143
|
+
* @param items - アイテムの配列
|
|
5144
|
+
* @param updateItem
|
|
5145
|
+
* @description
|
|
5146
|
+
* グリッドアイテムの追加/削除を行う:
|
|
5147
|
+
* - 追加の場合:
|
|
5148
|
+
* 1. 最後の要素をクローン
|
|
5149
|
+
* 2. クローンを親要素に追加
|
|
5150
|
+
* 3. クローン内のアイテムを初期化してitemsに追加
|
|
5151
|
+
* - 削除の場合:
|
|
5152
|
+
* 1. 最後の要素を削除
|
|
5153
|
+
* 2. itemsから対応するアイテムを削除
|
|
5154
|
+
*/
|
|
5155
|
+
function updateGridItems($items, engine, addOrRemove, items, updateItem) {
|
|
5156
|
+
const $lastItem = $items.at(-1);
|
|
5157
|
+
if (!$lastItem) {
|
|
5158
|
+
return;
|
|
5159
|
+
}
|
|
5160
|
+
// Add
|
|
5161
|
+
if (addOrRemove === 1) {
|
|
5162
|
+
const $newItem = $lastItem.cloneNode(true);
|
|
5163
|
+
$lastItem.parentElement?.append($newItem);
|
|
5164
|
+
const $newItems = $newItem.querySelectorAll('[data-bge-group]');
|
|
5165
|
+
for (const $item of $newItems) {
|
|
5166
|
+
const item = Item$1.rebind(engine, $item);
|
|
5167
|
+
const newItems = [...items];
|
|
5168
|
+
newItems[newItems.length] = item;
|
|
5169
|
+
updateItem(newItems);
|
|
5170
|
+
}
|
|
5171
|
+
return;
|
|
5172
|
+
}
|
|
5173
|
+
// Remove
|
|
5174
|
+
const removeCount = $lastItem.querySelectorAll('[data-bge-group]').length;
|
|
5175
|
+
$lastItem.remove();
|
|
5176
|
+
const newItems = [...items];
|
|
5177
|
+
newItems.splice(-removeCount);
|
|
5178
|
+
updateItem(newItems);
|
|
5179
|
+
}
|
|
5180
|
+
|
|
5181
|
+
var _a;
|
|
5182
|
+
const bbMap = new WeakMap();
|
|
5183
|
+
let _lastUID = 0;
|
|
5184
|
+
class BurgerBlock {
|
|
5185
|
+
#createItemElement;
|
|
5186
|
+
#items = [];
|
|
5187
|
+
#uid;
|
|
5188
|
+
get items() {
|
|
5189
|
+
return this.#items;
|
|
5190
|
+
}
|
|
5191
|
+
set items(items) {
|
|
5192
|
+
this.#items = items;
|
|
5193
|
+
}
|
|
5194
|
+
get id() {
|
|
5195
|
+
return this.el.id;
|
|
5196
|
+
}
|
|
5197
|
+
get el() {
|
|
5198
|
+
return bbMap.get(this);
|
|
5199
|
+
}
|
|
5200
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
5201
|
+
constructor(createItemElement) {
|
|
5202
|
+
this.#uid = _lastUID++;
|
|
5203
|
+
this.#createItemElement = createItemElement;
|
|
5204
|
+
}
|
|
5205
|
+
/**
|
|
5206
|
+
* Change the semantic type of container frame and groups
|
|
5207
|
+
* @param frameSemantics - The semantic type to change to
|
|
5208
|
+
*/
|
|
5209
|
+
changeFrameSemantics(frameSemantics) {
|
|
5210
|
+
changeFrameSemantics(this.el, frameSemantics);
|
|
5211
|
+
}
|
|
5212
|
+
clone() {
|
|
5213
|
+
const originalData = this.#export();
|
|
5214
|
+
const newBlock = _a.create(originalData, this.#createItemElement);
|
|
5215
|
+
return newBlock;
|
|
5216
|
+
}
|
|
5217
|
+
existNext() {
|
|
5218
|
+
return !!this.el.nextElementSibling;
|
|
5219
|
+
}
|
|
5220
|
+
existPrev() {
|
|
5221
|
+
return !!this.el.previousElementSibling;
|
|
5222
|
+
}
|
|
5223
|
+
exportOptions() {
|
|
5224
|
+
return exportOptions(this.el);
|
|
5225
|
+
}
|
|
5226
|
+
getHTMLStringify() {
|
|
5227
|
+
return this.el.outerHTML;
|
|
5228
|
+
}
|
|
5229
|
+
async importJSONString(jsonString) {
|
|
5230
|
+
const data = JSON.parse(jsonString);
|
|
5231
|
+
try {
|
|
5232
|
+
await this.#import(data);
|
|
5233
|
+
}
|
|
5234
|
+
catch (error) {
|
|
5235
|
+
throw new Error(`ImportError: ${error instanceof Error ? error.message : error}`);
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
importOptions(options) {
|
|
5239
|
+
importOptions(this.el, options);
|
|
5240
|
+
}
|
|
5241
|
+
importTypes(extractor) {
|
|
5242
|
+
for (const [i, item] of this.items.entries()) {
|
|
5243
|
+
void item.import(extractor(i, item));
|
|
5244
|
+
}
|
|
5245
|
+
}
|
|
5246
|
+
is(block) {
|
|
5247
|
+
return this.#uid === block.#uid;
|
|
5248
|
+
}
|
|
5249
|
+
isDisable() {
|
|
5250
|
+
let msg = '';
|
|
5251
|
+
for (const type of this.items) {
|
|
5252
|
+
msg = type.isDisable();
|
|
5253
|
+
if (msg) {
|
|
5254
|
+
break;
|
|
5255
|
+
}
|
|
5256
|
+
}
|
|
5257
|
+
return msg;
|
|
5258
|
+
}
|
|
5259
|
+
isMutable() {
|
|
5260
|
+
return this.el.matches(':not([data-bge-container*=":immutable"])');
|
|
5261
|
+
}
|
|
5262
|
+
remove() {
|
|
5263
|
+
this.el.remove();
|
|
5264
|
+
}
|
|
5265
|
+
toJSONStringify(space) {
|
|
5266
|
+
return JSON.stringify(this.#export(), null, space);
|
|
5267
|
+
}
|
|
5268
|
+
updateGridItems(addOrRemove, engine) {
|
|
5269
|
+
updateGridItems([...this.el.querySelectorAll('[data-bge-group]')], engine, addOrRemove, this.items, (items) => (this.items = items));
|
|
5270
|
+
}
|
|
5271
|
+
#create(data) {
|
|
5272
|
+
return createPlainStructuredBlockElement(data, this.#createItemElement);
|
|
5273
|
+
}
|
|
5274
|
+
#export() {
|
|
5275
|
+
return parseHTMLToBlockData(this.el);
|
|
5276
|
+
}
|
|
5277
|
+
#fallbackBlockData(html) {
|
|
5278
|
+
return {
|
|
5279
|
+
name: 'text',
|
|
5280
|
+
containerProps: {
|
|
5281
|
+
type: 'grid',
|
|
5282
|
+
columns: 1,
|
|
5283
|
+
},
|
|
5284
|
+
classList: [],
|
|
5285
|
+
items: [[{ name: 'wysiwyg', data: { wysiwyg: html } }]],
|
|
5286
|
+
};
|
|
5287
|
+
}
|
|
5288
|
+
async #import(data) {
|
|
5289
|
+
this.el.replaceWith(await createPlainStructuredBlockElement(data, this.#createItemElement));
|
|
5290
|
+
}
|
|
5291
|
+
async #rebind(el) {
|
|
5292
|
+
if (isBurgerBlockElement(el)) {
|
|
5293
|
+
const itemContainers = el.querySelectorAll('[data-bge-item]');
|
|
5294
|
+
for (const itemContainer of itemContainers) {
|
|
5295
|
+
const itemElements = itemContainer.querySelectorAll('[data-bgi]');
|
|
5296
|
+
for (const itemElement of itemElements) {
|
|
5297
|
+
await this.#createItemElement(itemElement);
|
|
5298
|
+
}
|
|
5299
|
+
}
|
|
5300
|
+
return el;
|
|
5301
|
+
}
|
|
5302
|
+
// eslint-disable-next-line no-console
|
|
5303
|
+
console.error('%o is not a burger block', el);
|
|
5304
|
+
const fallbackEl = await createPlainStructuredBlockElement(this.#fallbackBlockData(el.outerHTML), this.#createItemElement);
|
|
5305
|
+
el.replaceWith(fallbackEl);
|
|
5306
|
+
return fallbackEl;
|
|
5307
|
+
}
|
|
5308
|
+
#set(el) {
|
|
5309
|
+
bbMap.set(this, el);
|
|
5310
|
+
_a.#blocks.set(this.el, this);
|
|
5311
|
+
}
|
|
5312
|
+
static #blocks = new WeakMap();
|
|
5313
|
+
static async create(data, createItemElement) {
|
|
5314
|
+
const block = new _a(createItemElement);
|
|
5315
|
+
const el = await block.#create(data);
|
|
5316
|
+
block.#set(el);
|
|
5317
|
+
return block;
|
|
5318
|
+
}
|
|
5319
|
+
static async rebind(el, createItemElement) {
|
|
5320
|
+
const block = new _a(createItemElement);
|
|
5321
|
+
const newEl = await block.#rebind(el);
|
|
5322
|
+
block.#set(newEl);
|
|
5323
|
+
return block;
|
|
5324
|
+
}
|
|
5325
|
+
static getBlock(el) {
|
|
5326
|
+
const block = this.#blocks.get(el);
|
|
5327
|
+
if (!block) {
|
|
5328
|
+
throw new Error('Do not get BurgerBlock instance.');
|
|
5329
|
+
}
|
|
5330
|
+
return block;
|
|
5331
|
+
}
|
|
5332
|
+
}
|
|
5333
|
+
_a = BurgerBlock;
|
|
5334
|
+
/**
|
|
5335
|
+
*
|
|
5336
|
+
* @param el
|
|
5337
|
+
*/
|
|
5338
|
+
function isBurgerBlockElement(el) {
|
|
5339
|
+
return el.matches([
|
|
5340
|
+
'[data-bge-name][data-bge-container]:has(>[data-bge-container-frame]>[data-bge-group]>[data-bge-item])',
|
|
5341
|
+
].join(','));
|
|
5342
|
+
}
|
|
5343
|
+
|
|
4890
5344
|
/**
|
|
4891
5345
|
*
|
|
4892
5346
|
* @param doc
|
|
@@ -6505,472 +6959,6 @@ class BurgerEditorEngine {
|
|
|
6505
6959
|
}
|
|
6506
6960
|
}
|
|
6507
6961
|
|
|
6508
|
-
/**
|
|
6509
|
-
* テンプレート文字列のプレースホルダーを設定値で置換する
|
|
6510
|
-
* @param template
|
|
6511
|
-
* @param config
|
|
6512
|
-
*/
|
|
6513
|
-
function replacePlaceholders(template, config) {
|
|
6514
|
-
return template
|
|
6515
|
-
.replaceAll('%sampleImagePath%', config.sampleImagePath)
|
|
6516
|
-
.replaceAll('%sampleFilePath%', config.sampleFilePath)
|
|
6517
|
-
.replaceAll('%googleMapsApiKey%', config.googleMapsApiKey ?? '');
|
|
6518
|
-
}
|
|
6519
|
-
|
|
6520
|
-
/**
|
|
6521
|
-
*
|
|
6522
|
-
* @param html
|
|
6523
|
-
* @param data
|
|
6524
|
-
*/
|
|
6525
|
-
function dataToHtml(html, data) {
|
|
6526
|
-
return frozenPatty(html, {
|
|
6527
|
-
attr: 'bge',
|
|
6528
|
-
typeConvert: true,
|
|
6529
|
-
valueFilter,
|
|
6530
|
-
})
|
|
6531
|
-
.merge(data)
|
|
6532
|
-
.toHTML();
|
|
6533
|
-
}
|
|
6534
|
-
|
|
6535
|
-
class ItemEditorService {
|
|
6536
|
-
#beforeChange;
|
|
6537
|
-
#beforeOpen;
|
|
6538
|
-
#data;
|
|
6539
|
-
#isDisable;
|
|
6540
|
-
#item;
|
|
6541
|
-
#migrate;
|
|
6542
|
-
#migrateElement;
|
|
6543
|
-
#onSubmit;
|
|
6544
|
-
#open;
|
|
6545
|
-
get item() {
|
|
6546
|
-
return this.#item;
|
|
6547
|
-
}
|
|
6548
|
-
constructor(item, seed) {
|
|
6549
|
-
this.#item = item;
|
|
6550
|
-
const options = seed.editorOptions ?? {};
|
|
6551
|
-
if (options.beforeOpen) {
|
|
6552
|
-
this.#beforeOpen = options.beforeOpen;
|
|
6553
|
-
}
|
|
6554
|
-
if (options.open) {
|
|
6555
|
-
this.#open = options.open;
|
|
6556
|
-
}
|
|
6557
|
-
if (options.beforeChange) {
|
|
6558
|
-
this.#beforeChange = options.beforeChange;
|
|
6559
|
-
}
|
|
6560
|
-
if (options.onSubmit) {
|
|
6561
|
-
this.#onSubmit = options.onSubmit;
|
|
6562
|
-
}
|
|
6563
|
-
if (options.migrate) {
|
|
6564
|
-
this.#migrate = options.migrate;
|
|
6565
|
-
}
|
|
6566
|
-
if (options.migrateElement) {
|
|
6567
|
-
this.#migrateElement = options.migrateElement;
|
|
6568
|
-
}
|
|
6569
|
-
if (options.isDisable) {
|
|
6570
|
-
this.#isDisable = options.isDisable;
|
|
6571
|
-
}
|
|
6572
|
-
this.#data = options.customData;
|
|
6573
|
-
}
|
|
6574
|
-
async beforeChange(newValues, editor) {
|
|
6575
|
-
if (this.#beforeChange) {
|
|
6576
|
-
return this.#beforeChange(newValues, editor);
|
|
6577
|
-
}
|
|
6578
|
-
return newValues;
|
|
6579
|
-
}
|
|
6580
|
-
beforeOpen(data, editor) {
|
|
6581
|
-
if (this.#beforeOpen) {
|
|
6582
|
-
return this.#beforeOpen(data, editor);
|
|
6583
|
-
}
|
|
6584
|
-
return data;
|
|
6585
|
-
}
|
|
6586
|
-
getData(customProperty) {
|
|
6587
|
-
return this.#data?.[customProperty] ?? null;
|
|
6588
|
-
}
|
|
6589
|
-
isDisable(item) {
|
|
6590
|
-
return this.#isDisable?.(item) ?? '';
|
|
6591
|
-
}
|
|
6592
|
-
migrate(item) {
|
|
6593
|
-
return this.#migrate ? this.#migrate(item) : item.export();
|
|
6594
|
-
}
|
|
6595
|
-
async migrateElement(data, item) {
|
|
6596
|
-
await this.#migrateElement?.(data, item);
|
|
6597
|
-
}
|
|
6598
|
-
onSubmit(e, submitter) {
|
|
6599
|
-
return this.#onSubmit?.(e, submitter);
|
|
6600
|
-
}
|
|
6601
|
-
async open(data, editor) {
|
|
6602
|
-
await this.#open?.(data, editor);
|
|
6603
|
-
}
|
|
6604
|
-
setData(customProperty, value) {
|
|
6605
|
-
if (!this.#data) {
|
|
6606
|
-
return;
|
|
6607
|
-
}
|
|
6608
|
-
this.#data[customProperty] = value;
|
|
6609
|
-
}
|
|
6610
|
-
}
|
|
6611
|
-
|
|
6612
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6613
|
-
const elMap = new WeakMap();
|
|
6614
|
-
let Item$1 = class Item {
|
|
6615
|
-
editor;
|
|
6616
|
-
name;
|
|
6617
|
-
#el;
|
|
6618
|
-
#engine;
|
|
6619
|
-
#service;
|
|
6620
|
-
#version;
|
|
6621
|
-
get el() {
|
|
6622
|
-
return this.#el;
|
|
6623
|
-
}
|
|
6624
|
-
get version() {
|
|
6625
|
-
return this.#version;
|
|
6626
|
-
}
|
|
6627
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
6628
|
-
constructor(engine, seed, el) {
|
|
6629
|
-
elMap.set(el, this);
|
|
6630
|
-
this.#el = el;
|
|
6631
|
-
this.#el.addEventListener('click', (e) => {
|
|
6632
|
-
e.preventDefault();
|
|
6633
|
-
e.stopPropagation();
|
|
6634
|
-
void this.#openEditor();
|
|
6635
|
-
});
|
|
6636
|
-
this.#engine = engine;
|
|
6637
|
-
this.name = seed.name;
|
|
6638
|
-
this.#version = seed.version;
|
|
6639
|
-
this.#service = new ItemEditorService(this, seed);
|
|
6640
|
-
this.editor = engine.itemEditorDialog;
|
|
6641
|
-
}
|
|
6642
|
-
export() {
|
|
6643
|
-
return dataFromHtml(this.el.innerHTML);
|
|
6644
|
-
}
|
|
6645
|
-
async import(newData, fromDialogChanges = false) {
|
|
6646
|
-
const currentData = this.export();
|
|
6647
|
-
let data = {
|
|
6648
|
-
...currentData,
|
|
6649
|
-
...newData,
|
|
6650
|
-
};
|
|
6651
|
-
if (fromDialogChanges) {
|
|
6652
|
-
data = await this.#service.beforeChange(data, this.editor);
|
|
6653
|
-
}
|
|
6654
|
-
this.el.innerHTML = dataToHtml(this.el.innerHTML, data);
|
|
6655
|
-
if (this.#isOld(this.#engine.items)) {
|
|
6656
|
-
await this.#service.migrateElement(data, this);
|
|
6657
|
-
}
|
|
6658
|
-
}
|
|
6659
|
-
isDisable() {
|
|
6660
|
-
return this.#service.isDisable(this);
|
|
6661
|
-
}
|
|
6662
|
-
async upgrade() {
|
|
6663
|
-
if (!this.#isOld(this.#engine.items)) {
|
|
6664
|
-
return;
|
|
6665
|
-
}
|
|
6666
|
-
const newTemplate = this.#engine.items.get(this.name)?.template;
|
|
6667
|
-
if (!newTemplate) {
|
|
6668
|
-
return;
|
|
6669
|
-
}
|
|
6670
|
-
const newEl = strToDOM(newTemplate);
|
|
6671
|
-
const v = newEl.dataset.bgiVer;
|
|
6672
|
-
const itemEditor = BurgerEditorEngine.getItemSeed(this.name);
|
|
6673
|
-
const currentData = itemEditor
|
|
6674
|
-
? // @ts-ignore
|
|
6675
|
-
itemEditor.migrate(this)
|
|
6676
|
-
: this.export();
|
|
6677
|
-
const newTemplateData = dataFromHtml(newEl.innerHTML);
|
|
6678
|
-
const data = { ...newTemplateData, ...currentData };
|
|
6679
|
-
this.el.innerHTML = newEl.innerHTML;
|
|
6680
|
-
this.el.dataset.bgiVer = v;
|
|
6681
|
-
await this.import(data);
|
|
6682
|
-
this.#version = v;
|
|
6683
|
-
}
|
|
6684
|
-
#isOld(currentItems) {
|
|
6685
|
-
const originVersion = currentItems.get(this.name)?.version ?? '0.0.0';
|
|
6686
|
-
const isOld = semver.lt(this.#version, originVersion);
|
|
6687
|
-
return isOld;
|
|
6688
|
-
}
|
|
6689
|
-
async #openEditor() {
|
|
6690
|
-
await this.editor.open(this.#service);
|
|
6691
|
-
}
|
|
6692
|
-
static async create(engine, name, initData = {}) {
|
|
6693
|
-
const seed = engine.items.get(name);
|
|
6694
|
-
if (!seed) {
|
|
6695
|
-
throw new Error(`Item seed not found: ${name}`);
|
|
6696
|
-
}
|
|
6697
|
-
const version = seed.version;
|
|
6698
|
-
const wrapper = document.createElement('div');
|
|
6699
|
-
wrapper.dataset.bgi = name;
|
|
6700
|
-
wrapper.dataset.bgiVer = version;
|
|
6701
|
-
wrapper.innerHTML = replacePlaceholders(seed.template, engine.config);
|
|
6702
|
-
const item = new Item(engine, seed, wrapper);
|
|
6703
|
-
await item.import(initData);
|
|
6704
|
-
return item;
|
|
6705
|
-
}
|
|
6706
|
-
static rebind(engine, el) {
|
|
6707
|
-
const name = el.dataset.bgi;
|
|
6708
|
-
if (!name) {
|
|
6709
|
-
throw new Error('data-bgi not found');
|
|
6710
|
-
}
|
|
6711
|
-
const seed = engine.items.get(name);
|
|
6712
|
-
if (!seed) {
|
|
6713
|
-
throw new Error(`Item seed not found: ${name}`);
|
|
6714
|
-
}
|
|
6715
|
-
const item = new Item(engine, seed, el);
|
|
6716
|
-
return item;
|
|
6717
|
-
}
|
|
6718
|
-
static getInstance(el) {
|
|
6719
|
-
return elMap.get(el);
|
|
6720
|
-
}
|
|
6721
|
-
};
|
|
6722
|
-
|
|
6723
|
-
/**
|
|
6724
|
-
* グリッドアイテムを追加または削除する
|
|
6725
|
-
* @param $items - 子要素の配列
|
|
6726
|
-
* @param engine - BurgerEditorEngineインスタンス
|
|
6727
|
-
* @param addOrRemove - 1: 追加, -1: 削除
|
|
6728
|
-
* @param items - アイテムの配列
|
|
6729
|
-
* @param updateItem
|
|
6730
|
-
* @description
|
|
6731
|
-
* グリッドアイテムの追加/削除を行う:
|
|
6732
|
-
* - 追加の場合:
|
|
6733
|
-
* 1. 最後の要素をクローン
|
|
6734
|
-
* 2. クローンを親要素に追加
|
|
6735
|
-
* 3. クローン内のアイテムを初期化してitemsに追加
|
|
6736
|
-
* - 削除の場合:
|
|
6737
|
-
* 1. 最後の要素を削除
|
|
6738
|
-
* 2. itemsから対応するアイテムを削除
|
|
6739
|
-
*/
|
|
6740
|
-
function updateGridItems($items, engine, addOrRemove, items, updateItem) {
|
|
6741
|
-
const $lastItem = $items.at(-1);
|
|
6742
|
-
if (!$lastItem) {
|
|
6743
|
-
return;
|
|
6744
|
-
}
|
|
6745
|
-
// Add
|
|
6746
|
-
if (addOrRemove === 1) {
|
|
6747
|
-
const $newItem = $lastItem.cloneNode(true);
|
|
6748
|
-
$lastItem.parentElement?.append($newItem);
|
|
6749
|
-
const $newItems = $newItem.querySelectorAll('[data-bge-group]');
|
|
6750
|
-
for (const $item of $newItems) {
|
|
6751
|
-
const item = Item$1.rebind(engine, $item);
|
|
6752
|
-
const newItems = [...items];
|
|
6753
|
-
newItems[newItems.length] = item;
|
|
6754
|
-
updateItem(newItems);
|
|
6755
|
-
}
|
|
6756
|
-
return;
|
|
6757
|
-
}
|
|
6758
|
-
// Remove
|
|
6759
|
-
const removeCount = $lastItem.querySelectorAll('[data-bge-group]').length;
|
|
6760
|
-
$lastItem.remove();
|
|
6761
|
-
const newItems = [...items];
|
|
6762
|
-
newItems.splice(-removeCount);
|
|
6763
|
-
updateItem(newItems);
|
|
6764
|
-
}
|
|
6765
|
-
|
|
6766
|
-
var _a;
|
|
6767
|
-
const bbMap = new WeakMap();
|
|
6768
|
-
let _lastUID = 0;
|
|
6769
|
-
class BurgerBlock {
|
|
6770
|
-
#createItemElement;
|
|
6771
|
-
#items = [];
|
|
6772
|
-
#uid;
|
|
6773
|
-
get items() {
|
|
6774
|
-
return this.#items;
|
|
6775
|
-
}
|
|
6776
|
-
set items(items) {
|
|
6777
|
-
this.#items = items;
|
|
6778
|
-
}
|
|
6779
|
-
get id() {
|
|
6780
|
-
return this.el.id;
|
|
6781
|
-
}
|
|
6782
|
-
get el() {
|
|
6783
|
-
return bbMap.get(this);
|
|
6784
|
-
}
|
|
6785
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
6786
|
-
constructor(createItemElement) {
|
|
6787
|
-
this.#uid = _lastUID++;
|
|
6788
|
-
this.#createItemElement = createItemElement;
|
|
6789
|
-
}
|
|
6790
|
-
/**
|
|
6791
|
-
* Change the semantic type of container frame and groups
|
|
6792
|
-
* @param frameSemantics - The semantic type to change to
|
|
6793
|
-
*/
|
|
6794
|
-
changeFrameSemantics(frameSemantics) {
|
|
6795
|
-
const containerFrame = this.el.querySelector('[data-bge-container-frame]');
|
|
6796
|
-
if (!containerFrame) {
|
|
6797
|
-
throw new Error('Container frame not found');
|
|
6798
|
-
}
|
|
6799
|
-
// Determine target elements
|
|
6800
|
-
const frameTagName = frameSemantics === 'div' ? 'div' : frameSemantics;
|
|
6801
|
-
const groupTagName = frameSemantics === 'div' ? 'div' : 'li';
|
|
6802
|
-
// Create new container frame element
|
|
6803
|
-
const newFrame = document.createElement(frameTagName);
|
|
6804
|
-
this.#copyAttributes(containerFrame, newFrame);
|
|
6805
|
-
// Transform groups
|
|
6806
|
-
const groups = containerFrame.querySelectorAll('[data-bge-group]');
|
|
6807
|
-
for (const group of groups) {
|
|
6808
|
-
const newGroup = document.createElement(groupTagName);
|
|
6809
|
-
this.#copyAttributes(group, newGroup);
|
|
6810
|
-
// Move all child content
|
|
6811
|
-
while (group.firstChild) {
|
|
6812
|
-
newGroup.append(group.firstChild);
|
|
6813
|
-
}
|
|
6814
|
-
newFrame.append(newGroup);
|
|
6815
|
-
}
|
|
6816
|
-
// Replace old frame with new frame
|
|
6817
|
-
containerFrame.parentNode?.replaceChild(newFrame, containerFrame);
|
|
6818
|
-
// Update internal references
|
|
6819
|
-
_a.#blocks.set(this.el, this);
|
|
6820
|
-
// Update options with new frameSemantics
|
|
6821
|
-
const currentOptions = this.exportOptions();
|
|
6822
|
-
this.importOptions({
|
|
6823
|
-
...currentOptions,
|
|
6824
|
-
containerProps: {
|
|
6825
|
-
...currentOptions.containerProps,
|
|
6826
|
-
frameSemantics,
|
|
6827
|
-
},
|
|
6828
|
-
});
|
|
6829
|
-
}
|
|
6830
|
-
clone() {
|
|
6831
|
-
const originalData = this.#export();
|
|
6832
|
-
const newBlock = _a.create(originalData, this.#createItemElement);
|
|
6833
|
-
return newBlock;
|
|
6834
|
-
}
|
|
6835
|
-
existNext() {
|
|
6836
|
-
return !!this.el.nextElementSibling;
|
|
6837
|
-
}
|
|
6838
|
-
existPrev() {
|
|
6839
|
-
return !!this.el.previousElementSibling;
|
|
6840
|
-
}
|
|
6841
|
-
exportOptions() {
|
|
6842
|
-
return exportOptions(this.el);
|
|
6843
|
-
}
|
|
6844
|
-
getHTMLStringify() {
|
|
6845
|
-
return this.el.outerHTML;
|
|
6846
|
-
}
|
|
6847
|
-
async importJSONString(jsonString) {
|
|
6848
|
-
const data = JSON.parse(jsonString);
|
|
6849
|
-
try {
|
|
6850
|
-
await this.#import(data);
|
|
6851
|
-
}
|
|
6852
|
-
catch (error) {
|
|
6853
|
-
throw new Error(`ImportError: ${error instanceof Error ? error.message : error}`);
|
|
6854
|
-
}
|
|
6855
|
-
}
|
|
6856
|
-
importOptions(options) {
|
|
6857
|
-
importOptions(this.el, options);
|
|
6858
|
-
}
|
|
6859
|
-
importTypes(extractor) {
|
|
6860
|
-
for (const [i, item] of this.items.entries()) {
|
|
6861
|
-
void item.import(extractor(i, item));
|
|
6862
|
-
}
|
|
6863
|
-
}
|
|
6864
|
-
is(block) {
|
|
6865
|
-
return this.#uid === block.#uid;
|
|
6866
|
-
}
|
|
6867
|
-
isDisable() {
|
|
6868
|
-
let msg = '';
|
|
6869
|
-
for (const type of this.items) {
|
|
6870
|
-
msg = type.isDisable();
|
|
6871
|
-
if (msg) {
|
|
6872
|
-
break;
|
|
6873
|
-
}
|
|
6874
|
-
}
|
|
6875
|
-
return msg;
|
|
6876
|
-
}
|
|
6877
|
-
isMutable() {
|
|
6878
|
-
return this.el.matches(':not([data-bge-container*=":immutable"])');
|
|
6879
|
-
}
|
|
6880
|
-
remove() {
|
|
6881
|
-
this.el.remove();
|
|
6882
|
-
}
|
|
6883
|
-
toJSONStringify(space) {
|
|
6884
|
-
return JSON.stringify(this.#export(), null, space);
|
|
6885
|
-
}
|
|
6886
|
-
updateGridItems(addOrRemove, engine) {
|
|
6887
|
-
updateGridItems([...this.el.querySelectorAll('[data-bge-group]')], engine, addOrRemove, this.items, (items) => (this.items = items));
|
|
6888
|
-
}
|
|
6889
|
-
/**
|
|
6890
|
-
* Copy all attributes from source to target element
|
|
6891
|
-
* @param source - Source element
|
|
6892
|
-
* @param target - Target element
|
|
6893
|
-
*/
|
|
6894
|
-
#copyAttributes(source, target) {
|
|
6895
|
-
for (const attr of source.attributes) {
|
|
6896
|
-
target.setAttribute(attr.name, attr.value);
|
|
6897
|
-
}
|
|
6898
|
-
// Copy classes
|
|
6899
|
-
target.className = source.className;
|
|
6900
|
-
}
|
|
6901
|
-
#create(data) {
|
|
6902
|
-
return createPlainStructuredBlockElement(data, this.#createItemElement);
|
|
6903
|
-
}
|
|
6904
|
-
#export() {
|
|
6905
|
-
return parseHTMLToBlockData(this.el);
|
|
6906
|
-
}
|
|
6907
|
-
#fallbackBlockData(html) {
|
|
6908
|
-
return {
|
|
6909
|
-
name: 'text',
|
|
6910
|
-
containerProps: {
|
|
6911
|
-
type: 'grid',
|
|
6912
|
-
columns: 1,
|
|
6913
|
-
},
|
|
6914
|
-
classList: [],
|
|
6915
|
-
items: [[{ name: 'wysiwyg', data: { wysiwyg: html } }]],
|
|
6916
|
-
};
|
|
6917
|
-
}
|
|
6918
|
-
async #import(data) {
|
|
6919
|
-
this.el.replaceWith(await createPlainStructuredBlockElement(data, this.#createItemElement));
|
|
6920
|
-
}
|
|
6921
|
-
async #rebind(el) {
|
|
6922
|
-
if (isBurgerBlockElement(el)) {
|
|
6923
|
-
const itemContainers = el.querySelectorAll('[data-bge-item]');
|
|
6924
|
-
for (const itemContainer of itemContainers) {
|
|
6925
|
-
const itemElements = itemContainer.querySelectorAll('[data-bgi]');
|
|
6926
|
-
for (const itemElement of itemElements) {
|
|
6927
|
-
await this.#createItemElement(itemElement);
|
|
6928
|
-
}
|
|
6929
|
-
}
|
|
6930
|
-
return el;
|
|
6931
|
-
}
|
|
6932
|
-
// eslint-disable-next-line no-console
|
|
6933
|
-
console.error('%o is not a burger block', el);
|
|
6934
|
-
const fallbackEl = await createPlainStructuredBlockElement(this.#fallbackBlockData(el.outerHTML), this.#createItemElement);
|
|
6935
|
-
el.replaceWith(fallbackEl);
|
|
6936
|
-
return fallbackEl;
|
|
6937
|
-
}
|
|
6938
|
-
#set(el) {
|
|
6939
|
-
bbMap.set(this, el);
|
|
6940
|
-
_a.#blocks.set(this.el, this);
|
|
6941
|
-
}
|
|
6942
|
-
static #blocks = new WeakMap();
|
|
6943
|
-
static async create(data, createItemElement) {
|
|
6944
|
-
const block = new _a(createItemElement);
|
|
6945
|
-
const el = await block.#create(data);
|
|
6946
|
-
block.#set(el);
|
|
6947
|
-
return block;
|
|
6948
|
-
}
|
|
6949
|
-
static async rebind(el, createItemElement) {
|
|
6950
|
-
const block = new _a(createItemElement);
|
|
6951
|
-
const newEl = await block.#rebind(el);
|
|
6952
|
-
block.#set(newEl);
|
|
6953
|
-
return block;
|
|
6954
|
-
}
|
|
6955
|
-
static getBlock(el) {
|
|
6956
|
-
const block = this.#blocks.get(el);
|
|
6957
|
-
if (!block) {
|
|
6958
|
-
throw new Error('Do not get BurgerBlock instance.');
|
|
6959
|
-
}
|
|
6960
|
-
return block;
|
|
6961
|
-
}
|
|
6962
|
-
}
|
|
6963
|
-
_a = BurgerBlock;
|
|
6964
|
-
/**
|
|
6965
|
-
*
|
|
6966
|
-
* @param el
|
|
6967
|
-
*/
|
|
6968
|
-
function isBurgerBlockElement(el) {
|
|
6969
|
-
return el.matches([
|
|
6970
|
-
'[data-bge-name][data-bge-container]:has(>[data-bge-container-frame]>[data-bge-group]>[data-bge-item])',
|
|
6971
|
-
].join(','));
|
|
6972
|
-
}
|
|
6973
|
-
|
|
6974
6962
|
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 -2z\" />\n <path d=\"M11 17h2\" />\n <path d=\"M9 12h6\" />\n <path d=\"M10 7h4\" />\n</svg>";
|
|
6975
6963
|
|
|
6976
6964
|
const IconBlockquote = "<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-blockquote\"\n>\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\"/>\n <path d=\"M6 15h15\" />\n <path d=\"M21 19h-15\" />\n <path d=\"M15 11h6\" />\n <path d=\"M21 7h-6\" />\n <path d=\"M9 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2\" />\n <path d=\"M3 9h1a1 1 0 1 1 -1 1v-2.5a2 2 0 0 1 2 -2\" />\n</svg>";
|
|
@@ -21940,8 +21928,10 @@ function selectionToInsertionEnd(tr, startLen, bias) {
|
|
|
21940
21928
|
}
|
|
21941
21929
|
var InputRule = class {
|
|
21942
21930
|
constructor(config) {
|
|
21931
|
+
var _a;
|
|
21943
21932
|
this.find = config.find;
|
|
21944
21933
|
this.handler = config.handler;
|
|
21934
|
+
this.undoable = (_a = config.undoable) != null ? _a : true;
|
|
21945
21935
|
}
|
|
21946
21936
|
};
|
|
21947
21937
|
var inputRuleMatcherHandler = (text, find) => {
|
|
@@ -22013,12 +22003,14 @@ function run$3(config) {
|
|
|
22013
22003
|
if (handler === null || !tr.steps.length) {
|
|
22014
22004
|
return;
|
|
22015
22005
|
}
|
|
22016
|
-
|
|
22017
|
-
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
|
-
|
|
22021
|
-
|
|
22006
|
+
if (rule.undoable) {
|
|
22007
|
+
tr.setMeta(plugin, {
|
|
22008
|
+
transform: tr,
|
|
22009
|
+
from,
|
|
22010
|
+
to,
|
|
22011
|
+
text
|
|
22012
|
+
});
|
|
22013
|
+
}
|
|
22022
22014
|
view.dispatch(tr);
|
|
22023
22015
|
matched = true;
|
|
22024
22016
|
});
|
|
@@ -22509,7 +22501,7 @@ var ExtensionManager = class {
|
|
|
22509
22501
|
get plugins() {
|
|
22510
22502
|
const { editor } = this;
|
|
22511
22503
|
const extensions = sortExtensions([...this.extensions].reverse());
|
|
22512
|
-
const allPlugins = extensions.
|
|
22504
|
+
const allPlugins = extensions.flatMap((extension) => {
|
|
22513
22505
|
const context = {
|
|
22514
22506
|
name: extension.name,
|
|
22515
22507
|
options: extension.options,
|
|
@@ -22567,7 +22559,7 @@ var ExtensionManager = class {
|
|
|
22567
22559
|
plugins.push(...proseMirrorPlugins);
|
|
22568
22560
|
}
|
|
22569
22561
|
return plugins;
|
|
22570
|
-
})
|
|
22562
|
+
});
|
|
22571
22563
|
return allPlugins;
|
|
22572
22564
|
}
|
|
22573
22565
|
/**
|
|
@@ -24610,6 +24602,9 @@ var Editor = class extends EventEmitter {
|
|
|
24610
24602
|
}
|
|
24611
24603
|
this.createView(el);
|
|
24612
24604
|
this.emit("mount", { editor: this });
|
|
24605
|
+
if (this.css && !document.head.contains(this.css)) {
|
|
24606
|
+
document.head.appendChild(this.css);
|
|
24607
|
+
}
|
|
24613
24608
|
window.setTimeout(() => {
|
|
24614
24609
|
if (this.isDestroyed) {
|
|
24615
24610
|
return;
|
|
@@ -24725,7 +24720,7 @@ var Editor = class extends EventEmitter {
|
|
|
24725
24720
|
this.editorState = state;
|
|
24726
24721
|
},
|
|
24727
24722
|
dispatch: (tr) => {
|
|
24728
|
-
this.
|
|
24723
|
+
this.dispatchTransaction(tr);
|
|
24729
24724
|
},
|
|
24730
24725
|
// Stub some commonly accessed properties to prevent errors
|
|
24731
24726
|
composing: false,
|
|
@@ -24735,6 +24730,9 @@ var Editor = class extends EventEmitter {
|
|
|
24735
24730
|
},
|
|
24736
24731
|
{
|
|
24737
24732
|
get: (obj, key) => {
|
|
24733
|
+
if (this.editorView) {
|
|
24734
|
+
return this.editorView[key];
|
|
24735
|
+
}
|
|
24738
24736
|
if (key === "state") {
|
|
24739
24737
|
return this.editorState;
|
|
24740
24738
|
}
|
|
@@ -25098,7 +25096,8 @@ function markInputRule(config) {
|
|
|
25098
25096
|
tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));
|
|
25099
25097
|
tr.removeStoredMark(config.type);
|
|
25100
25098
|
}
|
|
25101
|
-
}
|
|
25099
|
+
},
|
|
25100
|
+
undoable: config.undoable
|
|
25102
25101
|
});
|
|
25103
25102
|
}
|
|
25104
25103
|
|
|
@@ -25128,7 +25127,8 @@ function nodeInputRule(config) {
|
|
|
25128
25127
|
tr.insert(insertionStart, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));
|
|
25129
25128
|
}
|
|
25130
25129
|
tr.scrollIntoView();
|
|
25131
|
-
}
|
|
25130
|
+
},
|
|
25131
|
+
undoable: config.undoable
|
|
25132
25132
|
});
|
|
25133
25133
|
}
|
|
25134
25134
|
|
|
@@ -25143,7 +25143,8 @@ function textblockTypeInputRule(config) {
|
|
|
25143
25143
|
return null;
|
|
25144
25144
|
}
|
|
25145
25145
|
state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);
|
|
25146
|
-
}
|
|
25146
|
+
},
|
|
25147
|
+
undoable: config.undoable
|
|
25147
25148
|
});
|
|
25148
25149
|
}
|
|
25149
25150
|
function wrappingInputRule(config) {
|
|
@@ -25176,7 +25177,8 @@ function wrappingInputRule(config) {
|
|
|
25176
25177
|
if (before && before.type === config.type && canJoin(tr.doc, range.from - 1) && (!config.joinPredicate || config.joinPredicate(match, before))) {
|
|
25177
25178
|
tr.join(range.from - 1);
|
|
25178
25179
|
}
|
|
25179
|
-
}
|
|
25180
|
+
},
|
|
25181
|
+
undoable: config.undoable
|
|
25180
25182
|
});
|
|
25181
25183
|
}
|
|
25182
25184
|
function canInsertNode(state, nodeType) {
|
|
@@ -25495,6 +25497,7 @@ var Code = Mark.create({
|
|
|
25495
25497
|
});
|
|
25496
25498
|
|
|
25497
25499
|
// src/code-block.ts
|
|
25500
|
+
var DEFAULT_TAB_SIZE = 4;
|
|
25498
25501
|
var backtickInputRegex = /^```([a-z]+)?[\s\n]$/;
|
|
25499
25502
|
var tildeInputRegex = /^~~~([a-z]+)?[\s\n]$/;
|
|
25500
25503
|
var CodeBlock = Node3.create({
|
|
@@ -25506,7 +25509,7 @@ var CodeBlock = Node3.create({
|
|
|
25506
25509
|
exitOnArrowDown: true,
|
|
25507
25510
|
defaultLanguage: null,
|
|
25508
25511
|
enableTabIndentation: false,
|
|
25509
|
-
tabSize:
|
|
25512
|
+
tabSize: DEFAULT_TAB_SIZE,
|
|
25510
25513
|
HTMLAttributes: {}
|
|
25511
25514
|
};
|
|
25512
25515
|
},
|
|
@@ -25522,6 +25525,9 @@ var CodeBlock = Node3.create({
|
|
|
25522
25525
|
parseHTML: (element) => {
|
|
25523
25526
|
var _a;
|
|
25524
25527
|
const { languageClassPrefix } = this.options;
|
|
25528
|
+
if (!languageClassPrefix) {
|
|
25529
|
+
return null;
|
|
25530
|
+
}
|
|
25525
25531
|
const classNames = [...((_a = element.firstElementChild) == null ? void 0 : _a.classList) || []];
|
|
25526
25532
|
const languages = classNames.filter((className) => className.startsWith(languageClassPrefix)).map((className) => className.replace(languageClassPrefix, ""));
|
|
25527
25533
|
const language = languages[0];
|
|
@@ -25582,16 +25588,18 @@ var CodeBlock = Node3.create({
|
|
|
25582
25588
|
},
|
|
25583
25589
|
// handle tab indentation
|
|
25584
25590
|
Tab: ({ editor }) => {
|
|
25591
|
+
var _a;
|
|
25585
25592
|
if (!this.options.enableTabIndentation) {
|
|
25586
25593
|
return false;
|
|
25587
25594
|
}
|
|
25595
|
+
const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
|
|
25588
25596
|
const { state } = editor;
|
|
25589
25597
|
const { selection } = state;
|
|
25590
25598
|
const { $from, empty } = selection;
|
|
25591
25599
|
if ($from.parent.type !== this.type) {
|
|
25592
25600
|
return false;
|
|
25593
25601
|
}
|
|
25594
|
-
const indent = " ".repeat(
|
|
25602
|
+
const indent = " ".repeat(tabSize);
|
|
25595
25603
|
if (empty) {
|
|
25596
25604
|
return editor.commands.insertContent(indent);
|
|
25597
25605
|
}
|
|
@@ -25606,9 +25614,11 @@ var CodeBlock = Node3.create({
|
|
|
25606
25614
|
},
|
|
25607
25615
|
// handle shift+tab reverse indentation
|
|
25608
25616
|
"Shift-Tab": ({ editor }) => {
|
|
25617
|
+
var _a;
|
|
25609
25618
|
if (!this.options.enableTabIndentation) {
|
|
25610
25619
|
return false;
|
|
25611
25620
|
}
|
|
25621
|
+
const tabSize = (_a = this.options.tabSize) != null ? _a : DEFAULT_TAB_SIZE;
|
|
25612
25622
|
const { state } = editor;
|
|
25613
25623
|
const { selection } = state;
|
|
25614
25624
|
const { $from, empty } = selection;
|
|
@@ -25617,7 +25627,7 @@ var CodeBlock = Node3.create({
|
|
|
25617
25627
|
}
|
|
25618
25628
|
if (empty) {
|
|
25619
25629
|
return editor.commands.command(({ tr }) => {
|
|
25620
|
-
var
|
|
25630
|
+
var _a2;
|
|
25621
25631
|
const { pos } = $from;
|
|
25622
25632
|
const codeBlockStart = $from.start();
|
|
25623
25633
|
const codeBlockEnd = $from.end();
|
|
@@ -25634,8 +25644,8 @@ var CodeBlock = Node3.create({
|
|
|
25634
25644
|
charCount += lines[i].length + 1;
|
|
25635
25645
|
}
|
|
25636
25646
|
const currentLine = lines[currentLineIndex];
|
|
25637
|
-
const leadingSpaces = ((
|
|
25638
|
-
const spacesToRemove = Math.min(leadingSpaces.length,
|
|
25647
|
+
const leadingSpaces = ((_a2 = currentLine.match(/^ */)) == null ? void 0 : _a2[0]) || "";
|
|
25648
|
+
const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
|
|
25639
25649
|
if (spacesToRemove === 0) {
|
|
25640
25650
|
return true;
|
|
25641
25651
|
}
|
|
@@ -25656,9 +25666,9 @@ var CodeBlock = Node3.create({
|
|
|
25656
25666
|
const text = state.doc.textBetween(from, to, "\n", "\n");
|
|
25657
25667
|
const lines = text.split("\n");
|
|
25658
25668
|
const reverseIndentText = lines.map((line) => {
|
|
25659
|
-
var
|
|
25660
|
-
const leadingSpaces = ((
|
|
25661
|
-
const spacesToRemove = Math.min(leadingSpaces.length,
|
|
25669
|
+
var _a2;
|
|
25670
|
+
const leadingSpaces = ((_a2 = line.match(/^ */)) == null ? void 0 : _a2[0]) || "";
|
|
25671
|
+
const spacesToRemove = Math.min(leadingSpaces.length, tabSize);
|
|
25662
25672
|
return line.slice(spacesToRemove);
|
|
25663
25673
|
}).join("\n");
|
|
25664
25674
|
tr.replaceWith(from, to, state.schema.text(reverseIndentText));
|
|
@@ -25909,7 +25919,8 @@ var HorizontalRule = Node3.create({
|
|
|
25909
25919
|
name: "horizontalRule",
|
|
25910
25920
|
addOptions() {
|
|
25911
25921
|
return {
|
|
25912
|
-
HTMLAttributes: {}
|
|
25922
|
+
HTMLAttributes: {},
|
|
25923
|
+
nextNodeType: "paragraph"
|
|
25913
25924
|
};
|
|
25914
25925
|
},
|
|
25915
25926
|
group: "block",
|
|
@@ -25935,8 +25946,7 @@ var HorizontalRule = Node3.create({
|
|
|
25935
25946
|
} else {
|
|
25936
25947
|
currentChain.insertContent({ type: this.name });
|
|
25937
25948
|
}
|
|
25938
|
-
return currentChain.command(({ tr, dispatch }) => {
|
|
25939
|
-
var _a;
|
|
25949
|
+
return currentChain.command(({ state: chainState, tr, dispatch }) => {
|
|
25940
25950
|
if (dispatch) {
|
|
25941
25951
|
const { $to } = tr.selection;
|
|
25942
25952
|
const posAfter = $to.end();
|
|
@@ -25949,7 +25959,8 @@ var HorizontalRule = Node3.create({
|
|
|
25949
25959
|
tr.setSelection(TextSelection.create(tr.doc, $to.pos));
|
|
25950
25960
|
}
|
|
25951
25961
|
} else {
|
|
25952
|
-
const
|
|
25962
|
+
const nodeType = chainState.schema.nodes[this.options.nextNodeType] || $to.parent.type.contentMatch.defaultType;
|
|
25963
|
+
const node = nodeType == null ? void 0 : nodeType.create();
|
|
25953
25964
|
if (node) {
|
|
25954
25965
|
tr.insert(posAfter, node);
|
|
25955
25966
|
tr.setSelection(TextSelection.create(tr.doc, posAfter + 1));
|
|
@@ -32610,8 +32621,17 @@ var TableCell$1 = Node3.create({
|
|
|
32610
32621
|
colwidth: {
|
|
32611
32622
|
default: null,
|
|
32612
32623
|
parseHTML: (element) => {
|
|
32624
|
+
var _a, _b;
|
|
32613
32625
|
const colwidth = element.getAttribute("colwidth");
|
|
32614
32626
|
const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
|
|
32627
|
+
if (!value) {
|
|
32628
|
+
const cols = (_a = element.closest("table")) == null ? void 0 : _a.querySelectorAll("colgroup > col");
|
|
32629
|
+
const cellIndex = Array.from(((_b = element.parentElement) == null ? void 0 : _b.children) || []).indexOf(element);
|
|
32630
|
+
if (cellIndex && cellIndex > -1 && cols && cols[cellIndex]) {
|
|
32631
|
+
const colWidth = cols[cellIndex].getAttribute("width");
|
|
32632
|
+
return colWidth ? [parseInt(colWidth, 10)] : null;
|
|
32633
|
+
}
|
|
32634
|
+
}
|
|
32615
32635
|
return value;
|
|
32616
32636
|
}
|
|
32617
32637
|
}
|
|
@@ -32751,7 +32771,15 @@ var TableView = class {
|
|
|
32751
32771
|
return true;
|
|
32752
32772
|
}
|
|
32753
32773
|
ignoreMutation(mutation) {
|
|
32754
|
-
|
|
32774
|
+
const target = mutation.target;
|
|
32775
|
+
const isInsideWrapper = this.dom.contains(target);
|
|
32776
|
+
const isInsideContent = this.contentDOM.contains(target);
|
|
32777
|
+
if (isInsideWrapper && !isInsideContent) {
|
|
32778
|
+
if (mutation.type === "attributes" || mutation.type === "childList" || mutation.type === "characterData") {
|
|
32779
|
+
return true;
|
|
32780
|
+
}
|
|
32781
|
+
}
|
|
32782
|
+
return false;
|
|
32755
32783
|
}
|
|
32756
32784
|
};
|
|
32757
32785
|
|
|
@@ -34544,25 +34572,12 @@ function is_runes() {
|
|
|
34544
34572
|
/** @type {Array<() => void>} */
|
|
34545
34573
|
let micro_tasks = [];
|
|
34546
34574
|
|
|
34547
|
-
/** @type {Array<() => void>} */
|
|
34548
|
-
let idle_tasks = [];
|
|
34549
|
-
|
|
34550
34575
|
function run_micro_tasks() {
|
|
34551
34576
|
var tasks = micro_tasks;
|
|
34552
34577
|
micro_tasks = [];
|
|
34553
34578
|
run_all(tasks);
|
|
34554
34579
|
}
|
|
34555
34580
|
|
|
34556
|
-
function run_idle_tasks() {
|
|
34557
|
-
var tasks = idle_tasks;
|
|
34558
|
-
idle_tasks = [];
|
|
34559
|
-
run_all(tasks);
|
|
34560
|
-
}
|
|
34561
|
-
|
|
34562
|
-
function has_pending_tasks() {
|
|
34563
|
-
return micro_tasks.length > 0 || idle_tasks.length > 0;
|
|
34564
|
-
}
|
|
34565
|
-
|
|
34566
34581
|
/**
|
|
34567
34582
|
* @param {() => void} fn
|
|
34568
34583
|
*/
|
|
@@ -34589,13 +34604,9 @@ function queue_micro_task(fn) {
|
|
|
34589
34604
|
* Synchronously run any queued tasks.
|
|
34590
34605
|
*/
|
|
34591
34606
|
function flush_tasks() {
|
|
34592
|
-
|
|
34607
|
+
while (micro_tasks.length > 0) {
|
|
34593
34608
|
run_micro_tasks();
|
|
34594
34609
|
}
|
|
34595
|
-
|
|
34596
|
-
if (idle_tasks.length > 0) {
|
|
34597
|
-
run_idle_tasks();
|
|
34598
|
-
}
|
|
34599
34610
|
}
|
|
34600
34611
|
|
|
34601
34612
|
/** @import { Derived, Effect } from '#client' */
|
|
@@ -34675,7 +34686,7 @@ function apply_adjustments(error) {
|
|
|
34675
34686
|
}
|
|
34676
34687
|
}
|
|
34677
34688
|
|
|
34678
|
-
/** @import { Derived, Effect, Source } from '#client' */
|
|
34689
|
+
/** @import { Derived, Effect, Source, Value } from '#client' */
|
|
34679
34690
|
|
|
34680
34691
|
/** @type {Set<Batch>} */
|
|
34681
34692
|
const batches = new Set();
|
|
@@ -34737,22 +34748,8 @@ class Batch {
|
|
|
34737
34748
|
#deferred = null;
|
|
34738
34749
|
|
|
34739
34750
|
/**
|
|
34740
|
-
*
|
|
34741
|
-
*
|
|
34742
|
-
*/
|
|
34743
|
-
#neutered = false;
|
|
34744
|
-
|
|
34745
|
-
/**
|
|
34746
|
-
* Async effects (created inside `async_derived`) encountered during processing.
|
|
34747
|
-
* These run after the rest of the batch has updated, since they should
|
|
34748
|
-
* always have the latest values
|
|
34749
|
-
* @type {Effect[]}
|
|
34750
|
-
*/
|
|
34751
|
-
#async_effects = [];
|
|
34752
|
-
|
|
34753
|
-
/**
|
|
34754
|
-
* The same as `#async_effects`, but for effects inside a newly-created
|
|
34755
|
-
* `<svelte:boundary>` — these do not prevent the batch from committing
|
|
34751
|
+
* Async effects inside a newly-created `<svelte:boundary>`
|
|
34752
|
+
* — these do not prevent the batch from committing
|
|
34756
34753
|
* @type {Effect[]}
|
|
34757
34754
|
*/
|
|
34758
34755
|
#boundary_async_effects = [];
|
|
@@ -34805,13 +34802,15 @@ class Batch {
|
|
|
34805
34802
|
|
|
34806
34803
|
previous_batch = null;
|
|
34807
34804
|
|
|
34805
|
+
var revert = Batch.apply(this);
|
|
34806
|
+
|
|
34808
34807
|
for (const root of root_effects) {
|
|
34809
34808
|
this.#traverse_effect_tree(root);
|
|
34810
34809
|
}
|
|
34811
34810
|
|
|
34812
34811
|
// if we didn't start any new async work, and no async work
|
|
34813
34812
|
// is outstanding from a previous flush, commit
|
|
34814
|
-
if (this.#
|
|
34813
|
+
if (this.#pending === 0) {
|
|
34815
34814
|
this.#commit();
|
|
34816
34815
|
|
|
34817
34816
|
var render_effects = this.#render_effects;
|
|
@@ -34823,21 +34822,12 @@ class Batch {
|
|
|
34823
34822
|
|
|
34824
34823
|
// If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
|
|
34825
34824
|
// newly updated sources, which could lead to infinite loops when effects run over and over again.
|
|
34826
|
-
previous_batch =
|
|
34825
|
+
previous_batch = this;
|
|
34827
34826
|
current_batch = null;
|
|
34828
34827
|
|
|
34829
34828
|
flush_queued_effects(render_effects);
|
|
34830
34829
|
flush_queued_effects(effects);
|
|
34831
34830
|
|
|
34832
|
-
// Reinstate the current batch if there was no new one created, as `process()` runs in a loop in `flush_effects()`.
|
|
34833
|
-
// That method expects `current_batch` to be set, and could run the loop again if effects result in new effects
|
|
34834
|
-
// being scheduled but without writes happening in which case no new batch is created.
|
|
34835
|
-
if (current_batch === null) {
|
|
34836
|
-
current_batch = this;
|
|
34837
|
-
} else {
|
|
34838
|
-
batches.delete(this);
|
|
34839
|
-
}
|
|
34840
|
-
|
|
34841
34831
|
this.#deferred?.resolve();
|
|
34842
34832
|
} else {
|
|
34843
34833
|
this.#defer_effects(this.#render_effects);
|
|
@@ -34845,15 +34835,12 @@ class Batch {
|
|
|
34845
34835
|
this.#defer_effects(this.#block_effects);
|
|
34846
34836
|
}
|
|
34847
34837
|
|
|
34848
|
-
|
|
34849
|
-
update_effect(effect);
|
|
34850
|
-
}
|
|
34838
|
+
revert();
|
|
34851
34839
|
|
|
34852
34840
|
for (const effect of this.#boundary_async_effects) {
|
|
34853
34841
|
update_effect(effect);
|
|
34854
34842
|
}
|
|
34855
34843
|
|
|
34856
|
-
this.#async_effects = [];
|
|
34857
34844
|
this.#boundary_async_effects = [];
|
|
34858
34845
|
}
|
|
34859
34846
|
|
|
@@ -34880,12 +34867,8 @@ class Batch {
|
|
|
34880
34867
|
} else if ((flags & EFFECT) !== 0) {
|
|
34881
34868
|
this.#effects.push(effect);
|
|
34882
34869
|
} else if ((flags & CLEAN) === 0) {
|
|
34883
|
-
if ((flags & ASYNC) !== 0) {
|
|
34884
|
-
|
|
34885
|
-
? this.#boundary_async_effects
|
|
34886
|
-
: this.#async_effects;
|
|
34887
|
-
|
|
34888
|
-
effects.push(effect);
|
|
34870
|
+
if ((flags & ASYNC) !== 0 && effect.b?.is_pending()) {
|
|
34871
|
+
this.#boundary_async_effects.push(effect);
|
|
34889
34872
|
} else if (is_dirty(effect)) {
|
|
34890
34873
|
if ((effect.f & BLOCK_EFFECT) !== 0) this.#block_effects.push(effect);
|
|
34891
34874
|
update_effect(effect);
|
|
@@ -34958,25 +34941,17 @@ class Batch {
|
|
|
34958
34941
|
}
|
|
34959
34942
|
}
|
|
34960
34943
|
|
|
34961
|
-
neuter() {
|
|
34962
|
-
this.#neutered = true;
|
|
34963
|
-
}
|
|
34964
|
-
|
|
34965
34944
|
flush() {
|
|
34966
34945
|
if (queued_root_effects.length > 0) {
|
|
34946
|
+
this.activate();
|
|
34967
34947
|
flush_effects();
|
|
34968
|
-
} else {
|
|
34969
|
-
this.#commit();
|
|
34970
|
-
}
|
|
34971
|
-
|
|
34972
|
-
if (current_batch !== this) {
|
|
34973
|
-
// this can happen if a `flushSync` occurred during `flush_effects()`,
|
|
34974
|
-
// which is permitted in legacy mode despite being a terrible idea
|
|
34975
|
-
return;
|
|
34976
|
-
}
|
|
34977
34948
|
|
|
34978
|
-
|
|
34979
|
-
|
|
34949
|
+
if (current_batch !== null && current_batch !== this) {
|
|
34950
|
+
// this can happen if a new batch was created during `flush_effects()`
|
|
34951
|
+
return;
|
|
34952
|
+
}
|
|
34953
|
+
} else if (this.#pending === 0) {
|
|
34954
|
+
this.#commit();
|
|
34980
34955
|
}
|
|
34981
34956
|
|
|
34982
34957
|
this.deactivate();
|
|
@@ -34986,13 +34961,59 @@ class Batch {
|
|
|
34986
34961
|
* Append and remove branches to/from the DOM
|
|
34987
34962
|
*/
|
|
34988
34963
|
#commit() {
|
|
34989
|
-
|
|
34990
|
-
|
|
34991
|
-
fn();
|
|
34992
|
-
}
|
|
34964
|
+
for (const fn of this.#callbacks) {
|
|
34965
|
+
fn();
|
|
34993
34966
|
}
|
|
34994
34967
|
|
|
34995
34968
|
this.#callbacks.clear();
|
|
34969
|
+
|
|
34970
|
+
// If there are other pending batches, they now need to be 'rebased' —
|
|
34971
|
+
// in other words, we re-run block/async effects with the newly
|
|
34972
|
+
// committed state, unless the batch in question has a more
|
|
34973
|
+
// recent value for a given source
|
|
34974
|
+
if (batches.size > 1) {
|
|
34975
|
+
this.#previous.clear();
|
|
34976
|
+
|
|
34977
|
+
let is_earlier = true;
|
|
34978
|
+
|
|
34979
|
+
for (const batch of batches) {
|
|
34980
|
+
if (batch === this) {
|
|
34981
|
+
is_earlier = false;
|
|
34982
|
+
continue;
|
|
34983
|
+
}
|
|
34984
|
+
|
|
34985
|
+
for (const [source, value] of this.current) {
|
|
34986
|
+
if (batch.current.has(source)) {
|
|
34987
|
+
if (is_earlier) {
|
|
34988
|
+
// bring the value up to date
|
|
34989
|
+
batch.current.set(source, value);
|
|
34990
|
+
} else {
|
|
34991
|
+
// later batch has more recent value,
|
|
34992
|
+
// no need to re-run these effects
|
|
34993
|
+
continue;
|
|
34994
|
+
}
|
|
34995
|
+
}
|
|
34996
|
+
|
|
34997
|
+
mark_effects(source);
|
|
34998
|
+
}
|
|
34999
|
+
|
|
35000
|
+
if (queued_root_effects.length > 0) {
|
|
35001
|
+
current_batch = batch;
|
|
35002
|
+
const revert = Batch.apply(batch);
|
|
35003
|
+
|
|
35004
|
+
for (const root of queued_root_effects) {
|
|
35005
|
+
batch.#traverse_effect_tree(root);
|
|
35006
|
+
}
|
|
35007
|
+
|
|
35008
|
+
queued_root_effects = [];
|
|
35009
|
+
revert();
|
|
35010
|
+
}
|
|
35011
|
+
}
|
|
35012
|
+
|
|
35013
|
+
current_batch = null;
|
|
35014
|
+
}
|
|
35015
|
+
|
|
35016
|
+
batches.delete(this);
|
|
34996
35017
|
}
|
|
34997
35018
|
|
|
34998
35019
|
increment() {
|
|
@@ -35013,9 +35034,6 @@ class Batch {
|
|
|
35013
35034
|
schedule_effect(e);
|
|
35014
35035
|
}
|
|
35015
35036
|
|
|
35016
|
-
this.#render_effects = [];
|
|
35017
|
-
this.#effects = [];
|
|
35018
|
-
|
|
35019
35037
|
this.flush();
|
|
35020
35038
|
} else {
|
|
35021
35039
|
this.deactivate();
|
|
@@ -35055,6 +35073,15 @@ class Batch {
|
|
|
35055
35073
|
static enqueue(task) {
|
|
35056
35074
|
queue_micro_task(task);
|
|
35057
35075
|
}
|
|
35076
|
+
|
|
35077
|
+
/**
|
|
35078
|
+
* @param {Batch} current_batch
|
|
35079
|
+
*/
|
|
35080
|
+
static apply(current_batch) {
|
|
35081
|
+
{
|
|
35082
|
+
return noop;
|
|
35083
|
+
}
|
|
35084
|
+
}
|
|
35058
35085
|
}
|
|
35059
35086
|
|
|
35060
35087
|
/**
|
|
@@ -35077,7 +35104,7 @@ function flushSync(fn) {
|
|
|
35077
35104
|
while (true) {
|
|
35078
35105
|
flush_tasks();
|
|
35079
35106
|
|
|
35080
|
-
if (queued_root_effects.length === 0
|
|
35107
|
+
if (queued_root_effects.length === 0) {
|
|
35081
35108
|
current_batch?.flush();
|
|
35082
35109
|
|
|
35083
35110
|
// we need to check again, in case we just updated an `$effect.pending()`
|
|
@@ -35192,6 +35219,26 @@ function flush_queued_effects(effects) {
|
|
|
35192
35219
|
eager_block_effects = null;
|
|
35193
35220
|
}
|
|
35194
35221
|
|
|
35222
|
+
/**
|
|
35223
|
+
* This is similar to `mark_reactions`, but it only marks async/block effects
|
|
35224
|
+
* so that these can re-run after another batch has been committed
|
|
35225
|
+
* @param {Value} value
|
|
35226
|
+
*/
|
|
35227
|
+
function mark_effects(value) {
|
|
35228
|
+
if (value.reactions !== null) {
|
|
35229
|
+
for (const reaction of value.reactions) {
|
|
35230
|
+
const flags = reaction.f;
|
|
35231
|
+
|
|
35232
|
+
if ((flags & DERIVED) !== 0) {
|
|
35233
|
+
mark_effects(/** @type {Derived} */ (reaction));
|
|
35234
|
+
} else if ((flags & (ASYNC | BLOCK_EFFECT)) !== 0) {
|
|
35235
|
+
set_signal_status(reaction, DIRTY);
|
|
35236
|
+
schedule_effect(/** @type {Effect} */ (reaction));
|
|
35237
|
+
}
|
|
35238
|
+
}
|
|
35239
|
+
}
|
|
35240
|
+
}
|
|
35241
|
+
|
|
35195
35242
|
/**
|
|
35196
35243
|
* @param {Effect} signal
|
|
35197
35244
|
* @returns {void}
|
|
@@ -35535,6 +35582,13 @@ class Boundary {
|
|
|
35535
35582
|
this.#anchor.before(this.#offscreen_fragment);
|
|
35536
35583
|
this.#offscreen_fragment = null;
|
|
35537
35584
|
}
|
|
35585
|
+
|
|
35586
|
+
// TODO this feels like a little bit of a kludge, but until we
|
|
35587
|
+
// overhaul the boundary/batch relationship it's probably
|
|
35588
|
+
// the most pragmatic solution available to us
|
|
35589
|
+
queue_micro_task(() => {
|
|
35590
|
+
Batch.ensure().flush();
|
|
35591
|
+
});
|
|
35538
35592
|
}
|
|
35539
35593
|
}
|
|
35540
35594
|
|
|
@@ -35812,34 +35866,37 @@ function async_derived(fn, location) {
|
|
|
35812
35866
|
var promise = /** @type {Promise<V>} */ (/** @type {unknown} */ (undefined));
|
|
35813
35867
|
var signal = source(/** @type {V} */ (UNINITIALIZED));
|
|
35814
35868
|
|
|
35815
|
-
/** @type {Promise<V> | null} */
|
|
35816
|
-
var prev = null;
|
|
35817
|
-
|
|
35818
35869
|
// only suspend in async deriveds created on initialisation
|
|
35819
35870
|
var should_suspend = !active_reaction;
|
|
35820
35871
|
|
|
35872
|
+
/** @type {Map<Batch, ReturnType<typeof deferred<V>>>} */
|
|
35873
|
+
var deferreds = new Map();
|
|
35874
|
+
|
|
35821
35875
|
async_effect(() => {
|
|
35822
35876
|
|
|
35877
|
+
/** @type {ReturnType<typeof deferred<V>>} */
|
|
35878
|
+
var d = deferred();
|
|
35879
|
+
promise = d.promise;
|
|
35880
|
+
|
|
35823
35881
|
try {
|
|
35824
|
-
|
|
35825
|
-
//
|
|
35826
|
-
|
|
35827
|
-
if (prev) Promise.resolve(p).catch(() => {}); // avoid unhandled rejection
|
|
35882
|
+
// If this code is changed at some point, make sure to still access the then property
|
|
35883
|
+
// of fn() to read any signals it might access, so that we track them as dependencies.
|
|
35884
|
+
Promise.resolve(fn()).then(d.resolve, d.reject);
|
|
35828
35885
|
} catch (error) {
|
|
35829
|
-
|
|
35886
|
+
d.reject(error);
|
|
35830
35887
|
}
|
|
35831
35888
|
|
|
35832
|
-
var r = () => p;
|
|
35833
|
-
promise = prev?.then(r, r) ?? Promise.resolve(p);
|
|
35834
|
-
|
|
35835
|
-
prev = promise;
|
|
35836
|
-
|
|
35837
35889
|
var batch = /** @type {Batch} */ (current_batch);
|
|
35838
35890
|
var pending = boundary.is_pending();
|
|
35839
35891
|
|
|
35840
35892
|
if (should_suspend) {
|
|
35841
35893
|
boundary.update_pending_count(1);
|
|
35842
|
-
if (!pending)
|
|
35894
|
+
if (!pending) {
|
|
35895
|
+
batch.increment();
|
|
35896
|
+
|
|
35897
|
+
deferreds.get(batch)?.reject(STALE_REACTION);
|
|
35898
|
+
deferreds.set(batch, d);
|
|
35899
|
+
}
|
|
35843
35900
|
}
|
|
35844
35901
|
|
|
35845
35902
|
/**
|
|
@@ -35847,7 +35904,6 @@ function async_derived(fn, location) {
|
|
|
35847
35904
|
* @param {unknown} error
|
|
35848
35905
|
*/
|
|
35849
35906
|
const handler = (value, error = undefined) => {
|
|
35850
|
-
prev = null;
|
|
35851
35907
|
|
|
35852
35908
|
if (!pending) batch.activate();
|
|
35853
35909
|
|
|
@@ -35874,12 +35930,12 @@ function async_derived(fn, location) {
|
|
|
35874
35930
|
unset_context();
|
|
35875
35931
|
};
|
|
35876
35932
|
|
|
35877
|
-
promise.then(handler, (e) => handler(null, e || 'unknown'));
|
|
35933
|
+
d.promise.then(handler, (e) => handler(null, e || 'unknown'));
|
|
35934
|
+
});
|
|
35878
35935
|
|
|
35879
|
-
|
|
35880
|
-
|
|
35881
|
-
|
|
35882
|
-
};
|
|
35936
|
+
teardown(() => {
|
|
35937
|
+
for (const d of deferreds.values()) {
|
|
35938
|
+
d.reject(STALE_REACTION);
|
|
35883
35939
|
}
|
|
35884
35940
|
});
|
|
35885
35941
|
|
|
@@ -44011,7 +44067,7 @@ function parseConfig(config) {
|
|
|
44011
44067
|
}
|
|
44012
44068
|
}
|
|
44013
44069
|
|
|
44014
|
-
const version = "4.0.0-alpha.
|
|
44070
|
+
const version = "4.0.0-alpha.26";
|
|
44015
44071
|
function attachDraftSwitcher(engine) {
|
|
44016
44072
|
if (engine.hasDraft()) {
|
|
44017
44073
|
const container = document.createElement("div");
|