@clepit/core 0.4.0 → 0.5.0-beta.350

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/CHANGELOG.md CHANGED
@@ -7,13 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.5.0] - 2026-08-31
11
+
12
+ Note: 0.4.0 was released without a changelog entry, so the notes below cover
13
+ everything since 0.3.0, part of which already shipped as 0.4.0.
14
+
10
15
  ### Added
11
16
  - Block identity flows end to end: `createBlockElement` honors an incoming `block.id` as the rendered `data-id` (minting one only when the block has none), `getBlockData` returns the id, and `EditorAPI.blocks.insert` accepts an optional `id` so a caller can insert a block under an identity it already holds. Previously the id existed only in the store and evaporated through every DOM-derived path.
12
17
  - `BLOCK_TOOLS` is exported as a value, so a host can check whether a block type is one this editor understands.
18
+ - `INLINE_TOOLS` is exported as a value, and it now names `status`, the badge tool the inline toolbar already serves; `InlineToolType` widens with it.
13
19
 
14
20
  ### Changed
15
21
  - `BlockTunes` narrowed to the flat map its writer actually produces; the nested contract had no implementation on any path.
16
22
 
23
+ ### Fixed
24
+ - Rendered headings are sized again. The output stylesheet keyed its per-level sizes on a `data-level` attribute no render path ever wrote, so every heading in `renderBlocks`/`draw` output fell back to browser defaults. Sizes now key on the heading tags the renderer actually emits.
25
+
17
26
  ## [0.3.0] — 2026-08-11
18
27
 
19
28
  ### Added
package/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # @clepit/core
2
2
 
