refactor(editor): extract database block (#9435)
Part of: [BS-2269](https://linear.app/affine-design/issue/BS-2269/%E8%BF%81%E7%A7%BB-database-block-%E5%88%B0-affine-%E6%96%87%E4%BB%B6%E5%A4%B9%E4%B8%8B%E5%B9%B6%E5%BC%80%E5%90%AF-nouncheckedindexedaccess)
This commit is contained in:
63 files changed
+268
-127
No files matched your search
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "@blocksuite/affine-block-database",
|
||||
"description": "Database block for BlockSuite.",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test:unit": "nx vite:test --run --passWithNoTests",
|
||||
"test:unit:coverage": "nx vite:test --run --coverage",
|
||||
"test:e2e": "playwright test"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"keywords": [],
|
||||
"author": "toeverything",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@blocksuite/affine-components": "workspace:*",
|
||||
"@blocksuite/affine-model": "workspace:*",
|
||||
"@blocksuite/affine-shared": "workspace:*",
|
||||
"@blocksuite/block-std": "workspace:*",
|
||||
"@blocksuite/data-view": "workspace:*",
|
||||
"@blocksuite/global": "workspace:*",
|
||||
"@blocksuite/inline": "workspace:*",
|
||||
"@blocksuite/store": "workspace:*",
|
||||
"@floating-ui/dom": "^1.6.10",
|
||||
"@lit/context": "^1.1.2",
|
||||
"@preact/signals-core": "^1.8.0",
|
||||
"@toeverything/theme": "^1.1.3",
|
||||
"@types/mdast": "^4.0.4",
|
||||
"date-fns": "^4.0.0",
|
||||
"lit": "^3.2.0",
|
||||
"minimatch": "^10.0.1",
|
||||
"zod": "^3.23.8"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts",
|
||||
"./effects": "./src/effects.ts"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"!src/__tests__",
|
||||
"!dist/__tests__"
|
||||
],
|
||||
"version": "0.19.0"
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,4 @@
|
||||
export * from './html';
|
||||
export * from './markdown';
|
||||
export * from './notion-html';
|
||||
export * from './plain-text';
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-1
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
|
||||
import {
|
||||
insertPositionToIndex,
|
||||
+1
-1
@@ -347,7 +347,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<
|
||||
get optionsConfig(): DatabaseOptionsConfig {
|
||||
return {
|
||||
configure: (_model, options) => options,
|
||||
...this.std.getConfig('affine:page')?.databaseOptions,
|
||||
...this.std.getConfig('affine:database'),
|
||||
};
|
||||
}
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,74 @@
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
|
||||
|
||||
import type { insertDatabaseBlockCommand } from './commands';
|
||||
import { CenterPeek } from './components/layout';
|
||||
import { DatabaseTitle } from './components/title';
|
||||
import type { DatabaseOptionsConfig } from './config';
|
||||
import { DatabaseBlockComponent } from './database-block';
|
||||
import type { DatabaseBlockService } from './database-service';
|
||||
import { BlockRenderer } from './detail-panel/block-renderer';
|
||||
import { NoteRenderer } from './detail-panel/note-renderer';
|
||||
import { LinkCell, LinkCellEditing } from './properties/link/cell-renderer';
|
||||
import { LinkNode } from './properties/link/components/link-node';
|
||||
import {
|
||||
RichTextCell,
|
||||
RichTextCellEditing,
|
||||
} from './properties/rich-text/cell-renderer';
|
||||
import { IconCell } from './properties/title/icon';
|
||||
import {
|
||||
HeaderAreaTextCell,
|
||||
HeaderAreaTextCellEditing,
|
||||
} from './properties/title/text';
|
||||
|
||||
export function effects() {
|
||||
customElements.define('affine-database-title', DatabaseTitle);
|
||||
customElements.define('data-view-header-area-icon', IconCell);
|
||||
customElements.define('affine-database-link-cell', LinkCell);
|
||||
customElements.define('affine-database-link-cell-editing', LinkCellEditing);
|
||||
customElements.define('data-view-header-area-text', HeaderAreaTextCell);
|
||||
customElements.define(
|
||||
'data-view-header-area-text-editing',
|
||||
HeaderAreaTextCellEditing
|
||||
);
|
||||
customElements.define('affine-database-rich-text-cell', RichTextCell);
|
||||
customElements.define(
|
||||
'affine-database-rich-text-cell-editing',
|
||||
RichTextCellEditing
|
||||
);
|
||||
customElements.define('center-peek', CenterPeek);
|
||||
customElements.define('database-datasource-note-renderer', NoteRenderer);
|
||||
customElements.define('database-datasource-block-renderer', BlockRenderer);
|
||||
customElements.define('affine-database-link-node', LinkNode);
|
||||
customElements.define('affine-database', DatabaseBlockComponent);
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockModels {
|
||||
'affine:database': DatabaseBlockModel;
|
||||
}
|
||||
|
||||
interface BlockConfigs {
|
||||
'affine:database': Partial<DatabaseOptionsConfig>;
|
||||
}
|
||||
|
||||
interface CommandContext {
|
||||
insertedDatabaseBlockId?: string;
|
||||
}
|
||||
|
||||
interface Commands {
|
||||
/**
|
||||
* insert a database block after or before the current block selection
|
||||
* @param latex the LaTeX content. A input dialog will be shown if not provided
|
||||
* @param removeEmptyLine remove the current block if it is empty
|
||||
* @param place where to insert the LaTeX block
|
||||
* @returns the id of the inserted LaTeX block
|
||||
*/
|
||||
insertDatabaseBlock: typeof insertDatabaseBlockCommand;
|
||||
}
|
||||
|
||||
interface BlockServices {
|
||||
'affine:database': DatabaseBlockService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
|
||||
|
||||
export * from './adapters';
|
||||
export type { DatabaseOptionsConfig } from './config';
|
||||
export * from './data-source';
|
||||
export * from './database-block';
|
||||
export * from './database-service';
|
||||
export * from './database-spec';
|
||||
export * from './detail-panel/block-renderer';
|
||||
export * from './detail-panel/note-renderer';
|
||||
export * from './properties';
|
||||
export * from './properties/rich-text/cell-renderer';
|
||||
export * from './properties/utils';
|
||||
export * from './utils/block-utils';
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockModels {
|
||||
'affine:database': DatabaseBlockModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-2
@@ -22,7 +22,6 @@ import { css, type TemplateResult } from 'lit';
|
||||
import { property, query } from 'lit/decorators.js';
|
||||
import { html } from 'lit/static-html.js';
|
||||
|
||||
import { ClipboardAdapter } from '../../../root-block/clipboard/adapter.js';
|
||||
import { HostContextKey } from '../../context/host-context.js';
|
||||
import type { DatabaseBlockComponent } from '../../database-block.js';
|
||||
import { getSingleDocIdFromText } from '../../utils/title-doc.js';
|
||||
@@ -262,7 +261,7 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
|
||||
};
|
||||
const snapshot = this.std?.clipboard?.readFromClipboard(
|
||||
e.clipboardData
|
||||
)[ClipboardAdapter.MIME];
|
||||
)['BLOCKSUITE/SNAPSHOT'];
|
||||
const deltas = (
|
||||
JSON.parse(snapshot).snapshot.content as BlockSnapshot[]
|
||||
).flatMap(getDeltas);
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,47 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src/",
|
||||
"outDir": "./dist/",
|
||||
"noEmit": false
|
||||
},
|
||||
"include": ["./src"],
|
||||
"references": [
|
||||
{
|
||||
"path": "../../framework/global"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/store"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/block-std"
|
||||
},
|
||||
{
|
||||
"path": "../../framework/inline"
|
||||
},
|
||||
{
|
||||
"path": "../model"
|
||||
},
|
||||
{
|
||||
"path": "../components"
|
||||
},
|
||||
{
|
||||
"path": "../shared"
|
||||
},
|
||||
{
|
||||
"path": "../data-view"
|
||||
},
|
||||
{
|
||||
"path": "../block-embed"
|
||||
},
|
||||
{
|
||||
"path": "../block-paragraph"
|
||||
},
|
||||
{
|
||||
"path": "../block-note"
|
||||
},
|
||||
{
|
||||
"path": "../block-list"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
"@blocksuite/affine-block-attachment": "workspace:*",
|
||||
"@blocksuite/affine-block-bookmark": "workspace:*",
|
||||
"@blocksuite/affine-block-code": "workspace:*",
|
||||
"@blocksuite/affine-block-database": "workspace:*",
|
||||
"@blocksuite/affine-block-divider": "workspace:*",
|
||||
"@blocksuite/affine-block-edgeless-text": "workspace:*",
|
||||
"@blocksuite/affine-block-embed": "workspace:*",
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
import {
|
||||
addProperty,
|
||||
copyCellsByProperty,
|
||||
databaseBlockColumns,
|
||||
deleteColumn,
|
||||
getCell,
|
||||
getProperty,
|
||||
updateCell,
|
||||
} from '@blocksuite/affine-block-database';
|
||||
import {
|
||||
type Cell,
|
||||
type Column,
|
||||
@@ -12,16 +21,6 @@ import type { BlockModel, Doc } from '@blocksuite/store';
|
||||
import { DocCollection, IdGeneratorType, Schema } from '@blocksuite/store';
|
||||
import { beforeEach, describe, expect, test } from 'vitest';
|
||||
|
||||
import { databaseBlockColumns } from '../../database-block/index.js';
|
||||
import {
|
||||
addProperty,
|
||||
copyCellsByProperty,
|
||||
deleteColumn,
|
||||
getCell,
|
||||
getProperty,
|
||||
updateCell,
|
||||
} from '../../database-block/utils/block-utils.js';
|
||||
|
||||
const AffineSchemas = [
|
||||
RootBlockSchema,
|
||||
NoteBlockSchema,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BookmarkBlockHtmlAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockHtmlAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockHtmlAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockHtmlAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaBlockHtmlAdapterExtension,
|
||||
@@ -13,7 +14,6 @@ import { ImageBlockHtmlAdapterExtension } from '@blocksuite/affine-block-image';
|
||||
import { ListBlockHtmlAdapterExtension } from '@blocksuite/affine-block-list';
|
||||
import { ParagraphBlockHtmlAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
|
||||
import { DatabaseBlockHtmlAdapterExtension } from '../../../database-block/adapters/html.js';
|
||||
import { RootBlockHtmlAdapterExtension } from '../../../root-block/adapters/html.js';
|
||||
|
||||
export const defaultBlockHtmlAdapterMatchers = [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { bookmarkBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-bookmark';
|
||||
import { codeBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-code';
|
||||
import { databaseBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-database';
|
||||
import { dividerBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
embedFigmaBlockMarkdownAdapterMatcher,
|
||||
@@ -14,7 +15,6 @@ import { latexBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-latex
|
||||
import { listBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-list';
|
||||
import { paragraphBlockMarkdownAdapterMatcher } from '@blocksuite/affine-block-paragraph';
|
||||
|
||||
import { databaseBlockMarkdownAdapterMatcher } from '../../../database-block/adapters/markdown.js';
|
||||
import { rootBlockMarkdownAdapterMatcher } from '../../../root-block/adapters/markdown.js';
|
||||
|
||||
export const defaultBlockMarkdownAdapterMatchers = [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AttachmentBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-attachment';
|
||||
import { BookmarkBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaBlockNotionHtmlAdapterExtension,
|
||||
@@ -14,7 +15,6 @@ import { ListBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-li
|
||||
import { ParagraphBlockNotionHtmlAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
import type { ExtensionType } from '@blocksuite/block-std';
|
||||
|
||||
import { DatabaseBlockNotionHtmlAdapterExtension } from '../../../database-block/adapters/notion-html.js';
|
||||
import { RootBlockNotionHtmlAdapterExtension } from '../../../root-block/adapters/notion-html.js';
|
||||
|
||||
export const defaultBlockNotionHtmlAdapterMatchers: ExtensionType[] = [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BookmarkBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-divider';
|
||||
import {
|
||||
EmbedFigmaBlockPlainTextAdapterExtension,
|
||||
@@ -14,8 +15,6 @@ import { ListBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-lis
|
||||
import { ParagraphBlockPlainTextAdapterExtension } from '@blocksuite/affine-block-paragraph';
|
||||
import type { ExtensionType } from '@blocksuite/block-std';
|
||||
|
||||
import { DatabaseBlockPlainTextAdapterExtension } from '../../../database-block/adapters/plain-text.js';
|
||||
|
||||
export const defaultBlockPlainTextAdapterMatchers: ExtensionType[] = [
|
||||
ParagraphBlockPlainTextAdapterExtension,
|
||||
ListBlockPlainTextAdapterExtension,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { AttachmentBlockSpec } from '@blocksuite/affine-block-attachment';
|
||||
import { BookmarkBlockSpec } from '@blocksuite/affine-block-bookmark';
|
||||
import { CodeBlockSpec } from '@blocksuite/affine-block-code';
|
||||
import { DatabaseBlockSpec } from '@blocksuite/affine-block-database';
|
||||
import { DividerBlockSpec } from '@blocksuite/affine-block-divider';
|
||||
import { EdgelessTextBlockSpec } from '@blocksuite/affine-block-edgeless-text';
|
||||
import { EmbedExtensions } from '@blocksuite/affine-block-embed';
|
||||
@@ -34,7 +35,6 @@ import type { ExtensionType } from '@blocksuite/block-std';
|
||||
|
||||
import { AdapterFactoryExtensions } from '../_common/adapters/extension.js';
|
||||
import { DataViewBlockSpec } from '../data-view-block/data-view-spec.js';
|
||||
import { DatabaseBlockSpec } from '../database-block/database-spec.js';
|
||||
|
||||
export const CommonBlockSpecs: ExtensionType[] = [
|
||||
DocDisplayMetaService,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { richTextColumnConfig } from '@blocksuite/affine-block-database';
|
||||
import { type ListBlockModel, ListBlockSchema } from '@blocksuite/affine-model';
|
||||
import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||
|
||||
import { richTextColumnConfig } from '../../database-block/properties/rich-text/cell-renderer.js';
|
||||
import { createBlockMeta } from './base.js';
|
||||
|
||||
export const todoMeta = createBlockMeta<ListBlockModel>({
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { richTextColumnConfig } from '@blocksuite/affine-block-database';
|
||||
import type { PropertyMetaConfig } from '@blocksuite/data-view';
|
||||
import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||
|
||||
import { richTextColumnConfig } from '../../database-block/properties/rich-text/cell-renderer.js';
|
||||
|
||||
export const queryBlockColumns = [
|
||||
propertyPresets.datePropertyConfig,
|
||||
propertyPresets.numberPropertyConfig,
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
databaseBlockAllPropertyMap,
|
||||
databasePropertyConverts,
|
||||
} from '@blocksuite/affine-block-database';
|
||||
import type { Column } from '@blocksuite/affine-model';
|
||||
import {
|
||||
insertPositionToIndex,
|
||||
@@ -9,10 +13,6 @@ import { propertyPresets } from '@blocksuite/data-view/property-presets';
|
||||
import { assertExists, Slot } from '@blocksuite/global/utils';
|
||||
import type { Block, Doc } from '@blocksuite/store';
|
||||
|
||||
import {
|
||||
databaseBlockAllPropertyMap,
|
||||
databasePropertyConverts,
|
||||
} from '../database-block/properties/index.js';
|
||||
import type { BlockMeta } from './block-meta/base.js';
|
||||
import { blockMetaMap } from './block-meta/index.js';
|
||||
import { queryBlockAllColumnMap, queryBlockColumns } from './columns/index.js';
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { BlockRenderer, NoteRenderer } from '@blocksuite/affine-block-database';
|
||||
import type { NoteBlockComponent } from '@blocksuite/affine-block-note';
|
||||
import { CaptionedBlockComponent } from '@blocksuite/affine-components/caption';
|
||||
import {
|
||||
@@ -39,8 +40,6 @@ import { computed, signal } from '@preact/signals-core';
|
||||
import { css, nothing, unsafeCSS } from 'lit';
|
||||
import { html } from 'lit/static-html.js';
|
||||
|
||||
import { BlockRenderer } from '../database-block/detail-panel/block-renderer.js';
|
||||
import { NoteRenderer } from '../database-block/detail-panel/note-renderer.js';
|
||||
import {
|
||||
EdgelessRootBlockComponent,
|
||||
type RootService,
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export * from './html.js';
|
||||
export * from './markdown.js';
|
||||
export * from './notion-html.js';
|
||||
@@ -1,30 +0,0 @@
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
|
||||
|
||||
import type { insertDatabaseBlockCommand } from './commands.js';
|
||||
|
||||
export function effects() {
|
||||
// TODO(@L-Sun): move other effects to this file
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockModels {
|
||||
'affine:database': DatabaseBlockModel;
|
||||
}
|
||||
|
||||
interface CommandContext {
|
||||
insertedDatabaseBlockId?: string;
|
||||
}
|
||||
|
||||
interface Commands {
|
||||
/**
|
||||
* insert a database block after or before the current block selection
|
||||
* @param latex the LaTeX content. A input dialog will be shown if not provided
|
||||
* @param removeEmptyLine remove the current block if it is empty
|
||||
* @param place where to insert the LaTeX block
|
||||
* @returns the id of the inserted LaTeX block
|
||||
*/
|
||||
insertDatabaseBlock: typeof insertDatabaseBlockCommand;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
|
||||
|
||||
export * from './adapters/markdown.js';
|
||||
export type { DatabaseOptionsConfig } from './config.js';
|
||||
export * from './data-source.js';
|
||||
export * from './database-block.js';
|
||||
export * from './database-service.js';
|
||||
export * from './database-spec.js';
|
||||
export { databaseBlockColumns } from './properties/index.js';
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockModels {
|
||||
'affine:database': DatabaseBlockModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { effects as blockAttachmentEffects } from '@blocksuite/affine-block-attachment/effects';
|
||||
import { effects as blockBookmarkEffects } from '@blocksuite/affine-block-bookmark/effects';
|
||||
import { effects as blockCodeEffects } from '@blocksuite/affine-block-code/effects';
|
||||
import { effects as blockDatabaseEffects } from '@blocksuite/affine-block-database/effects';
|
||||
import { effects as blockDividerEffects } from '@blocksuite/affine-block-divider/effects';
|
||||
import { effects as blockEdgelessTextEffects } from '@blocksuite/affine-block-edgeless-text/effects';
|
||||
import { effects as blockEmbedEffects } from '@blocksuite/affine-block-embed/effects';
|
||||
@@ -38,29 +39,6 @@ import type { BlockModel } from '@blocksuite/store';
|
||||
|
||||
import { registerSpecs } from './_specs/register-specs.js';
|
||||
import { DataViewBlockComponent } from './data-view-block/index.js';
|
||||
import { CenterPeek } from './database-block/components/layout.js';
|
||||
import { DatabaseTitle } from './database-block/components/title/index.js';
|
||||
import { BlockRenderer } from './database-block/detail-panel/block-renderer.js';
|
||||
import { NoteRenderer } from './database-block/detail-panel/note-renderer.js';
|
||||
import { effects as blockDatabaseEffects } from './database-block/effects.js';
|
||||
import {
|
||||
DatabaseBlockComponent,
|
||||
type DatabaseBlockService,
|
||||
} from './database-block/index.js';
|
||||
import {
|
||||
LinkCell,
|
||||
LinkCellEditing,
|
||||
} from './database-block/properties/link/cell-renderer.js';
|
||||
import { LinkNode } from './database-block/properties/link/components/link-node.js';
|
||||
import {
|
||||
RichTextCell,
|
||||
RichTextCellEditing,
|
||||
} from './database-block/properties/rich-text/cell-renderer.js';
|
||||
import { IconCell } from './database-block/properties/title/icon.js';
|
||||
import {
|
||||
HeaderAreaTextCell,
|
||||
HeaderAreaTextCellEditing,
|
||||
} from './database-block/properties/title/text.js';
|
||||
import { EdgelessAutoCompletePanel } from './root-block/edgeless/components/auto-complete/auto-complete-panel.js';
|
||||
import { EdgelessAutoComplete } from './root-block/edgeless/components/auto-complete/edgeless-auto-complete.js';
|
||||
import { EdgelessToolIconButton } from './root-block/edgeless/components/buttons/tool-icon-button.js';
|
||||
@@ -252,23 +230,6 @@ export function effects() {
|
||||
widgetDragHandleEffects();
|
||||
dataViewEffects();
|
||||
|
||||
customElements.define('affine-database-title', DatabaseTitle);
|
||||
customElements.define('data-view-header-area-icon', IconCell);
|
||||
customElements.define('affine-database-link-cell', LinkCell);
|
||||
customElements.define('affine-database-link-cell-editing', LinkCellEditing);
|
||||
customElements.define('data-view-header-area-text', HeaderAreaTextCell);
|
||||
customElements.define(
|
||||
'data-view-header-area-text-editing',
|
||||
HeaderAreaTextCellEditing
|
||||
);
|
||||
customElements.define('affine-database-rich-text-cell', RichTextCell);
|
||||
customElements.define(
|
||||
'affine-database-rich-text-cell-editing',
|
||||
RichTextCellEditing
|
||||
);
|
||||
customElements.define('center-peek', CenterPeek);
|
||||
customElements.define('database-datasource-note-renderer', NoteRenderer);
|
||||
customElements.define('database-datasource-block-renderer', BlockRenderer);
|
||||
customElements.define('affine-page-root', PageRootBlockComponent);
|
||||
customElements.define('affine-preview-root', PreviewRootBlockComponent);
|
||||
customElements.define('mini-mindmap-preview', MiniMindmapPreview);
|
||||
@@ -291,7 +252,6 @@ export function effects() {
|
||||
EdgelessRootPreviewBlockComponent
|
||||
);
|
||||
customElements.define('affine-custom-modal', AffineCustomModal);
|
||||
customElements.define('affine-database', DatabaseBlockComponent);
|
||||
customElements.define('affine-slash-menu', SlashMenu);
|
||||
customElements.define('inner-slash-menu', InnerSlashMenu);
|
||||
customElements.define('generating-placeholder', GeneratingPlaceholder);
|
||||
@@ -357,7 +317,6 @@ export function effects() {
|
||||
customElements.define('edgeless-note-tool-button', EdgelessNoteToolButton);
|
||||
customElements.define('edgeless-note-menu', EdgelessNoteMenu);
|
||||
customElements.define('edgeless-line-width-panel', EdgelessLineWidthPanel);
|
||||
customElements.define('affine-database-link-node', LinkNode);
|
||||
customElements.define(
|
||||
'edgeless-frame-order-button',
|
||||
EdgelessFrameOrderButton
|
||||
@@ -470,7 +429,6 @@ declare global {
|
||||
}
|
||||
interface BlockServices {
|
||||
'affine:page': RootService;
|
||||
'affine:database': DatabaseBlockService;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ export * from './_common/transformers/index.js';
|
||||
export { type AbstractEditor } from './_common/types.js';
|
||||
export * from './_specs/index.js';
|
||||
export * from './data-view-block';
|
||||
export * from './database-block';
|
||||
export { EdgelessTemplatePanel } from './root-block/edgeless/components/toolbar/template/template-panel.js';
|
||||
export type {
|
||||
Template,
|
||||
@@ -42,6 +41,7 @@ export {
|
||||
export * from '@blocksuite/affine-block-attachment';
|
||||
export * from '@blocksuite/affine-block-bookmark';
|
||||
export * from '@blocksuite/affine-block-code';
|
||||
export * from '@blocksuite/affine-block-database';
|
||||
export * from '@blocksuite/affine-block-divider';
|
||||
export * from '@blocksuite/affine-block-edgeless-text';
|
||||
export * from '@blocksuite/affine-block-embed';
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import type { ToolbarMoreMenuConfig } from '@blocksuite/affine-components/toolbar';
|
||||
|
||||
import type { DatabaseOptionsConfig } from '../database-block/config.js';
|
||||
import type { KeyboardToolbarConfig } from './widgets/keyboard-toolbar/config.js';
|
||||
import type { LinkedWidgetConfig } from './widgets/linked-doc/index.js';
|
||||
|
||||
export interface RootBlockConfig {
|
||||
linkedWidget?: Partial<LinkedWidgetConfig>;
|
||||
toolbarMoreMenu?: Partial<ToolbarMoreMenuConfig>;
|
||||
databaseOptions?: Partial<DatabaseOptionsConfig>;
|
||||
keyboardToolbar?: Partial<KeyboardToolbarConfig>;
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
import {
|
||||
convertToDatabase,
|
||||
DATABASE_CONVERT_WHITE_LIST,
|
||||
} from '@blocksuite/affine-block-database';
|
||||
import {
|
||||
convertSelectedBlocksToLinkedDoc,
|
||||
getTitleFromSelectedModels,
|
||||
@@ -43,8 +47,6 @@ import { assertExists } from '@blocksuite/global/utils';
|
||||
import { Slice } from '@blocksuite/store';
|
||||
import { html, type TemplateResult } from 'lit';
|
||||
|
||||
import { convertToDatabase } from '../../../database-block/data-source.js';
|
||||
import { DATABASE_CONVERT_WHITE_LIST } from '../../../database-block/utils/block-utils.js';
|
||||
import { FormatBarContext } from './context.js';
|
||||
import type { AffineFormatBarWidget } from './format-bar.js';
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
{
|
||||
"path": "../affine/block-bookmark"
|
||||
},
|
||||
{
|
||||
"path": "../affine/block-database"
|
||||
},
|
||||
{
|
||||
"path": "../affine/block-attachment"
|
||||
},
|
||||
|
||||
+1
-1
@@ -233,10 +233,10 @@ function getEditorConfigExtension(
|
||||
const editorSettingService = framework.get(EditorSettingService);
|
||||
return [
|
||||
EditorSettingExtension(editorSettingService.editorSetting.settingSignal),
|
||||
ConfigExtension('affine:database', createDatabaseOptionsConfig(framework)),
|
||||
ConfigExtension('affine:page', {
|
||||
linkedWidget: createLinkedWidgetConfig(framework),
|
||||
toolbarMoreMenu: createToolbarMoreMenuConfig(framework),
|
||||
databaseOptions: createDatabaseOptionsConfig(framework),
|
||||
} satisfies RootBlockConfig),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -55,6 +55,20 @@ export const PackageList = [
|
||||
'blocksuite/framework/store',
|
||||
],
|
||||
},
|
||||
{
|
||||
location: 'blocksuite/affine/block-database',
|
||||
name: '@blocksuite/affine-block-database',
|
||||
workspaceDependencies: [
|
||||
'blocksuite/affine/components',
|
||||
'blocksuite/affine/model',
|
||||
'blocksuite/affine/shared',
|
||||
'blocksuite/framework/block-std',
|
||||
'blocksuite/affine/data-view',
|
||||
'blocksuite/framework/global',
|
||||
'blocksuite/framework/inline',
|
||||
'blocksuite/framework/store',
|
||||
],
|
||||
},
|
||||
{
|
||||
location: 'blocksuite/affine/block-divider',
|
||||
name: '@blocksuite/affine-block-divider',
|
||||
@@ -292,6 +306,7 @@ export const PackageList = [
|
||||
'blocksuite/affine/block-attachment',
|
||||
'blocksuite/affine/block-bookmark',
|
||||
'blocksuite/affine/block-code',
|
||||
'blocksuite/affine/block-database',
|
||||
'blocksuite/affine/block-divider',
|
||||
'blocksuite/affine/block-edgeless-text',
|
||||
'blocksuite/affine/block-embed',
|
||||
@@ -643,6 +658,7 @@ export type PackageName =
|
||||
| '@blocksuite/affine-block-attachment'
|
||||
| '@blocksuite/affine-block-bookmark'
|
||||
| '@blocksuite/affine-block-code'
|
||||
| '@blocksuite/affine-block-database'
|
||||
| '@blocksuite/affine-block-divider'
|
||||
| '@blocksuite/affine-block-edgeless-text'
|
||||
| '@blocksuite/affine-block-embed'
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
{ "path": "./blocksuite/affine/block-attachment" },
|
||||
{ "path": "./blocksuite/affine/block-bookmark" },
|
||||
{ "path": "./blocksuite/affine/block-code" },
|
||||
{ "path": "./blocksuite/affine/block-database" },
|
||||
{ "path": "./blocksuite/affine/block-divider" },
|
||||
{ "path": "./blocksuite/affine/block-edgeless-text" },
|
||||
{ "path": "./blocksuite/affine/block-embed" },
|
||||
|
||||
@@ -3331,6 +3331,30 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@blocksuite/affine-block-database@workspace:*, @blocksuite/affine-block-database@workspace:blocksuite/affine/block-database":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@blocksuite/affine-block-database@workspace:blocksuite/affine/block-database"
|
||||
dependencies:
|
||||
"@blocksuite/affine-components": "workspace:*"
|
||||
"@blocksuite/affine-model": "workspace:*"
|
||||
"@blocksuite/affine-shared": "workspace:*"
|
||||
"@blocksuite/block-std": "workspace:*"
|
||||
"@blocksuite/data-view": "workspace:*"
|
||||
"@blocksuite/global": "workspace:*"
|
||||
"@blocksuite/inline": "workspace:*"
|
||||
"@blocksuite/store": "workspace:*"
|
||||
"@floating-ui/dom": "npm:^1.6.10"
|
||||
"@lit/context": "npm:^1.1.2"
|
||||
"@preact/signals-core": "npm:^1.8.0"
|
||||
"@toeverything/theme": "npm:^1.1.3"
|
||||
"@types/mdast": "npm:^4.0.4"
|
||||
date-fns: "npm:^4.0.0"
|
||||
lit: "npm:^3.2.0"
|
||||
minimatch: "npm:^10.0.1"
|
||||
zod: "npm:^3.23.8"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@blocksuite/affine-block-divider@workspace:*, @blocksuite/affine-block-divider@workspace:blocksuite/affine/block-divider":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@blocksuite/affine-block-divider@workspace:blocksuite/affine/block-divider"
|
||||
@@ -3753,6 +3777,7 @@ __metadata:
|
||||
"@blocksuite/affine-block-attachment": "workspace:*"
|
||||
"@blocksuite/affine-block-bookmark": "workspace:*"
|
||||
"@blocksuite/affine-block-code": "workspace:*"
|
||||
"@blocksuite/affine-block-database": "workspace:*"
|
||||
"@blocksuite/affine-block-divider": "workspace:*"
|
||||
"@blocksuite/affine-block-edgeless-text": "workspace:*"
|
||||
"@blocksuite/affine-block-embed": "workspace:*"
|
||||
|
||||
Reference in new issue
Block a user