@juo/blocks 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ExtensionRoot-sq31lwIQ.js → ExtensionRoot-BmfKKpcU.js} +3 -2
- package/dist/{theme-state-D3w_B6gQ.js → block-C8lPBCF8.js} +46 -209
- package/dist/block.d.ts +43 -1
- package/dist/block.d.ts.map +1 -1
- package/dist/{bridge-DAUIcGuq.js → bridge-BOcO9toS.js} +48 -25
- package/dist/core.js +96 -25
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/components.d.ts +12 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +35 -3
- package/dist/editor/messages.d.ts.map +1 -1
- package/dist/editor.js +424 -36
- package/dist/flows/WorkflowService.d.ts.map +1 -1
- package/dist/{juo-workflow-BVrh5lpE.js → juo-workflow-B3OHYsp-.js} +7 -5
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/preact/block.d.ts.map +1 -1
- package/dist/preact.js +4 -2
- package/dist/react/block.d.ts.map +1 -1
- package/dist/react.js +4 -2
- package/dist/services/subscription/adapter.d.ts +21 -3
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- package/dist/services/subscription/discountErrors.d.ts +27 -0
- package/dist/services/subscription/discountErrors.d.ts.map +1 -0
- package/dist/services/subscription/index.d.ts +2 -1
- package/dist/services/subscription/index.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.test.d.ts +2 -0
- package/dist/services/subscription/subscriptionService.test.d.ts.map +1 -0
- package/dist/services/subscription/types.d.ts +11 -3
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/dist/theme-state-LZS5T-Xb.js +202 -0
- package/dist/vue/block.d.ts +2 -1
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue/setupTests.d.ts +2 -0
- package/dist/vue/setupTests.d.ts.map +1 -0
- package/dist/vue.js +7 -2
- package/dist/web-components/editor/InlineText.d.ts +2 -0
- package/dist/web-components/editor/InlineText.d.ts.map +1 -1
- package/dist/web-components/editor/InlineText.test.d.ts +2 -0
- package/dist/web-components/editor/InlineText.test.d.ts.map +1 -0
- package/dist/web-components-editor.js +16 -5
- package/dist/web-components-runtime.js +3 -3
- package/package.json +1 -1
|
@@ -3,8 +3,9 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
import { signal, effect, createBlockInstance } from "@juo/blocks";
|
|
5
5
|
import { reportBlockWarning, reportBlockError } from "./observability.js";
|
|
6
|
-
import { d, v as subscribeContext,
|
|
7
|
-
import "./
|
|
6
|
+
import { d, v as subscribeContext, E, y as withWrapper, x as n, e as backfillInstanceDefaults, p as isStubDefinition, q as onRegisterBlock } from "./block-C8lPBCF8.js";
|
|
7
|
+
import { T as ThemeStateContext } from "./theme-state-LZS5T-Xb.js";
|
|
8
|
+
import "./juo-workflow-B3OHYsp-.js";
|
|
8
9
|
class Block extends HTMLElement {
|
|
9
10
|
constructor() {
|
|
10
11
|
super();
|
|
@@ -469,6 +469,42 @@ function E(i2) {
|
|
|
469
469
|
r[Symbol.dispose] = r;
|
|
470
470
|
return r;
|
|
471
471
|
}
|
|
472
|
+
function hasRenderedContent(scope) {
|
|
473
|
+
var _a;
|
|
474
|
+
for (const child of scope.children) {
|
|
475
|
+
if (!(child instanceof HTMLElement)) {
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
const display = (_a = child.ownerDocument.defaultView) == null ? void 0 : _a.getComputedStyle(child).display;
|
|
479
|
+
if (display === "contents") {
|
|
480
|
+
if (hasRenderedContent(child)) {
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
continue;
|
|
484
|
+
}
|
|
485
|
+
if (child.checkVisibility()) {
|
|
486
|
+
return true;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
function attachEmptyTracking(host, scope) {
|
|
492
|
+
let observer = null;
|
|
493
|
+
let disposed = false;
|
|
494
|
+
queueMicrotask(() => {
|
|
495
|
+
if (disposed) return;
|
|
496
|
+
const observed = scope ?? host.shadowRoot ?? host;
|
|
497
|
+
const sync = () => host.toggleAttribute("data-empty", !hasRenderedContent(observed));
|
|
498
|
+
observer = new MutationObserver(sync);
|
|
499
|
+
observer.observe(observed, { childList: true, subtree: true });
|
|
500
|
+
sync();
|
|
501
|
+
});
|
|
502
|
+
return () => {
|
|
503
|
+
disposed = true;
|
|
504
|
+
observer == null ? void 0 : observer.disconnect();
|
|
505
|
+
observer = null;
|
|
506
|
+
};
|
|
507
|
+
}
|
|
472
508
|
function serializeBlocks(blocks) {
|
|
473
509
|
return blocks.map((block) => serializeBlock(block));
|
|
474
510
|
}
|
|
@@ -647,9 +683,6 @@ function createCeRenderer(name) {
|
|
|
647
683
|
});
|
|
648
684
|
}
|
|
649
685
|
return (block) => {
|
|
650
|
-
const wrapper = document.createElement("div");
|
|
651
|
-
wrapper.setAttribute("data-block-id", block.id);
|
|
652
|
-
wrapper.setAttribute("data-block-type", block.type);
|
|
653
686
|
const el = document.createElement(name);
|
|
654
687
|
el.setAttribute("data-block-id", block.id);
|
|
655
688
|
el.setAttribute("data-block-type", block.type);
|
|
@@ -657,8 +690,8 @@ function createCeRenderer(name) {
|
|
|
657
690
|
el[key] = value;
|
|
658
691
|
});
|
|
659
692
|
el.replaceChildren(...renderSlots(block.slots, block));
|
|
660
|
-
|
|
661
|
-
return
|
|
693
|
+
attachEmptyTracking(el);
|
|
694
|
+
return el;
|
|
662
695
|
};
|
|
663
696
|
}
|
|
664
697
|
const stubDefinitionCache = /* @__PURE__ */ new Map();
|
|
@@ -789,221 +822,25 @@ function createBlockInstanceFromJSON(input) {
|
|
|
789
822
|
throw error;
|
|
790
823
|
}
|
|
791
824
|
}
|
|
792
|
-
const DEFAULT_GLOBAL_STYLES = {
|
|
793
|
-
volume: "comfort",
|
|
794
|
-
style: "ghost",
|
|
795
|
-
corners: "round",
|
|
796
|
-
buttonCorners: "round",
|
|
797
|
-
thumbnailCorners: "circle",
|
|
798
|
-
theme: "preset",
|
|
799
|
-
themeType: "neutral",
|
|
800
|
-
colors: {
|
|
801
|
-
accent: "#000000",
|
|
802
|
-
secondary: "#000000",
|
|
803
|
-
tint: "#111111",
|
|
804
|
-
callout: "#F5F5F5",
|
|
805
|
-
success: "#287a25",
|
|
806
|
-
error: "#a93c3c",
|
|
807
|
-
information: "#0075a3",
|
|
808
|
-
warning: "#8a5e00",
|
|
809
|
-
background: "#FFFFFF"
|
|
810
|
-
}
|
|
811
|
-
};
|
|
812
|
-
const ThemeStateContext = createContext("theme-state");
|
|
813
|
-
function normalizeLocale(locale) {
|
|
814
|
-
return locale.trim().toLowerCase().split("-")[0] || "en";
|
|
815
|
-
}
|
|
816
|
-
function toStringRecord(input) {
|
|
817
|
-
if (input == null) return {};
|
|
818
|
-
return Object.fromEntries(
|
|
819
|
-
Object.entries(input).filter(([, value]) => typeof value === "string")
|
|
820
|
-
);
|
|
821
|
-
}
|
|
822
|
-
function parseBlockLocaleFile(file) {
|
|
823
|
-
if (file == null) {
|
|
824
|
-
return { defaults: {}, modes: {} };
|
|
825
|
-
}
|
|
826
|
-
const entries = Object.entries(file).filter(
|
|
827
|
-
([key, value]) => key !== "overrides" && typeof value === "string"
|
|
828
|
-
);
|
|
829
|
-
const topLevel = Object.fromEntries(entries);
|
|
830
|
-
const overrides = toStringRecord(file.overrides);
|
|
831
|
-
return {
|
|
832
|
-
defaults: { ...topLevel, ...overrides },
|
|
833
|
-
modes: {
|
|
834
|
-
...Object.fromEntries(
|
|
835
|
-
Object.keys(topLevel).map((key) => [key, "default"])
|
|
836
|
-
),
|
|
837
|
-
...Object.fromEntries(
|
|
838
|
-
Object.keys(overrides).map((key) => [key, "override"])
|
|
839
|
-
)
|
|
840
|
-
}
|
|
841
|
-
};
|
|
842
|
-
}
|
|
843
|
-
function indexOverrides(overrides) {
|
|
844
|
-
const indexed = {
|
|
845
|
-
theme: {},
|
|
846
|
-
blocks: {}
|
|
847
|
-
};
|
|
848
|
-
for (const item of overrides) {
|
|
849
|
-
if (item.scope.kind === "theme") {
|
|
850
|
-
indexed.theme[item.key] = item.value;
|
|
851
|
-
continue;
|
|
852
|
-
}
|
|
853
|
-
if (indexed.blocks[item.scope.blockId] == null) {
|
|
854
|
-
indexed.blocks[item.scope.blockId] = {};
|
|
855
|
-
}
|
|
856
|
-
indexed.blocks[item.scope.blockId][item.key] = item.value;
|
|
857
|
-
}
|
|
858
|
-
return indexed;
|
|
859
|
-
}
|
|
860
|
-
function createThemeState(deps) {
|
|
861
|
-
var _a;
|
|
862
|
-
const surfaces = {
|
|
863
|
-
page: { blocks: d([]) },
|
|
864
|
-
overlay: { blocks: d([]) }
|
|
865
|
-
};
|
|
866
|
-
const locale = d("en");
|
|
867
|
-
const catalogs = d(null);
|
|
868
|
-
const globalStyles = d(
|
|
869
|
-
deps.initialGlobalStyles ?? DEFAULT_GLOBAL_STYLES
|
|
870
|
-
);
|
|
871
|
-
function setGlobalStyles(styles) {
|
|
872
|
-
globalStyles.value = styles;
|
|
873
|
-
}
|
|
874
|
-
async function collectBlockDefaults(loc) {
|
|
875
|
-
const nextDefaults = {};
|
|
876
|
-
const nextModes = {};
|
|
877
|
-
for (const block of getDefinedBlocks()) {
|
|
878
|
-
if (block.locales == null) continue;
|
|
879
|
-
let file = null;
|
|
880
|
-
try {
|
|
881
|
-
file = await block.locales.load(loc);
|
|
882
|
-
} catch {
|
|
883
|
-
file = null;
|
|
884
|
-
}
|
|
885
|
-
const parsed = parseBlockLocaleFile(file);
|
|
886
|
-
nextDefaults[block.name] = parsed.defaults;
|
|
887
|
-
nextModes[block.name] = parsed.modes;
|
|
888
|
-
}
|
|
889
|
-
return { defaults: nextDefaults, modes: nextModes };
|
|
890
|
-
}
|
|
891
|
-
async function setLocale(nextLocaleRaw) {
|
|
892
|
-
var _a2;
|
|
893
|
-
const nextLocale = normalizeLocale(nextLocaleRaw);
|
|
894
|
-
const [blockData, loadedOverrides] = await Promise.all([
|
|
895
|
-
collectBlockDefaults(nextLocale),
|
|
896
|
-
((_a2 = deps.translations) == null ? void 0 : _a2.resolveTranslations(nextLocale).catch(() => [])) ?? Promise.resolve([])
|
|
897
|
-
]);
|
|
898
|
-
const overrides = loadedOverrides.filter(
|
|
899
|
-
(item) => normalizeLocale(item.locale) === nextLocale
|
|
900
|
-
);
|
|
901
|
-
const indexed = indexOverrides(overrides);
|
|
902
|
-
catalogs.value = {
|
|
903
|
-
theme: {
|
|
904
|
-
defaults: {},
|
|
905
|
-
overrides: indexed.theme
|
|
906
|
-
},
|
|
907
|
-
blocks: {
|
|
908
|
-
defaults: blockData.defaults,
|
|
909
|
-
modes: blockData.modes,
|
|
910
|
-
overrides: indexed.blocks
|
|
911
|
-
}
|
|
912
|
-
};
|
|
913
|
-
locale.value = nextLocale;
|
|
914
|
-
}
|
|
915
|
-
async function resolve(surface, path) {
|
|
916
|
-
var _a2, _b, _c, _d;
|
|
917
|
-
surfaces[surface].blocks.value = [];
|
|
918
|
-
const stored = await deps.resolve(surface, path);
|
|
919
|
-
if (stored != null) {
|
|
920
|
-
surfaces[surface].blocks.value = stored.blocks.flatMap((block) => {
|
|
921
|
-
try {
|
|
922
|
-
return [createBlockInstanceFromObject(block)];
|
|
923
|
-
} catch (error) {
|
|
924
|
-
reportBlockError(error, {
|
|
925
|
-
site: "theme-state.resolve.hydrate",
|
|
926
|
-
extra: {
|
|
927
|
-
surface,
|
|
928
|
-
path,
|
|
929
|
-
blockType: typeof (block == null ? void 0 : block.type) === "string" ? block.type : "(unknown)"
|
|
930
|
-
}
|
|
931
|
-
});
|
|
932
|
-
return [];
|
|
933
|
-
}
|
|
934
|
-
});
|
|
935
|
-
return stored;
|
|
936
|
-
}
|
|
937
|
-
const blockToUse = surface === "page" ? (_b = (_a2 = deps.routerService) == null ? void 0 : _a2.getPages().find((p2) => p2.path === path)) == null ? void 0 : _b.block : (_c = getDefinedBlocks().find((b2) => b2.name === path)) == null ? void 0 : _c.name;
|
|
938
|
-
if (blockToUse != null) {
|
|
939
|
-
const instance = createBlockInstance(blockToUse);
|
|
940
|
-
surfaces[surface].blocks.value = [instance];
|
|
941
|
-
const serialized = serializeBlocks([instance]);
|
|
942
|
-
(_d = deps.upsertState) == null ? void 0 : _d.call(deps, surface, path, serialized);
|
|
943
|
-
return { blocks: serialized };
|
|
944
|
-
}
|
|
945
|
-
return { blocks: [] };
|
|
946
|
-
}
|
|
947
|
-
onRegisterBlock(async (_2, block) => {
|
|
948
|
-
if (block.locales == null || catalogs.value == null) return;
|
|
949
|
-
const localeAtLoadStart = locale.value;
|
|
950
|
-
let file = null;
|
|
951
|
-
try {
|
|
952
|
-
file = await block.locales.load(localeAtLoadStart);
|
|
953
|
-
} catch {
|
|
954
|
-
file = null;
|
|
955
|
-
}
|
|
956
|
-
if (catalogs.value == null || locale.value !== localeAtLoadStart) return;
|
|
957
|
-
const parsed = parseBlockLocaleFile(file);
|
|
958
|
-
const current = catalogs.value;
|
|
959
|
-
catalogs.value = {
|
|
960
|
-
...current,
|
|
961
|
-
blocks: {
|
|
962
|
-
...current.blocks,
|
|
963
|
-
defaults: {
|
|
964
|
-
...current.blocks.defaults,
|
|
965
|
-
[block.name]: parsed.defaults
|
|
966
|
-
},
|
|
967
|
-
modes: {
|
|
968
|
-
...current.blocks.modes,
|
|
969
|
-
[block.name]: parsed.modes
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
};
|
|
973
|
-
});
|
|
974
|
-
(_a = deps.routerService) == null ? void 0 : _a.subscribe(({ path }) => {
|
|
975
|
-
resolve("page", path);
|
|
976
|
-
});
|
|
977
|
-
return {
|
|
978
|
-
page: surfaces.page,
|
|
979
|
-
overlay: surfaces.overlay,
|
|
980
|
-
locales: { locale, catalogs, setLocale },
|
|
981
|
-
globalStyles,
|
|
982
|
-
setGlobalStyles,
|
|
983
|
-
resolve
|
|
984
|
-
};
|
|
985
|
-
}
|
|
986
825
|
export {
|
|
987
826
|
BlockWrapperEvent as B,
|
|
988
827
|
ContextProvideEvent as C,
|
|
989
|
-
DEFAULT_GLOBAL_STYLES as D,
|
|
990
828
|
E,
|
|
991
829
|
SelectedBlockContext as S,
|
|
992
|
-
ThemeStateContext as T,
|
|
993
830
|
ContextRequestEvent as a,
|
|
994
|
-
|
|
831
|
+
attachEmptyTracking as b,
|
|
995
832
|
createContext as c,
|
|
996
833
|
d,
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
834
|
+
backfillInstanceDefaults as e,
|
|
835
|
+
createBlockInstance as f,
|
|
836
|
+
createBlockInstanceFromJSON as g,
|
|
837
|
+
createBlockInstanceFromObject as h,
|
|
838
|
+
createCeRenderer as i,
|
|
839
|
+
createSelectedBlock as j,
|
|
1003
840
|
defineBlock as k,
|
|
1004
841
|
defineBlockRuntime as l,
|
|
1005
842
|
getDefinedBlocks as m,
|
|
1006
|
-
|
|
843
|
+
hasRenderedContent as n,
|
|
1007
844
|
injectContext as o,
|
|
1008
845
|
isStubDefinition as p,
|
|
1009
846
|
onRegisterBlock as q,
|
package/dist/block.d.ts
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
1
|
import { JSONSchema } from 'json-schema-to-ts';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if `scope` has at least one visible direct element child.
|
|
4
|
+
* "Visible" follows the platform's `Element.checkVisibility()` rule
|
|
5
|
+
* (not `display: none`, not `visibility: hidden`, not `[hidden]`).
|
|
6
|
+
*
|
|
7
|
+
* Direct children that are themselves `display: contents` are traversed
|
|
8
|
+
* transparently — those elements generate no box of their own, so their
|
|
9
|
+
* own children are what the browser actually paints in the parent's flow.
|
|
10
|
+
* This matches the platform's rendering model: framework-injected
|
|
11
|
+
* `display: contents` wrappers (e.g. `<ContextProvider>`) don't make
|
|
12
|
+
* their host scope falsely appear non-empty.
|
|
13
|
+
*
|
|
14
|
+
* UA-default `display: none` on `<style>` / `<script>` / `<template>` /
|
|
15
|
+
* `<link>` / `<meta>` / `<noscript>` means those never count.
|
|
16
|
+
*
|
|
17
|
+
* Authoring convention: blocks that may render nothing must do so via
|
|
18
|
+
* `v-if`, `v-show`, or `hidden` on the template root — an always-rendered
|
|
19
|
+
* empty wrapper element (with any `display` other than `contents`) will
|
|
20
|
+
* be reported as non-empty.
|
|
21
|
+
*/
|
|
22
|
+
export declare function hasRenderedContent(scope: ParentNode): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Wire `data-empty` tracking on a block host element.
|
|
25
|
+
*
|
|
26
|
+
* - host: the element on which to toggle `data-empty`.
|
|
27
|
+
* - scope: optional override for what to observe. If omitted, the
|
|
28
|
+
* helper picks `host.shadowRoot ?? host` lazily inside its deferred
|
|
29
|
+
* setup — so CE hosts whose shadow root is attached in
|
|
30
|
+
* connectedCallback (Preact/React) are observed correctly.
|
|
31
|
+
*
|
|
32
|
+
* Behavior:
|
|
33
|
+
* - Defers initial observe+sync via `queueMicrotask`. The microtask
|
|
34
|
+
* fires after the current synchronous task completes, which is
|
|
35
|
+
* after the caller (e.g. ExtensionRoot) has appended the host
|
|
36
|
+
* and any CE's connectedCallback has run.
|
|
37
|
+
* - Uses `MutationObserver` with `{ childList: true, subtree: true }`.
|
|
38
|
+
* - Sets/removes the `data-empty` attribute as a boolean attribute
|
|
39
|
+
* (no value).
|
|
40
|
+
*
|
|
41
|
+
* Returns a teardown function that disconnects the observer.
|
|
42
|
+
*/
|
|
43
|
+
export declare function attachEmptyTracking(host: HTMLElement, scope?: ParentNode): () => void;
|
|
2
44
|
type Schema = {} | (JSONSchema & {
|
|
3
45
|
type: "object";
|
|
4
46
|
});
|
|
@@ -87,7 +129,7 @@ export declare function defineBlockRuntime<T = never>(name: string, opts: {
|
|
|
87
129
|
renderer: (block: BlockInstance) => HTMLElement;
|
|
88
130
|
}): BlockDefinition<T>;
|
|
89
131
|
export declare function getDefinedBlocks(): BlockDefinition[];
|
|
90
|
-
export declare function createCeRenderer(name: string): (block: BlockInstance) =>
|
|
132
|
+
export declare function createCeRenderer(name: string): (block: BlockInstance) => HTMLElement;
|
|
91
133
|
export declare function isStubDefinition(definition: BlockDefinition): boolean;
|
|
92
134
|
/**
|
|
93
135
|
* Backfill an empty block instance with `props`/`slots` defaults sourced
|
package/dist/block.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,UAAU,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAErD,MAAM,WAAW,WAAW,CAC1B,MAAM,GAAG,OAAO,EAChB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElE,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,MAAM,EACN,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAC9C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG;IAAE,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,KAAK,WAAW,CAAC;AAChG,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA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 -1,8 +1,8 @@
|
|
|
1
1
|
function isEditorMessage(message) {
|
|
2
|
-
return message.type === "PROVIDE_THEME_STATE" || message.type === "PROVIDE_TRANSLATION_OVERRIDES" || message.type === "SELECT_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "ADD_BLOCK" || message.type === "REMOVE_BLOCK" || message.type === "MOVE_BLOCK" || message.type === "SET_BLOCK_PRESET" || message.type === "SET_LOCALE" || message.type === "SET_GLOBAL_STYLES" || message.type === "PROVIDE_GLOBAL_STYLES" || message.type === "SCROLL_SYNC" || message.type === "REQUEST_CONTENT_HEIGHT";
|
|
2
|
+
return message.type === "PROVIDE_THEME_STATE" || message.type === "PROVIDE_TRANSLATION_OVERRIDES" || message.type === "SELECT_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "ADD_BLOCK" || message.type === "REMOVE_BLOCK" || message.type === "MOVE_BLOCK" || message.type === "SET_BLOCK_PRESET" || message.type === "SET_LOCALE" || message.type === "SET_GLOBAL_STYLES" || message.type === "PROVIDE_GLOBAL_STYLES" || message.type === "SCROLL_SYNC" || message.type === "REQUEST_CONTENT_HEIGHT" || message.type === "ADD_BLOCK_MENU_CLOSED";
|
|
3
3
|
}
|
|
4
4
|
function isIframeMessage(message) {
|
|
5
|
-
return message.type === "SELECT_BLOCK" || message.type === "IFRAME_READY" || message.type === "REGISTER_BLOCKS" || message.type === "REGISTER_ROUTES" || message.type === "REMOVE_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "REQUEST_THEME_STATE" || message.type === "UPSERT_THEME_STATE" || message.type === "REQUEST_TRANSLATION_OVERRIDES" || message.type === "UPDATE_BLOCK_TRANSLATION" || message.type === "REGISTER_BLOCK_TRANSLATION_KEYS" || message.type === "FOCUS_INLINE_TEXT" || message.type === "REQUEST_GLOBAL_STYLES" || message.type === "PROVIDE_INITIAL_GLOBAL_STYLES" || message.type === "REPORT_CONTENT_HEIGHT" || message.type === "SCROLL_SYNC";
|
|
5
|
+
return message.type === "SELECT_BLOCK" || message.type === "IFRAME_READY" || message.type === "REGISTER_BLOCKS" || message.type === "REGISTER_ROUTES" || message.type === "REMOVE_BLOCK" || message.type === "UPDATE_BLOCK_PROPS" || message.type === "REQUEST_THEME_STATE" || message.type === "UPSERT_THEME_STATE" || message.type === "REQUEST_TRANSLATION_OVERRIDES" || message.type === "UPDATE_BLOCK_TRANSLATION" || message.type === "REGISTER_BLOCK_TRANSLATION_KEYS" || message.type === "FOCUS_INLINE_TEXT" || message.type === "REQUEST_GLOBAL_STYLES" || message.type === "PROVIDE_INITIAL_GLOBAL_STYLES" || message.type === "REPORT_CONTENT_HEIGHT" || message.type === "SCROLL_SYNC" || message.type === "OPEN_ADD_BLOCK_MENU";
|
|
6
6
|
}
|
|
7
7
|
function createProvideThemeStateMessage(payload) {
|
|
8
8
|
return {
|
|
@@ -182,6 +182,20 @@ function createReportContentHeightMessage(payload) {
|
|
|
182
182
|
timestamp: Date.now()
|
|
183
183
|
};
|
|
184
184
|
}
|
|
185
|
+
function createOpenAddBlockMenuMessage(payload) {
|
|
186
|
+
return {
|
|
187
|
+
type: "OPEN_ADD_BLOCK_MENU",
|
|
188
|
+
payload,
|
|
189
|
+
timestamp: Date.now()
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function createAddBlockMenuClosedMessage(payload) {
|
|
193
|
+
return {
|
|
194
|
+
type: "ADD_BLOCK_MENU_CLOSED",
|
|
195
|
+
payload,
|
|
196
|
+
timestamp: Date.now()
|
|
197
|
+
};
|
|
198
|
+
}
|
|
185
199
|
let bridgeInstance = null;
|
|
186
200
|
function getEditorBridge() {
|
|
187
201
|
return bridgeInstance;
|
|
@@ -243,13 +257,20 @@ function createEditorBridge() {
|
|
|
243
257
|
}
|
|
244
258
|
return false;
|
|
245
259
|
});
|
|
260
|
+
const isAddBlockButton = path.some((node) => {
|
|
261
|
+
if (!(node instanceof HTMLElement)) return false;
|
|
262
|
+
return node.classList.contains("block-wrapper__add-btn") || node.classList.contains("block-wrapper__add-btn-inner") || node.classList.contains("block-wrapper__add-btn-surface") || node.classList.contains("block-wrapper__add-btn-plus") || node.classList.contains("block-wrapper__add-btn-text");
|
|
263
|
+
});
|
|
264
|
+
if (isAddBlockButton) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
246
267
|
const isEditorUI = path.some((node) => {
|
|
247
268
|
if (!(node instanceof HTMLElement)) return false;
|
|
248
269
|
let current = node;
|
|
249
270
|
const root = node.getRootNode();
|
|
250
271
|
while (current && current !== root) {
|
|
251
272
|
const classList = current.classList;
|
|
252
|
-
if (classList.contains("block-wrapper__name") || classList.contains("block-wrapper__actions") || classList.contains("block-wrapper__icon") || classList.contains("block-wrapper__remove-icon") || current.hasAttribute("data-block-editor")) {
|
|
273
|
+
if (classList.contains("block-wrapper__name") || classList.contains("block-wrapper__actions") || classList.contains("block-wrapper__icon") || classList.contains("block-wrapper__remove-icon") || classList.contains("block-wrapper__add-btn") || current.hasAttribute("data-block-editor")) {
|
|
253
274
|
return true;
|
|
254
275
|
}
|
|
255
276
|
current = current.parentElement;
|
|
@@ -501,31 +522,33 @@ function createEditorBridge() {
|
|
|
501
522
|
return bridgeInstance;
|
|
502
523
|
}
|
|
503
524
|
export {
|
|
504
|
-
|
|
525
|
+
getEditorBridge as A,
|
|
526
|
+
isEditorMessage as B,
|
|
527
|
+
isIframeMessage as C,
|
|
505
528
|
createEditorBridge as a,
|
|
506
529
|
createFocusInlineTextMessage as b,
|
|
507
530
|
createRegisterBlockTranslationKeysMessage as c,
|
|
508
531
|
createUpdateBlockTranslationMessage as d,
|
|
509
532
|
createSelectBlockMessage as e,
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
533
|
+
createOpenAddBlockMenuMessage as f,
|
|
534
|
+
createRemoveBlockMessage as g,
|
|
535
|
+
createRegisterBlocksMessage as h,
|
|
536
|
+
createRegisterRoutesMessage as i,
|
|
537
|
+
createAddBlockMenuClosedMessage as j,
|
|
538
|
+
createAddBlockMessage as k,
|
|
539
|
+
createMoveBlockMessage as l,
|
|
540
|
+
createProvideGlobalStylesMessage as m,
|
|
541
|
+
createProvideInitialGlobalStylesMessage as n,
|
|
542
|
+
createProvideThemeStateMessage as o,
|
|
543
|
+
createProvideTranslationOverridesMessage as p,
|
|
544
|
+
createReportContentHeightMessage as q,
|
|
545
|
+
createRequestGlobalStylesMessage as r,
|
|
546
|
+
createRequestThemeStateMessage as s,
|
|
547
|
+
createRequestTranslationOverridesMessage as t,
|
|
548
|
+
createScrollSyncMessage as u,
|
|
549
|
+
createSetBlockPresetMessage as v,
|
|
550
|
+
createSetGlobalStylesMessage as w,
|
|
551
|
+
createSetLocaleMessage as x,
|
|
552
|
+
createUpdateBlockPropsMessage as y,
|
|
553
|
+
createUpsertThemeStateMessage as z
|
|
531
554
|
};
|