@bloklabs/vue 1.16.1 → 2.0.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/README.md +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +146 -104
- package/package.json +3 -4
- package/types/index.d.ts +57 -3
- package/src/BlockPortalHost.ts +0 -46
- package/src/BlokContent.ts +0 -103
- package/src/BlokEditor.ts +0 -326
- package/src/block-portal-registry.ts +0 -93
- package/src/blocks-snapshot.ts +0 -17
- package/src/blok-instance.ts +0 -40
- package/src/config-keys.ts +0 -82
- package/src/content-baseline-map.ts +0 -38
- package/src/createVueBlock.ts +0 -740
- package/src/holder-map.ts +0 -19
- package/src/index.ts +0 -30
- package/src/provide-blok.ts +0 -65
- package/src/registry-map.ts +0 -21
- package/src/types.ts +0 -36
- package/src/useBlocks.ts +0 -182
- package/src/useBlok.ts +0 -686
- package/src/useBlokReady.ts +0 -70
package/src/useBlokReady.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// packages/vue/src/useBlokReady.ts
|
|
2
|
-
import {
|
|
3
|
-
onMounted,
|
|
4
|
-
onScopeDispose,
|
|
5
|
-
shallowRef,
|
|
6
|
-
toValue,
|
|
7
|
-
type MaybeRefOrGetter,
|
|
8
|
-
type ShallowRef,
|
|
9
|
-
} from 'vue';
|
|
10
|
-
|
|
11
|
-
import { Blok as BlokRuntime } from '@bloklabs/core';
|
|
12
|
-
|
|
13
|
-
/** Options accepted by {@link useBlokReady}. */
|
|
14
|
-
export interface UseBlokReadyOptions {
|
|
15
|
-
/**
|
|
16
|
-
* Restrict the wait to editors mounted inside this element. Accepts the
|
|
17
|
-
* template ref you already hold on the container (or a getter); it is
|
|
18
|
-
* re-read on every readiness change, so a ref that fills in on mount is
|
|
19
|
-
* picked up.
|
|
20
|
-
*
|
|
21
|
-
* Omit it to observe every editor on the page. Passing it while it still
|
|
22
|
-
* resolves to null reports NOT ready — an unresolved scope must never fall
|
|
23
|
-
* back to the page-global one.
|
|
24
|
-
*/
|
|
25
|
-
within?: MaybeRefOrGetter<Element | null | undefined>;
|
|
26
|
-
/**
|
|
27
|
-
* `'ready'` (default) settles when each editor has finished booting.
|
|
28
|
-
* `'rendered'` also waits for its content to be in the DOM and re-arms on
|
|
29
|
-
* every post-boot re-render.
|
|
30
|
-
*/
|
|
31
|
-
settleOn?: 'ready' | 'rendered';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Vue composable exposing the live readiness of the Blok editors in a DOM
|
|
36
|
-
* scope as a boolean ref.
|
|
37
|
-
*
|
|
38
|
-
* The readiness logic itself is framework-agnostic and lives in core
|
|
39
|
-
* (`Blok.readyState` / `Blok.subscribeReady`) — the SAME implementation behind
|
|
40
|
-
* React's `useBlokReady` and Angular's `injectBlokReady`, so the three adapters
|
|
41
|
-
* cannot drift. This composable supplies only Vue's reactivity wrapper: a
|
|
42
|
-
* `shallowRef` re-read on every registry change, with the subscription
|
|
43
|
-
* disposed by the surrounding effect scope.
|
|
44
|
-
*
|
|
45
|
-
* The ref starts `false` and takes its first real reading on mount, once the
|
|
46
|
-
* template ref has filled in. Over-waiting is safe; under-waiting is a bug.
|
|
47
|
-
* @param options - scope and readiness depth
|
|
48
|
-
*/
|
|
49
|
-
export function useBlokReady(options: UseBlokReadyOptions = {}): Readonly<ShallowRef<boolean>> {
|
|
50
|
-
const { within, settleOn } = options;
|
|
51
|
-
const ready = shallowRef(false);
|
|
52
|
-
|
|
53
|
-
const read = (): void => {
|
|
54
|
-
const scope = within === undefined ? null : (toValue(within) ?? null);
|
|
55
|
-
|
|
56
|
-
// A scope that was asked for but has not resolved yet is NOT the global
|
|
57
|
-
// scope — reporting ready here would gate on the wrong set of editors.
|
|
58
|
-
ready.value = within !== undefined && scope === null
|
|
59
|
-
? false
|
|
60
|
-
: BlokRuntime.readyState({
|
|
61
|
-
within: scope,
|
|
62
|
-
settleOn,
|
|
63
|
-
}).ready;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
onScopeDispose(BlokRuntime.subscribeReady(read));
|
|
67
|
-
onMounted(read);
|
|
68
|
-
|
|
69
|
-
return ready;
|
|
70
|
-
}
|