@jackuait/blok 0.22.0 → 0.23.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/README.md +12 -1
- package/dist/blok.cjs +1 -1
- package/dist/blok.iife.js +5 -5
- package/dist/blok.mjs +2 -2
- package/dist/blok.umd.js +5 -5
- package/dist/chunks/{blok-S6c68iVJ.mjs → blok-BPeM6wKv.mjs} +33 -1
- package/dist/chunks/{blok-Blnd71Ww.cjs → blok-Ci1zCOUg.cjs} +4 -4
- package/dist/chunks/{constants-BIqDMhRj.cjs → constants-Bkncy0y5.cjs} +1 -1
- package/dist/chunks/{constants-BvxJIgSQ.mjs → constants-DR3sya6U.mjs} +1 -1
- package/dist/chunks/{tools-B89FUeNz.mjs → tools-B72rczVw.mjs} +4 -1
- package/dist/chunks/{tools-DTjC0C5o.cjs → tools-DlOZpcVU.cjs} +1 -1
- package/dist/full.cjs +1 -1
- package/dist/full.mjs +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +69 -42
- package/dist/tools.cjs +1 -1
- package/dist/tools.mjs +2 -2
- package/package.json +1 -1
- package/src/blok.ts +43 -0
- package/src/components/block/index.ts +13 -0
- package/src/components/modules/blockManager/blockManager.ts +19 -0
- package/src/components/tools/base.ts +9 -0
- package/src/react/BlokEditor.tsx +88 -0
- package/src/react/config-keys.ts +51 -0
- package/src/react/index.ts +2 -0
- package/src/react/types.ts +14 -3
- package/src/react/useBlok.ts +27 -0
- package/src/tools/paragraph/index.ts +20 -0
- package/types/api/index.d.ts +1 -0
- package/types/api/placeholder.d.ts +18 -0
- package/types/index.d.ts +5 -0
- package/types/react.d.ts +40 -3
package/types/react.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import type { BlokConfig } from './index';
|
|
2
|
-
import type { Blok } from './index';
|
|
2
|
+
import type { Blok, EditorWidth } from './index';
|
|
3
3
|
import type React from 'react';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Configuration for the useBlok hook.
|
|
7
|
-
* Accepts all BlokConfig properties except `holder`,
|
|
7
|
+
* Accepts all BlokConfig properties except `holder`, plus a React-only `width` prop.
|
|
8
8
|
*
|
|
9
9
|
* Reactive props (sync after mount without recreation):
|
|
10
10
|
* - `readOnly` — calls `editor.readOnly.set(value)`
|
|
11
11
|
* - `autofocus` — calls `editor.focus()` when changed to true
|
|
12
|
+
* - `theme` — calls `editor.theme.set(value)`
|
|
13
|
+
* - `width` — calls `editor.width.set(value)`
|
|
14
|
+
* - `placeholder` — calls `editor.placeholder.set(value)`
|
|
12
15
|
*
|
|
13
16
|
* All other config is consumed once at editor creation.
|
|
14
17
|
*/
|
|
15
|
-
export interface UseBlokConfig extends Omit<BlokConfig, 'holder'> {
|
|
18
|
+
export interface UseBlokConfig extends Omit<BlokConfig, 'holder'> {
|
|
19
|
+
/** Editor content width mode. Synced reactively after mount. */
|
|
20
|
+
width?: EditorWidth;
|
|
21
|
+
}
|
|
16
22
|
|
|
17
23
|
/**
|
|
18
24
|
* Props for the BlokContent component.
|
|
@@ -56,3 +62,34 @@ export function useBlok(
|
|
|
56
62
|
* ```
|
|
57
63
|
*/
|
|
58
64
|
export declare const BlokContent: React.ForwardRefExoticComponent<BlokContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Props for the BlokEditor component — all useBlok config (except `onReady`,
|
|
68
|
+
* re-typed to receive the ready instance) plus every standard HTML div attribute
|
|
69
|
+
* (forwarded to the container, like `BlokContent`) and an optional `deps` list
|
|
70
|
+
* that forces recreation when changed. `style`/`onChange` keep editor-config meaning.
|
|
71
|
+
*/
|
|
72
|
+
export interface BlokEditorProps
|
|
73
|
+
extends Omit<UseBlokConfig, 'onReady'>,
|
|
74
|
+
Omit<React.HTMLAttributes<HTMLDivElement>, 'style' | 'onChange'> {
|
|
75
|
+
/** When any value changes, the editor is destroyed and recreated. */
|
|
76
|
+
deps?: React.DependencyList;
|
|
77
|
+
/** Test id forwarded to the editor container element (via data-testid). */
|
|
78
|
+
'data-testid'?: string;
|
|
79
|
+
/** Called once the editor is ready, with the live Blok instance (ref is also committed). */
|
|
80
|
+
onReady?: (editor: Blok) => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The recommended all-in-one React component. Wires useBlok + BlokContent and
|
|
85
|
+
* forwards a ref to the live Blok instance (null before the editor is ready).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* const ref = useRef<Blok | null>(null);
|
|
90
|
+
* <BlokEditor ref={ref} tools={tools} data={data} theme="dark" />;
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare const BlokEditor: React.ForwardRefExoticComponent<
|
|
94
|
+
BlokEditorProps & React.RefAttributes<Blok | null>
|
|
95
|
+
>;
|