Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/TEXT_SELECTION_REGULAR_TEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ Use this only for custom rendering paths where automatic `text()` extraction is

## Current scope

- Automatic adapter support is for regular `text()` blocks with `id`.
- Automatic adapter support covers regular `text()` blocks with `id`.
- It also covers custom blocks that expose selection geometry through the block registry, including `texta()` once `registerTextaBlockType()` has been called.
- Cross-block selections are not supported.
- `texta()` requires custom handling if you need selection behavior equivalent to `text()`.
12 changes: 12 additions & 0 deletions packages/core/src/core/block-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,23 @@ export interface CustomBlockDebugApi {
context: RenderContext;
}

export interface CustomBlockSelectionApi {
context?: RenderContext;
}

export interface CustomBlockSelectionGeometry {
blockId: string;
layoutSignature: string;
rgrclCharacterBounds?: Rc[];
resolveCharacterBounds?: () => Rc[];
}

export interface CustomBlockHandlers {
render?: (block: CustomBlockDescriptor, api: CustomBlockRenderApi) => void;
hitTestShape?: (block: CustomBlockDescriptor, xl: number, yl: number, api: CustomBlockHitTestApi) => boolean;
rcl?: (block: CustomBlockDescriptor) => Rc | null;
getDebugOutlineBounds?: (block: CustomBlockDescriptor, api: CustomBlockDebugApi) => Rc | null;
getSelectionGeometry?: (block: CustomBlockDescriptor, api: CustomBlockSelectionApi) => CustomBlockSelectionGeometry | null;
}

const mpCustomBlockHandlers = new Map<string, CustomBlockHandlers>();
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ export {
} from './core/block-registry.ts';
export type {
BlockLayoutCache,
CustomBlockDescriptor,
CustomBlockHandlers,
CustomBlockRenderApi,
CustomBlockHitTestApi,
CustomBlockDebugApi
CustomBlockDebugApi,
CustomBlockSelectionApi,
CustomBlockSelectionGeometry
} from './core/block-registry.ts';

// Block factory functions
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/component-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h2>Raw Blocks</h2>

<nav class="page-nav">
<a href="calendar.html">← Calendar</a>
<a href="text-selection-debug.html">Text Selection Debug →</a>
<a href="text-selection-debug.html">Text Selection Debug (Regular) →</a>
</nav>
</body>
</html>
3 changes: 2 additions & 1 deletion packages/demo/performance.html
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,11 @@ <h1>Vitrine Performance Test</h1>
}, blocks)
,

// Text workload to exercise text measurement caches
// Keep the text workload invisible so the cache exercise does not clutter the scene.
group({
x: 470 + Math.cos(config.time * 0.35) * 120,
y: 320 + Math.sin(config.time * 0.45) * 70,
opacity: 0,
}, textBlocks)
]);

Expand Down
Loading
Loading