@almadar/ui 4.39.1 → 4.40.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.
|
@@ -26895,16 +26895,6 @@ function nextBlockId(prefix = "blk") {
|
|
|
26895
26895
|
const random = Math.random().toString(36).slice(2, 8);
|
|
26896
26896
|
return `${prefix}-${Date.now().toString(36)}-${_idSeq}-${random}`;
|
|
26897
26897
|
}
|
|
26898
|
-
function normalizeBlocks(raw) {
|
|
26899
|
-
if (!raw || raw.length === 0) return [createBlock("paragraph")];
|
|
26900
|
-
return raw.map((row) => {
|
|
26901
|
-
const r = row;
|
|
26902
|
-
const rawType = r.type;
|
|
26903
|
-
const type = typeof rawType === "string" && BLOCK_TYPES.has(rawType) ? rawType : "paragraph";
|
|
26904
|
-
const id = typeof r.id === "string" && r.id ? r.id : nextBlockId(type);
|
|
26905
|
-
return { ...r, id, type };
|
|
26906
|
-
});
|
|
26907
|
-
}
|
|
26908
26898
|
function createBlock(type) {
|
|
26909
26899
|
switch (type) {
|
|
26910
26900
|
case "bullet-list":
|
|
@@ -27455,7 +27445,7 @@ function BlockRow({
|
|
|
27455
27445
|
}
|
|
27456
27446
|
);
|
|
27457
27447
|
}
|
|
27458
|
-
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq
|
|
27448
|
+
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq; exports.RichBlockEditor = void 0;
|
|
27459
27449
|
var init_RichBlockEditor = __esm({
|
|
27460
27450
|
"components/molecules/RichBlockEditor.tsx"() {
|
|
27461
27451
|
"use client";
|
|
@@ -27502,18 +27492,6 @@ var init_RichBlockEditor = __esm({
|
|
|
27502
27492
|
"code"
|
|
27503
27493
|
];
|
|
27504
27494
|
_idSeq = 0;
|
|
27505
|
-
BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
27506
|
-
"paragraph",
|
|
27507
|
-
"heading-1",
|
|
27508
|
-
"heading-2",
|
|
27509
|
-
"heading-3",
|
|
27510
|
-
"bullet-list",
|
|
27511
|
-
"numbered-list",
|
|
27512
|
-
"quote",
|
|
27513
|
-
"code",
|
|
27514
|
-
"divider",
|
|
27515
|
-
"image"
|
|
27516
|
-
]);
|
|
27517
27495
|
exports.RichBlockEditor = ({
|
|
27518
27496
|
initialBlocks,
|
|
27519
27497
|
onChange,
|
|
@@ -27524,7 +27502,7 @@ var init_RichBlockEditor = __esm({
|
|
|
27524
27502
|
className
|
|
27525
27503
|
}) => {
|
|
27526
27504
|
const [blocks, setBlocks] = React121.useState(
|
|
27527
|
-
() =>
|
|
27505
|
+
() => initialBlocks ?? [createBlock("paragraph")]
|
|
27528
27506
|
);
|
|
27529
27507
|
const onChangeRef = React121.useRef(onChange);
|
|
27530
27508
|
React121.useEffect(() => {
|
package/dist/components/index.js
CHANGED
|
@@ -26850,16 +26850,6 @@ function nextBlockId(prefix = "blk") {
|
|
|
26850
26850
|
const random = Math.random().toString(36).slice(2, 8);
|
|
26851
26851
|
return `${prefix}-${Date.now().toString(36)}-${_idSeq}-${random}`;
|
|
26852
26852
|
}
|
|
26853
|
-
function normalizeBlocks(raw) {
|
|
26854
|
-
if (!raw || raw.length === 0) return [createBlock("paragraph")];
|
|
26855
|
-
return raw.map((row) => {
|
|
26856
|
-
const r = row;
|
|
26857
|
-
const rawType = r.type;
|
|
26858
|
-
const type = typeof rawType === "string" && BLOCK_TYPES.has(rawType) ? rawType : "paragraph";
|
|
26859
|
-
const id = typeof r.id === "string" && r.id ? r.id : nextBlockId(type);
|
|
26860
|
-
return { ...r, id, type };
|
|
26861
|
-
});
|
|
26862
|
-
}
|
|
26863
26853
|
function createBlock(type) {
|
|
26864
26854
|
switch (type) {
|
|
26865
26855
|
case "bullet-list":
|
|
@@ -27410,7 +27400,7 @@ function BlockRow({
|
|
|
27410
27400
|
}
|
|
27411
27401
|
);
|
|
27412
27402
|
}
|
|
27413
|
-
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq,
|
|
27403
|
+
var TOOLBAR_ENTRIES, BLOCK_TYPE_LABEL, CHANGEABLE_TYPES, _idSeq, RichBlockEditor;
|
|
27414
27404
|
var init_RichBlockEditor = __esm({
|
|
27415
27405
|
"components/molecules/RichBlockEditor.tsx"() {
|
|
27416
27406
|
"use client";
|
|
@@ -27457,18 +27447,6 @@ var init_RichBlockEditor = __esm({
|
|
|
27457
27447
|
"code"
|
|
27458
27448
|
];
|
|
27459
27449
|
_idSeq = 0;
|
|
27460
|
-
BLOCK_TYPES = /* @__PURE__ */ new Set([
|
|
27461
|
-
"paragraph",
|
|
27462
|
-
"heading-1",
|
|
27463
|
-
"heading-2",
|
|
27464
|
-
"heading-3",
|
|
27465
|
-
"bullet-list",
|
|
27466
|
-
"numbered-list",
|
|
27467
|
-
"quote",
|
|
27468
|
-
"code",
|
|
27469
|
-
"divider",
|
|
27470
|
-
"image"
|
|
27471
|
-
]);
|
|
27472
27450
|
RichBlockEditor = ({
|
|
27473
27451
|
initialBlocks,
|
|
27474
27452
|
onChange,
|
|
@@ -27479,7 +27457,7 @@ var init_RichBlockEditor = __esm({
|
|
|
27479
27457
|
className
|
|
27480
27458
|
}) => {
|
|
27481
27459
|
const [blocks, setBlocks] = useState(
|
|
27482
|
-
() =>
|
|
27460
|
+
() => initialBlocks ?? [createBlock("paragraph")]
|
|
27483
27461
|
);
|
|
27484
27462
|
const onChangeRef = useRef(onChange);
|
|
27485
27463
|
useEffect(() => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* scope for the Phase 10 scaffold.
|
|
9
9
|
*/
|
|
10
10
|
import React from "react";
|
|
11
|
-
import type {
|
|
11
|
+
import type { EventEmit, EventPayloadValue } from '@almadar/core';
|
|
12
12
|
export type BlockType = "paragraph" | "heading-1" | "heading-2" | "heading-3" | "bullet-list" | "numbered-list" | "quote" | "code" | "divider" | "image";
|
|
13
13
|
export interface RichBlock {
|
|
14
14
|
id: string;
|
|
@@ -19,14 +19,7 @@ export interface RichBlock {
|
|
|
19
19
|
[key: string]: EventPayloadValue;
|
|
20
20
|
}
|
|
21
21
|
export interface RichBlockEditorProps {
|
|
22
|
-
|
|
23
|
-
* Initial block payload. Accepts strongly-typed RichBlock[] from native
|
|
24
|
-
* callers and the wider EntityRow[] shape that orb-bound traits emit
|
|
25
|
-
* (orb `[object]` lowers to `Record<string, FieldValue | undefined>[]`,
|
|
26
|
-
* which is structurally EntityRow[]). Items missing id/type are normalized
|
|
27
|
-
* into paragraph blocks at mount.
|
|
28
|
-
*/
|
|
29
|
-
initialBlocks?: readonly RichBlock[] | readonly EntityRow[];
|
|
22
|
+
initialBlocks?: RichBlock[];
|
|
30
23
|
onChange?: (blocks: RichBlock[]) => void;
|
|
31
24
|
changeEvent?: EventEmit<{
|
|
32
25
|
blocks: RichBlock[];
|