mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
refactor(editor): remove block models global type (#10086)
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
import {
|
import {
|
||||||
isInsideEdgelessEditor,
|
isInsideEdgelessEditor,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ export const AttachmentDropOption = FileDropConfigExtension({
|
|||||||
|
|
||||||
const maxFileSize = std.store.get(FileSizeLimitService).maxFileSize;
|
const maxFileSize = std.store.get(FileSizeLimitService).maxFileSize;
|
||||||
|
|
||||||
if (targetModel && !matchFlavours(targetModel, [SurfaceBlockModel])) {
|
if (targetModel && !matchModels(targetModel, [SurfaceBlockModel])) {
|
||||||
addSiblingAttachmentBlocks(
|
addSiblingAttachmentBlocks(
|
||||||
std.host,
|
std.host,
|
||||||
attachmentFiles,
|
attachmentFiles,
|
||||||
|
|||||||
@@ -1,14 +1,5 @@
|
|||||||
import { DataViewBlockComponent } from './data-view-block';
|
import { DataViewBlockComponent } from './data-view-block';
|
||||||
import type { DataViewBlockModel } from './data-view-model';
|
|
||||||
|
|
||||||
export function effects() {
|
export function effects() {
|
||||||
customElements.define('affine-data-view', DataViewBlockComponent);
|
customElements.define('affine-data-view', DataViewBlockComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:data-view': DataViewBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ import {
|
|||||||
import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';
|
import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';
|
||||||
import { TelemetryProvider } from '@blocksuite/affine-shared/services';
|
import { TelemetryProvider } from '@blocksuite/affine-shared/services';
|
||||||
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
|
||||||
import {
|
import { createDefaultDoc, matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
createDefaultDoc,
|
|
||||||
matchFlavours,
|
|
||||||
} from '@blocksuite/affine-shared/utils';
|
|
||||||
import { type EditorHost, ShadowlessElement } from '@blocksuite/block-std';
|
import { type EditorHost, ShadowlessElement } from '@blocksuite/block-std';
|
||||||
import type { DetailSlotProps, SingleView } from '@blocksuite/data-view';
|
import type { DetailSlotProps, SingleView } from '@blocksuite/data-view';
|
||||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
||||||
@@ -75,7 +72,7 @@ export class NoteRenderer
|
|||||||
note.root.children
|
note.root.children
|
||||||
.find(child => child.flavour === 'affine:note')
|
.find(child => child.flavour === 'affine:note')
|
||||||
?.children.find(block =>
|
?.children.find(block =>
|
||||||
matchFlavours(block, [
|
matchModels(block, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockComponent } from '@blocksuite/block-std';
|
import type { BlockComponent } from '@blocksuite/block-std';
|
||||||
import {
|
import {
|
||||||
BlockSelection,
|
BlockSelection,
|
||||||
@@ -162,7 +162,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
|||||||
const firstChild = this.model.firstChild();
|
const firstChild = this.model.firstChild();
|
||||||
if (
|
if (
|
||||||
!firstChild ||
|
!firstChild ||
|
||||||
!matchFlavours(firstChild, [ListBlockModel, ParagraphBlockModel])
|
!matchModels(firstChild, [ListBlockModel, ParagraphBlockModel])
|
||||||
) {
|
) {
|
||||||
newParagraphId = this.doc.addBlock(
|
newParagraphId = this.doc.addBlock(
|
||||||
'affine:paragraph',
|
'affine:paragraph',
|
||||||
@@ -175,7 +175,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
|
|||||||
const lastChild = this.model.lastChild();
|
const lastChild = this.model.lastChild();
|
||||||
if (
|
if (
|
||||||
!lastChild ||
|
!lastChild ||
|
||||||
!matchFlavours(lastChild, [ListBlockModel, ParagraphBlockModel])
|
!matchModels(lastChild, [ListBlockModel, ParagraphBlockModel])
|
||||||
) {
|
) {
|
||||||
newParagraphId = this.doc.addBlock(
|
newParagraphId = this.doc.addBlock(
|
||||||
'affine:paragraph',
|
'affine:paragraph',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { EMBED_CARD_HEIGHT } from '@blocksuite/affine-shared/consts';
|
import { EMBED_CARD_HEIGHT } from '@blocksuite/affine-shared/consts';
|
||||||
import { NotificationProvider } from '@blocksuite/affine-shared/services';
|
import { NotificationProvider } from '@blocksuite/affine-shared/services';
|
||||||
import { matchFlavours, SpecProvider } from '@blocksuite/affine-shared/utils';
|
import { matchModels, SpecProvider } from '@blocksuite/affine-shared/utils';
|
||||||
import { BlockStdScope } from '@blocksuite/block-std';
|
import { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
import {
|
import {
|
||||||
@@ -71,7 +71,7 @@ async function renderPageAsBanner(card: EmbedSyncedDocCard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const target = notes.flatMap(note =>
|
const target = notes.flatMap(note =>
|
||||||
note.children.filter(child => matchFlavours(child, [ImageBlockModel]))
|
note.children.filter(child => matchModels(child, [ImageBlockModel]))
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
@@ -142,7 +142,7 @@ async function renderNoteContent(
|
|||||||
|
|
||||||
const noteChildren = notes.flatMap(note =>
|
const noteChildren = notes.flatMap(note =>
|
||||||
note.children.filter(model => {
|
note.children.filter(model => {
|
||||||
if (matchFlavours(model, allowFlavours)) {
|
if (matchModels(model, allowFlavours)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return filterTextModel(model);
|
return filterTextModel(model);
|
||||||
@@ -215,7 +215,7 @@ async function renderNoteContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function filterTextModel(model: BlockModel) {
|
function filterTextModel(model: BlockModel) {
|
||||||
if (matchFlavours(model, [ParagraphBlockModel, ListBlockModel])) {
|
if (matchModels(model, [ParagraphBlockModel, ListBlockModel])) {
|
||||||
return !!model.text?.toString().length;
|
return !!model.text?.toString().length;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -224,7 +224,7 @@ function filterTextModel(model: BlockModel) {
|
|||||||
export function getNotesFromDoc(doc: Store) {
|
export function getNotesFromDoc(doc: Store) {
|
||||||
const notes = doc.root?.children.filter(
|
const notes = doc.root?.children.filter(
|
||||||
child =>
|
child =>
|
||||||
matchFlavours(child, [NoteBlockModel]) &&
|
matchModels(child, [NoteBlockModel]) &&
|
||||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ export function getDocContentWithMaxLength(doc: Store, maxlength = 500) {
|
|||||||
export function getTitleFromSelectedModels(selectedModels: DraftModel[]) {
|
export function getTitleFromSelectedModels(selectedModels: DraftModel[]) {
|
||||||
const firstBlock = selectedModels[0];
|
const firstBlock = selectedModels[0];
|
||||||
if (
|
if (
|
||||||
matchFlavours(firstBlock, [ParagraphBlockModel]) &&
|
matchModels(firstBlock, [ParagraphBlockModel]) &&
|
||||||
firstBlock.type.startsWith('h')
|
firstBlock.type.startsWith('h')
|
||||||
) {
|
) {
|
||||||
return firstBlock.text.toString();
|
return firstBlock.text.toString();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
cloneReferenceInfoWithoutAliases,
|
cloneReferenceInfoWithoutAliases,
|
||||||
isNewTabTrigger,
|
isNewTabTrigger,
|
||||||
isNewViewTrigger,
|
isNewViewTrigger,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
referenceToNode,
|
referenceToNode,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { BlockSelection } from '@blocksuite/block-std';
|
import { BlockSelection } from '@blocksuite/block-std';
|
||||||
@@ -374,7 +374,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinke
|
|||||||
const isLoading = this._loading;
|
const isLoading = this._loading;
|
||||||
const isError = this.isError;
|
const isError = this.isError;
|
||||||
const isEmpty = this._isDocEmpty() && this.isBannerEmpty;
|
const isEmpty = this._isDocEmpty() && this.isBannerEmpty;
|
||||||
const inCanvas = matchFlavours(this.model.parent, [SurfaceBlockModel]);
|
const inCanvas = matchModels(this.model.parent, [SurfaceBlockModel]);
|
||||||
|
|
||||||
const cardClassMap = classMap({
|
const cardClassMap = classMap({
|
||||||
loading: isLoading,
|
loading: isLoading,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
import {
|
import {
|
||||||
isInsideEdgelessEditor,
|
isInsideEdgelessEditor,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { BlockService } from '@blocksuite/block-std';
|
import { BlockService } from '@blocksuite/block-std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
||||||
@@ -26,7 +26,7 @@ export const ImageDropOption = FileDropConfigExtension({
|
|||||||
|
|
||||||
const maxFileSize = std.store.get(FileSizeLimitService).maxFileSize;
|
const maxFileSize = std.store.get(FileSizeLimitService).maxFileSize;
|
||||||
|
|
||||||
if (targetModel && !matchFlavours(targetModel, [SurfaceBlockModel])) {
|
if (targetModel && !matchModels(targetModel, [SurfaceBlockModel])) {
|
||||||
addSiblingImageBlock(
|
addSiblingImageBlock(
|
||||||
std.host,
|
std.host,
|
||||||
imageFiles,
|
imageFiles,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { ListBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel } from '@blocksuite/affine-model';
|
||||||
import type { IndentContext } from '@blocksuite/affine-shared/types';
|
import type { IndentContext } from '@blocksuite/affine-shared/types';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { correctNumberedListsOrderToPrev } from './utils.js';
|
import { correctNumberedListsOrderToPrev } from './utils.js';
|
||||||
@@ -54,7 +54,7 @@ export const canDedentListCommand: Command<
|
|||||||
* ccc
|
* ccc
|
||||||
*/
|
*/
|
||||||
const model = store.getBlock(blockId)?.model;
|
const model = store.getBlock(blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ListBlockModel])) {
|
if (!model || !matchModels(model, [ListBlockModel])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ListBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';
|
|||||||
import type { IndentContext } from '@blocksuite/affine-shared/types';
|
import type { IndentContext } from '@blocksuite/affine-shared/types';
|
||||||
import {
|
import {
|
||||||
getNearestHeadingBefore,
|
getNearestHeadingBefore,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ export const canIndentListCommand: Command<
|
|||||||
* ccc
|
* ccc
|
||||||
*/
|
*/
|
||||||
const model = store.getBlock(blockId)?.model;
|
const model = store.getBlock(blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ListBlockModel])) {
|
if (!model || !matchModels(model, [ListBlockModel])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const schema = std.store.schema;
|
const schema = std.store.schema;
|
||||||
@@ -126,7 +126,7 @@ export const indentListCommand: Command<{
|
|||||||
const nearestHeading = getNearestHeadingBefore(model);
|
const nearestHeading = getNearestHeadingBefore(model);
|
||||||
if (
|
if (
|
||||||
nearestHeading &&
|
nearestHeading &&
|
||||||
matchFlavours(nearestHeading, [ParagraphBlockModel]) &&
|
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||||
nearestHeading.collapsed
|
nearestHeading.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(nearestHeading, {
|
store.updateBlock(nearestHeading, {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { focusTextModel } from '@blocksuite/affine-components/rich-text';
|
import { focusTextModel } from '@blocksuite/affine-components/rich-text';
|
||||||
import { ListBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
|
|
||||||
export const listToParagraphCommand: Command<
|
export const listToParagraphCommand: Command<
|
||||||
@@ -17,7 +17,7 @@ export const listToParagraphCommand: Command<
|
|||||||
const doc = std.store;
|
const doc = std.store;
|
||||||
const model = doc.getBlock(id)?.model;
|
const model = doc.getBlock(id)?.model;
|
||||||
|
|
||||||
if (!model || !matchFlavours(model, [ListBlockModel])) return false;
|
if (!model || !matchModels(model, [ListBlockModel])) return false;
|
||||||
|
|
||||||
const parent = doc.getParent(model);
|
const parent = doc.getParent(model);
|
||||||
if (!parent) return false;
|
if (!parent) return false;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { focusTextModel } from '@blocksuite/affine-components/rich-text';
|
|||||||
import { ListBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
getNextContinuousNumberedLists,
|
getNextContinuousNumberedLists,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command, EditorHost } from '@blocksuite/block-std';
|
import type { Command, EditorHost } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ export const splitListCommand: Command<{
|
|||||||
const doc = host.doc;
|
const doc = host.doc;
|
||||||
|
|
||||||
const model = doc.getBlock(blockId)?.model;
|
const model = doc.getBlock(blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ListBlockModel])) {
|
if (!model || !matchModels(model, [ListBlockModel])) {
|
||||||
console.error(`block ${blockId} is not a list block`);
|
console.error(`block ${blockId} is not a list block`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ListBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
getNextContinuousNumberedLists,
|
getNextContinuousNumberedLists,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockModel, Store } from '@blocksuite/store';
|
import type { BlockModel, Store } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ export function correctNumberedListsOrderToPrev(
|
|||||||
if (!model) return;
|
if (!model) return;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!matchFlavours(model, [ListBlockModel]) ||
|
!matchModels(model, [ListBlockModel]) ||
|
||||||
model.type$.value !== 'numbered'
|
model.type$.value !== 'numbered'
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
@@ -33,7 +33,7 @@ export function correctNumberedListsOrderToPrev(
|
|||||||
const previousSibling = doc.getPrev(model);
|
const previousSibling = doc.getPrev(model);
|
||||||
if (
|
if (
|
||||||
previousSibling &&
|
previousSibling &&
|
||||||
matchFlavours(previousSibling, [ListBlockModel]) &&
|
matchModels(previousSibling, [ListBlockModel]) &&
|
||||||
previousSibling.type === 'numbered'
|
previousSibling.type === 'numbered'
|
||||||
) {
|
) {
|
||||||
if (!previousSibling.order) previousSibling.order = 1;
|
if (!previousSibling.order) previousSibling.order = 1;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ListBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
getNextContentBlock,
|
getNextContentBlock,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';
|
import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';
|
||||||
import type { Text } from '@blocksuite/store';
|
import type { Text } from '@blocksuite/store';
|
||||||
@@ -26,7 +26,7 @@ export function forwardDelete(std: BlockStdScope): true | undefined {
|
|||||||
const isCollapsed = text.isCollapsed();
|
const isCollapsed = text.isCollapsed();
|
||||||
const doc = std.store;
|
const doc = std.store;
|
||||||
const model = doc.getBlock(text.from.blockId)?.model;
|
const model = doc.getBlock(text.from.blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ListBlockModel])) return;
|
if (!model || !matchModels(model, [ListBlockModel])) return;
|
||||||
const isEnd = isCollapsed && text.from.index === model.text.length;
|
const isEnd = isCollapsed && text.from.index === model.text.length;
|
||||||
if (!isEnd) return;
|
if (!isEnd) return;
|
||||||
// Has children in list
|
// Has children in list
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
getTextSelectionCommand,
|
getTextSelectionCommand,
|
||||||
} from '@blocksuite/affine-shared/commands';
|
} from '@blocksuite/affine-shared/commands';
|
||||||
import {
|
import {
|
||||||
matchFlavours,
|
matchModels,
|
||||||
mergeToCodeModel,
|
mergeToCodeModel,
|
||||||
transformModel,
|
transformModel,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
@@ -27,7 +27,7 @@ import {
|
|||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
type UpdateBlockConfig = {
|
type UpdateBlockConfig = {
|
||||||
flavour: BlockSuite.Flavour;
|
flavour: string;
|
||||||
props?: Record<string, unknown>;
|
props?: Record<string, unknown>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ export const updateBlockType: Command<
|
|||||||
const newModels: BlockModel[] = [];
|
const newModels: BlockModel[] = [];
|
||||||
blockModels.forEach(model => {
|
blockModels.forEach(model => {
|
||||||
if (
|
if (
|
||||||
!matchFlavours(model, [
|
!matchModels(model, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
|
|
||||||
export const changeNoteDisplayMode: Command<{
|
export const changeNoteDisplayMode: Command<{
|
||||||
@@ -10,8 +10,7 @@ export const changeNoteDisplayMode: Command<{
|
|||||||
const { std, noteId, mode, stopCapture } = ctx;
|
const { std, noteId, mode, stopCapture } = ctx;
|
||||||
|
|
||||||
const noteBlockModel = std.store.getBlock(noteId)?.model;
|
const noteBlockModel = std.store.getBlock(noteId)?.model;
|
||||||
if (!noteBlockModel || !matchFlavours(noteBlockModel, [NoteBlockModel]))
|
if (!noteBlockModel || !matchModels(noteBlockModel, [NoteBlockModel])) return;
|
||||||
return;
|
|
||||||
|
|
||||||
const currentMode = noteBlockModel.displayMode;
|
const currentMode = noteBlockModel.displayMode;
|
||||||
if (currentMode === mode) return;
|
if (currentMode === mode) return;
|
||||||
@@ -27,7 +26,7 @@ export const changeNoteDisplayMode: Command<{
|
|||||||
const parent = std.store.getParent(noteBlockModel);
|
const parent = std.store.getParent(noteBlockModel);
|
||||||
if (parent) {
|
if (parent) {
|
||||||
const notes = parent.children.filter(child =>
|
const notes = parent.children.filter(child =>
|
||||||
matchFlavours(child, [NoteBlockModel])
|
matchModels(child, [NoteBlockModel])
|
||||||
);
|
);
|
||||||
const firstEdgelessOnlyNote = notes.find(
|
const firstEdgelessOnlyNote = notes.find(
|
||||||
note => note.displayMode === NoteDisplayMode.EdgelessOnly
|
note => note.displayMode === NoteDisplayMode.EdgelessOnly
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NoteBlockModel } from '@blocksuite/affine-model';
|
import { NoteBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { dedentBlock } from './dedent-block';
|
import { dedentBlock } from './dedent-block';
|
||||||
@@ -21,7 +21,7 @@ export const dedentBlockToRoot: Command<{
|
|||||||
|
|
||||||
let parent = store.getParent(model);
|
let parent = store.getParent(model);
|
||||||
let changed = false;
|
let changed = false;
|
||||||
while (parent && !matchFlavours(parent, [NoteBlockModel])) {
|
while (parent && !matchModels(parent, [NoteBlockModel])) {
|
||||||
if (!changed) {
|
if (!changed) {
|
||||||
if (stopCapture) store.captureSync();
|
if (stopCapture) store.captureSync();
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ export const dedentBlock: Command<{
|
|||||||
if (stopCapture) store.captureSync();
|
if (stopCapture) store.captureSync();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [ParagraphBlockModel]) &&
|
matchModels(model, [ParagraphBlockModel]) &&
|
||||||
model.type.startsWith('h') &&
|
model.type.startsWith('h') &&
|
||||||
model.collapsed
|
model.collapsed
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { NoteBlockModel } from '@blocksuite/affine-model';
|
import { NoteBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { dedentBlockToRoot } from './dedent-block-to-root';
|
import { dedentBlockToRoot } from './dedent-block-to-root';
|
||||||
@@ -31,7 +31,7 @@ export const dedentBlocksToRoot: Command<{
|
|||||||
for (let i = blockIds.length - 1; i >= 0; i--) {
|
for (let i = blockIds.length - 1; i >= 0; i--) {
|
||||||
const model = blockIds[i];
|
const model = blockIds[i];
|
||||||
const parent = store.getParent(model);
|
const parent = store.getParent(model);
|
||||||
if (parent && !matchFlavours(parent, [NoteBlockModel])) {
|
if (parent && !matchModels(parent, [NoteBlockModel])) {
|
||||||
std.command.exec(dedentBlockToRoot, {
|
std.command.exec(dedentBlockToRoot, {
|
||||||
blockId: model,
|
blockId: model,
|
||||||
stopCapture: false,
|
stopCapture: false,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export const dedentBlocks: Command<{
|
|||||||
const model = store.getBlock(id)?.model;
|
const model = store.getBlock(id)?.model;
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [ParagraphBlockModel]) &&
|
matchModels(model, [ParagraphBlockModel]) &&
|
||||||
model.type.startsWith('h') &&
|
model.type.startsWith('h') &&
|
||||||
model.collapsed
|
model.collapsed
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ListBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ export const indentBlock: Command<{
|
|||||||
if (stopCapture) store.captureSync();
|
if (stopCapture) store.captureSync();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [ParagraphBlockModel]) &&
|
matchModels(model, [ParagraphBlockModel]) &&
|
||||||
model.type.startsWith('h') &&
|
model.type.startsWith('h') &&
|
||||||
model.collapsed
|
model.collapsed
|
||||||
) {
|
) {
|
||||||
@@ -62,7 +62,7 @@ export const indentBlock: Command<{
|
|||||||
|
|
||||||
// update collapsed state of affine list
|
// update collapsed state of affine list
|
||||||
if (
|
if (
|
||||||
matchFlavours(previousSibling, [ListBlockModel]) &&
|
matchModels(previousSibling, [ListBlockModel]) &&
|
||||||
previousSibling.collapsed
|
previousSibling.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(previousSibling, {
|
store.updateBlock(previousSibling, {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
|||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
getNearestHeadingBefore,
|
getNearestHeadingBefore,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ export const indentBlocks: Command<{
|
|||||||
const model = store.getBlock(id)?.model;
|
const model = store.getBlock(id)?.model;
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [ParagraphBlockModel]) &&
|
matchModels(model, [ParagraphBlockModel]) &&
|
||||||
model.type.startsWith('h') &&
|
model.type.startsWith('h') &&
|
||||||
model.collapsed
|
model.collapsed
|
||||||
) {
|
) {
|
||||||
@@ -84,7 +84,7 @@ export const indentBlocks: Command<{
|
|||||||
const nearestHeading = getNearestHeadingBefore(firstModel);
|
const nearestHeading = getNearestHeadingBefore(firstModel);
|
||||||
if (
|
if (
|
||||||
nearestHeading &&
|
nearestHeading &&
|
||||||
matchFlavours(nearestHeading, [ParagraphBlockModel]) &&
|
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||||
nearestHeading.collapsed
|
nearestHeading.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(nearestHeading, { collapsed: false });
|
store.updateBlock(nearestHeading, { collapsed: false });
|
||||||
@@ -105,7 +105,7 @@ export const indentBlocks: Command<{
|
|||||||
const nearestHeading = getNearestHeadingBefore(firstModel);
|
const nearestHeading = getNearestHeadingBefore(firstModel);
|
||||||
if (
|
if (
|
||||||
nearestHeading &&
|
nearestHeading &&
|
||||||
matchFlavours(nearestHeading, [ParagraphBlockModel]) &&
|
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||||
nearestHeading.collapsed
|
nearestHeading.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(nearestHeading, { collapsed: false });
|
store.updateBlock(nearestHeading, { collapsed: false });
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
|||||||
import {
|
import {
|
||||||
getClosestBlockComponentByPoint,
|
getClosestBlockComponentByPoint,
|
||||||
handleNativeRangeAtPoint,
|
handleNativeRangeAtPoint,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
stopPropagation,
|
stopPropagation,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
@@ -100,10 +100,10 @@ export class EdgelessNoteBackground extends SignalWatcher(
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
(!nearestModel.text ||
|
(!nearestModel.text ||
|
||||||
!matchFlavours(nearestModel, [ParagraphBlockModel, ListBlockModel])) &&
|
!matchModels(nearestModel, [ParagraphBlockModel, ListBlockModel])) &&
|
||||||
(!siblingModel ||
|
(!siblingModel ||
|
||||||
!siblingModel.text ||
|
!siblingModel.text ||
|
||||||
!matchFlavours(siblingModel, [ParagraphBlockModel, ListBlockModel]))
|
!matchModels(siblingModel, [ParagraphBlockModel, ListBlockModel]))
|
||||||
) {
|
) {
|
||||||
const [pId] = this.doc.addSiblingBlocks(
|
const [pId] = this.doc.addSiblingBlocks(
|
||||||
nearestModel,
|
nearestModel,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
getPrevBlockCommand,
|
getPrevBlockCommand,
|
||||||
getTextSelectionCommand,
|
getTextSelectionCommand,
|
||||||
} from '@blocksuite/affine-shared/commands';
|
} from '@blocksuite/affine-shared/commands';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
type BlockComponent,
|
type BlockComponent,
|
||||||
BlockSelection,
|
BlockSelection,
|
||||||
@@ -155,7 +155,7 @@ export class NoteBlockService extends BlockService {
|
|||||||
const doc = this._std.store;
|
const doc = this._std.store;
|
||||||
let parent = doc.getBlock(blockId)?.model ?? null;
|
let parent = doc.getBlock(blockId)?.model ?? null;
|
||||||
while (parent) {
|
while (parent) {
|
||||||
if (matchFlavours(parent, [NoteBlockModel])) {
|
if (matchModels(parent, [NoteBlockModel])) {
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
parent = doc.getParent(parent);
|
parent = doc.getParent(parent);
|
||||||
@@ -194,7 +194,7 @@ export class NoteBlockService extends BlockService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!matchFlavours(nextBlock.model, [
|
!matchModels(nextBlock.model, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
@@ -230,7 +230,7 @@ export class NoteBlockService extends BlockService {
|
|||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
if (
|
if (
|
||||||
matchFlavours(nextBlock.model, [
|
matchModels(nextBlock.model, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
@@ -284,7 +284,7 @@ export class NoteBlockService extends BlockService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!matchFlavours(prevBlock.model, [
|
!matchModels(prevBlock.model, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
@@ -318,7 +318,7 @@ export class NoteBlockService extends BlockService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(prevBlock.model, [
|
matchModels(prevBlock.model, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
||||||
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -11,7 +11,7 @@ export function isPageBlock(std: BlockStdScope, note: NoteBlockModel) {
|
|||||||
std.get(FeatureFlagService).getFlag('enable_page_block') &&
|
std.get(FeatureFlagService).getFlag('enable_page_block') &&
|
||||||
note.parent?.children.find(
|
note.parent?.children.find(
|
||||||
child =>
|
child =>
|
||||||
matchFlavours(child, [NoteBlockModel]) &&
|
matchModels(child, [NoteBlockModel]) &&
|
||||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||||
) === note
|
) === note
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
|||||||
import type { IndentContext } from '@blocksuite/affine-shared/types';
|
import type { IndentContext } from '@blocksuite/affine-shared/types';
|
||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export const canDedentParagraphCommand: Command<
|
|||||||
}
|
}
|
||||||
|
|
||||||
const model = store.getBlock(blockId)?.model;
|
const model = store.getBlock(blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) {
|
if (!model || !matchModels(model, [ParagraphBlockModel])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@ export const dedentParagraphCommand: Command<{
|
|||||||
store.captureSync();
|
store.captureSync();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [ParagraphBlockModel]) &&
|
matchModels(model, [ParagraphBlockModel]) &&
|
||||||
model.type.startsWith('h') &&
|
model.type.startsWith('h') &&
|
||||||
model.collapsed
|
model.collapsed
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { IndentContext } from '@blocksuite/affine-shared/types';
|
|||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
getNearestHeadingBefore,
|
getNearestHeadingBefore,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ export const canIndentParagraphCommand: Command<
|
|||||||
}
|
}
|
||||||
|
|
||||||
const model = std.store.getBlock(blockId)?.model;
|
const model = std.store.getBlock(blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) {
|
if (!model || !matchModels(model, [ParagraphBlockModel])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ export const indentParagraphCommand: Command<{
|
|||||||
const nearestHeading = getNearestHeadingBefore(model);
|
const nearestHeading = getNearestHeadingBefore(model);
|
||||||
if (
|
if (
|
||||||
nearestHeading &&
|
nearestHeading &&
|
||||||
matchFlavours(nearestHeading, [ParagraphBlockModel]) &&
|
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||||
nearestHeading.collapsed
|
nearestHeading.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(nearestHeading, {
|
store.updateBlock(nearestHeading, {
|
||||||
@@ -105,7 +105,7 @@ export const indentParagraphCommand: Command<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [ParagraphBlockModel]) &&
|
matchModels(model, [ParagraphBlockModel]) &&
|
||||||
model.type.startsWith('h') &&
|
model.type.startsWith('h') &&
|
||||||
model.collapsed
|
model.collapsed
|
||||||
) {
|
) {
|
||||||
@@ -124,7 +124,7 @@ export const indentParagraphCommand: Command<{
|
|||||||
const nearestHeading = getNearestHeadingBefore(model);
|
const nearestHeading = getNearestHeadingBefore(model);
|
||||||
if (
|
if (
|
||||||
nearestHeading &&
|
nearestHeading &&
|
||||||
matchFlavours(nearestHeading, [ParagraphBlockModel]) &&
|
matchModels(nearestHeading, [ParagraphBlockModel]) &&
|
||||||
nearestHeading.collapsed
|
nearestHeading.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(nearestHeading, {
|
store.updateBlock(nearestHeading, {
|
||||||
@@ -135,7 +135,7 @@ export const indentParagraphCommand: Command<{
|
|||||||
|
|
||||||
// update collapsed state of affine list
|
// update collapsed state of affine list
|
||||||
if (
|
if (
|
||||||
matchFlavours(previousSibling, [ListBlockModel]) &&
|
matchModels(previousSibling, [ListBlockModel]) &&
|
||||||
previousSibling.collapsed
|
previousSibling.collapsed
|
||||||
) {
|
) {
|
||||||
store.updateBlock(previousSibling, {
|
store.updateBlock(previousSibling, {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
getInlineEditorByModel,
|
getInlineEditorByModel,
|
||||||
} from '@blocksuite/affine-components/rich-text';
|
} from '@blocksuite/affine-components/rich-text';
|
||||||
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
export const splitParagraphCommand: Command<
|
export const splitParagraphCommand: Command<
|
||||||
@@ -24,7 +24,7 @@ export const splitParagraphCommand: Command<
|
|||||||
if (!blockId) return;
|
if (!blockId) return;
|
||||||
|
|
||||||
const model = store.getBlock(blockId)?.model;
|
const model = store.getBlock(blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;
|
if (!model || !matchModels(model, [ParagraphBlockModel])) return;
|
||||||
|
|
||||||
const inlineEditor = getInlineEditorByModel(host, model);
|
const inlineEditor = getInlineEditorByModel(host, model);
|
||||||
const range = inlineEditor?.getInlineRange();
|
const range = inlineEditor?.getInlineRange();
|
||||||
@@ -43,7 +43,7 @@ export const splitParagraphCommand: Command<
|
|||||||
store.captureSync();
|
store.captureSync();
|
||||||
const right = model.text.split(splitIndex, splitLength);
|
const right = model.text.split(splitIndex, splitLength);
|
||||||
const id = store.addBlock(
|
const id = store.addBlock(
|
||||||
model.flavour as BlockSuite.Flavour,
|
model.flavour,
|
||||||
{
|
{
|
||||||
text: right,
|
text: right,
|
||||||
type: model.type,
|
type: model.type,
|
||||||
@@ -62,7 +62,7 @@ export const splitParagraphCommand: Command<
|
|||||||
store.captureSync();
|
store.captureSync();
|
||||||
const right = model.text.split(splitIndex, splitLength);
|
const right = model.text.split(splitIndex, splitLength);
|
||||||
const id = store.addBlock(
|
const id = store.addBlock(
|
||||||
model.flavour as BlockSuite.Flavour,
|
model.flavour,
|
||||||
{
|
{
|
||||||
text: right,
|
text: right,
|
||||||
type: model.type,
|
type: model.type,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
calculateCollapsedSiblings,
|
calculateCollapsedSiblings,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { KeymapExtension, TextSelection } from '@blocksuite/block-std';
|
import { KeymapExtension, TextSelection } from '@blocksuite/block-std';
|
||||||
import { IS_MAC } from '@blocksuite/global/env';
|
import { IS_MAC } from '@blocksuite/global/env';
|
||||||
@@ -40,7 +40,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
|
|||||||
|
|
||||||
const { store } = std;
|
const { store } = std;
|
||||||
const model = store.getBlock(text.from.blockId)?.model;
|
const model = store.getBlock(text.from.blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;
|
if (!model || !matchModels(model, [ParagraphBlockModel])) return;
|
||||||
|
|
||||||
const event = ctx.get('keyboardState').raw;
|
const event = ctx.get('keyboardState').raw;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -71,7 +71,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
|
|||||||
const text = std.selection.find(TextSelection);
|
const text = std.selection.find(TextSelection);
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
const model = store.getBlock(text.from.blockId)?.model;
|
const model = store.getBlock(text.from.blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;
|
if (!model || !matchModels(model, [ParagraphBlockModel])) return;
|
||||||
const inlineEditor = getInlineEditorByModel(
|
const inlineEditor = getInlineEditorByModel(
|
||||||
std.host,
|
std.host,
|
||||||
text.from.blockId
|
text.from.blockId
|
||||||
@@ -98,7 +98,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
|
|||||||
const text = std.selection.find(TextSelection);
|
const text = std.selection.find(TextSelection);
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
const model = store.getBlock(text.from.blockId)?.model;
|
const model = store.getBlock(text.from.blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;
|
if (!model || !matchModels(model, [ParagraphBlockModel])) return;
|
||||||
const inlineEditor = getInlineEditorByModel(
|
const inlineEditor = getInlineEditorByModel(
|
||||||
std.host,
|
std.host,
|
||||||
text.from.blockId
|
text.from.blockId
|
||||||
@@ -151,7 +151,7 @@ export const ParagraphKeymapExtension = KeymapExtension(
|
|||||||
|
|
||||||
const rightText = model.text.split(range.index);
|
const rightText = model.text.split(range.index);
|
||||||
const newId = store.addBlock(
|
const newId = store.addBlock(
|
||||||
model.flavour as BlockSuite.Flavour,
|
model.flavour,
|
||||||
{ type: model.type, text: rightText },
|
{ type: model.type, text: rightText },
|
||||||
parent,
|
parent,
|
||||||
index + collapsedSiblings.length + 1
|
index + collapsedSiblings.length + 1
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
import { EMBED_BLOCK_MODEL_LIST } from '@blocksuite/affine-shared/consts';
|
import { EMBED_BLOCK_MODEL_LIST } from '@blocksuite/affine-shared/consts';
|
||||||
import {
|
import {
|
||||||
getNextContentBlock,
|
getNextContentBlock,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
BlockSelection,
|
BlockSelection,
|
||||||
@@ -25,7 +25,7 @@ export function forwardDelete(std: BlockStdScope) {
|
|||||||
if (!text) return;
|
if (!text) return;
|
||||||
const isCollapsed = text.isCollapsed();
|
const isCollapsed = text.isCollapsed();
|
||||||
const model = store.getBlock(text.from.blockId)?.model;
|
const model = store.getBlock(text.from.blockId)?.model;
|
||||||
if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;
|
if (!model || !matchModels(model, [ParagraphBlockModel])) return;
|
||||||
const isEnd = isCollapsed && text.from.index === model.text.length;
|
const isEnd = isCollapsed && text.from.index === model.text.length;
|
||||||
if (!isEnd) return;
|
if (!isEnd) return;
|
||||||
const parent = store.getParent(model);
|
const parent = store.getParent(model);
|
||||||
@@ -34,7 +34,7 @@ export function forwardDelete(std: BlockStdScope) {
|
|||||||
const nextSibling = store.getNext(model);
|
const nextSibling = store.getNext(model);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(nextSibling, [
|
matchModels(nextSibling, [
|
||||||
AttachmentBlockModel,
|
AttachmentBlockModel,
|
||||||
BookmarkBlockModel,
|
BookmarkBlockModel,
|
||||||
DatabaseBlockModel,
|
DatabaseBlockModel,
|
||||||
@@ -50,7 +50,7 @@ export function forwardDelete(std: BlockStdScope) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchFlavours(nextSibling, [ParagraphBlockModel, ListBlockModel])) {
|
if (matchModels(nextSibling, [ParagraphBlockModel, ListBlockModel])) {
|
||||||
model.text.join(nextSibling.text);
|
model.text.join(nextSibling.text);
|
||||||
if (nextSibling.children) {
|
if (nextSibling.children) {
|
||||||
const parent = store.getParent(nextSibling);
|
const parent = store.getParent(nextSibling);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import {
|
|||||||
focusTitle,
|
focusTitle,
|
||||||
getDocTitleInlineEditor,
|
getDocTitleInlineEditor,
|
||||||
getPrevContentBlock,
|
getPrevContentBlock,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { BlockSelection, type EditorHost } from '@blocksuite/block-std';
|
import { BlockSelection, type EditorHost } from '@blocksuite/block-std';
|
||||||
import type { BlockModel, Text } from '@blocksuite/store';
|
import type { BlockModel, Text } from '@blocksuite/store';
|
||||||
@@ -44,7 +44,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
|
|||||||
const parent = doc.getParent(model);
|
const parent = doc.getParent(model);
|
||||||
if (!parent) return false;
|
if (!parent) return false;
|
||||||
|
|
||||||
if (matchFlavours(parent, [EdgelessTextBlockModel])) {
|
if (matchModels(parent, [EdgelessTextBlockModel])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
|
|||||||
return handleNoPreviousSibling(editorHost, model);
|
return handleNoPreviousSibling(editorHost, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchFlavours(prevBlock, [ParagraphBlockModel, ListBlockModel])) {
|
if (matchModels(prevBlock, [ParagraphBlockModel, ListBlockModel])) {
|
||||||
const modelIndex = parent.children.indexOf(model);
|
const modelIndex = parent.children.indexOf(model);
|
||||||
if (
|
if (
|
||||||
(modelIndex === -1 || modelIndex === parent.children.length - 1) &&
|
(modelIndex === -1 || modelIndex === parent.children.length - 1) &&
|
||||||
@@ -74,7 +74,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
matchFlavours(prevBlock, [
|
matchModels(prevBlock, [
|
||||||
AttachmentBlockModel,
|
AttachmentBlockModel,
|
||||||
BookmarkBlockModel,
|
BookmarkBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
@@ -97,7 +97,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchFlavours(parent, [DatabaseBlockModel])) {
|
if (matchModels(parent, [DatabaseBlockModel])) {
|
||||||
doc.deleteBlock(model);
|
doc.deleteBlock(model);
|
||||||
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);
|
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);
|
||||||
return true;
|
return true;
|
||||||
@@ -115,7 +115,7 @@ function handleNoPreviousSibling(editorHost: EditorHost, model: ExtendedModel) {
|
|||||||
// Probably no title, e.g. in edgeless mode
|
// Probably no title, e.g. in edgeless mode
|
||||||
if (!titleEditor) {
|
if (!titleEditor) {
|
||||||
if (
|
if (
|
||||||
matchFlavours(parent, [EdgelessTextBlockModel]) ||
|
matchModels(parent, [EdgelessTextBlockModel]) ||
|
||||||
model.children.length > 0
|
model.children.length > 0
|
||||||
) {
|
) {
|
||||||
doc.deleteBlock(model, {
|
doc.deleteBlock(model, {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
FrameBlockModel,
|
FrameBlockModel,
|
||||||
type SurfaceRefProps,
|
type SurfaceRefProps,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { Command } from '@blocksuite/block-std';
|
import type { Command } from '@blocksuite/block-std';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ export const insertSurfaceRefBlockCommand: Command<
|
|||||||
|
|
||||||
if (element?.type === 'group') {
|
if (element?.type === 'group') {
|
||||||
surfaceRefProps.refFlavour = 'group';
|
surfaceRefProps.refFlavour = 'group';
|
||||||
} else if (matchFlavours(blockModel, [FrameBlockModel])) {
|
} else if (matchModels(blockModel, [FrameBlockModel])) {
|
||||||
surfaceRefProps.refFlavour = 'frame';
|
surfaceRefProps.refFlavour = 'frame';
|
||||||
} else {
|
} else {
|
||||||
console.error(`reference not found ${reference}`);
|
console.error(`reference not found ${reference}`);
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import {
|
|||||||
GfxBlockElementModel,
|
GfxBlockElementModel,
|
||||||
GfxControllerIdentifier,
|
GfxControllerIdentifier,
|
||||||
GfxExtension,
|
GfxExtension,
|
||||||
|
type GfxModel,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||||
import {
|
import {
|
||||||
@@ -249,7 +250,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
private readonly _previewSpec =
|
private readonly _previewSpec =
|
||||||
SpecProvider.getInstance().getSpec('edgeless:preview');
|
SpecProvider.getInstance().getSpec('edgeless:preview');
|
||||||
|
|
||||||
private _referencedModel: BlockSuite.EdgelessModel | null = null;
|
private _referencedModel: GfxModel | null = null;
|
||||||
|
|
||||||
private _referenceXYWH: SerializedXYWH | null = null;
|
private _referenceXYWH: SerializedXYWH | null = null;
|
||||||
|
|
||||||
@@ -321,10 +322,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
const surfaceModel = getSurfaceBlock(this.doc);
|
const surfaceModel = getSurfaceBlock(this.doc);
|
||||||
this._surfaceModel = surfaceModel;
|
this._surfaceModel = surfaceModel;
|
||||||
|
|
||||||
const findReferencedModel = (): [
|
const findReferencedModel = (): [GfxModel | null, string] => {
|
||||||
BlockSuite.EdgelessModel | null,
|
|
||||||
string,
|
|
||||||
] => {
|
|
||||||
if (!this.model.reference) return [null, this.doc.id];
|
if (!this.model.reference) return [null, this.doc.id];
|
||||||
|
|
||||||
if (this.doc.getBlock(this.model.reference)) {
|
if (this.doc.getBlock(this.model.reference)) {
|
||||||
@@ -541,10 +539,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
viewport.setViewportByBound(Bound.deserialize(this._referenceXYWH));
|
viewport.setViewportByBound(Bound.deserialize(this._referenceXYWH));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderMask(
|
private _renderMask(referencedModel: GfxModel, flavourOrType: string) {
|
||||||
referencedModel: BlockSuite.EdgelessModel,
|
|
||||||
flavourOrType: string
|
|
||||||
) {
|
|
||||||
const title = 'title' in referencedModel ? referencedModel.title : '';
|
const title = 'title' in referencedModel ? referencedModel.title : '';
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@@ -561,7 +556,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _renderRefContent(referencedModel: BlockSuite.EdgelessModel) {
|
private _renderRefContent(referencedModel: GfxModel) {
|
||||||
const [, , w, h] = deserializeXYWH(referencedModel.xywh);
|
const [, , w, h] = deserializeXYWH(referencedModel.xywh);
|
||||||
const flavourOrType =
|
const flavourOrType =
|
||||||
'flavour' in referencedModel
|
'flavour' in referencedModel
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { SurfaceBlockComponent } from './surface-block.js';
|
import { SurfaceBlockComponent } from './surface-block.js';
|
||||||
import { SurfaceBlockVoidComponent } from './surface-block-void.js';
|
import { SurfaceBlockVoidComponent } from './surface-block-void.js';
|
||||||
import type { SurfaceBlockModel } from './surface-model.js';
|
|
||||||
import type { SurfaceBlockService } from './surface-service.js';
|
import type { SurfaceBlockService } from './surface-service.js';
|
||||||
|
|
||||||
export function effects() {
|
export function effects() {
|
||||||
@@ -13,8 +12,5 @@ declare global {
|
|||||||
interface BlockServices {
|
interface BlockServices {
|
||||||
'affine:surface': SurfaceBlockService;
|
'affine:surface': SurfaceBlockService;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:surface': SurfaceBlockModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { EditPropsStore } from '@blocksuite/affine-shared/services';
|
import { EditPropsStore } from '@blocksuite/affine-shared/services';
|
||||||
import { type BlockStdScope, StdIdentifier } from '@blocksuite/block-std';
|
import { type BlockStdScope, StdIdentifier } from '@blocksuite/block-std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import {
|
||||||
|
GfxControllerIdentifier,
|
||||||
|
type GfxModel,
|
||||||
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { type Container, createIdentifier } from '@blocksuite/global/di';
|
import { type Container, createIdentifier } from '@blocksuite/global/di';
|
||||||
import { type BlockModel, Extension } from '@blocksuite/store';
|
import { type BlockModel, Extension } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -30,7 +33,7 @@ export class EdgelessCRUDExtension extends Extension {
|
|||||||
return this._gfx.surface as SurfaceBlockModel | null;
|
return this._gfx.surface as SurfaceBlockModel | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteElements = (elements: BlockSuite.EdgelessModel[]) => {
|
deleteElements = (elements: GfxModel[]) => {
|
||||||
const surface = this._surface;
|
const surface = this._surface;
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
console.error('surface is not initialized');
|
console.error('surface is not initialized');
|
||||||
@@ -134,7 +137,7 @@ export class EdgelessCRUDExtension extends Extension {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getElementById(id: string): BlockSuite.EdgelessModel | null {
|
getElementById(id: string): GfxModel | null {
|
||||||
const surface = this._surface;
|
const surface = this._surface;
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
import type { NoteBlockModel } from '@blocksuite/affine-model';
|
import type { NoteBlockModel } from '@blocksuite/affine-model';
|
||||||
|
import type { GfxModel } from '@blocksuite/block-std/gfx';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { Connectable } from '../managers/connector-manager';
|
import type { Connectable } from '../managers/connector-manager';
|
||||||
|
|
||||||
export function isConnectable(
|
export function isConnectable(
|
||||||
element: BlockSuite.EdgelessModel | null
|
element: GfxModel | null
|
||||||
): element is Connectable {
|
): element is Connectable {
|
||||||
return !!element && element.connectable;
|
return !!element && element.connectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isNoteBlock(
|
export function isNoteBlock(
|
||||||
element: BlockModel | BlockSuite.EdgelessModel | null
|
element: BlockModel | GfxModel | null
|
||||||
): element is NoteBlockModel {
|
): element is NoteBlockModel {
|
||||||
return !!element && 'flavour' in element && element.flavour === 'affine:note';
|
return !!element && 'flavour' in element && element.flavour === 'affine:note';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import { Overlay } from '../renderer/overlay.js';
|
|||||||
import { AStarRunner } from '../utils/a-star.js';
|
import { AStarRunner } from '../utils/a-star.js';
|
||||||
|
|
||||||
export type Connectable = Exclude<
|
export type Connectable = Exclude<
|
||||||
BlockSuite.EdgelessModel,
|
GfxModel,
|
||||||
ConnectorElementModel | BrushElementModel | GroupElementModel
|
ConnectorElementModel | BrushElementModel | GroupElementModel
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ export function addNote(
|
|||||||
const doc = std.store;
|
const doc = std.store;
|
||||||
|
|
||||||
const blockId = doc.addBlock(
|
const blockId = doc.addBlock(
|
||||||
options.childFlavour as BlockSuite.Flavour,
|
options.childFlavour,
|
||||||
{ type: options.childType },
|
{ type: options.childType },
|
||||||
noteId
|
noteId
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
type RootBlockModel,
|
type RootBlockModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import { ShadowlessElement } from '@blocksuite/block-std';
|
import { ShadowlessElement } from '@blocksuite/block-std';
|
||||||
import { WithDisposable } from '@blocksuite/global/utils';
|
import { WithDisposable } from '@blocksuite/global/utils';
|
||||||
import type { Store } from '@blocksuite/store';
|
import type { Store } from '@blocksuite/store';
|
||||||
@@ -72,7 +72,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {
|
|||||||
private _getOrCreateFirstPageVisibleNote() {
|
private _getOrCreateFirstPageVisibleNote() {
|
||||||
const note = this._rootModel.children.find(
|
const note = this._rootModel.children.find(
|
||||||
(child): child is NoteBlockModel =>
|
(child): child is NoteBlockModel =>
|
||||||
matchFlavours(child, [NoteBlockModel]) &&
|
matchModels(child, [NoteBlockModel]) &&
|
||||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||||
);
|
);
|
||||||
if (note) return note;
|
if (note) return note;
|
||||||
@@ -105,7 +105,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {
|
|||||||
|
|
||||||
const note = this._getOrCreateFirstPageVisibleNote();
|
const note = this._getOrCreateFirstPageVisibleNote();
|
||||||
const firstText = note?.children.find(block =>
|
const firstText = note?.children.find(block =>
|
||||||
matchFlavours(block, [
|
matchModels(block, [
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
ListBlockModel,
|
ListBlockModel,
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
type DropTarget,
|
type DropTarget,
|
||||||
getClosestBlockComponentByPoint,
|
getClosestBlockComponentByPoint,
|
||||||
isInsidePageEditor,
|
isInsidePageEditor,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
type BlockComponent,
|
type BlockComponent,
|
||||||
@@ -59,7 +59,7 @@ export class FileDropExtension extends LifeCycleWatcher {
|
|||||||
const model = element.model;
|
const model = element.model;
|
||||||
const parent = this.std.store.getParent(model);
|
const parent = this.std.store.getParent(model);
|
||||||
|
|
||||||
if (!matchFlavours(parent, [SurfaceBlockModel])) {
|
if (!matchModels(parent, [SurfaceBlockModel])) {
|
||||||
const point = this.point$.value;
|
const point = this.point$.value;
|
||||||
target = point && calcDropTarget(point, model, element);
|
target = point && calcDropTarget(point, model, element);
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ export class FileDropExtension extends LifeCycleWatcher {
|
|||||||
if (!rootModel) return null;
|
if (!rootModel) return null;
|
||||||
|
|
||||||
let lastNote = rootModel.children[rootModel.children.length - 1];
|
let lastNote = rootModel.children[rootModel.children.length - 1];
|
||||||
if (!lastNote || !matchFlavours(lastNote, [NoteBlockModel])) {
|
if (!lastNote || !matchModels(lastNote, [NoteBlockModel])) {
|
||||||
const newNoteId = this.doc.addBlock('affine:note', {}, rootModel.id);
|
const newNoteId = this.doc.addBlock('affine:note', {}, rootModel.id);
|
||||||
const newNote = this.doc.getBlock(newNoteId)?.model;
|
const newNote = this.doc.getBlock(newNoteId)?.model;
|
||||||
if (!newNote) return null;
|
if (!newNote) return null;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
* which are also used for registering hotkeys for converting block flavours.
|
* which are also used for registering hotkeys for converting block flavours.
|
||||||
*/
|
*/
|
||||||
export interface TextConversionConfig {
|
export interface TextConversionConfig {
|
||||||
flavour: BlockSuite.Flavour;
|
flavour: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { DatabaseBlockModel } from '@blocksuite/affine-model';
|
|||||||
import {
|
import {
|
||||||
asyncGetBlockComponent,
|
asyncGetBlockComponent,
|
||||||
getCurrentNativeRange,
|
getCurrentNativeRange,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
type BlockStdScope,
|
type BlockStdScope,
|
||||||
@@ -42,7 +42,7 @@ export function getInlineEditorByModel(
|
|||||||
typeof model === 'string'
|
typeof model === 'string'
|
||||||
? editorHost.std.store.getBlock(model)?.model
|
? editorHost.std.store.getBlock(model)?.model
|
||||||
: model;
|
: model;
|
||||||
if (!blockModel || matchFlavours(blockModel, [DatabaseBlockModel])) {
|
if (!blockModel || matchModels(blockModel, [DatabaseBlockModel])) {
|
||||||
// Not support database model since it's may be have multiple inline editor instances.
|
// Not support database model since it's may be have multiple inline editor instances.
|
||||||
// Support to enter the editing state through the Enter key in the database.
|
// Support to enter the editing state through the Enter key in the database.
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { RootBlockModel } from '@blocksuite/affine-model';
|
import { RootBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import { type Command, TextSelection } from '@blocksuite/block-std';
|
import { type Command, TextSelection } from '@blocksuite/block-std';
|
||||||
import type { Text } from '@blocksuite/store';
|
import type { Text } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ export const deleteTextCommand: Command<{
|
|||||||
if (!fromElement) return;
|
if (!fromElement) return;
|
||||||
|
|
||||||
let fromText: Text | undefined;
|
let fromText: Text | undefined;
|
||||||
if (matchFlavours(fromElement.model, [RootBlockModel])) {
|
if (matchModels(fromElement.model, [RootBlockModel])) {
|
||||||
fromText = fromElement.model.title;
|
fromText = fromElement.model.title;
|
||||||
} else {
|
} else {
|
||||||
fromText = fromElement.model.text;
|
fromText = fromElement.model.text;
|
||||||
|
|||||||
@@ -28,10 +28,7 @@ export const formatBlockCommand: Command<{
|
|||||||
.chain()
|
.chain()
|
||||||
.pipe(getSelectedBlocksCommand, {
|
.pipe(getSelectedBlocksCommand, {
|
||||||
blockSelections,
|
blockSelections,
|
||||||
filter: el =>
|
filter: el => FORMAT_BLOCK_SUPPORT_FLAVOURS.includes(el.model.flavour),
|
||||||
FORMAT_BLOCK_SUPPORT_FLAVOURS.includes(
|
|
||||||
el.model.flavour as BlockSuite.Flavour
|
|
||||||
),
|
|
||||||
types: ['block'],
|
types: ['block'],
|
||||||
})
|
})
|
||||||
.pipe((ctx, next) => {
|
.pipe((ctx, next) => {
|
||||||
|
|||||||
@@ -31,9 +31,7 @@ export const formatNativeCommand: Command<{
|
|||||||
.filter(el => {
|
.filter(el => {
|
||||||
const block = el.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);
|
const block = el.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);
|
||||||
if (block) {
|
if (block) {
|
||||||
return FORMAT_NATIVE_SUPPORT_FLAVOURS.includes(
|
return FORMAT_NATIVE_SUPPORT_FLAVOURS.includes(block.model.flavour);
|
||||||
block.model.flavour as BlockSuite.Flavour
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,10 +22,7 @@ export const formatTextCommand: Command<{
|
|||||||
.chain()
|
.chain()
|
||||||
.pipe(getSelectedBlocksCommand, {
|
.pipe(getSelectedBlocksCommand, {
|
||||||
textSelection,
|
textSelection,
|
||||||
filter: el =>
|
filter: el => FORMAT_TEXT_SUPPORT_FLAVOURS.includes(el.model.flavour),
|
||||||
FORMAT_TEXT_SUPPORT_FLAVOURS.includes(
|
|
||||||
el.model.flavour as BlockSuite.Flavour
|
|
||||||
),
|
|
||||||
types: ['text'],
|
types: ['text'],
|
||||||
})
|
})
|
||||||
.pipe((ctx, next) => {
|
.pipe((ctx, next) => {
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
import { CodeBlockModel } from '@blocksuite/affine-model';
|
import { CodeBlockModel } from '@blocksuite/affine-model';
|
||||||
import { BRACKET_PAIRS } from '@blocksuite/affine-shared/consts';
|
import { BRACKET_PAIRS } from '@blocksuite/affine-shared/consts';
|
||||||
import {
|
import { createDefaultDoc, matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
createDefaultDoc,
|
|
||||||
matchFlavours,
|
|
||||||
} from '@blocksuite/affine-shared/utils';
|
|
||||||
import {
|
import {
|
||||||
type BlockStdScope,
|
type BlockStdScope,
|
||||||
TextSelection,
|
TextSelection,
|
||||||
@@ -29,7 +26,7 @@ export const bracketKeymap = (
|
|||||||
if (!textSelection) return;
|
if (!textSelection) return;
|
||||||
const model = doc.getBlock(textSelection.from.blockId)?.model;
|
const model = doc.getBlock(textSelection.from.blockId)?.model;
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
if (!matchFlavours(model, [CodeBlockModel])) return;
|
if (!matchModels(model, [CodeBlockModel])) return;
|
||||||
const inlineEditor = getInlineEditorByModel(
|
const inlineEditor = getInlineEditorByModel(
|
||||||
std.host,
|
std.host,
|
||||||
textSelection.from.blockId
|
textSelection.from.blockId
|
||||||
@@ -56,7 +53,7 @@ export const bracketKeymap = (
|
|||||||
const model = doc.getBlock(textSelection.from.blockId)?.model;
|
const model = doc.getBlock(textSelection.from.blockId)?.model;
|
||||||
if (!model) return;
|
if (!model) return;
|
||||||
|
|
||||||
const isCodeBlock = matchFlavours(model, [CodeBlockModel]);
|
const isCodeBlock = matchModels(model, [CodeBlockModel]);
|
||||||
// When selection is collapsed, only trigger auto complete in code block
|
// When selection is collapsed, only trigger auto complete in code block
|
||||||
if (textSelection.isCollapsed() && !isCodeBlock) return;
|
if (textSelection.isCollapsed() && !isCodeBlock) return;
|
||||||
if (!textSelection.isInSameBlock()) return;
|
if (!textSelection.isInSameBlock()) return;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
DividerBlockModel,
|
DividerBlockModel,
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -16,8 +16,8 @@ export function toDivider(
|
|||||||
) {
|
) {
|
||||||
const { store: doc } = std;
|
const { store: doc } = std;
|
||||||
if (
|
if (
|
||||||
matchFlavours(model, [DividerBlockModel]) ||
|
matchModels(model, [DividerBlockModel]) ||
|
||||||
(matchFlavours(model, [ParagraphBlockModel]) && model.type === 'quote')
|
(matchModels(model, [ParagraphBlockModel]) && model.type === 'quote')
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import {
|
|||||||
type ListType,
|
type ListType,
|
||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { matchFlavours, toNumberedList } from '@blocksuite/affine-shared/utils';
|
import { matchModels, toNumberedList } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ export function toList(
|
|||||||
prefix: string,
|
prefix: string,
|
||||||
otherProperties?: Partial<ListProps>
|
otherProperties?: Partial<ListProps>
|
||||||
) {
|
) {
|
||||||
if (!matchFlavours(model, [ParagraphBlockModel])) {
|
if (!matchModels(model, [ParagraphBlockModel])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { store: doc } = std;
|
const { store: doc } = std;
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import { CodeBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { CodeBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import {
|
import { isMarkdownPrefix, matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
isMarkdownPrefix,
|
|
||||||
matchFlavours,
|
|
||||||
} from '@blocksuite/affine-shared/utils';
|
|
||||||
import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';
|
import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { getInlineEditorByModel } from '../dom.js';
|
import { getInlineEditorByModel } from '../dom.js';
|
||||||
@@ -32,10 +29,10 @@ export function markdownInput(
|
|||||||
const prefixText = getPrefixText(inline);
|
const prefixText = getPrefixText(inline);
|
||||||
if (!isMarkdownPrefix(prefixText)) return;
|
if (!isMarkdownPrefix(prefixText)) return;
|
||||||
|
|
||||||
const isParagraph = matchFlavours(model, [ParagraphBlockModel]);
|
const isParagraph = matchModels(model, [ParagraphBlockModel]);
|
||||||
const isHeading = isParagraph && model.type.startsWith('h');
|
const isHeading = isParagraph && model.type.startsWith('h');
|
||||||
const isParagraphQuoteBlock = isParagraph && model.type === 'quote';
|
const isParagraphQuoteBlock = isParagraph && model.type === 'quote';
|
||||||
const isCodeBlock = matchFlavours(model, [CodeBlockModel]);
|
const isCodeBlock = matchModels(model, [CodeBlockModel]);
|
||||||
if (isHeading || isParagraphQuoteBlock || isCodeBlock) return;
|
if (isHeading || isParagraphQuoteBlock || isCodeBlock) return;
|
||||||
|
|
||||||
const lineInfo = inline.getLine(range.index);
|
const lineInfo = inline.getLine(range.index);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
ParagraphBlockModel,
|
ParagraphBlockModel,
|
||||||
type ParagraphType,
|
type ParagraphType,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ export function toParagraph(
|
|||||||
prefix: string
|
prefix: string
|
||||||
) {
|
) {
|
||||||
const { store: doc } = std;
|
const { store: doc } = std;
|
||||||
if (!matchFlavours(model, [ParagraphBlockModel])) {
|
if (!matchModels(model, [ParagraphBlockModel])) {
|
||||||
const parent = doc.getParent(model);
|
const parent = doc.getParent(model);
|
||||||
if (!parent) return;
|
if (!parent) return;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ export function toParagraph(
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchFlavours(model, [ParagraphBlockModel]) && model.type !== type) {
|
if (matchModels(model, [ParagraphBlockModel]) && model.type !== type) {
|
||||||
beforeConvert(std, model, prefix.length);
|
beforeConvert(std, model, prefix.length);
|
||||||
|
|
||||||
doc.updateBlock(model, { type });
|
doc.updateBlock(model, { type });
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ export function toCode(
|
|||||||
prefixText: string,
|
prefixText: string,
|
||||||
language: string | null
|
language: string | null
|
||||||
) {
|
) {
|
||||||
if (matchFlavours(model, [ParagraphBlockModel]) && model.type === 'quote') {
|
if (matchModels(model, [ParagraphBlockModel]) && model.type === 'quote') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:attachment': AttachmentBlockModel;
|
'affine:attachment': AttachmentBlockModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:attachment': AttachmentBlockModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:bookmark': BookmarkBlockModel;
|
'affine:bookmark': BookmarkBlockModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:bookmark': BookmarkBlockModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,11 +33,3 @@ export const CodeBlockSchema = defineBlockSchema({
|
|||||||
export class CodeBlockModel extends BlockModel<CodeBlockProps> {
|
export class CodeBlockModel extends BlockModel<CodeBlockProps> {
|
||||||
override text!: Text;
|
override text!: Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:code': CodeBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -28,11 +28,3 @@ export const DatabaseBlockSchema = defineBlockSchema({
|
|||||||
},
|
},
|
||||||
toModel: () => new DatabaseBlockModel(),
|
toModel: () => new DatabaseBlockModel(),
|
||||||
});
|
});
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:database': DatabaseBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -15,11 +15,3 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export class DividerBlockModel extends BlockModel<Props> {}
|
export class DividerBlockModel extends BlockModel<Props> {}
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:divider': DividerBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -82,10 +82,6 @@ export class EdgelessTextBlockModel
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace BlockSuite {
|
namespace BlockSuite {
|
||||||
interface BlockModels {
|
|
||||||
'affine:edgeless-text': EdgelessTextBlockModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:edgeless-text': EdgelessTextBlockModel;
|
'affine:edgeless-text': EdgelessTextBlockModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-figma': EmbedFigmaModel;
|
'affine:embed-figma': EmbedFigmaModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-figma': EmbedFigmaModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-github': EmbedGithubModel;
|
'affine:embed-github': EmbedGithubModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-github': EmbedGithubModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-html': EmbedHtmlModel;
|
'affine:embed-html': EmbedHtmlModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-html': EmbedHtmlModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-linked-doc': EmbedLinkedDocModel;
|
'affine:embed-linked-doc': EmbedLinkedDocModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-linked-doc': EmbedLinkedDocModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,8 +27,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-loom': EmbedLoomModel;
|
'affine:embed-loom': EmbedLoomModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-loom': EmbedLoomModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-synced-doc': EmbedSyncedDocModel;
|
'affine:embed-synced-doc': EmbedSyncedDocModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-synced-doc': EmbedSyncedDocModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:embed-youtube': EmbedYoutubeModel;
|
'affine:embed-youtube': EmbedYoutubeModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:embed-youtube': EmbedYoutubeModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,8 +150,5 @@ declare global {
|
|||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:frame': FrameBlockModel;
|
'affine:frame': FrameBlockModel;
|
||||||
}
|
}
|
||||||
interface BlockModels {
|
|
||||||
'affine:frame': FrameBlockModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,9 +45,6 @@ export class ImageBlockModel
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace BlockSuite {
|
namespace BlockSuite {
|
||||||
interface BlockModels {
|
|
||||||
'affine:image': ImageBlockModel;
|
|
||||||
}
|
|
||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:image': ImageBlockModel;
|
'affine:image': ImageBlockModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,6 @@ export class LatexBlockModel
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace BlockSuite {
|
namespace BlockSuite {
|
||||||
interface BlockModels {
|
|
||||||
'affine:latex': LatexBlockModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:latex': LatexBlockModel;
|
'affine:latex': LatexBlockModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,11 +41,3 @@ export const ListBlockSchema = defineBlockSchema({
|
|||||||
export class ListBlockModel extends BlockModel<ListProps> {
|
export class ListBlockModel extends BlockModel<ListProps> {
|
||||||
override text!: Text;
|
override text!: Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:list': ListBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -158,9 +158,6 @@ export class NoteBlockModel
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace BlockSuite {
|
namespace BlockSuite {
|
||||||
interface BlockModels {
|
|
||||||
'affine:note': NoteBlockModel;
|
|
||||||
}
|
|
||||||
interface EdgelessBlockModelMap {
|
interface EdgelessBlockModelMap {
|
||||||
'affine:note': NoteBlockModel;
|
'affine:note': NoteBlockModel;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,11 +44,3 @@ export class ParagraphBlockModel extends BlockModel<ParagraphProps> {
|
|||||||
return this.text$.value.length === 0 && this.children.length === 0;
|
return this.text$.value.length === 0 && this.children.length === 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:paragraph': ParagraphBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -51,11 +51,3 @@ export const RootBlockSchema = defineBlockSchema({
|
|||||||
},
|
},
|
||||||
toModel: () => new RootBlockModel(),
|
toModel: () => new RootBlockModel(),
|
||||||
});
|
});
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:page': RootBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -22,11 +22,3 @@ export const SurfaceRefBlockSchema = defineBlockSchema({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export class SurfaceRefBlockModel extends BlockModel<SurfaceRefProps> {}
|
export class SurfaceRefBlockModel extends BlockModel<SurfaceRefProps> {}
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
'affine:surface-ref': SurfaceRefBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -56,11 +56,3 @@ export const TableBlockSchema = defineBlockSchema({
|
|||||||
},
|
},
|
||||||
toModel: () => new TableBlockModel(),
|
toModel: () => new TableBlockModel(),
|
||||||
});
|
});
|
||||||
|
|
||||||
declare global {
|
|
||||||
namespace BlockSuite {
|
|
||||||
interface BlockModels {
|
|
||||||
[TableModelFlavour]: TableBlockModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import type {
|
|||||||
GfxBlockElementModel,
|
GfxBlockElementModel,
|
||||||
GfxGroupLikeElementModel,
|
GfxGroupLikeElementModel,
|
||||||
GfxLocalElementModel,
|
GfxLocalElementModel,
|
||||||
GfxModel,
|
|
||||||
GfxPrimitiveElementModel,
|
GfxPrimitiveElementModel,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
|
|
||||||
@@ -14,8 +13,6 @@ declare global {
|
|||||||
| EdgelessBlockModelMap[EdgelessBlockModelKeyType]
|
| EdgelessBlockModelMap[EdgelessBlockModelKeyType]
|
||||||
| GfxBlockElementModel;
|
| GfxBlockElementModel;
|
||||||
|
|
||||||
type EdgelessModel = GfxModel;
|
|
||||||
|
|
||||||
interface EdgelessTextModelMap {}
|
interface EdgelessTextModelMap {}
|
||||||
type EdgelessTextModelKeyType = keyof EdgelessTextModelMap;
|
type EdgelessTextModelKeyType = keyof EdgelessTextModelMap;
|
||||||
type EdgelessTextModelType = EdgelessTextModelMap[EdgelessTextModelKeyType];
|
type EdgelessTextModelType = EdgelessTextModelMap[EdgelessTextModelKeyType];
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import type {
|
|||||||
TransformerSlots,
|
TransformerSlots,
|
||||||
} from '@blocksuite/store';
|
} from '@blocksuite/store';
|
||||||
|
|
||||||
import { matchFlavours } from '../../utils';
|
import { matchModels } from '../../utils';
|
||||||
|
|
||||||
const handlePoint = (
|
const handlePoint = (
|
||||||
point: TextRangePoint,
|
point: TextRangePoint,
|
||||||
@@ -20,7 +20,7 @@ const handlePoint = (
|
|||||||
model: DraftModel
|
model: DraftModel
|
||||||
) => {
|
) => {
|
||||||
const { index, length } = point;
|
const { index, length } = point;
|
||||||
if (matchFlavours(model, [RootBlockModel])) {
|
if (matchModels(model, [RootBlockModel])) {
|
||||||
if (length === 0) return;
|
if (length === 0) return;
|
||||||
(snapshot.props.title as Record<string, unknown>).delta =
|
(snapshot.props.title as Record<string, unknown>).delta =
|
||||||
model.title.sliceToDelta(index, length + index);
|
model.title.sliceToDelta(index, length + index);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
TelemetryProvider,
|
TelemetryProvider,
|
||||||
} from '../../services';
|
} from '../../services';
|
||||||
import type { AffineTextAttributes } from '../../types';
|
import type { AffineTextAttributes } from '../../types';
|
||||||
import { matchFlavours, referenceToNode } from '../../utils';
|
import { matchModels, referenceToNode } from '../../utils';
|
||||||
|
|
||||||
function findLastMatchingNode(
|
function findLastMatchingNode(
|
||||||
root: BlockSnapshot[],
|
root: BlockSnapshot[],
|
||||||
@@ -293,7 +293,7 @@ class PasteTr {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!cursorModel.text) {
|
if (!cursorModel.text) {
|
||||||
if (matchFlavours(cursorModel, [ImageBlockModel])) {
|
if (matchModels(cursorModel, [ImageBlockModel])) {
|
||||||
const selection = this.std.selection.create(ImageSelection, {
|
const selection = this.std.selection.create(ImageSelection, {
|
||||||
blockId: target.blockId,
|
blockId: target.blockId,
|
||||||
});
|
});
|
||||||
@@ -358,7 +358,7 @@ class PasteTr {
|
|||||||
if (
|
if (
|
||||||
this.firstSnapshot !== this.lastSnapshot &&
|
this.firstSnapshot !== this.lastSnapshot &&
|
||||||
this.lastSnapshot.props.text &&
|
this.lastSnapshot.props.text &&
|
||||||
!matchFlavours(this.pointState.model, [CodeBlockModel])
|
!matchModels(this.pointState.model, [CodeBlockModel])
|
||||||
) {
|
) {
|
||||||
const text = fromJSON(this.lastSnapshot.props.text) as Text;
|
const text = fromJSON(this.lastSnapshot.props.text) as Text;
|
||||||
const doc = new Y.Doc();
|
const doc = new Y.Doc();
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import type { BlockComponent, Command } from '@blocksuite/block-std';
|
import type {
|
||||||
|
BlockComponent,
|
||||||
|
BlockStdScope,
|
||||||
|
Command,
|
||||||
|
} from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { getNextContentBlock } from '../../utils/index.js';
|
import { getNextContentBlock } from '../../utils/index.js';
|
||||||
|
|
||||||
function getNextBlock(std: BlockSuite.Std, path: string) {
|
function getNextBlock(std: BlockStdScope, path: string) {
|
||||||
const view = std.view;
|
const view = std.view;
|
||||||
const model = std.store.getBlock(path)?.model;
|
const model = std.store.getBlock(path)?.model;
|
||||||
if (!model) return null;
|
if (!model) return null;
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import type { BlockComponent, Command } from '@blocksuite/block-std';
|
import type {
|
||||||
|
BlockComponent,
|
||||||
|
BlockStdScope,
|
||||||
|
Command,
|
||||||
|
} from '@blocksuite/block-std';
|
||||||
|
|
||||||
import { getPrevContentBlock } from '../../utils/index.js';
|
import { getPrevContentBlock } from '../../utils/index.js';
|
||||||
|
|
||||||
function getPrevBlock(std: BlockSuite.Std, path: string) {
|
function getPrevBlock(std: BlockStdScope, path: string) {
|
||||||
const view = std.view;
|
const view = std.view;
|
||||||
|
|
||||||
const model = std.store.getBlock(path)?.model;
|
const model = std.store.getBlock(path)?.model;
|
||||||
|
|||||||
@@ -52,10 +52,7 @@ export type EmbedOptions = {
|
|||||||
export type IndentContext = {
|
export type IndentContext = {
|
||||||
blockId: string;
|
blockId: string;
|
||||||
inlineIndex: number;
|
inlineIndex: number;
|
||||||
flavour: Extract<
|
flavour: string;
|
||||||
keyof BlockSuite.BlockModels,
|
|
||||||
'affine:paragraph' | 'affine:list'
|
|
||||||
>;
|
|
||||||
type: 'indent' | 'dedent';
|
type: 'indent' | 'dedent';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
import { ParagraphBlockModel } from '@blocksuite/affine-model';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
import { matchFlavours } from '../model/checker.js';
|
import { matchModels } from '../model/checker.js';
|
||||||
|
|
||||||
export function calculateCollapsedSiblings(
|
export function calculateCollapsedSiblings(
|
||||||
model: ParagraphBlockModel
|
model: ParagraphBlockModel
|
||||||
@@ -15,7 +15,7 @@ export function calculateCollapsedSiblings(
|
|||||||
const collapsedEdgeIndex = children.findIndex((child, i) => {
|
const collapsedEdgeIndex = children.findIndex((child, i) => {
|
||||||
if (
|
if (
|
||||||
i > index &&
|
i > index &&
|
||||||
matchFlavours(child, [ParagraphBlockModel]) &&
|
matchModels(child, [ParagraphBlockModel]) &&
|
||||||
child.type.startsWith('h')
|
child.type.startsWith('h')
|
||||||
) {
|
) {
|
||||||
const modelLevel = parseInt(model.type.slice(1));
|
const modelLevel = parseInt(model.type.slice(1));
|
||||||
@@ -46,7 +46,7 @@ export function getNearestHeadingBefore(
|
|||||||
for (let i = index - 1; i >= 0; i--) {
|
for (let i = index - 1; i >= 0; i--) {
|
||||||
const sibling = parent.children[i];
|
const sibling = parent.children[i];
|
||||||
if (
|
if (
|
||||||
matchFlavours(sibling, [ParagraphBlockModel]) &&
|
matchModels(sibling, [ParagraphBlockModel]) &&
|
||||||
sibling.type.startsWith('h')
|
sibling.type.startsWith('h')
|
||||||
) {
|
) {
|
||||||
return sibling;
|
return sibling;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
getClosestBlockComponentByElement,
|
getClosestBlockComponentByElement,
|
||||||
getRectByBlockComponent,
|
getRectByBlockComponent,
|
||||||
} from '../dom/index.js';
|
} from '../dom/index.js';
|
||||||
import { matchFlavours } from '../model/index.js';
|
import { matchModels } from '../model/index.js';
|
||||||
import { getDropRectByPoint } from './get-drop-rect-by-point.js';
|
import { getDropRectByPoint } from './get-drop-rect-by-point.js';
|
||||||
import { DropFlags, type DropPlacement, type DropTarget } from './types.js';
|
import { DropFlags, type DropPlacement, type DropTarget } from './types.js';
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ export function calcDropTarget(
|
|||||||
.every(m => children.includes(m.flavour));
|
.every(m => children.includes(m.flavour));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!shouldAppendToDatabase && !matchFlavours(model, [DatabaseBlockModel])) {
|
if (!shouldAppendToDatabase && !matchModels(model, [DatabaseBlockModel])) {
|
||||||
const databaseBlockComponent =
|
const databaseBlockComponent =
|
||||||
element.closest<BlockComponent>('affine-database');
|
element.closest<BlockComponent>('affine-database');
|
||||||
if (databaseBlockComponent) {
|
if (databaseBlockComponent) {
|
||||||
@@ -150,7 +150,7 @@ export function calcDropTarget(
|
|||||||
const hasChild = (element as BlockComponent).childBlocks.length;
|
const hasChild = (element as BlockComponent).childBlocks.length;
|
||||||
if (
|
if (
|
||||||
allowSublist &&
|
allowSublist &&
|
||||||
matchFlavours(model, [ListBlockModel]) &&
|
matchModels(model, [ListBlockModel]) &&
|
||||||
!hasChild &&
|
!hasChild &&
|
||||||
point.x > domRect.x + BLOCK_CHILDREN_CONTAINER_PADDING_LEFT
|
point.x > domRect.x + BLOCK_CHILDREN_CONTAINER_PADDING_LEFT
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import type { Point } from '@blocksuite/global/utils';
|
|||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
import { getRectByBlockComponent } from '../dom/index.js';
|
import { getRectByBlockComponent } from '../dom/index.js';
|
||||||
import { matchFlavours } from '../model/index.js';
|
import { matchModels } from '../model/index.js';
|
||||||
import { DropFlags } from './types.js';
|
import { DropFlags } from './types.js';
|
||||||
|
|
||||||
const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;
|
const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;
|
||||||
@@ -25,7 +25,7 @@ export function getDropRectByPoint(
|
|||||||
flag: DropFlags.Normal,
|
flag: DropFlags.Normal,
|
||||||
};
|
};
|
||||||
|
|
||||||
const isDatabase = matchFlavours(model, [DatabaseBlockModel]);
|
const isDatabase = matchModels(model, [DatabaseBlockModel]);
|
||||||
|
|
||||||
if (isDatabase) {
|
if (isDatabase) {
|
||||||
const table = getDatabaseBlockTableElement(element);
|
const table = getDatabaseBlockTableElement(element);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { BlockModel } from '@blocksuite/store';
|
|||||||
|
|
||||||
import { BLOCK_CHILDREN_CONTAINER_PADDING_LEFT } from '../../consts/index.js';
|
import { BLOCK_CHILDREN_CONTAINER_PADDING_LEFT } from '../../consts/index.js';
|
||||||
import { clamp } from '../math.js';
|
import { clamp } from '../math.js';
|
||||||
import { matchFlavours } from '../model/checker.js';
|
import { matchModels } from '../model/checker.js';
|
||||||
|
|
||||||
const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;
|
const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ function hasBlockId(element: Element): element is BlockComponent {
|
|||||||
* Returns `true` if element is default/edgeless page or note.
|
* Returns `true` if element is default/edgeless page or note.
|
||||||
*/
|
*/
|
||||||
function isRootOrNoteOrSurface(element: BlockComponent) {
|
function isRootOrNoteOrSurface(element: BlockComponent) {
|
||||||
return matchFlavours(element.model, [
|
return matchModels(element.model, [
|
||||||
RootBlockModel,
|
RootBlockModel,
|
||||||
NoteBlockModel,
|
NoteBlockModel,
|
||||||
SurfaceBlockModel,
|
SurfaceBlockModel,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { FrameBlockModel, GroupElementModel } from '@blocksuite/affine-model';
|
import { FrameBlockModel, GroupElementModel } from '@blocksuite/affine-model';
|
||||||
import type { GfxBlockElementModel } from '@blocksuite/block-std/gfx';
|
import type { GfxBlockElementModel, GfxModel } from '@blocksuite/block-std/gfx';
|
||||||
import {
|
import {
|
||||||
deserializeXYWH,
|
deserializeXYWH,
|
||||||
getQuadBoundWithRotation,
|
getQuadBoundWithRotation,
|
||||||
} from '@blocksuite/global/utils';
|
} from '@blocksuite/global/utils';
|
||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
export function getSelectedRect(selected: BlockSuite.EdgelessModel[]): DOMRect {
|
export function getSelectedRect(selected: GfxModel[]): DOMRect {
|
||||||
if (selected.length === 0) {
|
if (selected.length === 0) {
|
||||||
return new DOMRect();
|
return new DOMRect();
|
||||||
}
|
}
|
||||||
@@ -57,8 +57,8 @@ export function getSelectedRect(selected: BlockSuite.EdgelessModel[]): DOMRect {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getElementsWithoutGroup(elements: BlockSuite.EdgelessModel[]) {
|
export function getElementsWithoutGroup(elements: GfxModel[]) {
|
||||||
const set = new Set<BlockSuite.EdgelessModel>();
|
const set = new Set<GfxModel>();
|
||||||
|
|
||||||
elements.forEach(element => {
|
elements.forEach(element => {
|
||||||
if (element instanceof GroupElementModel) {
|
if (element instanceof GroupElementModel) {
|
||||||
@@ -73,7 +73,7 @@ export function getElementsWithoutGroup(elements: BlockSuite.EdgelessModel[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isTopLevelBlock(
|
export function isTopLevelBlock(
|
||||||
selectable: BlockModel | BlockSuite.EdgelessModel | null
|
selectable: BlockModel | GfxModel | null
|
||||||
): selectable is GfxBlockElementModel {
|
): selectable is GfxBlockElementModel {
|
||||||
return !!selectable && 'flavour' in selectable;
|
return !!selectable && 'flavour' in selectable;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ type ModelList<T> =
|
|||||||
: never
|
: never
|
||||||
: never;
|
: never;
|
||||||
|
|
||||||
export function matchFlavours<
|
export function matchModels<
|
||||||
const Model extends ConstructorType<BlockModel>[],
|
const Model extends ConstructorType<BlockModel>[],
|
||||||
U extends ModelList<Model>[number] = ModelList<Model>[number],
|
U extends ModelList<Model>[number] = ModelList<Model>[number],
|
||||||
>(model: unknown, expected: Model): model is U {
|
>(model: unknown, expected: Model): model is U {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { EditorHost } from '@blocksuite/block-std';
|
|||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
import { DocModeProvider } from '../../services/doc-mode-service.js';
|
import { DocModeProvider } from '../../services/doc-mode-service.js';
|
||||||
import { matchFlavours } from './checker.js';
|
import { matchModels } from './checker.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -74,7 +74,7 @@ export function getPrevContentBlock(
|
|||||||
|
|
||||||
const prev = getPrev(model);
|
const prev = getPrev(model);
|
||||||
if (prev) {
|
if (prev) {
|
||||||
if (prev.role === 'content' && !matchFlavours(prev, [FrameBlockModel])) {
|
if (prev.role === 'content' && !matchModels(prev, [FrameBlockModel])) {
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
|||||||
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
|
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
|
||||||
import type { BlockModel, Store } from '@blocksuite/store';
|
import type { BlockModel, Store } from '@blocksuite/store';
|
||||||
|
|
||||||
import { matchFlavours } from './checker.js';
|
import { matchModels } from './checker.js';
|
||||||
|
|
||||||
export function findAncestorModel(
|
export function findAncestorModel(
|
||||||
model: BlockModel,
|
model: BlockModel,
|
||||||
@@ -37,7 +37,7 @@ export async function asyncGetBlockComponent(
|
|||||||
|
|
||||||
export function findNoteBlockModel(model: BlockModel) {
|
export function findNoteBlockModel(model: BlockModel) {
|
||||||
return findAncestorModel(model, m =>
|
return findAncestorModel(model, m =>
|
||||||
matchFlavours(m, [NoteBlockModel])
|
matchModels(m, [NoteBlockModel])
|
||||||
) as NoteBlockModel | null;
|
) as NoteBlockModel | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ export function getLastNoteBlock(doc: Store) {
|
|||||||
for (let i = children.length - 1; i >= 0; i--) {
|
for (let i = children.length - 1; i >= 0; i--) {
|
||||||
const child = children[i];
|
const child = children[i];
|
||||||
if (
|
if (
|
||||||
matchFlavours(child, [NoteBlockModel]) &&
|
matchModels(child, [NoteBlockModel]) &&
|
||||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||||
) {
|
) {
|
||||||
note = child as NoteBlockModel;
|
note = child as NoteBlockModel;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ListBlockModel } from '@blocksuite/affine-model';
|
|||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import type { BlockModel, Store } from '@blocksuite/store';
|
import type { BlockModel, Store } from '@blocksuite/store';
|
||||||
|
|
||||||
import { matchFlavours } from './checker.js';
|
import { matchModels } from './checker.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass in a list model, and this function will look forward to find continuous sibling numbered lists,
|
* Pass in a list model, and this function will look forward to find continuous sibling numbered lists,
|
||||||
@@ -23,7 +23,7 @@ export function getNextContinuousNumberedLists(
|
|||||||
const firstNotNumberedListIndex = parent.children.findIndex(
|
const firstNotNumberedListIndex = parent.children.findIndex(
|
||||||
(model, i) =>
|
(model, i) =>
|
||||||
i > modelIndex &&
|
i > modelIndex &&
|
||||||
(!matchFlavours(model, [ListBlockModel]) || model.type !== 'numbered')
|
(!matchModels(model, [ListBlockModel]) || model.type !== 'numbered')
|
||||||
);
|
);
|
||||||
const newContinuousLists = parent.children.slice(
|
const newContinuousLists = parent.children.slice(
|
||||||
modelIndex + 1,
|
modelIndex + 1,
|
||||||
@@ -31,8 +31,7 @@ export function getNextContinuousNumberedLists(
|
|||||||
);
|
);
|
||||||
if (
|
if (
|
||||||
!newContinuousLists.every(
|
!newContinuousLists.every(
|
||||||
model =>
|
model => matchModels(model, [ListBlockModel]) && model.type === 'numbered'
|
||||||
matchFlavours(model, [ListBlockModel]) && model.type === 'numbered'
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return [];
|
return [];
|
||||||
@@ -56,7 +55,7 @@ export function toNumberedList(
|
|||||||
// if there is a numbered list before, the order continues from the previous list
|
// if there is a numbered list before, the order continues from the previous list
|
||||||
if (
|
if (
|
||||||
prevSibling &&
|
prevSibling &&
|
||||||
matchFlavours(prevSibling, [ListBlockModel]) &&
|
matchModels(prevSibling, [ListBlockModel]) &&
|
||||||
prevSibling.type === 'numbered'
|
prevSibling.type === 'numbered'
|
||||||
) {
|
) {
|
||||||
doc.transact(() => {
|
doc.transact(() => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type { BlockModel, Store, Text } from '@blocksuite/store';
|
|||||||
|
|
||||||
export function transformModel(
|
export function transformModel(
|
||||||
model: BlockModel,
|
model: BlockModel,
|
||||||
flavour: BlockSuite.Flavour,
|
flavour: string,
|
||||||
props?: Parameters<Store['addBlock']>[1]
|
props?: Parameters<Store['addBlock']>[1]
|
||||||
) {
|
) {
|
||||||
const doc = model.doc;
|
const doc = model.doc;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { correctNumberedListsOrderToPrev } from '@blocksuite/affine-block-list';
|
import { correctNumberedListsOrderToPrev } from '@blocksuite/affine-block-list';
|
||||||
import { ListBlockModel } from '@blocksuite/affine-model';
|
import { ListBlockModel } from '@blocksuite/affine-model';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import type { TransformerMiddleware } from '@blocksuite/store';
|
import type { TransformerMiddleware } from '@blocksuite/store';
|
||||||
|
|
||||||
@@ -10,10 +10,7 @@ export const reorderList =
|
|||||||
slots.afterImport.on(payload => {
|
slots.afterImport.on(payload => {
|
||||||
if (payload.type === 'block') {
|
if (payload.type === 'block') {
|
||||||
const model = payload.model;
|
const model = payload.model;
|
||||||
if (
|
if (matchModels(model, [ListBlockModel]) && model.type === 'numbered') {
|
||||||
matchFlavours(model, [ListBlockModel]) &&
|
|
||||||
model.type === 'numbered'
|
|
||||||
) {
|
|
||||||
const next = std.store.getNext(model);
|
const next = std.store.getNext(model);
|
||||||
correctNumberedListsOrderToPrev(std.store, model);
|
correctNumberedListsOrderToPrev(std.store, model);
|
||||||
if (next) {
|
if (next) {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
findClosestBlockComponent,
|
findClosestBlockComponent,
|
||||||
getBlockProps,
|
getBlockProps,
|
||||||
getClosestBlockComponentByPoint,
|
getClosestBlockComponentByPoint,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
|
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
|
||||||
import { Point, Rect } from '@blocksuite/global/utils';
|
import { Point, Rect } from '@blocksuite/global/utils';
|
||||||
@@ -220,7 +220,7 @@ export const getDropResult = (
|
|||||||
|
|
||||||
const model = closestBlock.model;
|
const model = closestBlock.model;
|
||||||
|
|
||||||
const isDatabase = matchFlavours(model, [DatabaseBlockModel]);
|
const isDatabase = matchModels(model, [DatabaseBlockModel]);
|
||||||
if (isDatabase) {
|
if (isDatabase) {
|
||||||
return dropIndicator;
|
return dropIndicator;
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ export const getDropResult = (
|
|||||||
export function getDragHandleLeftPadding(blocks: BlockComponent[]) {
|
export function getDragHandleLeftPadding(blocks: BlockComponent[]) {
|
||||||
const hasToggleList = blocks.some(
|
const hasToggleList = blocks.some(
|
||||||
block =>
|
block =>
|
||||||
(matchFlavours(block.model, [ListBlockModel]) &&
|
(matchModels(block.model, [ListBlockModel]) &&
|
||||||
block.model.children.length > 0) ||
|
block.model.children.length > 0) ||
|
||||||
(block instanceof ParagraphBlockComponent &&
|
(block instanceof ParagraphBlockComponent &&
|
||||||
block.model.type.startsWith('h') &&
|
block.model.type.startsWith('h') &&
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
getBlockComponentsExcludeSubtrees,
|
getBlockComponentsExcludeSubtrees,
|
||||||
getRectByBlockComponent,
|
getRectByBlockComponent,
|
||||||
getScrollContainer,
|
getScrollContainer,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
type BlockComponent,
|
type BlockComponent,
|
||||||
@@ -161,17 +161,17 @@ export class DragEventWatcher {
|
|||||||
!snapshot ||
|
!snapshot ||
|
||||||
snapshot.content.length === 0 ||
|
snapshot.content.length === 0 ||
|
||||||
!dragPayload?.from ||
|
!dragPayload?.from ||
|
||||||
matchFlavours(model, [DatabaseBlockModel])
|
matchModels(model, [DatabaseBlockModel])
|
||||||
)
|
)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
const isDropOnNoteBlock = matchFlavours(model, [NoteBlockModel]);
|
const isDropOnNoteBlock = matchModels(model, [NoteBlockModel]);
|
||||||
|
|
||||||
const edge = dropPayload.edge;
|
const edge = dropPayload.edge;
|
||||||
const scale = this.widget.scale.peek();
|
const scale = this.widget.scale.peek();
|
||||||
let result: DropResult;
|
let result: DropResult;
|
||||||
|
|
||||||
if (edge === 'right' && matchFlavours(dropBlock.model, [ListBlockModel])) {
|
if (edge === 'right' && matchModels(dropBlock.model, [ListBlockModel])) {
|
||||||
const domRect = getRectByBlockComponent(dropBlock);
|
const domRect = getRectByBlockComponent(dropBlock);
|
||||||
const placement = 'in';
|
const placement = 'in';
|
||||||
const rect = Rect.fromLWTH(
|
const rect = Rect.fromLWTH(
|
||||||
@@ -373,7 +373,7 @@ export class DragEventWatcher {
|
|||||||
result.placement === 'in' ? model : this.std.store.getParent(model);
|
result.placement === 'in' ? model : this.std.store.getParent(model);
|
||||||
|
|
||||||
if (!parent) return;
|
if (!parent) return;
|
||||||
if (matchFlavours(parent, [SurfaceBlockModel])) {
|
if (matchModels(parent, [SurfaceBlockModel])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +383,7 @@ export class DragEventWatcher {
|
|||||||
: parent.children.indexOf(model) +
|
: parent.children.indexOf(model) +
|
||||||
(result.placement === 'before' ? 0 : 1);
|
(result.placement === 'before' ? 0 : 1);
|
||||||
|
|
||||||
if (matchFlavours(parent, [NoteBlockModel])) {
|
if (matchModels(parent, [NoteBlockModel])) {
|
||||||
const [first] = snapshot.content;
|
const [first] = snapshot.content;
|
||||||
if (first.flavour === 'affine:note') {
|
if (first.flavour === 'affine:note') {
|
||||||
if (parent.id !== first.id) {
|
if (parent.id !== first.id) {
|
||||||
@@ -685,7 +685,7 @@ export class DragEventWatcher {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
if (matchFlavours(view.model, [AttachmentBlockModel, BookmarkBlockModel])) {
|
if (matchModels(view.model, [AttachmentBlockModel, BookmarkBlockModel])) {
|
||||||
cleanups.push(this._makeDraggable(view));
|
cleanups.push(this._makeDraggable(view));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,7 @@ import {
|
|||||||
SurfaceRefBlockModel,
|
SurfaceRefBlockModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
||||||
import {
|
import { matchModels, stopPropagation } from '@blocksuite/affine-shared/utils';
|
||||||
matchFlavours,
|
|
||||||
stopPropagation,
|
|
||||||
} from '@blocksuite/affine-shared/utils';
|
|
||||||
import { WidgetComponent } from '@blocksuite/block-std';
|
import { WidgetComponent } from '@blocksuite/block-std';
|
||||||
import {
|
import {
|
||||||
type GfxController,
|
type GfxController,
|
||||||
@@ -195,7 +192,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<RootBlockModel> {
|
|||||||
|
|
||||||
const pageVisibleBlocks = new Map<AutoConnectElement, number>();
|
const pageVisibleBlocks = new Map<AutoConnectElement, number>();
|
||||||
const notes = service.doc.root?.children.filter(child =>
|
const notes = service.doc.root?.children.filter(child =>
|
||||||
matchFlavours(child, [NoteBlockModel])
|
matchModels(child, [NoteBlockModel])
|
||||||
);
|
);
|
||||||
const edgelessOnlyNotesSet = new Set<NoteBlockModel>();
|
const edgelessOnlyNotesSet = new Set<NoteBlockModel>();
|
||||||
|
|
||||||
@@ -209,7 +206,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<RootBlockModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
note.children.forEach(model => {
|
note.children.forEach(model => {
|
||||||
if (matchFlavours(model, [SurfaceRefBlockModel])) {
|
if (matchModels(model, [SurfaceRefBlockModel])) {
|
||||||
const reference = this._crud.getElementById(model.reference);
|
const reference = this._crud.getElementById(model.reference);
|
||||||
|
|
||||||
if (!isAutoConnectElement(reference)) return;
|
if (!isAutoConnectElement(reference)) return;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { getSelectionRectsCommand } from '@blocksuite/affine-shared/commands';
|
import { getSelectionRectsCommand } from '@blocksuite/affine-shared/commands';
|
||||||
import { EMBED_BLOCK_MODEL_LIST } from '@blocksuite/affine-shared/consts';
|
import { EMBED_BLOCK_MODEL_LIST } from '@blocksuite/affine-shared/consts';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
BlockSelection,
|
BlockSelection,
|
||||||
TextSelection,
|
TextSelection,
|
||||||
@@ -76,7 +76,7 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
|
|||||||
private get _config(): DocRemoteSelectionConfig {
|
private get _config(): DocRemoteSelectionConfig {
|
||||||
return {
|
return {
|
||||||
blockSelectionBackgroundTransparent: block => {
|
blockSelectionBackgroundTransparent: block => {
|
||||||
return matchFlavours(block, [
|
return matchModels(block, [
|
||||||
CodeBlockModel,
|
CodeBlockModel,
|
||||||
DatabaseBlockModel,
|
DatabaseBlockModel,
|
||||||
ImageBlockModel,
|
ImageBlockModel,
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import {
|
|||||||
requestThrottledConnectedFrame,
|
requestThrottledConnectedFrame,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import { WidgetComponent } from '@blocksuite/block-std';
|
import { WidgetComponent } from '@blocksuite/block-std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
|
import {
|
||||||
|
GfxControllerIdentifier,
|
||||||
|
type GfxModel,
|
||||||
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { pickValues } from '@blocksuite/global/utils';
|
import { pickValues } from '@blocksuite/global/utils';
|
||||||
import type { UserInfo } from '@blocksuite/store';
|
import type { UserInfo } from '@blocksuite/store';
|
||||||
import { css, html, nothing } from 'lit';
|
import { css, html, nothing } from 'lit';
|
||||||
@@ -118,7 +121,7 @@ export class EdgelessRemoteSelectionWidget extends WidgetComponent<RootBlockMode
|
|||||||
|
|
||||||
const elements = selection.elements
|
const elements = selection.elements
|
||||||
.map(id => this.crud.getElementById(id))
|
.map(id => this.crud.getElementById(id))
|
||||||
.filter(element => element) as BlockSuite.EdgelessModel[];
|
.filter(element => element) as GfxModel[];
|
||||||
const rect = getSelectedRect(elements);
|
const rect = getSelectedRect(elements);
|
||||||
|
|
||||||
if (rect.width === 0 || rect.height === 0) return;
|
if (rect.width === 0 || rect.height === 0) return;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ describe('DatabaseManager', () => {
|
|||||||
noteBlockId = doc.addBlock('affine:note', {}, rootId);
|
noteBlockId = doc.addBlock('affine:note', {}, rootId);
|
||||||
|
|
||||||
databaseBlockId = doc.addBlock(
|
databaseBlockId = doc.addBlock(
|
||||||
'affine:database' as BlockSuite.Flavour,
|
'affine:database',
|
||||||
{
|
{
|
||||||
columns: [],
|
columns: [],
|
||||||
titleColumn: 'Title',
|
titleColumn: 'Title',
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { MindmapElementModel } from '@blocksuite/affine-model';
|
import { MindmapElementModel } from '@blocksuite/affine-model';
|
||||||
import type { Viewport } from '@blocksuite/block-std/gfx';
|
import type { GfxModel, Viewport } from '@blocksuite/block-std/gfx';
|
||||||
|
|
||||||
export function isSingleMindMapNode(els: BlockSuite.EdgelessModel[]) {
|
export function isSingleMindMapNode(els: GfxModel[]) {
|
||||||
return els.length === 1 && els[0].group instanceof MindmapElementModel;
|
return els.length === 1 && els[0].group instanceof MindmapElementModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isElementOutsideViewport(
|
export function isElementOutsideViewport(
|
||||||
viewport: Viewport,
|
viewport: Viewport,
|
||||||
element: BlockSuite.EdgelessModel,
|
element: GfxModel,
|
||||||
padding: [number, number] = [0, 0]
|
padding: [number, number] = [0, 0]
|
||||||
) {
|
) {
|
||||||
const elementBound = element.elementBound;
|
const elementBound = element.elementBound;
|
||||||
@@ -25,7 +25,7 @@ export function isElementOutsideViewport(
|
|||||||
|
|
||||||
export function getNearestTranslation(
|
export function getNearestTranslation(
|
||||||
viewport: Viewport,
|
viewport: Viewport,
|
||||||
element: BlockSuite.EdgelessModel,
|
element: GfxModel,
|
||||||
padding: [number, number] = [0, 0]
|
padding: [number, number] = [0, 0]
|
||||||
) {
|
) {
|
||||||
const viewportBound = viewport.viewportBounds;
|
const viewportBound = viewport.viewportBounds;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import {
|
|||||||
} from '@blocksuite/affine-shared/consts';
|
} from '@blocksuite/affine-shared/consts';
|
||||||
import {
|
import {
|
||||||
isInsidePageEditor,
|
isInsidePageEditor,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
} from '@blocksuite/affine-shared/utils';
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
type BlockStdScope,
|
type BlockStdScope,
|
||||||
@@ -458,7 +458,7 @@ export class ExportManager {
|
|||||||
edgeless?.service.gfx.getElementsByBound(bound, { type: 'block' }) ??
|
edgeless?.service.gfx.getElementsByBound(bound, { type: 'block' }) ??
|
||||||
[];
|
[];
|
||||||
for (const block of blocks) {
|
for (const block of blocks) {
|
||||||
if (matchFlavours(block, [ImageBlockModel])) {
|
if (matchModels(block, [ImageBlockModel])) {
|
||||||
if (!block.sourceId) return;
|
if (!block.sourceId) return;
|
||||||
|
|
||||||
const blob = await block.doc.blobSync.get(block.sourceId);
|
const blob = await block.doc.blobSync.get(block.sourceId);
|
||||||
@@ -495,7 +495,7 @@ export class ExportManager {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (matchFlavours(block, [FrameBlockModel])) {
|
if (matchModels(block, [FrameBlockModel])) {
|
||||||
// TODO(@L-Sun): use children of frame instead of bound
|
// TODO(@L-Sun): use children of frame instead of bound
|
||||||
const blocksInsideFrame = getBlocksInFrameBound(this.doc, block, false);
|
const blocksInsideFrame = getBlocksInFrameBound(this.doc, block, false);
|
||||||
const frameBound = Bound.deserialize(block.xywh);
|
const frameBound = Bound.deserialize(block.xywh);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type {
|
|||||||
DocMode,
|
DocMode,
|
||||||
GroupElementModel,
|
GroupElementModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
|
import type { GfxModel } from '@blocksuite/block-std/gfx';
|
||||||
import type { Store } from '@blocksuite/store';
|
import type { Store } from '@blocksuite/store';
|
||||||
|
|
||||||
export type AbstractEditor = {
|
export type AbstractEditor = {
|
||||||
@@ -12,6 +13,6 @@ export type AbstractEditor = {
|
|||||||
} & HTMLElement;
|
} & HTMLElement;
|
||||||
|
|
||||||
export type Connectable = Exclude<
|
export type Connectable = Exclude<
|
||||||
BlockSuite.EdgelessModel,
|
GfxModel,
|
||||||
ConnectorElementModel | BrushElementModel | GroupElementModel
|
ConnectorElementModel | BrushElementModel | GroupElementModel
|
||||||
>;
|
>;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* oxlint-disable @typescript-eslint/triple-slash-reference */
|
/* oxlint-disable @typescript-eslint/triple-slash-reference */
|
||||||
/// <reference path="./effects.ts" />
|
/// <reference path="./effects.ts" />
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchModels } from '@blocksuite/affine-shared/utils';
|
||||||
import { deserializeXYWH, Point } from '@blocksuite/global/utils';
|
import { deserializeXYWH, Point } from '@blocksuite/global/utils';
|
||||||
|
|
||||||
import { splitElements } from './root-block/edgeless/utils/clipboard-utils.js';
|
import { splitElements } from './root-block/edgeless/utils/clipboard-utils.js';
|
||||||
@@ -142,7 +142,7 @@ export {
|
|||||||
getLastNoteBlock,
|
getLastNoteBlock,
|
||||||
isInsideEdgelessEditor,
|
isInsideEdgelessEditor,
|
||||||
isInsidePageEditor,
|
isInsidePageEditor,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
on,
|
on,
|
||||||
once,
|
once,
|
||||||
openFileOrFiles,
|
openFileOrFiles,
|
||||||
@@ -155,7 +155,7 @@ export type { DragBlockPayload } from '@blocksuite/affine-widget-drag-handle';
|
|||||||
|
|
||||||
export const BlocksUtils = {
|
export const BlocksUtils = {
|
||||||
splitElements,
|
splitElements,
|
||||||
matchFlavours,
|
matchModels,
|
||||||
deserializeXYWH,
|
deserializeXYWH,
|
||||||
isCanvasElement,
|
isCanvasElement,
|
||||||
Point,
|
Point,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user