@jackuait/blok 0.23.2 → 0.23.3
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/blok.cjs +1 -1
- package/dist/blok.iife.js +73 -73
- package/dist/blok.mjs +3 -3
- package/dist/blok.umd.js +53 -53
- package/dist/chunks/{blok-Cm1FH7mi.mjs → blok-1H9roBGf.mjs} +2271 -2249
- package/dist/chunks/{blok-9mk1DbT_.cjs → blok-J3Lfa_bK.cjs} +13 -13
- package/dist/chunks/{constants-BTnQPoO-.mjs → constants-BJ79cqMa.mjs} +288 -284
- package/dist/chunks/constants-BZUc1kAY.cjs +606 -0
- package/dist/chunks/{tools-CJIl8RiU.mjs → tools-ByOjWADT.mjs} +420 -418
- package/dist/chunks/{tools-ZtOAeoEZ.cjs → tools-OHDv2C7w.cjs} +2 -2
- package/dist/full.cjs +1 -1
- package/dist/full.mjs +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +54 -33
- package/dist/tools.cjs +1 -1
- package/dist/tools.mjs +2 -2
- package/package.json +1 -1
- package/src/blok.ts +12 -0
- package/src/components/block/tool-renderer.ts +2 -2
- package/src/components/blocks.ts +32 -10
- package/src/components/constants/test-ids.ts +17 -0
- package/src/components/constants.ts +5 -0
- package/src/components/events/BlockRendered.ts +9 -0
- package/src/components/events/BlocksRendered.ts +13 -0
- package/src/components/events/index.ts +8 -0
- package/src/components/inline-tools/inline-tool-link.ts +23 -9
- package/src/components/modules/api/events.ts +10 -10
- package/src/components/modules/api/index.ts +3 -0
- package/src/components/modules/api/tools.ts +3 -0
- package/src/components/modules/blockManager/blockManager.ts +1 -1
- package/src/components/modules/paste/index.ts +10 -1
- package/src/components/modules/renderer.ts +146 -131
- package/src/components/modules/toolbar/plus-button.ts +2 -1
- package/src/components/modules/toolbar/settings-toggler.ts +2 -2
- package/src/components/modules/tools.ts +18 -0
- package/src/components/tools/factory.ts +28 -1
- package/src/react/BlokEditor.tsx +7 -4
- package/src/react/config-keys.ts +2 -0
- package/src/react/deep-equal.ts +48 -0
- package/src/react/types.ts +2 -0
- package/src/react/useBlok.ts +37 -0
- package/types/api/events.d.ts +35 -5
- package/types/api/tools.d.ts +16 -1
- package/types/configs/blok-config.d.ts +37 -0
- package/types/events/editor-events.ts +41 -0
- package/types/index.d.ts +5 -1
- package/types/react.d.ts +2 -0
- package/dist/chunks/constants-CrepXIds.cjs +0 -606
|
@@ -59,6 +59,17 @@ export interface BlokConfig {
|
|
|
59
59
|
*/
|
|
60
60
|
sanitizer?: SanitizerConfig;
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Transform or clean the raw clipboard HTML before Blok processes it.
|
|
64
|
+
* Runs on the unmodified `text/html` payload, before any Blok preprocessing
|
|
65
|
+
* or sanitization, so you no longer need a capture-phase paste interceptor.
|
|
66
|
+
*
|
|
67
|
+
* @param html - the raw `text/html` clipboard string
|
|
68
|
+
* @returns the transformed HTML to feed into the rest of the paste pipeline,
|
|
69
|
+
* or `null` to skip the HTML paste path (paste falls through to plain text).
|
|
70
|
+
*/
|
|
71
|
+
onBeforePaste?: (html: string) => string | null;
|
|
72
|
+
|
|
62
73
|
/**
|
|
63
74
|
* If true, toolbar won't be shown
|
|
64
75
|
*/
|
|
@@ -124,6 +135,32 @@ export interface BlokConfig {
|
|
|
124
135
|
*/
|
|
125
136
|
i18n?: I18nConfig;
|
|
126
137
|
|
|
138
|
+
/**
|
|
139
|
+
* Configures how the Link inline tool builds anchor elements, so consumers can
|
|
140
|
+
* control the created `<a>` instead of post-processing the rendered DOM.
|
|
141
|
+
*/
|
|
142
|
+
link?: {
|
|
143
|
+
/**
|
|
144
|
+
* `target` attribute applied to created anchors.
|
|
145
|
+
* @default '_blank'
|
|
146
|
+
*/
|
|
147
|
+
target?: string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* `rel` attribute applied to created anchors.
|
|
151
|
+
* @default 'nofollow'
|
|
152
|
+
*/
|
|
153
|
+
rel?: string;
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Transforms the href just before it is assigned to the anchor.
|
|
157
|
+
* Runs after URL validation/normalization, on the final value.
|
|
158
|
+
* @param href - the validated, protocol-normalized href
|
|
159
|
+
* @returns the href to set on the anchor
|
|
160
|
+
*/
|
|
161
|
+
transformHref?: (href: string) => string;
|
|
162
|
+
};
|
|
163
|
+
|
|
127
164
|
/**
|
|
128
165
|
* Notion-style link-paste behavior. Pasting a URL always opens a small menu
|
|
129
166
|
* (Plain link / Bookmark / Embed) instead of auto-inserting a block.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public payloads and name map for editor lifecycle events observable via
|
|
3
|
+
* `blok.events.on(...)`.
|
|
4
|
+
*
|
|
5
|
+
* These complement the mutation events delivered through the `onChange`
|
|
6
|
+
* config callback ({@link ./block}). Use together with the exported event-name
|
|
7
|
+
* constants `BlockRendered` (`'block:rendered'`) and `BlocksRendered`
|
|
8
|
+
* (`'blocks:rendered'`).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Payload for the `block:rendered` event.
|
|
13
|
+
*/
|
|
14
|
+
export interface BlockRenderedPayload {
|
|
15
|
+
/**
|
|
16
|
+
* Id of the block that has just been rendered into the DOM.
|
|
17
|
+
* Use `blok.blocks.getById(blockId)` to access it.
|
|
18
|
+
*/
|
|
19
|
+
blockId: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Payload for the `blocks:rendered` event.
|
|
24
|
+
*/
|
|
25
|
+
export interface BlocksRenderedPayload {
|
|
26
|
+
/**
|
|
27
|
+
* Number of top-level blocks rendered in the completed batch.
|
|
28
|
+
*/
|
|
29
|
+
count: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Map of editor lifecycle event name -> payload.
|
|
34
|
+
*
|
|
35
|
+
* Subscribers get fully typed payloads for these well-known events while the
|
|
36
|
+
* `Events` API still accepts arbitrary string event names for custom events.
|
|
37
|
+
*/
|
|
38
|
+
export interface BlokEditorEventMap {
|
|
39
|
+
'block:rendered': BlockRenderedPayload;
|
|
40
|
+
'blocks:rendered': BlocksRenderedPayload;
|
|
41
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ import { BlockAddedMutationType, BlockAddedEvent } from './events/block/BlockAdd
|
|
|
42
42
|
import { BlockChangedMutationType, BlockChangedEvent } from './events/block/BlockChanged';
|
|
43
43
|
import { BlockMovedMutationType, BlockMovedEvent } from './events/block/BlockMoved';
|
|
44
44
|
import { BlockRemovedMutationType, BlockRemovedEvent } from './events/block/BlockRemoved';
|
|
45
|
+
import { BlokEditorEventMap, BlockRenderedPayload, BlocksRenderedPayload } from './events/editor-events';
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Interfaces used for development
|
|
@@ -144,6 +145,9 @@ export {
|
|
|
144
145
|
BlockMovedEvent,
|
|
145
146
|
BlockChangedMutationType,
|
|
146
147
|
BlockChangedEvent,
|
|
148
|
+
BlokEditorEventMap,
|
|
149
|
+
BlockRenderedPayload,
|
|
150
|
+
BlocksRenderedPayload,
|
|
147
151
|
}
|
|
148
152
|
|
|
149
153
|
/**
|
|
@@ -170,7 +174,7 @@ export interface API {
|
|
|
170
174
|
ui: Ui;
|
|
171
175
|
theme: Theme;
|
|
172
176
|
/** Read-only view of selected editor configuration. */
|
|
173
|
-
config: Readonly<Pick<BlokConfig, 'linkPaste'>>;
|
|
177
|
+
config: Readonly<Pick<BlokConfig, 'linkPaste' | 'link'>>;
|
|
174
178
|
rectangleSelection: {
|
|
175
179
|
cancelActiveSelection: () => void;
|
|
176
180
|
isRectActivated: () => boolean;
|
package/types/react.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ import type React from 'react';
|
|
|
12
12
|
* - `theme` — calls `editor.theme.set(value)`
|
|
13
13
|
* - `width` — calls `editor.width.set(value)`
|
|
14
14
|
* - `placeholder` — calls `editor.placeholder.set(value)`
|
|
15
|
+
* - `data` — re-renders via `editor.render(value)` when the content changes
|
|
16
|
+
* (deep-equal–deduped and serialized; seeds the initial content at creation)
|
|
15
17
|
*
|
|
16
18
|
* All other config is consumed once at editor creation.
|
|
17
19
|
*/
|