@burger-editor/client 4.0.0-alpha.72 → 4.0.0-alpha.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -9
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/burger-editor-root.d.ts +3 -7
- package/dist/burger-editor-root.d.ts.map +1 -1
- package/dist/client.js +323 -133
- package/dist/client.js.map +1 -1
- package/dist/commands/register-engine-commands.d.ts +2 -1
- package/dist/commands/register-engine-commands.d.ts.map +1 -1
- package/dist/components/block-catalog.d.ts +3 -5
- package/dist/components/block-catalog.d.ts.map +1 -1
- package/dist/components/block-menu-button.d.ts +1 -1
- package/dist/components/block-menu-view.d.ts +7 -3
- package/dist/components/block-menu-view.d.ts.map +1 -1
- package/dist/components/block-menu.d.ts +2 -5
- package/dist/components/block-menu.d.ts.map +1 -1
- package/dist/components/block-options.d.ts +4 -6
- package/dist/components/block-options.d.ts.map +1 -1
- package/dist/components/draft-switcher.d.ts +11 -10
- package/dist/components/draft-switcher.d.ts.map +1 -1
- package/dist/components/editable-area-view.d.ts +11 -14
- package/dist/components/editable-area-view.d.ts.map +1 -1
- package/dist/components/file-list.d.ts +9 -9
- package/dist/components/file-list.d.ts.map +1 -1
- package/dist/components/file-uploader.d.ts +6 -6
- package/dist/components/file-uploader.d.ts.map +1 -1
- package/dist/components/front-matter-editor.d.ts +43 -11
- package/dist/components/front-matter-editor.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/initial-insertion-button.d.ts +7 -2
- package/dist/components/initial-insertion-button.d.ts.map +1 -1
- package/dist/components/item-editor-host.d.ts +7 -6
- package/dist/components/item-editor-host.d.ts.map +1 -1
- package/dist/components/preview.d.ts +4 -7
- package/dist/components/preview.d.ts.map +1 -1
- package/dist/components/table-editor.d.ts.map +1 -1
- package/dist/components/wysiwyg-field.d.ts +11 -1
- package/dist/components/wysiwyg-field.d.ts.map +1 -1
- package/dist/editable-area-view-DssYcTqQ.js +2941 -0
- package/dist/editable-area-view-DssYcTqQ.js.map +1 -0
- package/dist/editor-dialog.d.ts +16 -7
- package/dist/editor-dialog.d.ts.map +1 -1
- package/dist/{editable-area-view-C00DSDVk.js → engine-context-gX6mWHke.js} +199 -1951
- package/dist/engine-context-gX6mWHke.js.map +1 -0
- package/dist/engine-context.d.ts +40 -0
- package/dist/engine-context.d.ts.map +1 -0
- package/dist/file-browser/store.d.ts +127 -0
- package/dist/file-browser/store.d.ts.map +1 -0
- package/dist/file-browser/use-external-file-selection.d.ts +39 -0
- package/dist/file-browser/use-external-file-selection.d.ts.map +1 -0
- package/dist/file-browser/use-file-browser.d.ts +17 -0
- package/dist/file-browser/use-file-browser.d.ts.map +1 -0
- package/dist/form/text-field.d.ts +3 -1
- package/dist/form/text-field.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/mount.d.ts +6 -1
- package/dist/mount.d.ts.map +1 -1
- package/dist/root-error-boundary.d.ts +34 -0
- package/dist/root-error-boundary.d.ts.map +1 -0
- package/dist/testing/create-mock-engine.d.ts +30 -0
- package/dist/testing/create-mock-engine.d.ts.map +1 -0
- package/dist/testing/index.d.ts +4 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/render-with-engine.d.ts +20 -0
- package/dist/testing/render-with-engine.d.ts.map +1 -0
- package/dist/testing/suppress-console-error.d.ts +24 -0
- package/dist/testing/suppress-console-error.d.ts.map +1 -0
- package/dist/testing.js +119 -0
- package/dist/testing.js.map +1 -0
- package/dist/ui.d.ts +7 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +1618 -537
- package/dist/ui.js.map +1 -1
- package/dist/use-command.d.ts +13 -4
- package/dist/use-command.d.ts.map +1 -1
- package/dist/use-engine.d.ts +16 -32
- package/dist/use-engine.d.ts.map +1 -1
- package/dist/use-mount-effect.d.ts +20 -0
- package/dist/use-mount-effect.d.ts.map +1 -0
- package/dist/view/create-react-view.d.ts +33 -9
- package/dist/view/create-react-view.d.ts.map +1 -1
- package/package.json +45 -18
- package/dist/editable-area-view-C00DSDVk.js.map +0 -1
package/dist/client.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as BurgerEditorEngine, n as useEngine, t as EngineProvider } from "./engine-context-gX6mWHke.js";
|
|
2
|
+
import { d as registerEngineCommands, f as useUIState, g as BlockCatalog, h as BlockOptions, l as reactMount, m as EditorDialog, p as ItemEditorHost, s as RootErrorBoundary, t as EditableAreaView, u as DraftSwitcher } from "./editable-area-view-DssYcTqQ.js";
|
|
3
|
+
import { c } from "react/compiler-runtime";
|
|
2
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
5
|
import { createRoot } from "react-dom/client";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
4
7
|
//#region ../utils/dist/normalize-html.js
|
|
5
8
|
/**
|
|
6
9
|
* HTMLの構造を正規化して比較する
|
|
@@ -4533,9 +4536,9 @@ var Fitter = class {
|
|
|
4533
4536
|
}
|
|
4534
4537
|
openMore() {
|
|
4535
4538
|
let { content, openStart, openEnd } = this.unplaced;
|
|
4536
|
-
|
|
4537
|
-
if (
|
|
4538
|
-
this.unplaced = new Slice(content, openStart + 1,
|
|
4539
|
+
if (maxOpen(content, -1) <= openStart) return false;
|
|
4540
|
+
if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;
|
|
4541
|
+
this.unplaced = new Slice(content, openStart + 1, openEnd);
|
|
4539
4542
|
return true;
|
|
4540
4543
|
}
|
|
4541
4544
|
dropNode() {
|
|
@@ -4669,6 +4672,13 @@ function invalidMarks(type, fragment, start) {
|
|
|
4669
4672
|
function definesContent(type) {
|
|
4670
4673
|
return type.spec.defining || type.spec.definingForContent;
|
|
4671
4674
|
}
|
|
4675
|
+
function maxOpen(frag, side) {
|
|
4676
|
+
for (let count = 0;; count++) {
|
|
4677
|
+
let ch = side < 0 ? frag.firstChild : frag.lastChild;
|
|
4678
|
+
if (!ch || ch.isAtom) return count;
|
|
4679
|
+
frag = ch.content;
|
|
4680
|
+
}
|
|
4681
|
+
}
|
|
4672
4682
|
function replaceRange(tr, from, to, slice) {
|
|
4673
4683
|
if (!slice.size) return tr.deleteRange(from, to);
|
|
4674
4684
|
let $from = tr.doc.resolve(from), $to = tr.doc.resolve(to);
|
|
@@ -12421,9 +12431,10 @@ function normalizeKeyName(name) {
|
|
|
12421
12431
|
else if (/^a(lt)?$/i.test(mod)) alt = true;
|
|
12422
12432
|
else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;
|
|
12423
12433
|
else if (/^s(hift)?$/i.test(mod)) shift = true;
|
|
12424
|
-
else if (/^mod$/i.test(mod))
|
|
12425
|
-
|
|
12426
|
-
|
|
12434
|
+
else if (/^mod$/i.test(mod)) {
|
|
12435
|
+
if (isiOS() || isMacOS()) meta = true;
|
|
12436
|
+
else ctrl = true;
|
|
12437
|
+
} else throw new Error(`Unrecognized modifier name: ${mod}`);
|
|
12427
12438
|
}
|
|
12428
12439
|
if (alt) result = `Alt-${result}`;
|
|
12429
12440
|
if (ctrl) result = `Ctrl-${result}`;
|
|
@@ -12873,6 +12884,15 @@ function mergeAttributes(...objects) {
|
|
|
12873
12884
|
return objects.filter((item) => !!item).reduce((items, item) => {
|
|
12874
12885
|
const mergedAttributes = { ...items };
|
|
12875
12886
|
Object.entries(item).forEach(([key, value]) => {
|
|
12887
|
+
if (key === "__proto__") {
|
|
12888
|
+
Object.defineProperty(mergedAttributes, key, {
|
|
12889
|
+
configurable: true,
|
|
12890
|
+
enumerable: true,
|
|
12891
|
+
value,
|
|
12892
|
+
writable: true
|
|
12893
|
+
});
|
|
12894
|
+
return;
|
|
12895
|
+
}
|
|
12876
12896
|
if (!mergedAttributes[key]) {
|
|
12877
12897
|
mergedAttributes[key] = value;
|
|
12878
12898
|
return;
|
|
@@ -13510,27 +13530,29 @@ var setMark = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
|
|
|
13510
13530
|
const { selection } = tr;
|
|
13511
13531
|
const { empty, ranges } = selection;
|
|
13512
13532
|
const type = getMarkType(typeOrName, state.schema);
|
|
13513
|
-
if (dispatch)
|
|
13514
|
-
|
|
13515
|
-
|
|
13516
|
-
|
|
13517
|
-
|
|
13518
|
-
|
|
13519
|
-
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
if (
|
|
13527
|
-
|
|
13528
|
-
|
|
13529
|
-
|
|
13533
|
+
if (dispatch) {
|
|
13534
|
+
if (empty) {
|
|
13535
|
+
const oldAttributes = getMarkAttributes(state, type);
|
|
13536
|
+
tr.addStoredMark(type.create({
|
|
13537
|
+
...oldAttributes,
|
|
13538
|
+
...attributes
|
|
13539
|
+
}));
|
|
13540
|
+
} else ranges.forEach((range) => {
|
|
13541
|
+
const from = range.$from.pos;
|
|
13542
|
+
const to = range.$to.pos;
|
|
13543
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
13544
|
+
const trimmedFrom = Math.max(pos, from);
|
|
13545
|
+
const trimmedTo = Math.min(pos + node.nodeSize, to);
|
|
13546
|
+
if (node.marks.find((mark) => mark.type === type)) node.marks.forEach((mark) => {
|
|
13547
|
+
if (type === mark.type) tr.addMark(trimmedFrom, trimmedTo, type.create({
|
|
13548
|
+
...mark.attrs,
|
|
13549
|
+
...attributes
|
|
13550
|
+
}));
|
|
13551
|
+
});
|
|
13552
|
+
else tr.addMark(trimmedFrom, trimmedTo, type.create(attributes));
|
|
13530
13553
|
});
|
|
13531
|
-
else tr.addMark(trimmedFrom, trimmedTo, type.create(attributes));
|
|
13532
13554
|
});
|
|
13533
|
-
}
|
|
13555
|
+
}
|
|
13534
13556
|
return canSetMark(state, tr, type);
|
|
13535
13557
|
};
|
|
13536
13558
|
var setMeta = (key, value) => ({ tr }) => {
|
|
@@ -14122,8 +14144,10 @@ var EventEmitter = class {
|
|
|
14122
14144
|
}
|
|
14123
14145
|
off(event, fn) {
|
|
14124
14146
|
const callbacks = this.callbacks[event];
|
|
14125
|
-
if (callbacks)
|
|
14126
|
-
|
|
14147
|
+
if (callbacks) {
|
|
14148
|
+
if (fn) this.callbacks[event] = callbacks.filter((callback) => callback !== fn);
|
|
14149
|
+
else delete this.callbacks[event];
|
|
14150
|
+
}
|
|
14127
14151
|
return this;
|
|
14128
14152
|
}
|
|
14129
14153
|
once(event, fn) {
|
|
@@ -14774,12 +14798,14 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
14774
14798
|
while (i < lines.length) {
|
|
14775
14799
|
const currentLine = lines[i];
|
|
14776
14800
|
const itemMatch = currentLine.match(config.itemPattern);
|
|
14777
|
-
if (!itemMatch)
|
|
14778
|
-
|
|
14779
|
-
|
|
14780
|
-
|
|
14781
|
-
|
|
14782
|
-
|
|
14801
|
+
if (!itemMatch) {
|
|
14802
|
+
if (items.length > 0) break;
|
|
14803
|
+
else if (currentLine.trim() === "") {
|
|
14804
|
+
i += 1;
|
|
14805
|
+
totalRaw = `${totalRaw}${currentLine}\n`;
|
|
14806
|
+
continue;
|
|
14807
|
+
} else return;
|
|
14808
|
+
}
|
|
14783
14809
|
const itemData = config.extractItemData(itemMatch);
|
|
14784
14810
|
const { indentLevel, mainContent } = itemData;
|
|
14785
14811
|
totalRaw = `${totalRaw}${currentLine}\n`;
|
|
@@ -14809,8 +14835,10 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
14809
14835
|
const nestedContent = itemContent.slice(1);
|
|
14810
14836
|
if (nestedContent.length > 0) {
|
|
14811
14837
|
const dedentedNested = nestedContent.map((nestedLine) => nestedLine.slice(indentLevel + baseIndentSize)).join("\n");
|
|
14812
|
-
if (dedentedNested.trim())
|
|
14813
|
-
|
|
14838
|
+
if (dedentedNested.trim()) {
|
|
14839
|
+
if (config.customNestedParser) nestedTokens = config.customNestedParser(dedentedNested);
|
|
14840
|
+
else nestedTokens = lexer.blockTokens(dedentedNested);
|
|
14841
|
+
}
|
|
14814
14842
|
}
|
|
14815
14843
|
const token = config.createToken(itemData, nestedTokens);
|
|
14816
14844
|
items.push(token);
|
|
@@ -14838,6 +14866,9 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
14838
14866
|
* @param h - The markdown renderer helper
|
|
14839
14867
|
* @param prefixOrGenerator - Either a string prefix or a function that generates the prefix from context
|
|
14840
14868
|
* @param ctx - Optional context object (used when prefixOrGenerator is a function)
|
|
14869
|
+
* @param options - Optional rendering options
|
|
14870
|
+
* @param options.alignNestedToPrefix - Indent nested content to the width of the prefix
|
|
14871
|
+
* instead of the configured indent size, when the configured one is narrower
|
|
14841
14872
|
* @returns The rendered markdown string
|
|
14842
14873
|
*
|
|
14843
14874
|
* @example
|
|
@@ -14849,6 +14880,9 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
14849
14880
|
* const prefix = `- [${node.attrs?.checked ? 'x' : ' '}] `
|
|
14850
14881
|
* return renderNestedMarkdownContent(node, h, prefix)
|
|
14851
14882
|
*
|
|
14883
|
+
* // For an ordered list item, where the nested block has to line up with the marker
|
|
14884
|
+
* return renderNestedMarkdownContent(node, h, '10. ', ctx, { alignNestedToPrefix: true })
|
|
14885
|
+
*
|
|
14852
14886
|
* // For a blockquote with static prefix
|
|
14853
14887
|
* return renderNestedMarkdownContent(node, h, '> ')
|
|
14854
14888
|
*
|
|
@@ -14873,7 +14907,14 @@ function parseIndentedBlocks(src, config, lexer) {
|
|
|
14873
14907
|
* })
|
|
14874
14908
|
* ```
|
|
14875
14909
|
*/
|
|
14876
|
-
|
|
14910
|
+
var TAB_STOP = 4;
|
|
14911
|
+
/** Width of indentation in Markdown columns, where a tab runs to the next tab stop. */
|
|
14912
|
+
function columnWidth(text) {
|
|
14913
|
+
let width = 0;
|
|
14914
|
+
for (const character of text) width = character === " " ? width + TAB_STOP - width % TAB_STOP : width + 1;
|
|
14915
|
+
return width;
|
|
14916
|
+
}
|
|
14917
|
+
function renderNestedMarkdownContent(node, h, prefixOrGenerator, ctx, options) {
|
|
14877
14918
|
if (!node || !Array.isArray(node.content)) return "";
|
|
14878
14919
|
const prefix = typeof prefixOrGenerator === "function" ? prefixOrGenerator(ctx) : prefixOrGenerator;
|
|
14879
14920
|
const [content, ...children] = node.content;
|
|
@@ -14882,7 +14923,13 @@ function renderNestedMarkdownContent(node, h, prefixOrGenerator, ctx) {
|
|
|
14882
14923
|
var _h$renderChild, _h$renderChild2;
|
|
14883
14924
|
const childContent = (_h$renderChild = (_h$renderChild2 = h.renderChild) === null || _h$renderChild2 === void 0 ? void 0 : _h$renderChild2.call(h, child, index + 1)) !== null && _h$renderChild !== void 0 ? _h$renderChild : h.renderChildren([child]);
|
|
14884
14925
|
if (childContent !== void 0 && childContent !== null) {
|
|
14885
|
-
const
|
|
14926
|
+
const indentLine = (line) => {
|
|
14927
|
+
if (!(options === null || options === void 0 ? void 0 : options.alignNestedToPrefix)) return h.indent(line);
|
|
14928
|
+
const configured = h.indent("");
|
|
14929
|
+
const prefixWidth = columnWidth(prefix);
|
|
14930
|
+
return (columnWidth(configured) >= prefixWidth ? configured : " ".repeat(prefixWidth)) + line;
|
|
14931
|
+
};
|
|
14932
|
+
const indentedChild = childContent.split("\n").map((line) => line ? indentLine(line) : indentLine("")).join("\n");
|
|
14886
14933
|
output += child.type === "paragraph" ? `\n\n${indentedChild}` : `\n${indentedChild}`;
|
|
14887
14934
|
}
|
|
14888
14935
|
});
|
|
@@ -16151,14 +16198,16 @@ var NodePos = class NodePos {
|
|
|
16151
16198
|
let node = null;
|
|
16152
16199
|
let currentNode = this.parent;
|
|
16153
16200
|
while (currentNode && !node) {
|
|
16154
|
-
if (currentNode.node.type.name === selector)
|
|
16155
|
-
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16159
|
-
|
|
16160
|
-
|
|
16161
|
-
|
|
16201
|
+
if (currentNode.node.type.name === selector) {
|
|
16202
|
+
if (Object.keys(attributes).length > 0) {
|
|
16203
|
+
const nodeAttributes = currentNode.node.attrs;
|
|
16204
|
+
const attrKeys = Object.keys(attributes);
|
|
16205
|
+
for (let index = 0; index < attrKeys.length; index += 1) {
|
|
16206
|
+
const key = attrKeys[index];
|
|
16207
|
+
if (nodeAttributes[key] !== attributes[key]) break;
|
|
16208
|
+
}
|
|
16209
|
+
} else node = currentNode;
|
|
16210
|
+
}
|
|
16162
16211
|
currentNode = currentNode.parent;
|
|
16163
16212
|
}
|
|
16164
16213
|
return node;
|
|
@@ -18240,10 +18289,11 @@ var HorizontalRule = Node$1.create({
|
|
|
18240
18289
|
if (dispatch) {
|
|
18241
18290
|
const { $to } = tr.selection;
|
|
18242
18291
|
const posAfter = $to.end();
|
|
18243
|
-
if ($to.nodeAfter)
|
|
18244
|
-
|
|
18245
|
-
|
|
18246
|
-
|
|
18292
|
+
if ($to.nodeAfter) {
|
|
18293
|
+
if ($to.nodeAfter.isTextblock) tr.setSelection(TextSelection.create(tr.doc, $to.pos + 1));
|
|
18294
|
+
else if ($to.nodeAfter.isBlock) tr.setSelection(NodeSelection.create(tr.doc, $to.pos));
|
|
18295
|
+
else tr.setSelection(TextSelection.create(tr.doc, $to.pos));
|
|
18296
|
+
} else {
|
|
18247
18297
|
const nodeType = chainState.schema.nodes[this.options.nextNodeType] || $to.parent.type.contentMatch.defaultType;
|
|
18248
18298
|
const node = nodeType === null || nodeType === void 0 ? void 0 : nodeType.create();
|
|
18249
18299
|
if (node) {
|
|
@@ -20756,7 +20806,7 @@ var ListItem = Node$1.create({
|
|
|
20756
20806
|
return getListMarker((_context$meta2 = context.meta) === null || _context$meta2 === void 0 || (_context$meta2 = _context$meta2.parentAttrs) === null || _context$meta2 === void 0 ? void 0 : _context$meta2.type, start - 1 + (context.index || 0), ". ");
|
|
20757
20807
|
}
|
|
20758
20808
|
return "- ";
|
|
20759
|
-
}, ctx);
|
|
20809
|
+
}, ctx, { alignNestedToPrefix: (ctx === null || ctx === void 0 ? void 0 : ctx.parentType) === "orderedList" });
|
|
20760
20810
|
},
|
|
20761
20811
|
addExtensions() {
|
|
20762
20812
|
return [createBranchingListDeleteKeymap(this.name, [this.options.bulletListTypeName, this.options.orderedListTypeName])];
|
|
@@ -21524,13 +21574,16 @@ var TaskItem = Node$1.create({
|
|
|
21524
21574
|
const newKeys = new Set(Object.keys(newHTMLAttributes));
|
|
21525
21575
|
const staticAttrs = this.options.HTMLAttributes;
|
|
21526
21576
|
prevRenderedAttributeKeys.forEach((key) => {
|
|
21527
|
-
if (!newKeys.has(key))
|
|
21528
|
-
|
|
21577
|
+
if (!newKeys.has(key)) {
|
|
21578
|
+
if (key in staticAttrs) listItem.setAttribute(key, staticAttrs[key]);
|
|
21579
|
+
else listItem.removeAttribute(key);
|
|
21580
|
+
}
|
|
21529
21581
|
});
|
|
21530
21582
|
Object.entries(newHTMLAttributes).forEach(([key, value]) => {
|
|
21531
|
-
if (value === null || value === void 0)
|
|
21532
|
-
|
|
21533
|
-
|
|
21583
|
+
if (value === null || value === void 0) {
|
|
21584
|
+
if (key in staticAttrs) listItem.setAttribute(key, staticAttrs[key]);
|
|
21585
|
+
else listItem.removeAttribute(key);
|
|
21586
|
+
} else listItem.setAttribute(key, value);
|
|
21534
21587
|
});
|
|
21535
21588
|
prevRenderedAttributeKeys = newKeys;
|
|
21536
21589
|
return true;
|
|
@@ -23536,9 +23589,7 @@ var Image$1 = Node$1.create({
|
|
|
23536
23589
|
case "src":
|
|
23537
23590
|
case "width":
|
|
23538
23591
|
case "height": break;
|
|
23539
|
-
default:
|
|
23540
|
-
el.setAttribute(key, value);
|
|
23541
|
-
break;
|
|
23592
|
+
default: el.setAttribute(key, value);
|
|
23542
23593
|
}
|
|
23543
23594
|
});
|
|
23544
23595
|
if (mergedAttributes.src !== null) el.src = mergedAttributes.src;
|
|
@@ -25835,8 +25886,10 @@ var TableView = class {
|
|
|
25835
25886
|
this.dom = document.createElement("div");
|
|
25836
25887
|
this.dom.className = "tableWrapper";
|
|
25837
25888
|
this.table = this.dom.appendChild(document.createElement("table"));
|
|
25838
|
-
for (const [key, value] of Object.entries(HTMLAttributes)) if (value !== void 0 && value !== null)
|
|
25839
|
-
|
|
25889
|
+
for (const [key, value] of Object.entries(HTMLAttributes)) if (value !== void 0 && value !== null) {
|
|
25890
|
+
if (key === "style") this.table.style.cssText = String(value);
|
|
25891
|
+
else this.table.setAttribute(key, String(value));
|
|
25892
|
+
}
|
|
25840
25893
|
if (node.attrs.style) this.table.style.cssText = node.attrs.style;
|
|
25841
25894
|
this.colgroup = this.table.appendChild(document.createElement("colgroup"));
|
|
25842
25895
|
updateColumns(node, this.colgroup, this.table, cellMinWidth);
|
|
@@ -27411,8 +27464,24 @@ function defineBgeWysiwygEditorElement(options, global = window) {
|
|
|
27411
27464
|
if (!global.customElements.get(tagName)) global.customElements.define(tagName, BgeWysiwygEditorElement);
|
|
27412
27465
|
}
|
|
27413
27466
|
var BgeWysiwygEditorElement = class BgeWysiwygEditorElement extends HTMLElement {
|
|
27467
|
+
#contentCss = null;
|
|
27414
27468
|
#disposables = null;
|
|
27415
27469
|
#wysiwygElement = null;
|
|
27470
|
+
/**
|
|
27471
|
+
* CSS applied inside the WYSIWYG surface so it matches the published
|
|
27472
|
+
* page's styling. A plain property (not an attribute) — React 19 sets
|
|
27473
|
+
* it directly on custom elements, so consumers pass it as a JSX prop
|
|
27474
|
+
* instead of calling {@link setStyle} imperatively. Settable before
|
|
27475
|
+
* the element connects; the value is applied once the inner
|
|
27476
|
+
* `<bge-wysiwyg>` exists.
|
|
27477
|
+
*/
|
|
27478
|
+
get contentCss() {
|
|
27479
|
+
return this.#contentCss;
|
|
27480
|
+
}
|
|
27481
|
+
set contentCss(css) {
|
|
27482
|
+
this.#contentCss = css;
|
|
27483
|
+
this.#wysiwygElement?.setStyle(css);
|
|
27484
|
+
}
|
|
27416
27485
|
get editor() {
|
|
27417
27486
|
if (!this.#wysiwygElement) throw new ReferenceError("<bge-wysiwyg-editor> is not connected");
|
|
27418
27487
|
return this.#wysiwygElement.editor;
|
|
@@ -27541,6 +27610,7 @@ var BgeWysiwygEditorElement = class BgeWysiwygEditorElement extends HTMLElement
|
|
|
27541
27610
|
this.#wysiwygElement = this.querySelector("bge-wysiwyg");
|
|
27542
27611
|
if (!this.#wysiwygElement) throw new Error("bge-wysiwyg-editor is not connected");
|
|
27543
27612
|
const wysiwygElement = this.#wysiwygElement;
|
|
27613
|
+
if (this.#contentCss != null) wysiwygElement.setStyle(this.#contentCss);
|
|
27544
27614
|
stack.defer(() => {
|
|
27545
27615
|
try {
|
|
27546
27616
|
Object.getOwnPropertyDescriptor(Element.prototype, "innerHTML").set.call(this, wysiwygElement.value);
|
|
@@ -27738,96 +27808,209 @@ function updateButtonState(button, state, editorElement) {
|
|
|
27738
27808
|
//#region src/burger-editor-root.tsx
|
|
27739
27809
|
/**
|
|
27740
27810
|
* Root of the editor chrome React tree. Renders every dialog
|
|
27741
|
-
* declaratively from the engine's UI state store.
|
|
27742
|
-
* @
|
|
27743
|
-
* @param root0.engine
|
|
27811
|
+
* declaratively from the engine's UI state store. Reads the engine via
|
|
27812
|
+
* {@link useEngine}; the caller wraps this in an `EngineProvider`.
|
|
27744
27813
|
*/
|
|
27745
|
-
function BurgerEditorRoot(
|
|
27746
|
-
const
|
|
27814
|
+
function BurgerEditorRoot() {
|
|
27815
|
+
const $ = c(27);
|
|
27816
|
+
const engine = useEngine();
|
|
27817
|
+
const open = useUIState().openDialog;
|
|
27747
27818
|
const optionsBlock = open?.type === "block-options" ? open.block : null;
|
|
27748
|
-
const
|
|
27749
|
-
|
|
27750
|
-
|
|
27751
|
-
|
|
27752
|
-
|
|
27753
|
-
|
|
27819
|
+
const itemEditor = open?.type === "item-editor" ? open : null;
|
|
27820
|
+
let t0;
|
|
27821
|
+
if ($[0] !== engine) {
|
|
27822
|
+
t0 = () => {
|
|
27823
|
+
engine.uiState.closeDialog();
|
|
27824
|
+
engine.save();
|
|
27825
|
+
};
|
|
27826
|
+
$[0] = engine;
|
|
27827
|
+
$[1] = t0;
|
|
27828
|
+
} else t0 = $[1];
|
|
27829
|
+
const closeAndSave = t0;
|
|
27830
|
+
const t1 = open?.type === "block-catalog";
|
|
27831
|
+
let t2;
|
|
27832
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
27833
|
+
t2 = { close: "キャンセル" };
|
|
27834
|
+
$[2] = t2;
|
|
27835
|
+
} else t2 = $[2];
|
|
27836
|
+
let t3;
|
|
27837
|
+
if ($[3] !== engine.catalog) {
|
|
27838
|
+
t3 = /* @__PURE__ */ jsx(BlockCatalog, { catalog: engine.catalog });
|
|
27839
|
+
$[3] = engine.catalog;
|
|
27840
|
+
$[4] = t3;
|
|
27841
|
+
} else t3 = $[4];
|
|
27842
|
+
let t4;
|
|
27843
|
+
if ($[5] !== closeAndSave || $[6] !== t1 || $[7] !== t3) {
|
|
27844
|
+
t4 = /* @__PURE__ */ jsx(EditorDialog, {
|
|
27754
27845
|
name: "catalog",
|
|
27755
|
-
open:
|
|
27846
|
+
open: t1,
|
|
27756
27847
|
onClose: closeAndSave,
|
|
27757
|
-
buttons:
|
|
27758
|
-
children:
|
|
27759
|
-
|
|
27760
|
-
|
|
27761
|
-
|
|
27762
|
-
|
|
27763
|
-
|
|
27848
|
+
buttons: t2,
|
|
27849
|
+
children: t3
|
|
27850
|
+
});
|
|
27851
|
+
$[5] = closeAndSave;
|
|
27852
|
+
$[6] = t1;
|
|
27853
|
+
$[7] = t3;
|
|
27854
|
+
$[8] = t4;
|
|
27855
|
+
} else t4 = $[8];
|
|
27856
|
+
const t5 = optionsBlock !== null;
|
|
27857
|
+
let t6;
|
|
27858
|
+
if ($[9] !== closeAndSave || $[10] !== optionsBlock) {
|
|
27859
|
+
t6 = (formData) => {
|
|
27860
|
+
if (optionsBlock) applyBlockOptions(optionsBlock, formData);
|
|
27861
|
+
closeAndSave();
|
|
27862
|
+
};
|
|
27863
|
+
$[9] = closeAndSave;
|
|
27864
|
+
$[10] = optionsBlock;
|
|
27865
|
+
$[11] = t6;
|
|
27866
|
+
} else t6 = $[11];
|
|
27867
|
+
let t7;
|
|
27868
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
27869
|
+
t7 = {
|
|
27870
|
+
close: "キャンセル",
|
|
27871
|
+
complete: "決定"
|
|
27872
|
+
};
|
|
27873
|
+
$[12] = t7;
|
|
27874
|
+
} else t7 = $[12];
|
|
27875
|
+
let t8;
|
|
27876
|
+
if ($[13] !== optionsBlock) {
|
|
27877
|
+
t8 = optionsBlock ? /* @__PURE__ */ jsx(BlockOptions, { block: optionsBlock }) : null;
|
|
27878
|
+
$[13] = optionsBlock;
|
|
27879
|
+
$[14] = t8;
|
|
27880
|
+
} else t8 = $[14];
|
|
27881
|
+
let t9;
|
|
27882
|
+
if ($[15] !== closeAndSave || $[16] !== t5 || $[17] !== t6 || $[18] !== t8) {
|
|
27883
|
+
t9 = /* @__PURE__ */ jsx(EditorDialog, {
|
|
27764
27884
|
name: "options",
|
|
27765
|
-
open:
|
|
27885
|
+
open: t5,
|
|
27766
27886
|
onClose: closeAndSave,
|
|
27767
|
-
|
|
27768
|
-
|
|
27769
|
-
|
|
27770
|
-
|
|
27771
|
-
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
|
|
27775
|
-
|
|
27776
|
-
|
|
27777
|
-
|
|
27778
|
-
|
|
27779
|
-
|
|
27780
|
-
|
|
27781
|
-
|
|
27782
|
-
item:
|
|
27783
|
-
|
|
27784
|
-
|
|
27887
|
+
action: t6,
|
|
27888
|
+
buttons: t7,
|
|
27889
|
+
children: t8
|
|
27890
|
+
});
|
|
27891
|
+
$[15] = closeAndSave;
|
|
27892
|
+
$[16] = t5;
|
|
27893
|
+
$[17] = t6;
|
|
27894
|
+
$[18] = t8;
|
|
27895
|
+
$[19] = t9;
|
|
27896
|
+
} else t9 = $[19];
|
|
27897
|
+
const t10 = itemEditor?.item ?? null;
|
|
27898
|
+
const t11 = itemEditor?.containerType;
|
|
27899
|
+
let t12;
|
|
27900
|
+
if ($[20] !== t10 || $[21] !== t11) {
|
|
27901
|
+
t12 = /* @__PURE__ */ jsx(ItemEditorHost, {
|
|
27902
|
+
item: t10,
|
|
27903
|
+
containerType: t11
|
|
27904
|
+
});
|
|
27905
|
+
$[20] = t10;
|
|
27906
|
+
$[21] = t11;
|
|
27907
|
+
$[22] = t12;
|
|
27908
|
+
} else t12 = $[22];
|
|
27909
|
+
let t13;
|
|
27910
|
+
if ($[23] !== t12 || $[24] !== t4 || $[25] !== t9) {
|
|
27911
|
+
t13 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
27912
|
+
t4,
|
|
27913
|
+
t9,
|
|
27914
|
+
t12
|
|
27915
|
+
] });
|
|
27916
|
+
$[23] = t12;
|
|
27917
|
+
$[24] = t4;
|
|
27918
|
+
$[25] = t9;
|
|
27919
|
+
$[26] = t13;
|
|
27920
|
+
} else t13 = $[26];
|
|
27921
|
+
return t13;
|
|
27785
27922
|
}
|
|
27786
27923
|
//#endregion
|
|
27787
27924
|
//#region src/view/create-react-view.tsx
|
|
27788
27925
|
/**
|
|
27789
|
-
*
|
|
27790
|
-
*
|
|
27791
|
-
*
|
|
27792
|
-
*
|
|
27926
|
+
* A `ReactView` extends the core {@link BurgerEditorView} contract with a
|
|
27927
|
+
* client-only escape hatch: `mountChrome` lets `createBurgerEditorClient`
|
|
27928
|
+
* render the dialog chrome into the *same* React root the editable areas
|
|
27929
|
+
* use, once the engine has finished constructing. `core` never sees this
|
|
27930
|
+
* method — it only calls `createAreaHost` through the narrower
|
|
27931
|
+
* `BurgerEditorView` type.
|
|
27932
|
+
*/
|
|
27933
|
+
/**
|
|
27934
|
+
* The React implementation of the engine's view port.
|
|
27935
|
+
*
|
|
27936
|
+
* Unlike the pre-single-root design (one `createRoot` per editable area
|
|
27937
|
+
* plus a separate dialog-host root), this view owns exactly **one** React
|
|
27938
|
+
* root per engine. Editable areas are portaled into their own `<div>`
|
|
27939
|
+
* (still a direct child of `engine.viewArea`, preserving the DOM contract
|
|
27940
|
+
* `viewAreaClassList` consumers rely on) so each area keeps its own
|
|
27941
|
+
* subtree identity; the dialog chrome renders inline. Sharing one root
|
|
27942
|
+
* means `EngineProvider` only needs to wrap the tree once, and every
|
|
27943
|
+
* component below it — areas, block menu, dialogs — reads the engine via
|
|
27944
|
+
* `useEngine()` instead of taking it as a prop.
|
|
27793
27945
|
* @returns The view to pass to `BurgerEditorEngine.new`
|
|
27794
27946
|
* @example
|
|
27795
27947
|
* ```ts
|
|
27796
|
-
* const
|
|
27797
|
-
*
|
|
27798
|
-
*
|
|
27799
|
-
* });
|
|
27948
|
+
* const view = createReactView();
|
|
27949
|
+
* const engine = await BurgerEditorEngine.new({ ...options, view });
|
|
27950
|
+
* view.mountChrome(<EngineProvider engine={engine}><BurgerEditorRoot /></EngineProvider>);
|
|
27800
27951
|
* ```
|
|
27801
27952
|
*/
|
|
27802
27953
|
function createReactView() {
|
|
27803
|
-
|
|
27954
|
+
let root = null;
|
|
27955
|
+
let rootHost = null;
|
|
27956
|
+
let engine = null;
|
|
27957
|
+
let chrome = null;
|
|
27958
|
+
const areas = /* @__PURE__ */ new Map();
|
|
27959
|
+
/**
|
|
27960
|
+
*
|
|
27961
|
+
*/
|
|
27962
|
+
function paint() {
|
|
27963
|
+
if (!root || !engine) return;
|
|
27964
|
+
root.render(/* @__PURE__ */ jsx(EngineProvider, {
|
|
27965
|
+
engine,
|
|
27966
|
+
children: /* @__PURE__ */ jsxs(RootErrorBoundary, { children: [chrome, [...areas.values()].map((entry) => createPortal(/* @__PURE__ */ jsx(RootErrorBoundary, { children: /* @__PURE__ */ jsx(EditableAreaView, {
|
|
27967
|
+
type: entry.props.type,
|
|
27968
|
+
initialContent: entry.props.initialContent,
|
|
27969
|
+
stylesheets: entry.props.stylesheets,
|
|
27970
|
+
classList: entry.props.classList,
|
|
27971
|
+
onReady: entry.onReady
|
|
27972
|
+
}) }, entry.props.type), entry.mountEl))] })
|
|
27973
|
+
}));
|
|
27974
|
+
}
|
|
27804
27975
|
/**
|
|
27805
27976
|
*
|
|
27806
27977
|
*/
|
|
27807
27978
|
function teardown() {
|
|
27808
|
-
|
|
27809
|
-
|
|
27810
|
-
|
|
27811
|
-
|
|
27812
|
-
|
|
27979
|
+
root?.unmount();
|
|
27980
|
+
rootHost?.remove();
|
|
27981
|
+
for (const entry of areas.values()) entry.mountEl.remove();
|
|
27982
|
+
root = null;
|
|
27983
|
+
rootHost = null;
|
|
27984
|
+
areas.clear();
|
|
27813
27985
|
}
|
|
27814
27986
|
return {
|
|
27815
27987
|
createAreaHost(context) {
|
|
27816
27988
|
return new Promise((resolve) => {
|
|
27989
|
+
if (!root) {
|
|
27990
|
+
engine = context.engine;
|
|
27991
|
+
rootHost = context.engine.el.ownerDocument.createElement("div");
|
|
27992
|
+
context.engine.el.append(rootHost);
|
|
27993
|
+
root = createRoot(rootHost, { identifierPrefix: `bge${context.engine.commandBus.receiverId}-` });
|
|
27994
|
+
}
|
|
27817
27995
|
const mountEl = context.engine.viewArea.ownerDocument.createElement("div");
|
|
27818
27996
|
context.engine.viewArea.append(mountEl);
|
|
27819
|
-
|
|
27820
|
-
|
|
27821
|
-
|
|
27822
|
-
|
|
27823
|
-
|
|
27824
|
-
|
|
27825
|
-
|
|
27826
|
-
|
|
27997
|
+
areas.set(context.type, {
|
|
27998
|
+
mountEl,
|
|
27999
|
+
props: {
|
|
28000
|
+
type: context.type,
|
|
28001
|
+
initialContent: context.initialContent,
|
|
28002
|
+
stylesheets: context.stylesheets,
|
|
28003
|
+
classList: context.classList
|
|
28004
|
+
},
|
|
27827
28005
|
onReady: resolve
|
|
27828
|
-
})
|
|
28006
|
+
});
|
|
28007
|
+
paint();
|
|
27829
28008
|
});
|
|
27830
28009
|
},
|
|
28010
|
+
mountChrome(node) {
|
|
28011
|
+
chrome = node;
|
|
28012
|
+
paint();
|
|
28013
|
+
},
|
|
27831
28014
|
/** @deprecated Use a `using` declaration instead. */
|
|
27832
28015
|
destroy: teardown,
|
|
27833
28016
|
[Symbol.dispose]: teardown
|
|
@@ -27839,6 +28022,12 @@ var Migrator = class {};
|
|
|
27839
28022
|
//#endregion
|
|
27840
28023
|
//#region src/get-config.ts
|
|
27841
28024
|
/**
|
|
28025
|
+
* 意味ない。たぶんそれぞれのプラットフォームでConfigの型が違うから。
|
|
28026
|
+
* @deprecated
|
|
28027
|
+
* @param urlOrScriptElement
|
|
28028
|
+
* @returns
|
|
28029
|
+
*/
|
|
28030
|
+
/**
|
|
27842
28031
|
*
|
|
27843
28032
|
* @param urlOrScriptElement
|
|
27844
28033
|
*/
|
|
@@ -27880,12 +28069,16 @@ function parseConfig(config) {
|
|
|
27880
28069
|
}
|
|
27881
28070
|
//#endregion
|
|
27882
28071
|
//#region src/index.tsx
|
|
27883
|
-
var version = "4.0.0-alpha.
|
|
28072
|
+
var version = "4.0.0-alpha.74";
|
|
27884
28073
|
/**
|
|
27885
28074
|
* 本稿⇄下書き切替UIをビューエリアの直前にマウントする
|
|
27886
28075
|
*
|
|
27887
28076
|
* `createBurgerEditorClient` に含めず分離しているのは、配置位置
|
|
27888
28077
|
* (エディタの外側のどこに置くか)がアプリケーション側の判断のため。
|
|
28078
|
+
* 単一rootの対象外(`engine.viewArea`の外側、任意のDOM位置に置かれる
|
|
28079
|
+
* ため): `createReactView()`が持つ単一rootとは別の独立したReact root
|
|
28080
|
+
* を持つが、`EngineProvider`で包むため`DraftSwitcher`自体は
|
|
28081
|
+
* `useEngine()`で取得する(propsは受け取らない)。
|
|
27889
28082
|
* @param engine - 対象エンジン。下書きが無い構成では何もしない
|
|
27890
28083
|
* @returns マウントハンドル(`cleanUp`でアンマウント)。下書きが無い場合はnull
|
|
27891
28084
|
* @example
|
|
@@ -27899,7 +28092,10 @@ function attachDraftSwitcher(engine) {
|
|
|
27899
28092
|
const container = document.createElement("div");
|
|
27900
28093
|
container.dataset.bgeComponent = "draft-switcher";
|
|
27901
28094
|
engine.viewArea.insertAdjacentElement("beforebegin", container);
|
|
27902
|
-
return reactMount(/* @__PURE__ */ jsx(
|
|
28095
|
+
return reactMount(/* @__PURE__ */ jsx(EngineProvider, {
|
|
28096
|
+
engine,
|
|
28097
|
+
children: /* @__PURE__ */ jsx(RootErrorBoundary, { children: /* @__PURE__ */ jsx(DraftSwitcher, {}) })
|
|
28098
|
+
}), container);
|
|
27903
28099
|
}
|
|
27904
28100
|
return null;
|
|
27905
28101
|
}
|
|
@@ -27930,9 +28126,10 @@ function attachDraftSwitcher(engine) {
|
|
|
27930
28126
|
* ```
|
|
27931
28127
|
*/
|
|
27932
28128
|
async function createBurgerEditorClient(options) {
|
|
28129
|
+
const view = createReactView();
|
|
27933
28130
|
const engine = await BurgerEditorEngine.new({
|
|
27934
28131
|
...options,
|
|
27935
|
-
view
|
|
28132
|
+
view,
|
|
27936
28133
|
defineCustomElement(context) {
|
|
27937
28134
|
defineBgeWysiwygEditorElement({
|
|
27938
28135
|
wrapperElement: { className: context.className ?? "" },
|
|
@@ -27941,14 +28138,7 @@ async function createBurgerEditorClient(options) {
|
|
|
27941
28138
|
}
|
|
27942
28139
|
});
|
|
27943
28140
|
registerEngineCommands(engine, options.catalog);
|
|
27944
|
-
|
|
27945
|
-
dialogHost.dataset.bgeComponent = "dialog-host";
|
|
27946
|
-
engine.el.append(dialogHost);
|
|
27947
|
-
const dialogMount = reactMount(/* @__PURE__ */ jsx(BurgerEditorRoot, { engine }), dialogHost);
|
|
27948
|
-
engine.own({ [Symbol.dispose]() {
|
|
27949
|
-
dialogMount[Symbol.dispose]();
|
|
27950
|
-
dialogHost.remove();
|
|
27951
|
-
} });
|
|
28141
|
+
view.mountChrome(/* @__PURE__ */ jsx(BurgerEditorRoot, {}));
|
|
27952
28142
|
return { engine };
|
|
27953
28143
|
}
|
|
27954
28144
|
//#endregion
|