mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
refactor(editor): store should not rely on inline (#11017)
This commit is contained in:
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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']);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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 =
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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 = (
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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}/`
|
||||
|
||||
@@ -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<
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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<
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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>;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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: (
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["./src"],
|
||||
"references": [{ "path": "../global" }]
|
||||
"references": [{ "path": "../global" }, { "path": "../store" }]
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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>(
|
||||
|
||||
@@ -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<
|
||||
|
||||
3
blocksuite/framework/store/src/reactive/text/index.ts
Normal file
3
blocksuite/framework/store/src/reactive/text/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './attributes';
|
||||
export * from './text';
|
||||
export * from './types';
|
||||
@@ -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.
|
||||
22
blocksuite/framework/store/src/reactive/text/types.ts
Normal file
22
blocksuite/framework/store/src/reactive/text/types.ts
Normal 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;
|
||||
};
|
||||
@@ -6,9 +6,5 @@
|
||||
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||
},
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{ "path": "../global" },
|
||||
{ "path": "../inline" },
|
||||
{ "path": "../sync" }
|
||||
]
|
||||
"references": [{ "path": "../global" }, { "path": "../sync" }]
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user