@juo/blocks 1.16.0 → 1.16.1
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-C3lVJEBl.js → ExtensionRoot-DfpvN94s.js} +1 -1
- package/dist/core.js +3 -3
- package/dist/{css-runtime-ClH0MEYr.js → css-runtime-DTiXcYSs.js} +23 -17
- package/dist/editor/handler.d.ts.map +1 -1
- package/dist/editor.js +4 -1
- package/dist/{gridstack-adapter-CDWbSpbt.js → gridstack-adapter-BZWybRw1.js} +2 -2
- package/dist/{project-gridstack-CM783oKI.js → project-gridstack-C2cSYRMx.js} +1 -1
- package/dist/theme-state.d.ts +10 -1
- package/dist/theme-state.d.ts.map +1 -1
- package/dist/vue/context.d.ts +25 -1
- package/dist/vue/context.d.ts.map +1 -1
- package/dist/vue/useTranslatedProp.test.d.ts +2 -0
- package/dist/vue/useTranslatedProp.test.d.ts.map +1 -0
- package/dist/vue.js +36 -2
- package/dist/web-components/editor/InlineText.d.ts +1 -0
- package/dist/web-components/editor/InlineText.d.ts.map +1 -1
- package/dist/web-components-editor.js +13 -5
- package/dist/web-components-runtime.js +2 -2
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ 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, layoutSystemEnabled, untracked } from "@juo/blocks";
|
|
5
5
|
import { reportBlockWarning, reportBlockError } from "./observability.js";
|
|
6
|
-
import { L as LAYOUT_SCOPE_ATTR, b as buildGridLayout, a as isStubDefinition, w as withWrapper, s as subscribeContext, c as ThemeStateContext, d as backfillInstanceDefaults, o as onRegisterBlock } from "./css-runtime-
|
|
6
|
+
import { L as LAYOUT_SCOPE_ATTR, b as buildGridLayout, a as isStubDefinition, w as withWrapper, s as subscribeContext, c as ThemeStateContext, d as backfillInstanceDefaults, o as onRegisterBlock } from "./css-runtime-DTiXcYSs.js";
|
|
7
7
|
import { g as getInstrumentation } from "./index-JSv6UH_o.js";
|
|
8
8
|
class Block extends HTMLElement {
|
|
9
9
|
constructor() {
|
package/dist/core.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { f as createContext, g as d, h as w, j as registerBlock, E, u, k as getDefinedBlocks, l as createBlockInstance, m as defineBlock, s as subscribeContext, G as GRID_V1_ENGINE_ID, n as clampRect, p as applyFillExpansion, q as compactItems, t as findFreeRect, D as DEFAULT_GRID } from "./css-runtime-
|
|
5
|
-
import { B, v, x, y, z, L, P, S, c, T, A, d as d2, b, F, H, I, J, K, N, O, Q, R, U, V, W, X, Y, Z, i, _, a, $, a0, o, a1, a2, a3, e, a4, r, a5, a6, a7, w as w2 } from "./css-runtime-
|
|
4
|
+
import { f as createContext, g as d, h as w, j as registerBlock, E, u, k as getDefinedBlocks, l as createBlockInstance, m as defineBlock, s as subscribeContext, G as GRID_V1_ENGINE_ID, n as clampRect, p as applyFillExpansion, q as compactItems, t as findFreeRect, D as DEFAULT_GRID } from "./css-runtime-DTiXcYSs.js";
|
|
5
|
+
import { B, v, x, y, z, L, P, S, c, T, A, d as d2, b, F, H, I, J, K, N, O, Q, R, U, V, W, X, Y, Z, i, _, a, $, a0, o, a1, a2, a3, e, a4, r, a5, a6, a7, w as w2 } from "./css-runtime-DTiXcYSs.js";
|
|
6
6
|
import { reportBlockWarning, reportBlockError } from "./observability.js";
|
|
7
7
|
import { a as createEditorBridge, D as createSelectBlockMessage } from "./bridge-xiKEzCGR.js";
|
|
8
|
-
import { p } from "./project-gridstack-
|
|
8
|
+
import { p } from "./project-gridstack-C2cSYRMx.js";
|
|
9
9
|
import { clearLayoutModeAdapter, getLayoutModeAdapter, registerLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
|
|
10
10
|
function createState() {
|
|
11
11
|
const discountCode = d(null);
|
|
@@ -890,12 +890,16 @@ function parseBlockLocaleFile(file) {
|
|
|
890
890
|
}
|
|
891
891
|
};
|
|
892
892
|
}
|
|
893
|
-
function indexOverrides(overrides) {
|
|
893
|
+
function indexOverrides(overrides, locale) {
|
|
894
894
|
const indexed = {
|
|
895
895
|
theme: {},
|
|
896
896
|
blocks: {}
|
|
897
897
|
};
|
|
898
|
+
const wanted = locale == null ? null : normalizeLocale(locale);
|
|
898
899
|
for (const item of overrides) {
|
|
900
|
+
if (wanted != null && normalizeLocale(item.locale) !== wanted) {
|
|
901
|
+
continue;
|
|
902
|
+
}
|
|
899
903
|
if (item.scope.kind === "theme") {
|
|
900
904
|
indexed.theme[item.key] = item.value;
|
|
901
905
|
continue;
|
|
@@ -947,29 +951,31 @@ function createThemeState(deps) {
|
|
|
947
951
|
}
|
|
948
952
|
return { defaults: nextDefaults, modes: nextModes };
|
|
949
953
|
}
|
|
954
|
+
let localeVersion = 0;
|
|
950
955
|
async function setLocale(nextLocaleRaw) {
|
|
951
956
|
var _a2;
|
|
952
957
|
const nextLocale = normalizeLocale(nextLocaleRaw);
|
|
958
|
+
const version = ++localeVersion;
|
|
953
959
|
const [blockData, loadedOverrides] = await Promise.all([
|
|
954
960
|
collectBlockDefaults(nextLocale),
|
|
955
961
|
((_a2 = deps.translations) == null ? void 0 : _a2.resolveTranslations(nextLocale).catch(() => [])) ?? Promise.resolve([])
|
|
956
962
|
]);
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
)
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
}
|
|
971
|
-
|
|
972
|
-
|
|
963
|
+
if (version !== localeVersion) return;
|
|
964
|
+
const indexed = indexOverrides(loadedOverrides, nextLocale);
|
|
965
|
+
r(() => {
|
|
966
|
+
catalogs.value = {
|
|
967
|
+
theme: {
|
|
968
|
+
defaults: {},
|
|
969
|
+
overrides: indexed.theme
|
|
970
|
+
},
|
|
971
|
+
blocks: {
|
|
972
|
+
defaults: blockData.defaults,
|
|
973
|
+
modes: blockData.modes,
|
|
974
|
+
overrides: indexed.blocks
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
locale.value = nextLocale;
|
|
978
|
+
});
|
|
973
979
|
}
|
|
974
980
|
async function resolve(surface, path) {
|
|
975
981
|
var _a2, _b, _c, _d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/editor/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACrD;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB;6BAsE/B,aAAa;
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/editor/handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAKL,KAAK,UAAU,EAEhB,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;CACrD;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB;6BAsE/B,aAAa;EA0U9C"}
|
package/dist/editor.js
CHANGED
|
@@ -82,7 +82,10 @@ function createEditorHandler(options) {
|
|
|
82
82
|
const catalogs = themeState.locales.catalogs;
|
|
83
83
|
const current = catalogs.value;
|
|
84
84
|
if (current == null) return;
|
|
85
|
-
const indexed = indexOverrides(
|
|
85
|
+
const indexed = indexOverrides(
|
|
86
|
+
message.payload.overrides,
|
|
87
|
+
themeState.locales.locale.value
|
|
88
|
+
);
|
|
86
89
|
catalogs.value = {
|
|
87
90
|
...current,
|
|
88
91
|
theme: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as reconcileLayout, L as LAYOUT_SCOPE_ATTR, M as MAX_BLOCKS_PER_ROW } from "./css-runtime-
|
|
2
|
-
import { r as resolveActiveBreakpoint, p as projectToGridStack, M as MIN_BLOCK_ROWS, a as MIN_BLOCK_PX } from "./project-gridstack-
|
|
1
|
+
import { e as reconcileLayout, L as LAYOUT_SCOPE_ATTR, M as MAX_BLOCKS_PER_ROW } from "./css-runtime-DTiXcYSs.js";
|
|
2
|
+
import { r as resolveActiveBreakpoint, p as projectToGridStack, M as MIN_BLOCK_ROWS, a as MIN_BLOCK_PX } from "./project-gridstack-C2cSYRMx.js";
|
|
3
3
|
import { LAYOUT_POP_CLASS, LAYOUT_INTERACTION_START, LAYOUT_INTERACTION_END } from "./layout-mode-adapter-BBd4JRQd.js";
|
|
4
4
|
function obsolete(self, f, oldName, newName, rev) {
|
|
5
5
|
const wrapper = (...args) => {
|
package/dist/theme-state.d.ts
CHANGED
|
@@ -85,7 +85,16 @@ export type ThemeState = {
|
|
|
85
85
|
export declare const ThemeStateContext: {
|
|
86
86
|
__context__: ThemeState;
|
|
87
87
|
};
|
|
88
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Flatten overrides into the `(scope, key) -> value` shape the catalogs hold.
|
|
90
|
+
*
|
|
91
|
+
* Indexing is last-write-wins per `(scope, key)`, so a list spanning several
|
|
92
|
+
* locales resolves to whichever locale happens to come last — a silent
|
|
93
|
+
* cross-locale leak. `locale` is therefore **required for any multi-locale
|
|
94
|
+
* input**: pass it and entries for other locales are dropped. Only omit it
|
|
95
|
+
* when the caller has already narrowed the list to a single locale.
|
|
96
|
+
*/
|
|
97
|
+
export declare function indexOverrides(overrides: TranslationOverride[], locale?: string): {
|
|
89
98
|
theme: Record<string, string>;
|
|
90
99
|
blocks: Record<string, Record<string, string>>;
|
|
91
100
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-state.d.ts","sourceRoot":"","sources":["../src/theme-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,MAAM,EACZ,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAIL,KAAK,KAAK,EAEV,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD;;;;;;;;;GASG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG,QAAQ,CAAC;AAErD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAA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E,KAAK,IAAI,CAAC;CAC9E,GAAG,UAAU,CAwMb"}
|
package/dist/vue/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
1
|
+
import { MaybeRefOrGetter, Ref } from 'vue';
|
|
2
2
|
import { ContextType, UnknownContext } from '../main.ts';
|
|
3
3
|
import { Signal } from '@preact/signals-core';
|
|
4
4
|
export declare const ContextProvider: import('vue').DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, import('vue').PublicProps>;
|
|
@@ -13,6 +13,30 @@ export declare function useBlockType(): Ref<string | null>;
|
|
|
13
13
|
* This is a no-op when not running inside an editor iframe.
|
|
14
14
|
*/
|
|
15
15
|
export declare function useRegisterTranslationKeys(): (keys: Record<string, string>) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a single translation key into a reactive string.
|
|
18
|
+
*
|
|
19
|
+
* Use this for translatable text that lands in an **HTML attribute**
|
|
20
|
+
* (`placeholder`, `aria-label`, `alt`, `title`) and therefore cannot go through
|
|
21
|
+
* `<juo-text prop="...">`. Binding the raw Vue prop instead renders the block's
|
|
22
|
+
* untranslated schema default and silently ignores every merchant translation.
|
|
23
|
+
*
|
|
24
|
+
* Reactivity has to be established with a Preact `effect` rather than a Vue
|
|
25
|
+
* `computed`, because `TranslationService.resolve` reads `catalogs` and the
|
|
26
|
+
* async-loaded theme defaults from a closure over Preact signals that Vue
|
|
27
|
+
* cannot see. A `computed` that merely touches `locale.value` misses:
|
|
28
|
+
*
|
|
29
|
+
* - `catalogs`-only updates (a block's locale file is loaded lazily on
|
|
30
|
+
* registration — see `onRegisterBlock` in `theme-state.ts`), and
|
|
31
|
+
* - theme defaults that resolve *after* a locale switch, which leaves the old
|
|
32
|
+
* language on screen until something unrelated forces a re-render.
|
|
33
|
+
*
|
|
34
|
+
* The `watch` re-arms the effect once `blockId`/`blockType` become available,
|
|
35
|
+
* which for `.ce.vue` blocks only happens after the shadow host connects.
|
|
36
|
+
*
|
|
37
|
+
* Returns `fallback` (default `""`) while the key is unresolved or missing.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useTranslatedProp(key: MaybeRefOrGetter<string>, fallback?: MaybeRefOrGetter<string | undefined>): Ref<string>;
|
|
16
40
|
export declare function useContext<C extends UnknownContext>(context: C): Wrap<ContextType<C>>;
|
|
17
41
|
export declare function useProvideContext<C extends UnknownContext>(context: C, init: ContextType<C>): void;
|
|
18
42
|
type Wrap<T> = T extends Signal<infer V> ? Ref<V> : T extends Function ? T : T extends Record<any, any> ? {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/vue/context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/vue/context.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAgB,gBAAgB,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/D,OAAO,EACL,WAAW,EAKX,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,eAAO,MAAM,eAAe,wHAyB1B,CAAC;AAEH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,IAAI,CAE7E;AA+BD,wBAAgB,UAAU,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAI/C;AAED,wBAAgB,YAAY,IAAI,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,CAIjD;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,CAC5C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KACzB,IAAI,CAeR;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAC7B,QAAQ,CAAC,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,GAC9C,GAAG,CAAC,MAAM,CAAC,CAyCb;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,cAAc,EACjD,OAAO,EAAE,CAAC,GACT,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAOtB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,cAAc,EACxD,OAAO,EAAE,CAAC,EACV,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,GACnB,IAAI,CAON;AAED,KAAK,IAAI,CAAC,CAAC,IACT,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,CAAC,GACrB,GAAG,CAAC,CAAC,CAAC,GACN,CAAC,SAAS,QAAQ,GAChB,CAAC,GACD,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GACxB;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3B,GAAG;IAAE,CAAC,EAAE,CAAC,CAAA;CAAE,GACZ,CAAC,CAAC;AAEZ,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CA8CvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslatedProp.test.d.ts","sourceRoot":"","sources":["../../src/vue/useTranslatedProp.test.ts"],"names":[],"mappings":""}
|
package/dist/vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { customRef, toValue, watchEffect, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, useHost, defineCustomElement, triggerRef, render, shallowRef } from "vue";
|
|
1
|
+
import { customRef, toValue, watchEffect, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, watch, onScopeDispose, useHost, defineCustomElement, triggerRef, render, shallowRef } from "vue";
|
|
2
2
|
import { g as getInstrumentation } from "./index-JSv6UH_o.js";
|
|
3
|
-
import { effect, signal, injectContext, provideContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
|
|
3
|
+
import { effect, signal, injectContext, provideContext, TranslationContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
|
|
4
4
|
import { hasRenderedContent } from "@juo/blocks";
|
|
5
5
|
import { v as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-xiKEzCGR.js";
|
|
6
6
|
const signalsMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -104,6 +104,39 @@ function useRegisterTranslationKeys() {
|
|
|
104
104
|
);
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
+
function useTranslatedProp(key2, fallback) {
|
|
108
|
+
const blockId = useBlockId();
|
|
109
|
+
const blockType = useBlockType();
|
|
110
|
+
const service = useContext(TranslationContext).$;
|
|
111
|
+
const out = ref("");
|
|
112
|
+
let dispose;
|
|
113
|
+
watch(
|
|
114
|
+
[
|
|
115
|
+
blockId,
|
|
116
|
+
blockType,
|
|
117
|
+
() => toValue(key2),
|
|
118
|
+
() => toValue(fallback) ?? ""
|
|
119
|
+
],
|
|
120
|
+
([id, type, currentKey, currentFallback]) => {
|
|
121
|
+
dispose == null ? void 0 : dispose();
|
|
122
|
+
dispose = void 0;
|
|
123
|
+
if (!id || !type || !currentKey) {
|
|
124
|
+
out.value = currentFallback;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
dispose = effect(() => {
|
|
128
|
+
const resolved = service.resolve(type, id, currentKey);
|
|
129
|
+
out.value = resolved === currentKey ? currentFallback : resolved;
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
{ immediate: true }
|
|
133
|
+
);
|
|
134
|
+
onScopeDispose(() => {
|
|
135
|
+
dispose == null ? void 0 : dispose();
|
|
136
|
+
dispose = void 0;
|
|
137
|
+
});
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
107
140
|
function useContext(context) {
|
|
108
141
|
const root = inject(key);
|
|
109
142
|
if ((root == null ? void 0 : root.value) == null) {
|
|
@@ -328,5 +361,6 @@ export {
|
|
|
328
361
|
useProvideContextProvider,
|
|
329
362
|
useRegisterTranslationKeys,
|
|
330
363
|
useTarget,
|
|
364
|
+
useTranslatedProp,
|
|
331
365
|
wrap
|
|
332
366
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,kBAAkB,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAAqC;IACnE,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,SAAS,CAAuB;
|
|
1
|
+
{"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,kBAAkB,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAAqC;IACnE,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,SAAS,CAAuB;IAGxC,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,OAAO,CAAC,CAAa;IAI7B,OAAO,CAAC,cAAc,CAAS;IAE/B,MAAM,KAAK,kBAAkB,aAE5B;;IAMD,iBAAiB;IA0CjB,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,oBAAoB;IA6E5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAwC;IAEpE,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,UAAU;IA+BlB,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOzB,oBAAoB;CASrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,UAAU,CAAC;KACxB;CACF"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { i as injectContext, T as TranslationContext, C as ContextRoot } from "./css-runtime-
|
|
5
|
-
import { V as ViewLayoutController, E as ExtensionRoot, B as Block } from "./ExtensionRoot-
|
|
4
|
+
import { i as injectContext, T as TranslationContext, C as ContextRoot } from "./css-runtime-DTiXcYSs.js";
|
|
5
|
+
import { V as ViewLayoutController, E as ExtensionRoot, B as Block } from "./ExtensionRoot-DfpvN94s.js";
|
|
6
6
|
import { canvasMode, getActiveSurfaceContext, emitLayoutSetRects, effect } from "@juo/blocks";
|
|
7
7
|
import { getLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
|
|
8
8
|
import { a as createEditorBridge, m as createFocusInlineTextMessage, J as createUpdateBlockTranslationMessage } from "./bridge-xiKEzCGR.js";
|
|
@@ -110,6 +110,9 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
110
110
|
__publicField(this, "boundHandlePointerDown", this.handlePointerDown.bind(this));
|
|
111
111
|
__publicField(this, "boundHandleClick", this.handleClick.bind(this));
|
|
112
112
|
__publicField(this, "lastValue", null);
|
|
113
|
+
// The text the block itself rendered (its prop value), used when the catalog
|
|
114
|
+
// has no translation for this key. Survives DOM moves — see initializeEditorMode.
|
|
115
|
+
__publicField(this, "fallbackText", null);
|
|
113
116
|
__publicField(this, "dispose");
|
|
114
117
|
// One-time DOM/style setup guard — see initializeEditorMode. Persists across
|
|
115
118
|
// DOM moves so reconnecting (e.g. exiting layout mode) skips redundant,
|
|
@@ -177,17 +180,22 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
177
180
|
this.addEventListener("blur", this.boundHandleBlur);
|
|
178
181
|
this.addEventListener("pointerdown", this.boundHandlePointerDown);
|
|
179
182
|
this.addEventListener("click", this.boundHandleClick);
|
|
180
|
-
|
|
183
|
+
const rendered = this.textContent ?? "";
|
|
184
|
+
if (this.fallbackText == null || rendered !== this.lastValue) {
|
|
185
|
+
this.fallbackText = rendered;
|
|
186
|
+
}
|
|
187
|
+
this.lastValue = rendered;
|
|
181
188
|
if (this.translationService && this.propName && this.blockType && this.blockId) {
|
|
182
189
|
const key = this.propName;
|
|
183
|
-
const fallbackText = this.textContent ?? "";
|
|
184
190
|
this.dispose = effect(() => {
|
|
185
191
|
const service = this.translationService;
|
|
186
192
|
if (!service) return;
|
|
187
193
|
void service.locale.value;
|
|
188
194
|
const resolved = service.resolve(this.blockType, this.blockId, key);
|
|
189
195
|
const isMissing = resolved === key || this.hasAttribute("fallback-on-empty") && resolved.trim() === "";
|
|
196
|
+
const fallbackText = this.fallbackText ?? "";
|
|
190
197
|
const value = isMissing && fallbackText.trim().length > 0 ? fallbackText : resolved;
|
|
198
|
+
if (this.contentEditable === "plaintext-only") return;
|
|
191
199
|
this.textContent = value;
|
|
192
200
|
this.lastValue = value;
|
|
193
201
|
});
|
|
@@ -298,7 +306,7 @@ initMorphController();
|
|
|
298
306
|
void (async () => {
|
|
299
307
|
try {
|
|
300
308
|
const [{ createGridStackAdapter }, { registerLayoutModeAdapter }] = await Promise.all([
|
|
301
|
-
import("./gridstack-adapter-
|
|
309
|
+
import("./gridstack-adapter-BZWybRw1.js"),
|
|
302
310
|
import("./layout-mode-adapter-BBd4JRQd.js")
|
|
303
311
|
]);
|
|
304
312
|
registerLayoutModeAdapter(createGridStackAdapter());
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { i as injectContext, T as TranslationContext, C as ContextRoot } from "./css-runtime-
|
|
5
|
-
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-
|
|
4
|
+
import { i as injectContext, T as TranslationContext, C as ContextRoot } from "./css-runtime-DTiXcYSs.js";
|
|
5
|
+
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-DfpvN94s.js";
|
|
6
6
|
import { effect } from "@juo/blocks";
|
|
7
7
|
class InlineText extends HTMLElement {
|
|
8
8
|
constructor() {
|