refactor(editor): store should not rely on inline (#11017)

This commit is contained in:
Saul-Mirone
2025-03-20 01:33:29 +00:00
parent ee337a16af
commit 258c70cf07
82 changed files with 140 additions and 141 deletions

View File

@@ -5,7 +5,7 @@ import {
CODE_BLOCK_WRAP_KEY,
HastUtils,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import { bundledLanguagesInfo, codeToHast } from 'shiki';

View File

@@ -5,7 +5,7 @@ import {
CODE_BLOCK_WRAP_KEY,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import type { Code } from 'mdast';

View File

@@ -3,7 +3,7 @@ import {
BlockPlainTextAdapterExtension,
type BlockPlainTextAdapterMatcher,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
export const codeBlockPlainTextAdapterMatcher: BlockPlainTextAdapterMatcher = {
flavour: CodeBlockSchema.model.flavour,

View File

@@ -1,7 +1,8 @@
import { affineTextStyles } from '@blocksuite/affine-rich-text';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ShadowlessElement } from '@blocksuite/block-std';
import { type DeltaInsert, ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import { ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { html } from 'lit';
import { property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';

View File

@@ -1,6 +1,5 @@
import type { ColumnDataType, SerializedCells } from '@blocksuite/affine-model';
import type { DeltaInsert } from '@blocksuite/inline';
import type { BlockSnapshot } from '@blocksuite/store';
import type { BlockSnapshot, DeltaInsert } from '@blocksuite/store';
import { databaseBlockModels } from '../properties/model';

View File

@@ -12,7 +12,7 @@ import { createDefaultDoc, matchModels } from '@blocksuite/affine-shared/utils';
import { type EditorHost, ShadowlessElement } from '@blocksuite/block-std';
import type { DetailSlotProps, SingleView } from '@blocksuite/data-view';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import type { BaseTextAttributes } from '@blocksuite/inline';
import type { BaseTextAttributes } from '@blocksuite/store';
import { computed } from '@preact/signals-core';
import { css, html } from 'lit';
import { property } from 'lit/decorators.js';

View File

@@ -18,8 +18,7 @@ import {
createIcon,
} from '@blocksuite/data-view';
import { IS_MAC } from '@blocksuite/global/env';
import type { DeltaInsert } from '@blocksuite/inline';
import type { BlockSnapshot } from '@blocksuite/store';
import type { BlockSnapshot, DeltaInsert } from '@blocksuite/store';
import { Text } from '@blocksuite/store';
import { computed, effect, signal } from '@preact/signals-core';
import { ref } from 'lit/directives/ref.js';

View File

@@ -1,6 +1,6 @@
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { propertyType, t } from '@blocksuite/data-view';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { Text } from '@blocksuite/store';
import * as Y from 'yjs';
import zod from 'zod';

View File

@@ -13,8 +13,7 @@ import {
import { BaseCellRenderer } from '@blocksuite/data-view';
import { IS_MAC } from '@blocksuite/global/env';
import { LinkedPageIcon } from '@blocksuite/icons/lit';
import type { DeltaInsert } from '@blocksuite/inline';
import type { BlockSnapshot, Text } from '@blocksuite/store';
import type { BlockSnapshot, DeltaInsert, Text } from '@blocksuite/store';
import { signal } from '@preact/signals-core';
import { property } from 'lit/decorators.js';
import { createRef, ref } from 'lit/directives/ref.js';

View File

@@ -5,7 +5,7 @@ import {
type BlockHtmlAdapterMatcher,
HastUtils,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import type { Element } from 'hast';

View File

@@ -5,7 +5,7 @@ import {
type BlockMarkdownAdapterMatcher,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import type { List } from 'mdast';

View File

@@ -4,7 +4,7 @@ import {
type BlockNotionHtmlAdapterMatcher,
HastUtils,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
const listBlockMatchTags = new Set(['ul', 'ol', 'li']);

View File

@@ -3,7 +3,7 @@ import {
BlockPlainTextAdapterExtension,
type BlockPlainTextAdapterMatcher,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
export const listBlockPlainTextAdapterMatcher: BlockPlainTextAdapterMatcher = {
flavour: ListBlockSchema.model.flavour,

View File

@@ -5,8 +5,8 @@ import {
HastUtils,
type HtmlAST,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import { nanoid, type NodeProps } from '@blocksuite/store';
import type { DeltaInsert, NodeProps } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
const paragraphBlockMatchTags = new Set([
'p',

View File

@@ -4,7 +4,7 @@ import {
type BlockMarkdownAdapterMatcher,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import type { Heading } from 'mdast';

View File

@@ -3,7 +3,7 @@ import {
BlockPlainTextAdapterExtension,
type BlockPlainTextAdapterMatcher,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
export const paragraphBlockPlainTextAdapterMatcher: BlockPlainTextAdapterMatcher =
{

View File

@@ -3,7 +3,7 @@ import {
BlockMarkdownAdapterExtension,
type BlockMarkdownAdapterMatcher,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
export const rootBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher = {
flavour: RootBlockSchema.model.flavour,

View File

@@ -1,4 +1,4 @@
import type { DeltaInsert } from '@blocksuite/inline/types';
import type { DeltaInsert } from '@blocksuite/store';
import type { MindMapTreeNode } from '../types/mindmap.js';
import { buildMindMapTree } from './mindmap.js';

View File

@@ -7,7 +7,7 @@ import {
BlockPlainTextAdapterExtension,
type BlockPlainTextAdapterMatcher,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import { createTableProps, formatTable, processTable } from './utils.js';

View File

@@ -10,7 +10,7 @@ import {
} from '@blocksuite/affine-shared/adapters';
import { HastUtils } from '@blocksuite/affine-shared/adapters';
import { generateFractionalIndexingKeyBetween } from '@blocksuite/affine-shared/utils';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { nanoid } from '@blocksuite/store';
import type { Element } from 'hast';
import type { Table as MarkdownTable } from 'mdast';

View File

@@ -14,8 +14,7 @@ import { ShadowlessElement } from '@blocksuite/block-std';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { noop } from '@blocksuite/global/utils';
import { LinkedPageIcon } from '@blocksuite/icons/lit';
import type { DeltaInsert } from '@blocksuite/inline';
import type { BlockModel } from '@blocksuite/store';
import type { BlockModel, DeltaInsert } from '@blocksuite/store';
import { consume } from '@lit/context';
import { html, nothing } from 'lit';
import { property } from 'lit/decorators.js';

View File

@@ -1,5 +1,4 @@
import type { DeltaInsert } from '@blocksuite/inline';
import type { Text } from '@blocksuite/store';
import type { DeltaInsert, Text } from '@blocksuite/store';
import {
BlockModel,
BlockSchemaExtension,

View File

@@ -6,11 +6,13 @@ import {
} from '@blocksuite/global/di';
import {
type AttributeRenderer,
baseTextAttributes,
type DeltaInsert,
getDefaultAttributeRenderer,
} from '@blocksuite/inline';
import type { ExtensionType } from '@blocksuite/store';
import {
baseTextAttributes,
type DeltaInsert,
type ExtensionType,
} from '@blocksuite/store';
import { z, type ZodObject, type ZodTypeAny } from 'zod';
import { MarkdownMatcherIdentifier } from './markdown-matcher.js';

View File

@@ -1,10 +1,9 @@
import type {
AttributeRenderer,
BaseTextAttributes,
DeltaInsert,
InlineEditor,
InlineRange,
} from '@blocksuite/inline';
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import type * as Y from 'yjs';
import type { ZodTypeAny } from 'zod';

View File

@@ -1,6 +1,7 @@
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ShadowlessElement } from '@blocksuite/block-std';
import { type DeltaInsert, ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import { ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { html } from 'lit';
import { property } from 'lit/decorators.js';
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';

View File

@@ -10,12 +10,12 @@ import {
} from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/lit';
import {
type DeltaInsert,
INLINE_ROOT_ATTR,
type InlineRootElement,
ZERO_WIDTH_NON_JOINER,
ZERO_WIDTH_SPACE,
} from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { shift } from '@floating-ui/dom';
import { baseTheme } from '@toeverything/theme';
import { css, html, nothing, unsafeCSS } from 'lit';

View File

@@ -1,6 +1,7 @@
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ShadowlessElement } from '@blocksuite/block-std';
import { type DeltaInsert, ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import { ZERO_WIDTH_SPACE } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { html } from 'lit';
import { property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';

View File

@@ -8,11 +8,11 @@ import {
} from '@blocksuite/block-std';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import {
type DeltaInsert,
type InlineEditor,
ZERO_WIDTH_NON_JOINER,
ZERO_WIDTH_SPACE,
} from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { signal } from '@preact/signals-core';
import katex from 'katex';
import { css, html, render } from 'lit';

View File

@@ -9,11 +9,11 @@ import type { BlockComponent, BlockStdScope } from '@blocksuite/block-std';
import { BLOCK_ID_ATTR, ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/lit';
import {
type DeltaInsert,
INLINE_ROOT_ATTR,
type InlineRootElement,
ZERO_WIDTH_SPACE,
} from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { css, html } from 'lit';
import { property } from 'lit/decorators.js';
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';

View File

@@ -19,13 +19,12 @@ import { BLOCK_ID_ATTR, ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/lit';
import { LinkedPageIcon } from '@blocksuite/icons/lit';
import {
type DeltaInsert,
INLINE_ROOT_ATTR,
type InlineRootElement,
ZERO_WIDTH_NON_JOINER,
ZERO_WIDTH_SPACE,
} from '@blocksuite/inline';
import type { DocMeta, Store } from '@blocksuite/store';
import type { DeltaInsert, DocMeta, Store } from '@blocksuite/store';
import { css, html, nothing } from 'lit';
import { property, state } from 'lit/decorators.js';
import { choose } from 'lit/directives/choose.js';

View File

@@ -3,12 +3,12 @@ import { ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/lit';
import {
type AttributeRenderer,
type DeltaInsert,
InlineEditor,
type InlineRange,
type InlineRangeProvider,
type VLine,
} from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import { Text } from '@blocksuite/store';
import { effect, signal } from '@preact/signals-core';
import { css, html, type TemplateResult } from 'lit';

View File

@@ -3,8 +3,7 @@ import {
type ServiceIdentifier,
type ServiceProvider,
} from '@blocksuite/global/di';
import type { DeltaInsert } from '@blocksuite/inline';
import type { ExtensionType } from '@blocksuite/store';
import type { DeltaInsert, ExtensionType } from '@blocksuite/store';
import type { AffineTextAttributes } from '../../types/index.js';
import {

View File

@@ -2,8 +2,7 @@ import {
createIdentifier,
type ServiceIdentifier,
} from '@blocksuite/global/di';
import type { DeltaInsert } from '@blocksuite/inline/types';
import type { ExtensionType } from '@blocksuite/store';
import type { DeltaInsert, ExtensionType } from '@blocksuite/store';
import type { PhrasingContent } from 'mdast';
import type { AffineTextAttributes } from '../../types/index.js';

View File

@@ -1,12 +1,12 @@
import { DefaultTheme, NoteDisplayMode } from '@blocksuite/affine-model';
import type { ServiceProvider } from '@blocksuite/global/di';
import type { DeltaInsert } from '@blocksuite/inline';
import {
type AssetsManager,
ASTWalker,
BaseAdapter,
type BlockSnapshot,
BlockSnapshotSchema,
type DeltaInsert,
type DocSnapshot,
type ExtensionType,
type FromBlockSnapshotPayload,

View File

@@ -2,8 +2,7 @@ import {
createIdentifier,
type ServiceIdentifier,
} from '@blocksuite/global/di';
import type { DeltaInsert } from '@blocksuite/inline';
import type { ExtensionType } from '@blocksuite/store';
import type { DeltaInsert, ExtensionType } from '@blocksuite/store';
import isEqual from 'lodash-es/isEqual';
import type { AffineTextAttributes } from '../../types/index.js';

View File

@@ -1,10 +1,10 @@
import { DefaultTheme } from '@blocksuite/affine-model';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import type { DeltaInsert } from '@blocksuite/inline';
import {
type AssetsManager,
BaseAdapter,
type BlockSnapshot,
type DeltaInsert,
type DocSnapshot,
type ExtensionType,
type FromBlockSnapshotResult,

View File

@@ -2,8 +2,7 @@ import {
createIdentifier,
type ServiceIdentifier,
} from '@blocksuite/global/di';
import type { DeltaInsert } from '@blocksuite/inline';
import type { ExtensionType } from '@blocksuite/store';
import type { DeltaInsert, ExtensionType } from '@blocksuite/store';
import type { AffineTextAttributes } from '../../types/index.js';
import {

View File

@@ -1,12 +1,13 @@
import { createIdentifier, type ServiceProvider } from '@blocksuite/global/di';
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/inline';
import {
type AssetsManager,
type ASTWalker,
type ASTWalkerContext,
type BaseAdapter,
type BaseTextAttributes,
type BlockSnapshot,
BlockSnapshotSchema,
type DeltaInsert,
type NodeProps,
type Transformer,
} from '@blocksuite/store';

View File

@@ -1,5 +1,5 @@
import type { ReferenceParams } from '@blocksuite/affine-model';
import type { DeltaInsert } from '@blocksuite/inline';
import type { DeltaInsert } from '@blocksuite/store';
import isEqual from 'lodash-es/isEqual';
const mergeDeltas = (

View File

@@ -15,8 +15,7 @@ import {
TomorrowIcon,
YesterdayIcon,
} from '@blocksuite/icons/lit';
import type { DeltaInsert } from '@blocksuite/inline';
import { Slice, Text } from '@blocksuite/store';
import { type DeltaInsert, Slice, Text } from '@blocksuite/store';
import { slashMenuToolTips } from './tooltips';
import type { SlashMenuConfig } from './types';

View File

@@ -23,6 +23,7 @@
},
"dependencies": {
"@blocksuite/global": "workspace:*",
"@blocksuite/store": "workspace:*",
"@preact/signals-core": "^1.8.0",
"lit": "^3.2.0",
"rxjs": "^7.8.1",

View File

@@ -1,6 +1,7 @@
import type { DeltaInsert } from '@blocksuite/store';
import { expect, type Page } from '@playwright/test';
import type { DeltaInsert, InlineEditor, InlineRange } from '../index.js';
import type { InlineEditor, InlineRange } from '../index.js';
const defaultPlaygroundURL = new URL(
`http://localhost:${process.env.CI ? 4173 : 5173}/`

View File

@@ -1,6 +1,7 @@
import { DisposableGroup } from '@blocksuite/global/disposable';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import { SignalWatcher } from '@blocksuite/global/lit';
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import { effect, signal } from '@preact/signals-core';
import { html, LitElement } from 'lit';
import { property } from 'lit/decorators.js';
@@ -8,8 +9,6 @@ import { styleMap } from 'lit/directives/style-map.js';
import { ZERO_WIDTH_SPACE } from '../consts.js';
import type { InlineEditor } from '../inline-editor.js';
import type { DeltaInsert } from '../types.js';
import type { BaseTextAttributes } from '../utils/base-attributes.js';
import { isInlineRangeIntersect } from '../utils/inline-range.js';
export class VElement<

View File

@@ -1,11 +1,11 @@
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import type { DeltaInsert } from '@blocksuite/store';
import { html, LitElement, type TemplateResult } from 'lit';
import { property } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
import { INLINE_ROOT_ATTR, ZERO_WIDTH_SPACE } from '../consts.js';
import type { InlineRootElement } from '../inline-editor.js';
import type { DeltaInsert } from '../types.js';
import { EmbedGap } from './embed-gap.js';
export class VLine extends LitElement {

View File

@@ -1,5 +1,6 @@
import { DisposableGroup } from '@blocksuite/global/disposable';
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import { type Signal, signal } from '@preact/signals-core';
import { nothing, render, type TemplateResult } from 'lit';
import { Subject } from 'rxjs';
@@ -16,12 +17,8 @@ import {
} from './services/index.js';
import { RenderService } from './services/render.js';
import { InlineTextService } from './services/text.js';
import type { DeltaInsert, InlineRange } from './types.js';
import {
type BaseTextAttributes,
nativePointToTextPoint,
textPointToDomPoint,
} from './utils/index.js';
import type { InlineRange } from './types.js';
import { nativePointToTextPoint, textPointToDomPoint } from './utils/index.js';
import { getTextNodesFromElement } from './utils/text.js';
export type InlineRootElement<

View File

@@ -1,19 +1,16 @@
import { type BaseTextAttributes, baseTextAttributes } from '@blocksuite/store';
import type { z, ZodTypeDef } from 'zod';
import type { InlineEditor } from '../inline-editor.js';
import type { AttributeRenderer, InlineRange } from '../types.js';
import type { BaseTextAttributes } from '../utils/index.js';
import {
baseTextAttributes,
getDefaultAttributeRenderer,
} from '../utils/index.js';
import { getDefaultAttributeRenderer } from '../utils/index.js';
export class AttributeService<TextAttributes extends BaseTextAttributes> {
private _attributeRenderer: AttributeRenderer<TextAttributes> =
getDefaultAttributeRenderer<TextAttributes>();
private _attributeSchema: z.ZodSchema<TextAttributes, ZodTypeDef, unknown> =
baseTextAttributes as z.ZodSchema<TextAttributes, ZodTypeDef, unknown>;
baseTextAttributes as never;
private _marks: TextAttributes | null = null;

View File

@@ -1,6 +1,7 @@
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import type { InlineEditor } from '../inline-editor.js';
import type { DeltaEntry, DeltaInsert, InlineRange } from '../types.js';
import type { BaseTextAttributes } from '../utils/index.js';
import type { DeltaEntry, InlineRange } from '../types.js';
import { transformDeltasToEmbedDeltas } from '../utils/index.js';
export class DeltaService<TextAttributes extends BaseTextAttributes> {

View File

@@ -1,7 +1,8 @@
import type { BaseTextAttributes } from '@blocksuite/store';
import type { InlineEditor } from '../inline-editor.js';
import type { InlineRange } from '../types.js';
import {
type BaseTextAttributes,
isInEmbedElement,
isInEmbedGap,
isInEmptyLine,
@@ -115,7 +116,7 @@ export class EventService<TextAttributes extends BaseTextAttributes> {
ctx.data,
ctx.attributes,
ctx.inlineRange,
this.editor as InlineEditor
this.editor as never
);
this.editor.slots.inputting.next();

View File

@@ -1,6 +1,7 @@
import type { BaseTextAttributes } from '@blocksuite/store';
import type { InlineEditor } from '../inline-editor.js';
import type { InlineRange } from '../types.js';
import type { BaseTextAttributes } from '../utils/base-attributes.js';
export interface BeforeinputHookCtx<TextAttributes extends BaseTextAttributes> {
inlineEditor: InlineEditor<TextAttributes>;

View File

@@ -1,10 +1,10 @@
import type { BaseTextAttributes } from '@blocksuite/store';
import { effect } from '@preact/signals-core';
import * as Y from 'yjs';
import type { VLine } from '../components/v-line.js';
import type { InlineEditor } from '../inline-editor.js';
import type { InlineRange, TextPoint } from '../types.js';
import type { BaseTextAttributes } from '../utils/base-attributes.js';
import { isInEmbedGap } from '../utils/embed.js';
import { isMaybeInlineRangeEqual } from '../utils/inline-range.js';
import {

View File

@@ -1,4 +1,5 @@
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import type { BaseTextAttributes } from '@blocksuite/store';
import { html, render } from 'lit';
import { repeat } from 'lit/directives/repeat.js';
import * as Y from 'yjs';
@@ -6,7 +7,6 @@ import * as Y from 'yjs';
import type { VLine } from '../components/v-line.js';
import type { InlineEditor } from '../inline-editor.js';
import type { InlineRange } from '../types.js';
import type { BaseTextAttributes } from '../utils/base-attributes.js';
import { deltaInsertsToChunks } from '../utils/delta-convert.js';
export class RenderService<TextAttributes extends BaseTextAttributes> {

View File

@@ -1,6 +1,7 @@
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import type { InlineEditor } from '../inline-editor.js';
import type { DeltaInsert, InlineRange } from '../types.js';
import type { BaseTextAttributes } from '../utils/base-attributes.js';
import type { InlineRange } from '../types.js';
import { intersectInlineRange } from '../utils/inline-range.js';
export class InlineTextService<TextAttributes extends BaseTextAttributes> {

View File

@@ -1,14 +1,7 @@
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import type { TemplateResult } from 'lit';
import type { InlineEditor } from './inline-editor.js';
import type { BaseTextAttributes } from './utils/index.js';
export type DeltaInsert<
TextAttributes extends BaseTextAttributes = BaseTextAttributes,
> = {
insert: string;
attributes?: TextAttributes;
};
export type AttributeRenderer<
TextAttributes extends BaseTextAttributes = BaseTextAttributes,

View File

@@ -1,8 +1,8 @@
import type { BaseTextAttributes } from '@blocksuite/store';
import { html } from 'lit';
import { styleMap } from 'lit/directives/style-map.js';
import type { AttributeRenderer } from '../types.js';
import type { BaseTextAttributes } from './base-attributes.js';
function inlineTextStyles(
props: BaseTextAttributes

View File

@@ -1,5 +1,4 @@
import type { DeltaInsert } from '../types.js';
import type { BaseTextAttributes } from './base-attributes.js';
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
export function transformDelta<TextAttributes extends BaseTextAttributes>(
delta: DeltaInsert<TextAttributes>

View File

@@ -1,7 +1,7 @@
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import { VElement } from '../components/v-element.js';
import type { InlineEditor } from '../inline-editor.js';
import type { DeltaInsert } from '../types.js';
import type { BaseTextAttributes } from './base-attributes.js';
export function isInEmbedElement(node: Node): boolean {
if (node instanceof Element) {

View File

@@ -1,5 +1,4 @@
export * from './attribute-renderer.js';
export * from './base-attributes.js';
export * from './delta-convert.js';
export * from './embed.js';
export * from './guard.js';

View File

@@ -1,8 +1,6 @@
import type { BaseTextAttributes, DeltaInsert } from '@blocksuite/store';
import { html, type TemplateResult } from 'lit';
import type { DeltaInsert } from '../types.js';
import type { BaseTextAttributes } from './base-attributes.js';
export function renderElement<TextAttributes extends BaseTextAttributes>(
delta: DeltaInsert<TextAttributes>,
parseAttributes: (

View File

@@ -1,6 +1,7 @@
import type { BaseTextAttributes } from '@blocksuite/store';
import type { InlineEditor } from '../inline-editor.js';
import type { InlineRange } from '../types.js';
import type { BaseTextAttributes } from './base-attributes.js';
function handleInsertText<TextAttributes extends BaseTextAttributes>(
inlineRange: InlineRange,

View File

@@ -6,5 +6,5 @@
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
},
"include": ["./src"],
"references": [{ "path": "../global" }]
"references": [{ "path": "../global" }, { "path": "../store" }]
}

View File

@@ -11,7 +11,6 @@
"license": "MIT",
"dependencies": {
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/sync": "workspace:*",
"@preact/signals-core": "^1.8.0",
"@types/lodash.ismatch": "^4.4.9",

View File

@@ -10,7 +10,7 @@ import {
internalPrimitives,
} from '../model/block/index.js';
import type { YBlock } from '../model/block/types.js';
import type { Text } from '../reactive/text.js';
import type { Text } from '../reactive/text/index.js';
import { createAutoIncrementIdGenerator } from '../test/index.js';
import { TestWorkspace } from '../test/test-workspace.js';

View File

@@ -3,7 +3,7 @@ import { assert, beforeEach, describe, expect, it, vi } from 'vitest';
import { applyUpdate, type Doc, encodeStateAsUpdate } from 'yjs';
import type { BlockModel, DocMeta, Store } from '../index.js';
import { Text } from '../reactive/text.js';
import { Text } from '../reactive/text/index.js';
import { createAutoIncrementIdGenerator } from '../test/index.js';
import { TestWorkspace } from '../test/test-workspace.js';
import {

View File

@@ -4,5 +4,5 @@ export * from './is-pure-object.js';
export * from './native-y.js';
export * from './proxy.js';
export * from './stash-pop.js';
export * from './text.js';
export * from './text/index.js';
export * from './types.js';

View File

@@ -2,7 +2,7 @@ import { Array as YArray, Map as YMap, Text as YText } from 'yjs';
import { Boxed } from './boxed.js';
import { isPureObject } from './is-pure-object.js';
import { Text } from './text.js';
import { Text } from './text/index.js';
import type { Native2Y, TransformOptions } from './types.js';
export function native2Y<T>(

View File

@@ -6,7 +6,7 @@ import { BaseReactiveYData } from './base-reactive-data.js';
import { Boxed, type OnBoxedChange } from './boxed.js';
import { proxies } from './memory.js';
import { native2Y, y2Native } from './native-y.js';
import { type OnTextChange, Text } from './text.js';
import { type OnTextChange, Text } from './text/index.js';
import type { ProxyOptions, TransformOptions, UnRecord } from './types.js';
export class ReactiveYArray extends BaseReactiveYData<

View File

@@ -0,0 +1,3 @@
export * from './attributes';
export * from './text';
export * from './types';

View File

@@ -1,19 +1,8 @@
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
import type { DeltaInsert } from '@blocksuite/inline';
import { type Signal, signal } from '@preact/signals-core';
import * as Y from 'yjs';
export interface OptionalAttributes {
attributes?: Record<string, any>;
}
export type DeltaOperation = {
insert?: string;
delete?: number;
retain?: number;
} & OptionalAttributes;
export type OnTextChange = (data: Y.Text, isLocal: boolean) => void;
import type { DeltaInsert, DeltaOperation, OnTextChange } from './types';
/**
* Text is an abstraction of Y.Text.

View File

@@ -0,0 +1,22 @@
import type * as Y from 'yjs';
import type { BaseTextAttributes } from './attributes';
export interface OptionalAttributes {
attributes?: Record<string, any>;
}
export type DeltaOperation = {
insert?: string;
delete?: number;
retain?: number;
} & OptionalAttributes;
export type OnTextChange = (data: Y.Text, isLocal: boolean) => void;
export type DeltaInsert<
TextAttributes extends BaseTextAttributes = BaseTextAttributes,
> = {
insert: string;
attributes?: TextAttributes;
};

View File

@@ -6,9 +6,5 @@
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
},
"include": ["./src"],
"references": [
{ "path": "../global" },
{ "path": "../inline" },
{ "path": "../sync" }
]
"references": [{ "path": "../global" }, { "path": "../sync" }]
}

View File

@@ -34,7 +34,6 @@ import {
ErrorCode,
} from '@blocksuite/affine/global/exceptions';
import type { SerializedXYWH } from '@blocksuite/affine/global/gfx';
import type { DeltaInsert } from '@blocksuite/affine/inline/types';
import { ColorScheme, type DocMode } from '@blocksuite/affine/model';
import {
docLinkBaseURLMiddleware,
@@ -51,7 +50,11 @@ import {
StyleVariables,
} from '@blocksuite/affine/shared/theme';
import { openFileOrFiles, printToPdf } from '@blocksuite/affine/shared/utils';
import { Text, type Workspace } from '@blocksuite/affine/store';
import {
type DeltaInsert,
Text,
type Workspace,
} from '@blocksuite/affine/store';
import { NotionHtmlAdapter } from '@blocksuite/affine-shared/adapters';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { TestAffineEditorContainer } from '@blocksuite/integration-test';

View File

@@ -3,12 +3,14 @@ import '@shoelace-style/shoelace';
import { ShadowlessElement } from '@blocksuite/affine/block-std';
import {
type AttributeRenderer,
type BaseTextAttributes,
baseTextAttributes,
InlineEditor,
ZERO_WIDTH_NON_JOINER,
} from '@blocksuite/affine/inline';
import { effects } from '@blocksuite/affine/inline/effects';
import {
type BaseTextAttributes,
baseTextAttributes,
} from '@blocksuite/affine/store';
import { effect } from '@preact/signals-core';
import { css, html, nothing } from 'lit';
import { customElement, property, query } from 'lit/decorators.js';