@bloklabs/angular 1.2.6 → 1.3.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/fesm2022/bloklabs-angular.mjs +55 -19
- package/fesm2022/bloklabs-angular.mjs.map +1 -1
- package/index.d.ts +1 -675
- package/package.json +5 -4
- package/types/bloklabs-angular.d.ts +684 -0
|
@@ -182,7 +182,8 @@ class BlokContentDirective {
|
|
|
182
182
|
/** Emits the live Blok instance once it is ready, after `instance` is populated. */
|
|
183
183
|
ready = new EventEmitter();
|
|
184
184
|
/** The live Blok instance, or null before `isReady` resolves / after destroy. */
|
|
185
|
-
instance = signal(null,
|
|
185
|
+
instance = signal(null, /* @ts-ignore */
|
|
186
|
+
...(ngDevMode ? [{ debugName: "instance" }] : /* istanbul ignore next */ []));
|
|
186
187
|
/** The editor created by the most recent construction; used as the staleness key. */
|
|
187
188
|
current = null;
|
|
188
189
|
destroyed = false;
|
|
@@ -250,10 +251,10 @@ class BlokContentDirective {
|
|
|
250
251
|
this.registry = undefined;
|
|
251
252
|
this.instance.set(null);
|
|
252
253
|
}
|
|
253
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
254
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "
|
|
254
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BlokContentDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
255
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.7", type: BlokContentDirective, isStandalone: true, selector: "[blokContent]", inputs: { config: "config", recreateKey: "recreateKey" }, outputs: { ready: "ready" }, ngImport: i0 });
|
|
255
256
|
}
|
|
256
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
257
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BlokContentDirective, decorators: [{
|
|
257
258
|
type: Directive,
|
|
258
259
|
args: [{
|
|
259
260
|
selector: '[blokContent]',
|
|
@@ -2080,7 +2081,8 @@ class BlokEditorComponent {
|
|
|
2080
2081
|
defaults = inject(BLOK_DEFAULT_CONFIG, { optional: true }) ?? {};
|
|
2081
2082
|
contentQuery;
|
|
2082
2083
|
/** Signal bridge for the @ViewChild directive so effects react to its arrival. */
|
|
2083
|
-
content = signal(null,
|
|
2084
|
+
content = signal(null, /* @ts-ignore */
|
|
2085
|
+
...(ngDevMode ? [{ debugName: "content" }] : /* istanbul ignore next */ []));
|
|
2084
2086
|
/**
|
|
2085
2087
|
* Output half of two-way `[(data)]`. Emits the editor's serialized content on
|
|
2086
2088
|
* every change. Wiring the core `onSave` callback is gated on this being
|
|
@@ -2115,28 +2117,44 @@ class BlokEditorComponent {
|
|
|
2115
2117
|
// ---- Reactive inputs (signal-backed setters; synced in place, never recreate) ----
|
|
2116
2118
|
// Default undefined (not false) so an unset input falls back to a provideBlok
|
|
2117
2119
|
// default; the readOnly effect / buildConfig coerce undefined to false.
|
|
2118
|
-
readOnly$ = signal(undefined,
|
|
2120
|
+
readOnly$ = signal(undefined, /* @ts-ignore */
|
|
2121
|
+
...(ngDevMode ? [{ debugName: "readOnly$" }] : /* istanbul ignore next */ []));
|
|
2119
2122
|
set readOnly(value) {
|
|
2120
2123
|
this.readOnly$.set(value);
|
|
2121
2124
|
}
|
|
2122
|
-
theme$ = signal(undefined,
|
|
2125
|
+
theme$ = signal(undefined, /* @ts-ignore */
|
|
2126
|
+
...(ngDevMode ? [{ debugName: "theme$" }] : /* istanbul ignore next */ []));
|
|
2123
2127
|
set theme(value) {
|
|
2124
2128
|
this.theme$.set(value);
|
|
2125
2129
|
}
|
|
2126
|
-
width$ = signal(undefined,
|
|
2130
|
+
width$ = signal(undefined, /* @ts-ignore */
|
|
2131
|
+
...(ngDevMode ? [{ debugName: "width$" }] : /* istanbul ignore next */ []));
|
|
2127
2132
|
set width(value) {
|
|
2128
2133
|
this.width$.set(value);
|
|
2129
2134
|
}
|
|
2130
|
-
placeholder$ = signal(undefined,
|
|
2135
|
+
placeholder$ = signal(undefined, /* @ts-ignore */
|
|
2136
|
+
...(ngDevMode ? [{ debugName: "placeholder$" }] : /* istanbul ignore next */ []));
|
|
2131
2137
|
set placeholder(value) {
|
|
2132
2138
|
this.placeholder$.set(value);
|
|
2133
2139
|
}
|
|
2134
|
-
|
|
2140
|
+
/**
|
|
2141
|
+
* Theme tokens. Construction-only config forced hosts with a live light/dark
|
|
2142
|
+
* toggle to recreate the editor or hand-write the global stylesheet Blok
|
|
2143
|
+
* already injects; this drives the runtime `tokens` API instead.
|
|
2144
|
+
*/
|
|
2145
|
+
styleTokens$ = signal(undefined, /* @ts-ignore */
|
|
2146
|
+
...(ngDevMode ? [{ debugName: "styleTokens$" }] : /* istanbul ignore next */ []));
|
|
2147
|
+
set styleTokens(value) {
|
|
2148
|
+
this.styleTokens$.set(value);
|
|
2149
|
+
}
|
|
2150
|
+
autofocus$ = signal(false, /* @ts-ignore */
|
|
2151
|
+
...(ngDevMode ? [{ debugName: "autofocus$" }] : /* istanbul ignore next */ []));
|
|
2135
2152
|
set autofocus(value) {
|
|
2136
2153
|
this.autofocus$.set(value);
|
|
2137
2154
|
}
|
|
2138
2155
|
// ---- Reactive content (seeds construction, then re-renders on change) ----
|
|
2139
|
-
data$ = signal(undefined,
|
|
2156
|
+
data$ = signal(undefined, /* @ts-ignore */
|
|
2157
|
+
...(ngDevMode ? [{ debugName: "data$" }] : /* istanbul ignore next */ []));
|
|
2140
2158
|
set data(value) {
|
|
2141
2159
|
this.data$.set(value);
|
|
2142
2160
|
}
|
|
@@ -2156,6 +2174,8 @@ class BlokEditorComponent {
|
|
|
2156
2174
|
* no-op, so it won't clobber the caret. Renders are serialized via `renderChain`.
|
|
2157
2175
|
*/
|
|
2158
2176
|
lastRenderedData;
|
|
2177
|
+
/** Last token set pushed through `tokens.set`, for deep-equal deduping. */
|
|
2178
|
+
appliedTokens;
|
|
2159
2179
|
seededEditor = null;
|
|
2160
2180
|
renderChain = Promise.resolve();
|
|
2161
2181
|
/** Registered by `ControlValueAccessor.registerOnChange` (Angular forms). */
|
|
@@ -2178,7 +2198,8 @@ class BlokEditorComponent {
|
|
|
2178
2198
|
});
|
|
2179
2199
|
};
|
|
2180
2200
|
/** Live Blok instance, or null until `isReady` resolves / after destroy. */
|
|
2181
|
-
instance = computed(() => this.content()?.instance() ?? null,
|
|
2201
|
+
instance = computed(() => this.content()?.instance() ?? null, /* @ts-ignore */
|
|
2202
|
+
...(ngDevMode ? [{ debugName: "instance" }] : /* istanbul ignore next */ []));
|
|
2182
2203
|
/** Guards `ready` to one emission per editor instance. */
|
|
2183
2204
|
lastReadyInstance = null;
|
|
2184
2205
|
/**
|
|
@@ -2287,6 +2308,15 @@ class BlokEditorComponent {
|
|
|
2287
2308
|
editor.placeholder.set(placeholder);
|
|
2288
2309
|
}
|
|
2289
2310
|
});
|
|
2311
|
+
effect(() => {
|
|
2312
|
+
const editor = this.instance();
|
|
2313
|
+
const tokens = this.styleTokens$() ?? this.config?.style?.tokens;
|
|
2314
|
+
if (!editor || tokens === undefined || deepEqual(tokens, this.appliedTokens)) {
|
|
2315
|
+
return;
|
|
2316
|
+
}
|
|
2317
|
+
this.appliedTokens = { ...tokens };
|
|
2318
|
+
editor.tokens.set(tokens);
|
|
2319
|
+
});
|
|
2290
2320
|
effect(() => {
|
|
2291
2321
|
const editor = this.instance();
|
|
2292
2322
|
if (editor && this.autofocus$()) {
|
|
@@ -2366,8 +2396,8 @@ class BlokEditorComponent {
|
|
|
2366
2396
|
setDisabledState(isDisabled) {
|
|
2367
2397
|
this.readOnly$.set(isDisabled);
|
|
2368
2398
|
}
|
|
2369
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2370
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
2399
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BlokEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2400
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.0.7", type: BlokEditorComponent, isStandalone: true, selector: "blok-editor", inputs: { onBeforeRender: "onBeforeRender", onBeforePaste: "onBeforePaste", readOnly: "readOnly", theme: "theme", width: "width", placeholder: "placeholder", styleTokens: "styleTokens", autofocus: "autofocus", data: "data", tools: "tools", config: "config", recreateKey: "recreateKey" }, outputs: { ready: "ready", dataChange: "dataChange", save: "save", change: "change", afterRender: "afterRender", themeChange: "themeChange", blocksRendered: "blocksRendered", blockRendered: "blockRendered" }, providers: [
|
|
2371
2401
|
{
|
|
2372
2402
|
provide: NG_VALUE_ACCESSOR,
|
|
2373
2403
|
useExisting: forwardRef(() => BlokEditorComponent),
|
|
@@ -2375,7 +2405,7 @@ class BlokEditorComponent {
|
|
|
2375
2405
|
},
|
|
2376
2406
|
], viewQueries: [{ propertyName: "contentQuery", first: true, predicate: BlokContentDirective, descendants: true }], exportAs: ["blok"], ngImport: i0, template: `<div blokContent [config]="buildConfig()" [recreateKey]="recreateKey"></div>`, isInline: true, dependencies: [{ kind: "directive", type: BlokContentDirective, selector: "[blokContent]", inputs: ["config", "recreateKey"], outputs: ["ready"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
2377
2407
|
}
|
|
2378
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2408
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: BlokEditorComponent, decorators: [{
|
|
2379
2409
|
type: Component,
|
|
2380
2410
|
args: [{
|
|
2381
2411
|
selector: 'blok-editor',
|
|
@@ -2423,6 +2453,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.25", ngImpo
|
|
|
2423
2453
|
type: Input
|
|
2424
2454
|
}], placeholder: [{
|
|
2425
2455
|
type: Input
|
|
2456
|
+
}], styleTokens: [{
|
|
2457
|
+
type: Input
|
|
2426
2458
|
}], autofocus: [{
|
|
2427
2459
|
type: Input
|
|
2428
2460
|
}], data: [{
|
|
@@ -2492,8 +2524,10 @@ function createAngularBlock(spec) {
|
|
|
2492
2524
|
this.pointerDrag = () => api?.blocks?.isPointerDragActive === true;
|
|
2493
2525
|
this.mirror = fillDefaults(spec.propSchema, (options.data ?? {}));
|
|
2494
2526
|
this.lastRendered = this.mirror;
|
|
2495
|
-
this.dataSig = signal(this.mirror,
|
|
2496
|
-
|
|
2527
|
+
this.dataSig = signal(this.mirror, /* @ts-ignore */
|
|
2528
|
+
...(ngDevMode ? [{ debugName: "dataSig" }] : /* istanbul ignore next */ []));
|
|
2529
|
+
this.readOnlySig = signal(options.readOnly, /* @ts-ignore */
|
|
2530
|
+
...(ngDevMode ? [{ debugName: "readOnlySig" }] : /* istanbul ignore next */ []));
|
|
2497
2531
|
this.ctx = {
|
|
2498
2532
|
data: this.dataSig.asReadonly(),
|
|
2499
2533
|
commit: this.commit,
|
|
@@ -2662,13 +2696,15 @@ const BLOCK_CHANGED_EVENT = 'block changed';
|
|
|
2662
2696
|
function injectBlocks(editor) {
|
|
2663
2697
|
// Bumped on every `block changed`; the shared API's read methods touch it (via
|
|
2664
2698
|
// the onRead seam) so template/computed reads stay reactive.
|
|
2665
|
-
const version = signal(0,
|
|
2699
|
+
const version = signal(0, /* @ts-ignore */
|
|
2700
|
+
...(ngDevMode ? [{ debugName: "version" }] : /* istanbul ignore next */ []));
|
|
2666
2701
|
const touch = () => {
|
|
2667
2702
|
version();
|
|
2668
2703
|
};
|
|
2669
2704
|
// The API bound to the CURRENT editor; EMPTY_API while null. A signal so the
|
|
2670
2705
|
// facade's reads track the editor-identity swap.
|
|
2671
|
-
const bound = signal(EMPTY_API,
|
|
2706
|
+
const bound = signal(EMPTY_API, /* @ts-ignore */
|
|
2707
|
+
...(ngDevMode ? [{ debugName: "bound" }] : /* istanbul ignore next */ []));
|
|
2672
2708
|
// One subscription record (no `let` reassignment), re-bound on editor change.
|
|
2673
2709
|
const sub = { editor: null, handler: null };
|
|
2674
2710
|
const unsubscribe = () => {
|