3
- A framework-agnostic block-style editor with clean JSON output and a batteries-included renderer. Ships with 12 block types, 8 inline tools, and first-class theming.
4
-
5
- **Homepage:** [clepit.com](https://clepit.com) · **Docs:** [clepit.com/docs](https://clepit.com/docs)
3
+ [Clepit](https://clepit.com) is a block-style editor with clean JSON output and a renderer that works with or without a browser. This package is the framework-agnostic core behind clepit.com: the editor, the renderer, and the theming engine, with no framework dependency.
6
4
 
7
5
  ## Install
8
6
 
@@ -14,65 +12,27 @@ npm install @clepit/core
14
12
 
15
13
  ## Quick start
16
14
 
17
- ```html
18
- <div id="editor"></div>
19
- ```
20
-
21
15
  ```ts
22
16
  import { Editor } from '@clepit/core';
23
17
 
24
- const editor = Editor.create({
25
- containerId: 'editor',
26
- theme: 'auto', // 'auto' | 'light' | 'dark'
27
- });
28
-
18
+ const editor = Editor.create({ containerId: 'editor', theme: 'auto' });
29
19
  const data = editor.data.extract();
30
- console.log(data.blocks);
31
- ```
32
-
33
- ## Features
34
-
35
- - **12 built-in block types** — header, paragraph, list, checklist, quote, code, alert, table, image, video, delimiter, json.
36
- - **8 inline tools** — link, marker, tooltip, bold, italic, underline, strikethrough, inline-code.
37
- - **Framework-agnostic** — no React, Vue, or Svelte dependency. Drop into any app that can mount a DOM node.
38
- - **TypeScript-first** — every public API is typed. No `any`.
39
- - **Theme-aware** — pass `theme: 'auto'` and the editor follows the OS color scheme. Override any token with `themeOverrides`.
40
- - **Clean JSON output** — persist, sync, and render wherever you like.
41
-
42
- ## Theming
43
-
44
- ```ts
45
- Editor.create({
46
- containerId: 'editor',
47
- theme: 'auto',
48
- themeOverrides: {
49
- accentPrimary: '#5b5bff',
50
- bgDefault: '#ffffff',
51
- textPrimary: '#0a0a0a',
52
- },
53
- });
54
20
  ```
55
21
 
56
- Subscribe to runtime token changes:
57
-
58
- ```ts
59
- import { StyleManager } from '@clepit/core';
60
-
61
- const unsub = StyleManager.subscribe(tokens => {
62
- // sync surrounding UI with editor theme
63
- });
64
- ```
22
+ ## Documentation
65
23
 
66
- ## Rendering saved content
24
+ The full documentation lives at [clepit.com/docs](https://clepit.com/docs) and is rendered with this package:
67
25
 
68
- ```ts
69
- import { Renderer } from '@clepit/core';
26
+ - [Getting started](https://clepit.com/docs/getting-started)
27
+ - [Core concepts](https://clepit.com/docs/core-concepts)
28
+ - [Block types](https://clepit.com/docs/blocks)
29
+ - [Inline tools](https://clepit.com/docs/inline-tools)
30
+ - [Configuration](https://clepit.com/docs/configuration)
31
+ - [Theming](https://clepit.com/docs/themes)
32
+ - [Rendering and embedding](https://clepit.com/docs/embedding)
33
+ - [API reference](https://clepit.com/docs/api)
70
34
 
71
- Renderer.render({
72
- containerId: 'view',
73
- data, // block JSON from editor.data.extract()
74
- });
75
- ```
35
+ Using React? [`@clepit/react`](https://www.npmjs.com/package/@clepit/react) wraps this core in server-first components. Building with Dart or Flutter? [`clepit_core`](https://pub.dev/packages/clepit_core) is the native twin.
76
36
 
77
37
  ## License
78
38
 
@@ -0,0 +1,19 @@
1
+ /** Five minutes: an issue's status is a slow thing, and a page left open all
2
+ * day should not cost a tracker a read a minute. */
3
+ export declare const REFRESH_EVERY_MS: number;
4
+ /**
5
+ * Keeps a page's issues current while it is open: one lookup on mount, again
6
+ * when the window regains focus (the reader came back from the tracker), and
7
+ * every five minutes. Chips, cards and tables are redrawn in place; the
8
+ * document is not marked changed, because nothing the author did changed.
9
+ */
10
+ export declare class IssueRefresh {
11
+ private static timers;
12
+ private static focusHandlers;
13
+ static start(containerId: string): void;
14
+ static stop(containerId: string): void;
15
+ /** The URLs a refresh asks about: every chip and every issue card in the editor. */
16
+ static urls(containerId: string): string[];
17
+ static run(containerId: string): Promise<void>;
18
+ }
19
+ //# sourceMappingURL=issues.d.ts.map
@@ -1,4 +1,4 @@
1
- import { Block } from '../../types';
1
+ import { Block, EmbedLabel, IssueChipParts, IssueLabel, IssueSnapshot } from '../../types';
2
2
  /**
3
3
  * The construction surface a block's render path is allowed to use.
4
4
  *
@@ -54,6 +54,18 @@ export type DrawContext = {
54
54
  mapsEmbedKey?: string;
55
55
  /** How a doc card turns a page id into a link, which only the host knows. */
56
56
  docHref?: (pageId: string) => string;
57
+ /** The workspace's switched-off embed tools, by wire key: a card where the
58
+ * workspace said so, on a public page as much as in the editor. */
59
+ disabledEmbedProviders?: readonly string[];
60
+ /** Translated embed words; English fallbacks otherwise. */
61
+ embedLabels?: Partial<Record<EmbedLabel, string>>;
62
+ /** The freshest issue snapshots the host resolved, by URL: a chip, a card or
63
+ * a Linked issues row draws these over what the document stored. */
64
+ issues?: Record<string, IssueSnapshot>;
65
+ /** The reader's two chip switches; both on when absent. */
66
+ issueChip?: IssueChipParts;
67
+ /** Translated issue words; English fallbacks otherwise. */
68
+ issueLabels?: Partial<Record<IssueLabel, string>>;
57
69
  };
58
70
  export type Backing = {
59
71
  create(tag: string): ClepitElement;
@@ -8,6 +8,9 @@ export declare class BlockManager {
8
8
  private static createBlockElement;
9
9
  static insertBlock(block: Block, containerId: string, index: number): HTMLElement | null;
10
10
  static removeBlock(containerId: string, index: number): null | undefined;
11
+ /** Insert first, then remove: `removeBlock` keeps the last block of a document,
12
+ * so replacing the only block by removing it first left the old block in
13
+ * place beside the new one. */
11
14
  static replaceBlock(containerId: string, index: number, block: Block<BlockToolType>): void;
12
15
  static moveBlock(containerId: string, fromIndex: number, toIndex: number): void;
13
16
  static getBlock(blockId: string): HTMLElement | null;
@@ -8,6 +8,11 @@ export declare class EventManager {
8
8
  } | null;
9
9
  private static handleClick;
10
10
  private static handleSelectionChange;
11
+ /**
12
+ * A paste is intercepted only when it is one this editor turns into a block:
13
+ * an image URL, a video URL, or a link a provider renders. Plain text and
14
+ * links no provider knows reach the browser's own paste untouched.
15
+ */
11
16
  static handlePaste(event: ClipboardEvent): void;
12
17
  }
13
18
  //# sourceMappingURL=event.d.ts.map
package/dist/index.d.ts CHANGED
@@ -6,9 +6,14 @@ export { activateBlocks } from './core/renderer/activate';
6
6
  export { drawBlock } from './core/renderer/draw';
7
7
  export { type PublicPage, pageStylesheet, renderBlocks, renderPage } from './core/renderer/page';
8
8
  export { type ThemeTokens, tokensToLightDarkBlock } from './core/theme';
9
+ export { EMBED_ENGLISH, EMBED_TOOL_NAMES, embedLabel } from './tools/block/embed/output';
10
+ export { EMBED_WIRE_KEYS, isEmbedProviderDisabled, resolveEmbed } from './tools/block/embed/providers';
9
11
  export type { OpenApiGroup, OpenApiModel, OpenApiOperation, OpenApiServer } from './tools/block/openapi/spec';
10
12
  export { parseOpenApi } from './tools/block/openapi/spec';
11
- export type { ALERT_VARIANTS, AlertData, AlertVariant, AudioData, Block, BlockClassNames, BlockMargins, BlockStyles, BlockTune, CodeData, CodeVariant, CSSProperties, CSSValue, DelimiterData, DelimiterVariant, EditorAPI, EditorClassNames, EditorConfig, EditorData, EditorStyles, GlanceData, GlanceRow, HeaderData, HeaderLevel, ImageData, InlineToolType as InlineTool, InputClassNames, InputConfig, InputStyles, ListData, ListType, OpenApiData, OpenApiFilter, OutputComponent, OutputConfig, ParagraphData, QuoteData, RendererConfig, TableData, ToolType as BlockType, UploadFunction, VideoData, } from './types';
12
- export { BLOCK_TOOLS } from './types';
13
+ export { chipsInHtml, IssueChip, readChipMarkup, refreshChipsInHtml } from './tools/inline/issue';
14
+ export { ISSUE_ENGLISH, ISSUE_TOOL_NAMES, issueLabel, issueToolName } from './tools/inline/issue/labels';
15
+ export { classifyIssueUrl } from './tools/inline/issue/providers';
16
+ export type { ALERT_VARIANTS, AlertData, AlertVariant, AudioData, Block, BlockClassNames, BlockMargins, BlockStyles, BlockTune, CodeData, CodeVariant, CSSProperties, CSSValue, DelimiterData, DelimiterVariant, EditorAPI, EditorClassNames, EditorConfig, EditorData, EditorStyles, EmbedAction, EmbedData, EmbedFile, EmbedGist, EmbedGistFile, EmbedLabel, EmbedProvider, EmbedReason, EmbedResolution, GlanceData, GlanceRow, HeaderData, HeaderLevel, ImageData, InlineToolType as InlineTool, InputClassNames, InputConfig, InputStyles, IssueAction, IssueCards, IssueCategory, IssueChipParts, IssueLabel, IssueReason, IssueSnapshot, IssuesData, IssueTarget, IssueTool, ListData, ListType, OpenApiData, OpenApiFilter, OutputComponent, OutputConfig, ParagraphData, PasteEmbeds, QuoteData, RendererConfig, TableData, ToolType as BlockType, UploadFunction, VideoData, } from './types';
17
+ export { BLOCK_TOOLS, EMBED_LABELS, INLINE_TOOLS, ISSUE_LABELS, ISSUE_TOOLS } from './types';
13
18
  export { sanitizeHtmlWithoutDom } from './utils/sanitize-html-nodom';
14
19
  //# sourceMappingURL=index.d.ts.map