Files
AFFiNE-Mirror/blocksuite/affine/block-surface/src/index.ts
T
Saul-Mirone ce87dcf58e feat(editor): schema extension (#10447)
1. **Major Architectural Change: Schema Management**
   - Moved from `workspace.schema` to `store.schema` throughout the codebase
   - Removed schema property from Workspace and Doc interfaces
   - Added `BlockSchemaExtension` pattern across multiple block types

2. **Block Schema Extensions Added**
   - Added new `BlockSchemaExtension` to numerous block types including:
     - DataView, Surface, Attachment, Bookmark, Code
     - Database, Divider, EdgelessText, Embed blocks (Figma, Github, HTML, etc.)
     - Frame, Image, Latex, List, Note, Paragraph
     - Root, Surface Reference, Table blocks

3. **Import/Export System Updates**
   - Updated import functions to accept `schema` parameter:
     - `importHTMLToDoc`
     - `importHTMLZip`
     - `importMarkdownToDoc`
     - `importMarkdownZip`
     - `importNotionZip`
   - Modified export functions to use new schema pattern

4. **Test Infrastructure Updates**
   - Updated test files to use new schema extensions
   - Modified test document creation to include schema extensions
   - Removed direct schema registration in favor of extensions

5. **Service Layer Changes**
   - Updated various services to use `getAFFiNEWorkspaceSchema()`
   - Modified transformer initialization to use document schema
   - Updated collection initialization patterns

6. **Version Management**
   - Removed version-related properties and methods from:
     - `WorkspaceMetaImpl`
     - `TestMeta`
     - `DocImpl`
   - Removed `blockVersions` and `workspaceVersion/pageVersion`

7. **Store and Extension Updates**
   - Added new store extensions and adapters
   - Updated store initialization patterns
   - Added new schema-related functionality in store extension

This PR represents a significant architectural shift in how schemas are managed, moving from a workspace-centric to a store-centric approach, while introducing a more extensible block schema system through `BlockSchemaExtension`. The changes touch multiple layers of the application including core functionality, services, testing infrastructure, and import/export capabilities.
2025-02-26 11:31:29 +00:00

127 lines
3.3 KiB
TypeScript

// oxlint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./effects.ts" />
export { type IModelCoord, ZOOM_MAX, ZOOM_MIN, ZOOM_STEP } from './consts.js';
export { GRID_GAP_MAX, GRID_GAP_MIN } from './consts.js';
export {
SurfaceElementModel,
SurfaceGroupLikeModel,
} from './element-model/base.js';
export { CanvasElementType } from './element-model/index.js';
import {
isConnectorAndBindingsAllSelected,
isConnectorWithLabel,
} from './managers/connector-manager.js';
export {
calculateNearestLocation,
ConnectionOverlay,
ConnectorEndpointLocations,
ConnectorEndpointLocationsOnTriangle,
ConnectorPathGenerator,
PathGenerator,
} from './managers/connector-manager.js';
export { CanvasRenderer } from './renderer/canvas-renderer.js';
export * from './renderer/elements/group/consts.js';
export type { ElementRenderer } from './renderer/elements/index.js';
export {
elementRenderers,
normalizeShapeBound,
} from './renderer/elements/index.js';
export { fitContent } from './renderer/elements/shape/utils.js';
export * from './renderer/elements/type.js';
export { Overlay, OverlayIdentifier } from './renderer/overlay.js';
export { MindMapView } from './view/mindmap.js';
import {
getCursorByCoord,
getLineHeight,
isFontStyleSupported,
isFontWeightSupported,
normalizeTextBound,
splitIntoLines,
} from './renderer/elements/text/utils.js';
import {
getFontFaces,
getFontFacesByFontFamily,
isSameFontFamily,
wrapFontFamily,
} from './utils/font.js';
export {
EdgelessSurfaceBlockAdapterExtensions,
SurfaceBlockAdapterExtensions,
} from './adapters/index.js';
export type { SurfaceContext } from './surface-block.js';
export { SurfaceBlockComponent } from './surface-block.js';
export {
SurfaceBlockModel,
SurfaceBlockSchema,
SurfaceBlockSchemaExtension,
} from './surface-model.js';
export type { SurfaceBlockService } from './surface-service.js';
export {
EdgelessSurfaceBlockSpec,
PageSurfaceBlockSpec,
} from './surface-spec.js';
export { SurfaceBlockTransformer } from './surface-transformer.js';
export { AStarRunner } from './utils/a-star.js';
export {
NODE_FIRST_LEVEL_HORIZONTAL_SPACING,
NODE_HORIZONTAL_SPACING,
NODE_VERTICAL_SPACING,
} from './utils/mindmap/layout.js';
export { RoughCanvas } from './utils/rough/canvas.js';
import {
addTree,
containsNode,
createFromTree,
detachMindmap,
findTargetNode,
hideNodeConnector,
moveNode,
tryMoveNode,
} from './utils/mindmap/utils';
export * from './extensions';
export {
addNote,
addNoteAtPoint,
generateElementId,
getBgGridGap,
getLastPropsKey,
getSurfaceBlock,
normalizeWheelDeltaY,
} from './utils';
export * from './utils/mindmap/style-svg';
export type { Options } from './utils/rough/core';
export { sortIndex } from './utils/sort';
export { updateXYWH } from './utils/update-xywh.js';
export const ConnectorUtils = {
isConnectorAndBindingsAllSelected,
isConnectorWithLabel,
};
export const TextUtils = {
splitIntoLines,
normalizeTextBound,
getLineHeight,
getCursorByCoord,
isFontWeightSupported,
isFontStyleSupported,
wrapFontFamily,
getFontFaces,
getFontFacesByFontFamily,
isSameFontFamily,
};
export const MindmapUtils = {
addTree,
createFromTree,
detachMindmap,
moveNode,
findTargetNode,
tryMoveNode,
hideNodeConnector,
containsNode,
};
export * from './commands';