@jackuait/blok 0.21.1 → 0.22.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.
@@ -20,7 +20,7 @@
20
20
  * correctly-nested block tree.
21
21
  */
22
22
 
23
- import { colorVarName } from '../../shared/color-presets';
23
+ import { COLOR_PRESETS, colorVarName } from '../../shared/color-presets';
24
24
  import { DEFAULT_EMOJI } from '../../../tools/callout/constants';
25
25
  import { DEFAULT_LANGUAGE, LANGUAGES } from '../../../tools/code/constants';
26
26
  import { matchEmbedService } from '../../../tools/link/registry';
@@ -151,6 +151,17 @@ export function parseNotionBlocksV3(json: string): NotionParsedBlock[] | null {
151
151
 
152
152
  result.push(block);
153
153
 
154
+ // Blok's callout keeps its body in CHILD blocks, so the callout's own inline
155
+ // title line becomes a child paragraph (emitted before its `content`
156
+ // children), matching what a native callout copy carries.
157
+ if (value.type === 'callout') {
158
+ const calloutTitle = richText(value.properties?.title, byId);
159
+
160
+ if (calloutTitle.length > 0) {
161
+ result.push({ id: `${id}:callout-body`, tool: 'paragraph', data: { text: calloutTitle }, parentId: id });
162
+ }
163
+ }
164
+
154
165
  children.forEach((childId) => walk(childId, id));
155
166
  };
156
167
 
@@ -328,7 +339,10 @@ function mapValue(value: NotionValue, byId: Map<string, NotionValue>): Mapped |
328
339
  const emoji = typeof format.page_icon === 'string' && format.page_icon.length > 0 ? format.page_icon : DEFAULT_EMOJI;
329
340
  const { textColor, backgroundColor } = parseBlockColor(format.block_color);
330
341
 
331
- return { tool: 'callout', data: { emoji, text, textColor, backgroundColor } };
342
+ // No inline `text`: Blok's callout stores its body in CHILD blocks, so the
343
+ // callout's title line is emitted as a child paragraph by `walk` (and a
344
+ // stray `data.text` would be silently discarded by the callout tool).
345
+ return { tool: 'callout', data: { emoji, textColor, backgroundColor } };
332
346
  }
333
347
  case 'page':
334
348
  // A `page` block inside content is a SUB-PAGE reference: its body lives on
@@ -862,11 +876,21 @@ function buildColourStyle(colourFlags: unknown[]): string {
862
876
  return parts.join('; ');
863
877
  }
864
878
 
865
- /** Map a Notion `block_color` to callout `{ textColor, backgroundColor }` names. */
879
+ /** The set of colour preset names Blok recognises (its callout/marker palette). */
880
+ const BLOK_COLOR_NAMES = new Set(COLOR_PRESETS.map((preset) => preset.name));
881
+
882
+ /**
883
+ * Map a Notion `block_color` to callout `{ textColor, backgroundColor }` names.
884
+ * Names outside Blok's preset palette collapse to `null`: the callout tool
885
+ * builds `var(--blok-color-<name>-…)` from the name verbatim, so an unrecognised
886
+ * name yields an undefined custom property that silently drops the colour AND
887
+ * the callout's border. Notion's palette already aligns with Blok's, so this is
888
+ * a safety clamp rather than a remap.
889
+ */
866
890
  function parseBlockColor(token: unknown): { textColor: string | null; backgroundColor: string | null } {
867
891
  const colour = parseNotionColour(token);
868
892
 
869
- if (colour === null) {
893
+ if (colour === null || !BLOK_COLOR_NAMES.has(colour.name)) {
870
894
  return { textColor: null, backgroundColor: null };
871
895
  }
872
896