refactor(editor): merge inline to std (#11025)

This commit is contained in:
Saul-Mirone
2025-03-20 05:46:56 +00:00
parent 5aa36efab0
commit 92d76ba571
176 changed files with 142 additions and 534 deletions

View File

@@ -14,7 +14,6 @@
"@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^2.1.0",
"@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3",
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
@@ -39,7 +38,8 @@
"exports": {
".": "./src/index.ts",
"./gfx": "./src/gfx/index.ts",
"./effects": "./src/effects.ts"
"./effects": "./src/effects.ts",
"./inline": "./src/inline/index.ts"
},
"files": [
"src",

View File

@@ -3,7 +3,7 @@ import { expect, test } from 'vitest';
import {
deltaInsertsToChunks,
transformDelta,
} from '../utils/delta-convert.js';
} from '../../inline/utils/delta-convert.js';
test('transformDelta', () => {
expect(

View File

@@ -1,7 +1,7 @@
import { expect, test } from 'vitest';
import * as Y from 'yjs';
import { InlineEditor } from '../inline-editor.js';
import { InlineEditor } from '../../inline/index.js';
test('getDeltaByRangeIndex', () => {
const yDoc = new Y.Doc();

View File

@@ -12,7 +12,7 @@ import {
isInlineRangeIntersect,
isPoint,
mergeInlineRange,
} from '../utils/inline-range.js';
} from '../../inline/utils/inline-range.js';
test('isInlineRangeContain', () => {
expect(

View File

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

View File

@@ -1,7 +1,14 @@
import { GfxViewportElement } from './gfx/viewport-element.js';
import { VElement, VLine, VText } from './inline/index.js';
import { EditorHost } from './view/index.js';
export function effects() {
// editor host
customElements.define('editor-host', EditorHost);
// gfx
customElements.define('gfx-viewport', GfxViewportElement);
// inline
customElements.define('v-element', VElement);
customElements.define('v-line', VLine);
customElements.define('v-text', VText);
}

View File

@@ -3,7 +3,6 @@ export * from './command/index.js';
export * from './event/index.js';
export * from './extension/index.js';
export * from './identifier.js';
export * from './inline/index.js';
export * from './scope/index.js';
export * from './selection/index.js';
export * from './spec/index.js';

View File

@@ -1 +1,7 @@
export * from './components';
export * from './consts';
export * from './inline-editor';
export * from './range';
export * from './services';
export * from './types';
export * from './utils';

View File

@@ -1,4 +1,7 @@
import type { InlineRange, InlineRangeProvider } from '@blocksuite/inline';
import type {
InlineRange,
InlineRangeProvider,
} from '@blocksuite/block-std/inline';
import { signal } from '@preact/signals-core';
import { TextSelection } from '../../selection/index.js';

View File

@@ -1,9 +1,9 @@
import { INLINE_ROOT_ATTR, type InlineRootElement } from '@blocksuite/inline';
import { LifeCycleWatcher } from '../../extension/index.js';
import { TextSelection } from '../../selection/index.js';
import type { BlockComponent } from '../../view/element/block-component.js';
import { BLOCK_ID_ATTR } from '../../view/index.js';
import { INLINE_ROOT_ATTR } from '../consts.js';
import type { InlineRootElement } from '../inline-editor.js';
import { RANGE_QUERY_EXCLUDE_ATTR, RANGE_SYNC_EXCLUDE_ATTR } from './consts.js';
import { RangeBinding } from './range-binding.js';

View File

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

View File

@@ -1,3 +0,0 @@
# `@blocksuite/inline`
Inline rich text editing component for BlockSuite. Checkout the docs at [blocksuite.io/inline](https://blocksuite.io/guide/inline.html).

View File

@@ -1,37 +0,0 @@
{
"name": "@blocksuite/inline",
"description": "A micro editor.",
"type": "module",
"scripts": {
"build": "tsc"
},
"sideEffects": false,
"keywords": [],
"files": [
"src",
"dist",
"!src/__tests__",
"!dist/__tests__"
],
"author": "toeverything",
"license": "MIT",
"exports": {
".": "./src/index.ts",
"./consts": "./src/consts.ts",
"./effects": "./src/effects.ts",
"./types": "./src/types.ts"
},
"dependencies": {
"@blocksuite/global": "workspace:*",
"@blocksuite/store": "workspace:*",
"@preact/signals-core": "^1.8.0",
"lit": "^3.2.0",
"rxjs": "^7.8.1",
"yjs": "^13.6.21",
"zod": "^3.23.8"
},
"devDependencies": {
"vitest": "3.0.8"
},
"version": "0.20.0"
}

View File

@@ -1,7 +0,0 @@
import { VElement, VLine, VText } from './components/index.js';
export function effects() {
customElements.define('v-element', VElement);
customElements.define('v-line', VLine);
customElements.define('v-text', VText);
}

View File

@@ -1,6 +0,0 @@
export * from './components/index.js';
export * from './consts.js';
export * from './inline-editor.js';
export * from './services/index.js';
export * from './types.js';
export * from './utils/index.js';

View File

@@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
},
"include": ["./src"],
"references": [{ "path": "../global" }, { "path": "../store" }]
}

View File

@@ -1,28 +0,0 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
esbuild: {
target: 'es2018',
},
test: {
include: ['src/__tests__/**/*.unit.spec.ts'],
testTimeout: 500,
coverage: {
provider: 'istanbul', // or 'c8'
reporter: ['lcov'],
reportsDirectory: '../../../.coverage/inline',
},
/**
* Custom handler for console.log in tests.
*
* Return `false` to ignore the log.
*/
onConsoleLog(log, type) {
if (log.includes('https://lit.dev/msg/dev-mode')) {
return false;
}
console.warn(`Unexpected ${type} log`, log);
throw new Error(log);
},
},
});