mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-06 11:59:51 +08:00
refactor(editor): remove re-exports (#9406)
This commit is contained in:
@@ -21,6 +21,7 @@ import {
|
|||||||
type ExtensionType,
|
type ExtensionType,
|
||||||
StdIdentifier,
|
StdIdentifier,
|
||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
|
import type { GfxBlockElementModel } from '@blocksuite/block-std/gfx';
|
||||||
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';
|
||||||
import type { IBound } from '@blocksuite/global/utils';
|
import type { IBound } from '@blocksuite/global/utils';
|
||||||
import { Bound } from '@blocksuite/global/utils';
|
import { Bound } from '@blocksuite/global/utils';
|
||||||
@@ -30,14 +31,13 @@ import {
|
|||||||
getBlockComponentByModel,
|
getBlockComponentByModel,
|
||||||
getRootByEditorHost,
|
getRootByEditorHost,
|
||||||
} from '../../_common/utils/index.js';
|
} from '../../_common/utils/index.js';
|
||||||
import type { GfxBlockModel } from '../../root-block/edgeless/block-model.js';
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../root-block/edgeless/edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../../root-block/edgeless/edgeless-root-block.js';
|
||||||
import { getBlocksInFrameBound } from '../../root-block/edgeless/frame-manager.js';
|
import { getBlocksInFrameBound } from '../../root-block/edgeless/frame-manager.js';
|
||||||
import { xywhArrayToObject } from '../../root-block/edgeless/utils/convert.js';
|
import { xywhArrayToObject } from '../../root-block/edgeless/utils/convert.js';
|
||||||
import { getBackgroundGrid } from '../../root-block/edgeless/utils/query.js';
|
import { getBackgroundGrid } from '../../root-block/edgeless/utils/query.js';
|
||||||
import { FileExporter } from './file-exporter.js';
|
import { FileExporter } from './file-exporter.js';
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// oxlint-disable-next-line typescript/consistent-type-imports
|
||||||
type Html2CanvasFunction = typeof import('html2canvas').default;
|
type Html2CanvasFunction = typeof import('html2canvas').default;
|
||||||
|
|
||||||
export type ExportOptions = {
|
export type ExportOptions = {
|
||||||
@@ -408,7 +408,7 @@ export class ExportManager {
|
|||||||
surfaceRenderer: CanvasRenderer,
|
surfaceRenderer: CanvasRenderer,
|
||||||
bound: IBound,
|
bound: IBound,
|
||||||
edgeless?: EdgelessRootBlockComponent,
|
edgeless?: EdgelessRootBlockComponent,
|
||||||
nodes?: GfxBlockModel[],
|
nodes?: GfxBlockElementModel[],
|
||||||
surfaces?: BlockSuite.SurfaceElementModel[],
|
surfaces?: BlockSuite.SurfaceElementModel[],
|
||||||
edgelessBackground?: {
|
edgelessBackground?: {
|
||||||
zoom: number;
|
zoom: number;
|
||||||
|
|||||||
@@ -23,6 +23,3 @@ export type Connectable = Exclude<
|
|||||||
BlockSuite.EdgelessModel,
|
BlockSuite.EdgelessModel,
|
||||||
ConnectorElementModel | BrushElementModel | GroupElementModel
|
ConnectorElementModel | BrushElementModel | GroupElementModel
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type { EmbedCardStyle } from '@blocksuite/affine-model';
|
|
||||||
export * from '@blocksuite/affine-shared/types';
|
|
||||||
|
|||||||
@@ -1,16 +1,2 @@
|
|||||||
// Compat with SSR
|
|
||||||
export * from '../types.js';
|
export * from '../types.js';
|
||||||
export * from './query.js';
|
export * from './query.js';
|
||||||
export {
|
|
||||||
createButtonPopper,
|
|
||||||
getBlockProps,
|
|
||||||
getImageFilesFromLocal,
|
|
||||||
isMiddleButtonPressed,
|
|
||||||
isRightButtonPressed,
|
|
||||||
isValidUrl,
|
|
||||||
matchFlavours,
|
|
||||||
on,
|
|
||||||
once,
|
|
||||||
openFileOrFiles,
|
|
||||||
requestThrottledConnectedFrame,
|
|
||||||
} from '@blocksuite/affine-shared/utils';
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
/* 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 { deserializeXYWH, Point } from '@blocksuite/global/utils';
|
import { deserializeXYWH, Point } from '@blocksuite/global/utils';
|
||||||
|
|
||||||
import { matchFlavours } from './_common/utils/index.js';
|
|
||||||
import { splitElements } from './root-block/edgeless/utils/clipboard-utils.js';
|
import { splitElements } from './root-block/edgeless/utils/clipboard-utils.js';
|
||||||
import { isCanvasElement } from './root-block/edgeless/utils/query.js';
|
import { isCanvasElement } from './root-block/edgeless/utils/query.js';
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
export { GfxBlockElementModel as GfxBlockModel } from '@blocksuite/block-std/gfx';
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
|
import type { EmbedCardStyle } from '@blocksuite/affine-model';
|
||||||
import { WithDisposable } from '@blocksuite/global/utils';
|
import { WithDisposable } from '@blocksuite/global/utils';
|
||||||
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
import { css, html, LitElement, nothing, type TemplateResult } from 'lit';
|
||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { classMap } from 'lit/directives/class-map.js';
|
import { classMap } from 'lit/directives/class-map.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import type { EmbedCardStyle } from '../../../../_common/types.js';
|
|
||||||
|
|
||||||
export class CardStylePanel extends WithDisposable(LitElement) {
|
export class CardStylePanel extends WithDisposable(LitElement) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
|
|||||||
+1
-1
@@ -3,8 +3,8 @@ import {
|
|||||||
LassoFreeHandIcon,
|
LassoFreeHandIcon,
|
||||||
LassoPolygonalIcon,
|
LassoPolygonalIcon,
|
||||||
} from '@blocksuite/affine-components/icons';
|
} from '@blocksuite/affine-components/icons';
|
||||||
|
import { LassoMode } from '@blocksuite/affine-shared/types';
|
||||||
|
|
||||||
import { LassoMode } from '../../../../../_common/types.js';
|
|
||||||
import type { DenseMenuBuilder } from '../common/type.js';
|
import type { DenseMenuBuilder } from '../common/type.js';
|
||||||
|
|
||||||
export const buildLassoDenseMenu: DenseMenuBuilder = edgeless => {
|
export const buildLassoDenseMenu: DenseMenuBuilder = edgeless => {
|
||||||
|
|||||||
+1
-1
@@ -3,13 +3,13 @@ import {
|
|||||||
LassoFreeHandIcon,
|
LassoFreeHandIcon,
|
||||||
LassoPolygonalIcon,
|
LassoPolygonalIcon,
|
||||||
} from '@blocksuite/affine-components/icons';
|
} from '@blocksuite/affine-components/icons';
|
||||||
|
import { LassoMode } from '@blocksuite/affine-shared/types';
|
||||||
import { WithDisposable } from '@blocksuite/global/utils';
|
import { WithDisposable } from '@blocksuite/global/utils';
|
||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { query, state } from 'lit/decorators.js';
|
import { query, state } from 'lit/decorators.js';
|
||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { LassoMode } from '../../../../../_common/types.js';
|
|
||||||
import { getTooltipWithShortcut } from '../../utils.js';
|
import { getTooltipWithShortcut } from '../../utils.js';
|
||||||
import { QuickToolMixin } from '../mixins/quick-tool.mixin.js';
|
import { QuickToolMixin } from '../mixins/quick-tool.mixin.js';
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -13,10 +13,9 @@ import {
|
|||||||
QuoteIcon,
|
QuoteIcon,
|
||||||
TextIcon,
|
TextIcon,
|
||||||
} from '@blocksuite/affine-components/icons';
|
} from '@blocksuite/affine-components/icons';
|
||||||
|
import type { NoteChildrenFlavour } from '@blocksuite/affine-shared/types';
|
||||||
import type { TemplateResult } from 'lit';
|
import type { TemplateResult } from 'lit';
|
||||||
|
|
||||||
import type { NoteChildrenFlavour } from '../../../../../_common/utils/index.js';
|
|
||||||
|
|
||||||
export const BUTTON_GROUP_LENGTH = 10;
|
export const BUTTON_GROUP_LENGTH = 10;
|
||||||
|
|
||||||
export type NoteMenuItem = {
|
export type NoteMenuItem = {
|
||||||
|
|||||||
@@ -3,17 +3,17 @@ import { addImages, LoadedImageIcon } from '@blocksuite/affine-block-image';
|
|||||||
import { AttachmentIcon, LinkIcon } from '@blocksuite/affine-components/icons';
|
import { AttachmentIcon, LinkIcon } from '@blocksuite/affine-components/icons';
|
||||||
import { MAX_IMAGE_WIDTH } from '@blocksuite/affine-model';
|
import { MAX_IMAGE_WIDTH } from '@blocksuite/affine-model';
|
||||||
import { TelemetryProvider } from '@blocksuite/affine-shared/services';
|
import { TelemetryProvider } from '@blocksuite/affine-shared/services';
|
||||||
|
import type { NoteChildrenFlavour } from '@blocksuite/affine-shared/types';
|
||||||
|
import {
|
||||||
|
getImageFilesFromLocal,
|
||||||
|
openFileOrFiles,
|
||||||
|
} from '@blocksuite/affine-shared/utils';
|
||||||
import type { GfxToolsFullOptionValue } from '@blocksuite/block-std/gfx';
|
import type { GfxToolsFullOptionValue } from '@blocksuite/block-std/gfx';
|
||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
import { css, html, LitElement } from 'lit';
|
import { css, html, LitElement } from 'lit';
|
||||||
import { property, state } from 'lit/decorators.js';
|
import { property, state } from 'lit/decorators.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import {
|
|
||||||
getImageFilesFromLocal,
|
|
||||||
type NoteChildrenFlavour,
|
|
||||||
openFileOrFiles,
|
|
||||||
} from '../../../../../_common/utils/index.js';
|
|
||||||
import type { NoteToolOption } from '../../../gfx-tool/note-tool.js';
|
import type { NoteToolOption } from '../../../gfx-tool/note-tool.js';
|
||||||
import { getTooltipWithShortcut } from '../../utils.js';
|
import { getTooltipWithShortcut } from '../../utils.js';
|
||||||
import { EdgelessToolbarToolMixin } from '../mixins/tool.mixin.js';
|
import { EdgelessToolbarToolMixin } from '../mixins/tool.mixin.js';
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ import {
|
|||||||
EditPropsStore,
|
EditPropsStore,
|
||||||
TelemetryProvider,
|
TelemetryProvider,
|
||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
|
import { LassoMode } from '@blocksuite/affine-shared/types';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
||||||
import {
|
import {
|
||||||
|
GfxBlockElementModel,
|
||||||
type GfxToolsMap,
|
type GfxToolsMap,
|
||||||
type GfxToolsOption,
|
type GfxToolsOption,
|
||||||
isGfxGroupCompatibleModel,
|
isGfxGroupCompatibleModel,
|
||||||
@@ -27,9 +29,7 @@ import {
|
|||||||
isElementOutsideViewport,
|
isElementOutsideViewport,
|
||||||
isSingleMindMapNode,
|
isSingleMindMapNode,
|
||||||
} from '../../_common/edgeless/mindmap/index.js';
|
} from '../../_common/edgeless/mindmap/index.js';
|
||||||
import { LassoMode } from '../../_common/types.js';
|
|
||||||
import { PageKeyboardManager } from '../keyboard/keyboard-manager.js';
|
import { PageKeyboardManager } from '../keyboard/keyboard-manager.js';
|
||||||
import { GfxBlockModel } from './block-model.js';
|
|
||||||
import type { EdgelessRootBlockComponent } from './edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from './edgeless-root-block.js';
|
||||||
import { CopilotTool } from './gfx-tool/copilot-tool.js';
|
import { CopilotTool } from './gfx-tool/copilot-tool.js';
|
||||||
import { LassoTool } from './gfx-tool/lasso-tool.js';
|
import { LassoTool } from './gfx-tool/lasso-tool.js';
|
||||||
@@ -115,8 +115,8 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
selection.selectedElements.length === 1 &&
|
selection.selectedElements.length === 1 &&
|
||||||
selection.firstElement instanceof GfxBlockModel &&
|
selection.firstElement instanceof GfxBlockElementModel &&
|
||||||
matchFlavours(selection.firstElement as GfxBlockModel, [
|
matchFlavours(selection.firstElement as GfxBlockElementModel, [
|
||||||
'affine:note',
|
'affine:note',
|
||||||
])
|
])
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
FontLoaderService,
|
FontLoaderService,
|
||||||
ThemeProvider,
|
ThemeProvider,
|
||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
|
import type { Viewport } from '@blocksuite/affine-shared/types';
|
||||||
import {
|
import {
|
||||||
isTouchPadPinchEvent,
|
isTouchPadPinchEvent,
|
||||||
requestConnectedFrame,
|
requestConnectedFrame,
|
||||||
@@ -38,7 +39,6 @@ import { query } from 'lit/decorators.js';
|
|||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import { isSingleMindMapNode } from '../../_common/edgeless/mindmap/index.js';
|
import { isSingleMindMapNode } from '../../_common/edgeless/mindmap/index.js';
|
||||||
import type { Viewport } from '../../_common/utils/index.js';
|
|
||||||
import type { EdgelessRootBlockWidgetName } from '../types.js';
|
import type { EdgelessRootBlockWidgetName } from '../types.js';
|
||||||
import { EdgelessClipboardController } from './clipboard/clipboard.js';
|
import { EdgelessClipboardController } from './clipboard/clipboard.js';
|
||||||
import type { EdgelessSelectedRectWidget } from './components/rects/edgeless-selected-rect.js';
|
import type { EdgelessSelectedRectWidget } from './components/rects/edgeless-selected-rect.js';
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
FontLoaderService,
|
FontLoaderService,
|
||||||
ThemeProvider,
|
ThemeProvider,
|
||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
|
import { requestThrottledConnectedFrame } from '@blocksuite/affine-shared/utils';
|
||||||
import type {
|
import type {
|
||||||
GfxBlockComponent,
|
GfxBlockComponent,
|
||||||
SurfaceSelection,
|
SurfaceSelection,
|
||||||
@@ -17,7 +18,6 @@ import { assertExists } from '@blocksuite/global/utils';
|
|||||||
import { css, html } from 'lit';
|
import { css, html } from 'lit';
|
||||||
import { query, state } from 'lit/decorators.js';
|
import { query, state } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { requestThrottledConnectedFrame } from '../../_common/utils/index.js';
|
|
||||||
import type { EdgelessRootBlockWidgetName } from '../types.js';
|
import type { EdgelessRootBlockWidgetName } from '../types.js';
|
||||||
import type { EdgelessRootService } from './edgeless-root-service.js';
|
import type { EdgelessRootService } from './edgeless-root-service.js';
|
||||||
import { getBackgroundGrid, isCanvasElement } from './utils/query.js';
|
import { getBackgroundGrid, isCanvasElement } from './utils/query.js';
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import type {
|
|||||||
ReorderingDirection,
|
ReorderingDirection,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
import {
|
import {
|
||||||
|
GfxBlockElementModel,
|
||||||
GfxControllerIdentifier,
|
GfxControllerIdentifier,
|
||||||
GfxExtensionIdentifier,
|
GfxExtensionIdentifier,
|
||||||
isGfxGroupCompatibleModel,
|
isGfxGroupCompatibleModel,
|
||||||
@@ -32,7 +33,6 @@ import { Bound, getCommonBound } from '@blocksuite/global/utils';
|
|||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
|
|
||||||
import { RootService } from '../root-service.js';
|
import { RootService } from '../root-service.js';
|
||||||
import { GfxBlockModel } from './block-model.js';
|
|
||||||
import type { EdgelessFrameManager } from './frame-manager.js';
|
import type { EdgelessFrameManager } from './frame-manager.js';
|
||||||
import { TemplateJob } from './services/template.js';
|
import { TemplateJob } from './services/template.js';
|
||||||
import {
|
import {
|
||||||
@@ -60,7 +60,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {
|
|||||||
|
|
||||||
TemplateJob = TemplateJob;
|
TemplateJob = TemplateJob;
|
||||||
|
|
||||||
get blocks(): GfxBlockModel[] {
|
get blocks(): GfxBlockElementModel[] {
|
||||||
return this.layer.blocks;
|
return this.layer.blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el instanceof GfxBlockModel) {
|
if (el instanceof GfxBlockElementModel) {
|
||||||
this.doc.deleteBlock(el);
|
this.doc.deleteBlock(el);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -376,7 +376,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {
|
|||||||
const index = this.layer.getReorderedIndex(element, direction);
|
const index = this.layer.getReorderedIndex(element, direction);
|
||||||
|
|
||||||
// block should be updated in transaction
|
// block should be updated in transaction
|
||||||
if (element instanceof GfxBlockModel) {
|
if (element instanceof GfxBlockElementModel) {
|
||||||
this.doc.transact(() => {
|
this.doc.transact(() => {
|
||||||
element.index = index;
|
element.index = index;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { Overlay } from '@blocksuite/affine-block-surface';
|
|||||||
import {
|
import {
|
||||||
generateKeyBetweenV2,
|
generateKeyBetweenV2,
|
||||||
getTopElements,
|
getTopElements,
|
||||||
|
GfxBlockElementModel,
|
||||||
type GfxController,
|
type GfxController,
|
||||||
GfxExtension,
|
GfxExtension,
|
||||||
GfxExtensionIdentifier,
|
GfxExtensionIdentifier,
|
||||||
@@ -22,7 +23,6 @@ import type { Doc } from '@blocksuite/store';
|
|||||||
import { DocCollection, Text } from '@blocksuite/store';
|
import { DocCollection, Text } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { FrameBlockModel, NoteBlockModel } from '../../index.js';
|
import type { FrameBlockModel, NoteBlockModel } from '../../index.js';
|
||||||
import { GfxBlockModel } from './block-model.js';
|
|
||||||
import { areSetsEqual } from './utils/misc.js';
|
import { areSetsEqual } from './utils/misc.js';
|
||||||
import { isFrameBlock } from './utils/query.js';
|
import { isFrameBlock } from './utils/query.js';
|
||||||
|
|
||||||
@@ -254,7 +254,7 @@ export class EdgelessFrameManager extends GfxExtension {
|
|||||||
doc.slots.blockUpdated.on(payload => {
|
doc.slots.blockUpdated.on(payload => {
|
||||||
if (
|
if (
|
||||||
payload.type === 'add' &&
|
payload.type === 'add' &&
|
||||||
payload.model instanceof GfxBlockModel &&
|
payload.model instanceof GfxBlockElementModel &&
|
||||||
renderableInEdgeless(doc, surfaceModel, payload.model)
|
renderableInEdgeless(doc, surfaceModel, payload.model)
|
||||||
) {
|
) {
|
||||||
const frame = this.getFrameFromPoint(
|
const frame = this.getFrameFromPoint(
|
||||||
@@ -454,7 +454,7 @@ export class EdgelessFrameManager extends GfxExtension {
|
|||||||
|
|
||||||
removeFromParentFrame(element: GfxModel) {
|
removeFromParentFrame(element: GfxModel) {
|
||||||
const parentFrame = this.getParentFrame(element);
|
const parentFrame = this.getParentFrame(element);
|
||||||
// eslint-disable-next-line unicorn/prefer-dom-node-remove
|
// oxlint-disable-next-line unicorn/prefer-dom-node-remove
|
||||||
parentFrame?.removeChild(element);
|
parentFrame?.removeChild(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,7 +499,7 @@ export function getBlocksInFrameBound(
|
|||||||
).concat(
|
).concat(
|
||||||
surface.children.filter(ele => {
|
surface.children.filter(ele => {
|
||||||
if (ele.id === model.id) return false;
|
if (ele.id === model.id) return false;
|
||||||
if (ele instanceof GfxBlockModel) {
|
if (ele instanceof GfxBlockElementModel) {
|
||||||
const blockBound = Bound.deserialize(ele.xywh);
|
const blockBound = Bound.deserialize(ele.xywh);
|
||||||
return fullyContained
|
return fullyContained
|
||||||
? bound.contains(blockBound)
|
? bound.contains(blockBound)
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import type { PointerEventState } from '@blocksuite/block-std';
|
|||||||
import {
|
import {
|
||||||
BaseTool,
|
BaseTool,
|
||||||
getTopElements,
|
getTopElements,
|
||||||
|
type GfxBlockElementModel,
|
||||||
GfxExtensionIdentifier,
|
GfxExtensionIdentifier,
|
||||||
type GfxModel,
|
type GfxModel,
|
||||||
type GfxPrimitiveElementModel,
|
type GfxPrimitiveElementModel,
|
||||||
@@ -43,7 +44,6 @@ import {
|
|||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
|
|
||||||
import { isSingleMindMapNode } from '../../../_common/edgeless/mindmap/index.js';
|
import { isSingleMindMapNode } from '../../../_common/edgeless/mindmap/index.js';
|
||||||
import type { GfxBlockModel } from '../block-model.js';
|
|
||||||
import type { EdgelessRootBlockComponent } from '../edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../edgeless-root-block.js';
|
||||||
import type { EdgelessFrameManager, FrameOverlay } from '../frame-manager.js';
|
import type { EdgelessFrameManager, FrameOverlay } from '../frame-manager.js';
|
||||||
import { prepareCloneData } from '../utils/clone-utils.js';
|
import { prepareCloneData } from '../utils/clone-utils.js';
|
||||||
@@ -116,8 +116,8 @@ export class DefaultTool extends BaseTool {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly _pendingUpdates = new Map<
|
private readonly _pendingUpdates = new Map<
|
||||||
GfxBlockModel | GfxPrimitiveElementModel,
|
GfxBlockElementModel | GfxPrimitiveElementModel,
|
||||||
Partial<GfxBlockModel>
|
Partial<GfxBlockElementModel>
|
||||||
>();
|
>();
|
||||||
|
|
||||||
private _rafId: number | null = null;
|
private _rafId: number | null = null;
|
||||||
@@ -544,8 +544,8 @@ export class DefaultTool extends BaseTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _scheduleUpdate(
|
private _scheduleUpdate(
|
||||||
element: GfxBlockModel | GfxPrimitiveElementModel,
|
element: GfxBlockElementModel | GfxPrimitiveElementModel,
|
||||||
updates: Partial<GfxBlockModel>
|
updates: Partial<GfxBlockElementModel>
|
||||||
) {
|
) {
|
||||||
this._pendingUpdates.set(element, updates);
|
this._pendingUpdates.set(element, updates);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
type SurfaceBlockComponent,
|
type SurfaceBlockComponent,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
import { ThemeProvider } from '@blocksuite/affine-shared/services';
|
||||||
|
import { LassoMode } from '@blocksuite/affine-shared/types';
|
||||||
import type { PointerEventState } from '@blocksuite/block-std';
|
import type { PointerEventState } from '@blocksuite/block-std';
|
||||||
import { BaseTool } from '@blocksuite/block-std/gfx';
|
import { BaseTool } from '@blocksuite/block-std/gfx';
|
||||||
import type { IPoint, IVec } from '@blocksuite/global/utils';
|
import type { IPoint, IVec } from '@blocksuite/global/utils';
|
||||||
@@ -17,8 +18,6 @@ import {
|
|||||||
Vec,
|
Vec,
|
||||||
} from '@blocksuite/global/utils';
|
} from '@blocksuite/global/utils';
|
||||||
|
|
||||||
import { LassoMode } from '../../../_common/types.js';
|
|
||||||
|
|
||||||
class LassoOverlay extends Overlay {
|
class LassoOverlay extends Overlay {
|
||||||
d = '';
|
d = '';
|
||||||
|
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ import {
|
|||||||
DEFAULT_NOTE_WIDTH,
|
DEFAULT_NOTE_WIDTH,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import { EditPropsStore } from '@blocksuite/affine-shared/services';
|
import { EditPropsStore } from '@blocksuite/affine-shared/services';
|
||||||
|
import type { NoteChildrenFlavour } from '@blocksuite/affine-shared/types';
|
||||||
import type { PointerEventState } from '@blocksuite/block-std';
|
import type { PointerEventState } from '@blocksuite/block-std';
|
||||||
import { BaseTool } from '@blocksuite/block-std/gfx';
|
import { BaseTool } from '@blocksuite/block-std/gfx';
|
||||||
import { Point } from '@blocksuite/global/utils';
|
import { Point } from '@blocksuite/global/utils';
|
||||||
import { effect } from '@preact/signals-core';
|
import { effect } from '@preact/signals-core';
|
||||||
|
|
||||||
import {
|
import { hasClassNameInList } from '../../../_common/utils/index.js';
|
||||||
hasClassNameInList,
|
|
||||||
type NoteChildrenFlavour,
|
|
||||||
} from '../../../_common/utils/index.js';
|
|
||||||
import { addNote } from '../utils/common.js';
|
import { addNote } from '../utils/common.js';
|
||||||
import { EXCLUDING_MOUSE_OUT_CLASS_LIST } from '../utils/consts.js';
|
import { EXCLUDING_MOUSE_OUT_CLASS_LIST } from '../utils/consts.js';
|
||||||
import { DraggingNoteOverlay, NoteOverlay } from '../utils/tool-overlay.js';
|
import { DraggingNoteOverlay, NoteOverlay } from '../utils/tool-overlay.js';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
export { GfxBlockModel as EdgelessBlockModel } from './block-model.js';
|
|
||||||
export { FramePreview } from './components/frame/frame-preview.js';
|
export { FramePreview } from './components/frame/frame-preview.js';
|
||||||
export * from './edgeless-root-block.js';
|
export * from './edgeless-root-block.js';
|
||||||
export { EdgelessRootService } from './edgeless-root-service.js';
|
export { EdgelessRootService } from './edgeless-root-service.js';
|
||||||
|
|||||||
@@ -13,14 +13,13 @@ import {
|
|||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
import type { BlockStdScope } from '@blocksuite/block-std';
|
||||||
import {
|
import {
|
||||||
getTopElements,
|
getTopElements,
|
||||||
|
GfxBlockElementModel,
|
||||||
type GfxModel,
|
type GfxModel,
|
||||||
isGfxGroupCompatibleModel,
|
isGfxGroupCompatibleModel,
|
||||||
type SerializedElement,
|
type SerializedElement,
|
||||||
} from '@blocksuite/block-std/gfx';
|
} from '@blocksuite/block-std/gfx';
|
||||||
import { type BlockSnapshot, Job } from '@blocksuite/store';
|
import { type BlockSnapshot, Job } from '@blocksuite/store';
|
||||||
|
|
||||||
import { GfxBlockModel } from '../block-model.js';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return all elements in the tree of the elements
|
* return all elements in the tree of the elements
|
||||||
*/
|
*/
|
||||||
@@ -55,7 +54,7 @@ export function serializeElement(
|
|||||||
elements: GfxModel[],
|
elements: GfxModel[],
|
||||||
job: Job
|
job: Job
|
||||||
) {
|
) {
|
||||||
if (element instanceof GfxBlockModel) {
|
if (element instanceof GfxBlockElementModel) {
|
||||||
const snapshot = job.blockToSnapshot(element);
|
const snapshot = job.blockToSnapshot(element);
|
||||||
if (!snapshot) {
|
if (!snapshot) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
|
import type { GfxBlockElementModel } from '@blocksuite/block-std/gfx';
|
||||||
import { deserializeXYWH } from '@blocksuite/global/utils';
|
import { deserializeXYWH } from '@blocksuite/global/utils';
|
||||||
|
|
||||||
import type { GfxBlockModel } from '../block-model.js';
|
export function xywhArrayToObject(element: GfxBlockElementModel) {
|
||||||
|
|
||||||
export function xywhArrayToObject(element: GfxBlockModel) {
|
|
||||||
const [x, y, w, h] = deserializeXYWH(element.xywh);
|
const [x, y, w, h] = deserializeXYWH(element.xywh);
|
||||||
return { x, y, w, h };
|
return { x, y, w, h };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
TextElementModel,
|
TextElementModel,
|
||||||
} from '@blocksuite/affine-model';
|
} from '@blocksuite/affine-model';
|
||||||
import type {
|
import type {
|
||||||
|
GfxBlockElementModel,
|
||||||
GfxModel,
|
GfxModel,
|
||||||
GfxPrimitiveElementModel,
|
GfxPrimitiveElementModel,
|
||||||
GfxToolsFullOptionValue,
|
GfxToolsFullOptionValue,
|
||||||
@@ -39,20 +40,19 @@ import {
|
|||||||
import type { BlockModel } from '@blocksuite/store';
|
import type { BlockModel } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { Connectable } from '../../../_common/utils/index.js';
|
import type { Connectable } from '../../../_common/utils/index.js';
|
||||||
import type { GfxBlockModel } from '../block-model.js';
|
|
||||||
import { getElementsWithoutGroup } from './group.js';
|
import { getElementsWithoutGroup } from './group.js';
|
||||||
|
|
||||||
const { clamp } = CommonUtils;
|
const { clamp } = CommonUtils;
|
||||||
|
|
||||||
export function isMindmapNode(
|
export function isMindmapNode(
|
||||||
element: GfxBlockModel | BlockSuite.EdgelessModel | null
|
element: GfxBlockElementModel | BlockSuite.EdgelessModel | null
|
||||||
) {
|
) {
|
||||||
return element?.group instanceof MindmapElementModel;
|
return element?.group instanceof MindmapElementModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isTopLevelBlock(
|
export function isTopLevelBlock(
|
||||||
selectable: BlockModel | BlockSuite.EdgelessModel | null
|
selectable: BlockModel | BlockSuite.EdgelessModel | null
|
||||||
): selectable is GfxBlockModel {
|
): selectable is GfxBlockElementModel {
|
||||||
return !!selectable && 'flavour' in selectable;
|
return !!selectable && 'flavour' in selectable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { RootBlockSchema } from '@blocksuite/affine-model';
|
import { RootBlockSchema } from '@blocksuite/affine-model';
|
||||||
|
import type { Viewport } from '@blocksuite/affine-shared/types';
|
||||||
import { Slot } from '@blocksuite/store';
|
import { Slot } from '@blocksuite/store';
|
||||||
|
|
||||||
import type { Viewport } from '../../_common/utils/index.js';
|
|
||||||
import { RootService } from '../root-service.js';
|
import { RootService } from '../root-service.js';
|
||||||
|
|
||||||
export class PageRootService extends RootService {
|
export class PageRootService extends RootService {
|
||||||
|
|||||||
+4
-2
@@ -9,7 +9,10 @@ import {
|
|||||||
PaletteIcon,
|
PaletteIcon,
|
||||||
} from '@blocksuite/affine-components/icons';
|
} from '@blocksuite/affine-components/icons';
|
||||||
import { renderToolbarSeparator } from '@blocksuite/affine-components/toolbar';
|
import { renderToolbarSeparator } from '@blocksuite/affine-components/toolbar';
|
||||||
import type { AttachmentBlockModel } from '@blocksuite/affine-model';
|
import type {
|
||||||
|
AttachmentBlockModel,
|
||||||
|
EmbedCardStyle,
|
||||||
|
} from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
EMBED_CARD_HEIGHT,
|
EMBED_CARD_HEIGHT,
|
||||||
EMBED_CARD_WIDTH,
|
EMBED_CARD_WIDTH,
|
||||||
@@ -21,7 +24,6 @@ import { html, LitElement, nothing } from 'lit';
|
|||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
import { join } from 'lit/directives/join.js';
|
import { join } from 'lit/directives/join.js';
|
||||||
|
|
||||||
import type { EmbedCardStyle } from '../../../_common/types.js';
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
||||||
|
|
||||||
export class EdgelessChangeAttachmentButton extends WithDisposable(LitElement) {
|
export class EdgelessChangeAttachmentButton extends WithDisposable(LitElement) {
|
||||||
|
|||||||
+5
-2
@@ -28,7 +28,11 @@ import {
|
|||||||
type MenuItem,
|
type MenuItem,
|
||||||
renderToolbarSeparator,
|
renderToolbarSeparator,
|
||||||
} from '@blocksuite/affine-components/toolbar';
|
} from '@blocksuite/affine-components/toolbar';
|
||||||
import { type AliasInfo, BookmarkStyles } from '@blocksuite/affine-model';
|
import {
|
||||||
|
type AliasInfo,
|
||||||
|
BookmarkStyles,
|
||||||
|
type EmbedCardStyle,
|
||||||
|
} from '@blocksuite/affine-model';
|
||||||
import {
|
import {
|
||||||
EMBED_CARD_HEIGHT,
|
EMBED_CARD_HEIGHT,
|
||||||
EMBED_CARD_WIDTH,
|
EMBED_CARD_WIDTH,
|
||||||
@@ -52,7 +56,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|||||||
import { join } from 'lit/directives/join.js';
|
import { join } from 'lit/directives/join.js';
|
||||||
import { repeat } from 'lit/directives/repeat.js';
|
import { repeat } from 'lit/directives/repeat.js';
|
||||||
|
|
||||||
import type { EmbedCardStyle } from '../../../_common/types.js';
|
|
||||||
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
import type { EdgelessRootBlockComponent } from '../../edgeless/edgeless-root-block.js';
|
||||||
import {
|
import {
|
||||||
isBookmarkBlock,
|
isBookmarkBlock,
|
||||||
|
|||||||
@@ -30,15 +30,15 @@ import {
|
|||||||
ResetIcon,
|
ResetIcon,
|
||||||
} from '@blocksuite/icons/lit';
|
} from '@blocksuite/icons/lit';
|
||||||
|
|
||||||
import {
|
|
||||||
createLinkedDocFromEdgelessElements,
|
|
||||||
createLinkedDocFromNote,
|
|
||||||
} from '../../../../_common/utils/render-linked-doc.js';
|
|
||||||
import { duplicate } from '../../../edgeless/utils/clipboard-utils.js';
|
import { duplicate } from '../../../edgeless/utils/clipboard-utils.js';
|
||||||
import { getSortedCloneElements } from '../../../edgeless/utils/clone-utils.js';
|
import { getSortedCloneElements } from '../../../edgeless/utils/clone-utils.js';
|
||||||
import { moveConnectors } from '../../../edgeless/utils/connector.js';
|
import { moveConnectors } from '../../../edgeless/utils/connector.js';
|
||||||
import { deleteElements } from '../../../edgeless/utils/crud.js';
|
import { deleteElements } from '../../../edgeless/utils/crud.js';
|
||||||
import type { ElementToolbarMoreMenuContext } from './context.js';
|
import type { ElementToolbarMoreMenuContext } from './context.js';
|
||||||
|
import {
|
||||||
|
createLinkedDocFromEdgelessElements,
|
||||||
|
createLinkedDocFromNote,
|
||||||
|
} from './render-linked-doc.js';
|
||||||
|
|
||||||
type EmbedLinkBlockComponent =
|
type EmbedLinkBlockComponent =
|
||||||
| EmbedGithubBlockComponent
|
| EmbedGithubBlockComponent
|
||||||
|
|||||||
+5
-12
@@ -4,24 +4,17 @@ import { NoteDisplayMode } from '@blocksuite/affine-model';
|
|||||||
import { DocModeProvider } from '@blocksuite/affine-shared/services';
|
import { DocModeProvider } from '@blocksuite/affine-shared/services';
|
||||||
import { getBlockProps } from '@blocksuite/affine-shared/utils';
|
import { getBlockProps } from '@blocksuite/affine-shared/utils';
|
||||||
import type { EditorHost } from '@blocksuite/block-std';
|
import type { EditorHost } from '@blocksuite/block-std';
|
||||||
|
import { GfxBlockElementModel } from '@blocksuite/block-std/gfx';
|
||||||
import { type BlockModel, type Doc } from '@blocksuite/store';
|
import { type BlockModel, type Doc } from '@blocksuite/store';
|
||||||
|
|
||||||
import { GfxBlockModel } from '../../root-block/edgeless/block-model.js';
|
|
||||||
import {
|
import {
|
||||||
getElementProps,
|
getElementProps,
|
||||||
mapFrameIds,
|
mapFrameIds,
|
||||||
sortEdgelessElements,
|
sortEdgelessElements,
|
||||||
} from '../../root-block/edgeless/utils/clone-utils.js';
|
} from '../../../edgeless/utils/clone-utils.js';
|
||||||
import {
|
import { isFrameBlock, isNoteBlock } from '../../../edgeless/utils/query.js';
|
||||||
isFrameBlock,
|
|
||||||
isNoteBlock,
|
|
||||||
} from '../../root-block/edgeless/utils/query.js';
|
|
||||||
|
|
||||||
export function addBlocksToDoc(
|
function addBlocksToDoc(targetDoc: Doc, model: BlockModel, parentId: string) {
|
||||||
targetDoc: Doc,
|
|
||||||
model: BlockModel,
|
|
||||||
parentId: string
|
|
||||||
) {
|
|
||||||
// Add current block to linked doc
|
// Add current block to linked doc
|
||||||
const blockProps = getBlockProps(model);
|
const blockProps = getBlockProps(model);
|
||||||
const newModelId = targetDoc.addBlock(
|
const newModelId = targetDoc.addBlock(
|
||||||
@@ -87,7 +80,7 @@ export function createLinkedDocFromEdgelessElements(
|
|||||||
const ids = new Map<string, string>();
|
const ids = new Map<string, string>();
|
||||||
sortedElements.forEach(model => {
|
sortedElements.forEach(model => {
|
||||||
let newId = model.id;
|
let newId = model.id;
|
||||||
if (model instanceof GfxBlockModel) {
|
if (model instanceof GfxBlockElementModel) {
|
||||||
const blockProps = getBlockProps(model);
|
const blockProps = getBlockProps(model);
|
||||||
if (isNoteBlock(model)) {
|
if (isNoteBlock(model)) {
|
||||||
newId = linkedDoc.addBlock('affine:note', blockProps, rootId);
|
newId = linkedDoc.addBlock('affine:note', blockProps, rootId);
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
NewIcon,
|
NewIcon,
|
||||||
NotionIcon,
|
NotionIcon,
|
||||||
} from '@blocksuite/affine-components/icons';
|
} from '@blocksuite/affine-components/icons';
|
||||||
|
import { openFileOrFiles } from '@blocksuite/affine-shared/utils';
|
||||||
import { WithDisposable } from '@blocksuite/global/utils';
|
import { WithDisposable } from '@blocksuite/global/utils';
|
||||||
import type { DocCollection } from '@blocksuite/store';
|
import type { DocCollection } from '@blocksuite/store';
|
||||||
import { html, LitElement, type PropertyValues } from 'lit';
|
import { html, LitElement, type PropertyValues } from 'lit';
|
||||||
@@ -14,7 +15,6 @@ import { query, state } from 'lit/decorators.js';
|
|||||||
import { HtmlTransformer } from '../../../../_common/transformers/html.js';
|
import { HtmlTransformer } from '../../../../_common/transformers/html.js';
|
||||||
import { MarkdownTransformer } from '../../../../_common/transformers/markdown.js';
|
import { MarkdownTransformer } from '../../../../_common/transformers/markdown.js';
|
||||||
import { NotionHtmlTransformer } from '../../../../_common/transformers/notion-html.js';
|
import { NotionHtmlTransformer } from '../../../../_common/transformers/notion-html.js';
|
||||||
import { openFileOrFiles } from '../../../../_common/utils/index.js';
|
|
||||||
import { styles } from './styles.js';
|
import { styles } from './styles.js';
|
||||||
|
|
||||||
export type OnSuccessHandler = (
|
export type OnSuccessHandler = (
|
||||||
|
|||||||
Reference in New Issue
Block a user