Skip to content

Commit

Permalink
refactor(edgeless): remove redundant and unused blocks exports (#5754)
Browse files Browse the repository at this point in the history
  • Loading branch information
regischen authored Dec 18, 2023
1 parent 9944b0e commit 993a889
Show file tree
Hide file tree
Showing 43 changed files with 114 additions and 192 deletions.
4 changes: 0 additions & 4 deletions packages/blocks/src/_common/test-utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ export class TestUtils {

import type { BlockSnapshot } from '@blocksuite/store';

export function logJson(ast: unknown) {
console.log(JSON.stringify(ast, null, 2));
}

export function nanoidReplacement(snapshot: BlockSnapshot) {
return JSON.parse(nanoidReplacementString(JSON.stringify(snapshot)));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/_legacy/content-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
type SerializedBlock,
type TopLevelBlockModel,
} from '../../_common/utils/index.js';
import type { Renderer } from '../../index.js';
import type { PageBlockModel } from '../../models.js';
import type { EdgelessPageBlockComponent } from '../../page-block/edgeless/edgeless-page-block.js';
import { getBlocksInFrame } from '../../page-block/edgeless/frame-manager.js';
Expand All @@ -20,6 +19,7 @@ import { getBackgroundGrid } from '../../page-block/edgeless/utils/query.js';
import type { IBound } from '../../surface-block/consts.js';
import { EdgelessBlockType } from '../../surface-block/edgeless-types.js';
import type { SurfaceElement } from '../../surface-block/elements/surface-element.js';
import type { Renderer } from '../../surface-block/index.js';
import { Bound } from '../../surface-block/utils/bound.js';
import { FileExporter } from './file-exporter/file-exporter.js';
import type {
Expand Down
8 changes: 2 additions & 6 deletions packages/blocks/src/_legacy/content-parser/parse-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import { type DeltaOperation, nanoid, type Page } from '@blocksuite/store';
import { lightCssVariables } from '@toeverything/theme';

import { getTagColor } from '../../_common/components/tags/colors.js';
import type { SerializedBlock } from '../../_common/types.js';
import { getStandardLanguage } from '../../code-block/utils/code-languages.js';
import { FALLBACK_LANG } from '../../code-block/utils/consts.js';
import { columnManager } from '../../database-block/common/columns/manager.js';
import { richTextPureColumnConfig } from '../../database-block/common/columns/rich-text/define.js';
import type {
BlockSchemas,
Cell,
Column,
SerializedBlock,
} from '../../index.js';
import type { BlockSchemas, Cell, Column } from '../../index.js';
import type { ContentParser, ContextedContentParser } from './index.js';

export type FetchFileHandler = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertExists } from '@blocksuite/global/utils';
import type { Page } from '@blocksuite/store';

import type { SerializedBlock } from '../../index.js';
import type { SerializedBlock } from '../../_common/types.js';
import type { ContentParser, ContextedContentParser } from './index.js';
import {
BaseParser,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assertExists } from '@blocksuite/global/utils';
import type { Page } from '@blocksuite/store';

import type { SerializedBlock } from '../../index.js';
import type { SerializedBlock } from '../../_common/types.js';
import type { ContentParser, ContextedContentParser } from './index.js';
import {
BaseParser,
Expand Down
7 changes: 5 additions & 2 deletions packages/blocks/src/attachment-block/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export * from './attachment-block.js';
export * from './attachment-model.js';
export {
AttachmentBlockModel,
type AttachmentBlockProps,
AttachmentBlockSchema,
} from './attachment-model.js';
export * from './attachment-service.js';
export { uploadBlobForAttachment } from './utils.js';
2 changes: 1 addition & 1 deletion packages/blocks/src/attachment-block/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function turnImageIntoCardView(model: ImageBlockModel, blob: Blob) {
*
* @internal
*/
export async function uploadBlobForAttachment(
async function uploadBlobForAttachment(
page: Page,
attachmentModelId: string,
blob: Blob
Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/bookmark-block/bookmark-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type BookmarkBlockProps = {
} & BookmarkBlockUrlData &
BookmarkBlockEdgelessProps;

export const defaultBookmarkProps: BookmarkBlockProps = {
const defaultBookmarkProps: BookmarkBlockProps = {
style: 'horizontal',
url: '',
caption: null,
Expand Down
26 changes: 18 additions & 8 deletions packages/blocks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import './frame-block/index.js';
import './divider-block/index.js';
import './code-block/affine-code-line.js';
import './image-block/index.js';
import './surface-block/index.js';
import './database-block/index.js';
import './surface-ref-block/index.js';

Expand All @@ -17,8 +16,10 @@ import { matchFlavours } from './_common/utils/index.js';
import { splitElements } from './page-block/edgeless/utils/clipboard-utils.js';

export * from './_common/adapters/index.js';
export * from './_common/components/index.js';
export { NOTE_WIDTH } from './_common/consts.js';
export {
type AffineInlineEditor,
RichText,
} from './_common/components/index.js';
export {
EdgelessPresentationConsts as EdgelessPresentationConsts,
type NavigatorMode,
Expand All @@ -35,8 +36,8 @@ export {
ThemeObserver,
} from './_common/theme/theme-observer.js';
export * from './_common/transformers/index.js';
export * from './_common/types.js';
export { on, once, stopPropagation } from './_common/utils/event.js';
export { type AbstractEditor } from './_common/types.js';
export { on, once } from './_common/utils/event.js';
export { createDefaultPage } from './_common/utils/init.js';
export type { BlockModels } from './_common/utils/model.js';
export { getThemeMode } from './_common/utils/query.js';
Expand All @@ -60,9 +61,18 @@ export * from './models.js';
export * from './note-block/index.js';
export * from './page-block/index.js';
export * from './paragraph-block/index.js';
export * from './surface-block/index.js';
export * from './surface-block/surface-block.js';
export * from './surface-block/surface-model.js';
export {
Bound,
CanvasElementType,
ConnectorEndpointStyle,
ConnectorMode,
EdgelessBlockType,
generateKeyBetween,
ShapeStyle,
StrokeStyle,
} from './surface-block/index.js';
export { SurfaceBlockComponent } from './surface-block/surface-block.js';
export { SurfaceBlockSchema } from './surface-block/surface-model.js';
export * from './surface-block/surface-service.js';
export * from './surface-ref-block/index.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { toggleBookmarkEditModal } from '../../../../bookmark-block/components/i
import type { BookmarkBlockComponent } from '../../../../index.js';
import type { BookmarkBlockModel } from '../../../../models.js';
import type { SurfaceBlockComponent } from '../../../../surface-block/surface-block.js';
import type { EdgelessSelectionSlots } from '../../edgeless-page-block.js';

@customElement('edgeless-change-bookmark-button')
export class EdgelessChangeBookmarkButton extends WithDisposable(LitElement) {
Expand All @@ -29,9 +28,6 @@ export class EdgelessChangeBookmarkButton extends WithDisposable(LitElement) {
@property({ attribute: false })
surface!: SurfaceBlockComponent;

@property({ attribute: false })
slots!: EdgelessSelectionSlots;

override render() {
return html`<div class="change-bookmark-container">
<icon-button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type {
CanvasElementType,
} from '../../../../surface-block/index.js';
import type { SurfaceBlockComponent } from '../../../../surface-block/surface-block.js';
import type { EdgelessSelectionSlots } from '../../edgeless-page-block.js';
import {
type ColorEvent,
type EdgelessColorPanel,
Expand Down Expand Up @@ -100,9 +99,6 @@ export class EdgelessChangeBrushButton extends WithDisposable(LitElement) {
@property({ attribute: false })
surface!: SurfaceBlockComponent;

@property({ attribute: false })
slots!: EdgelessSelectionSlots;

@state()
private _showPopper = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { matchFlavours } from '../../../../_common/utils/model.js';
import { type NoteBlockModel } from '../../../../note-block/note-model.js';
import { Bound, StrokeStyle } from '../../../../surface-block/index.js';
import type { SurfaceBlockComponent } from '../../../../surface-block/surface-block.js';
import type { EdgelessSelectionSlots } from '../../edgeless-page-block.js';
import { type ColorEvent, ColorUnit } from '../panel/color-panel.js';
import {
LineStylesPanel,
Expand Down Expand Up @@ -172,9 +171,6 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
@property({ attribute: false })
surface!: SurfaceBlockComponent;

@property({ attribute: false })
slots!: EdgelessSelectionSlots;

@state()
private _queryCache = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ import type { CssVariableName } from '../../../../_common/theme/css-variables.js
import { LineWidth, type ShapeTool } from '../../../../_common/types.js';
import { countBy, maxBy } from '../../../../_common/utils/iterable.js';
import { CanvasTextFontFamily } from '../../../../surface-block/consts.js';
import {
FILL_COLORS,
STROKE_COLORS,
} from '../../../../surface-block/elements/shape/consts.js';
import type { CanvasElementType } from '../../../../surface-block/index.js';
import {
type ShapeElement,
ShapeStyle,
StrokeStyle,
} from '../../../../surface-block/index.js';
import type { SurfaceBlockComponent } from '../../../../surface-block/surface-block.js';
import type { EdgelessSelectionSlots } from '../../edgeless-page-block.js';
import {
SHAPE_FILL_COLOR_BLACK,
SHAPE_TEXT_COLOR_PURE_BLACK,
Expand Down Expand Up @@ -123,38 +126,6 @@ function getMostCommonShapeStyle(elements: ShapeElement[]): ShapeStyle {
return max ? (max[0] as ShapeStyle) : ShapeStyle.Scribbled;
}

const FILL_COLORS: CssVariableName[] = [
'--affine-palette-shape-yellow',
'--affine-palette-shape-orange',
'--affine-palette-shape-tangerine',
'--affine-palette-shape-red',
'--affine-palette-shape-magenta',
'--affine-palette-shape-purple',
'--affine-palette-shape-green',
'--affine-palette-shape-blue',
'--affine-palette-shape-navy',
'--affine-palette-shape-black',
'--affine-palette-shape-white',
'--affine-palette-transparent',
];
export const DEFAULT_SHAPE_FILL_COLOR = FILL_COLORS[0];

const STROKE_COLORS: CssVariableName[] = [
'--affine-palette-line-yellow',
'--affine-palette-line-orange',
'--affine-palette-line-tangerine',
'--affine-palette-line-red',
'--affine-palette-line-magenta',
'--affine-palette-line-purple',
'--affine-palette-line-green',
'--affine-palette-line-blue',
'--affine-palette-line-navy',
'--affine-palette-line-black',
'--affine-palette-line-white',
'--affine-palette-transparent',
];
export const DEFAULT_SHAPE_STROKE_COLOR = STROKE_COLORS[0];

@customElement('edgeless-change-shape-button')
export class EdgelessChangeShapeButton extends WithDisposable(LitElement) {
static override styles = [
Expand Down Expand Up @@ -270,9 +241,6 @@ export class EdgelessChangeShapeButton extends WithDisposable(LitElement) {
@property({ attribute: false })
surface!: SurfaceBlockComponent;

@property({ attribute: false })
slots!: EdgelessSelectionSlots;

@state()
private _showPopper = false;

Expand Down Expand Up @@ -590,7 +558,6 @@ export class EdgelessChangeShapeButton extends WithDisposable(LitElement) {
.elements=${this.elements}
.elementType=${'shape'}
.surface=${this.surface}
.slots=${this.slots}
></edgeless-change-text-menu>`
: nothing}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { customElement, property } from 'lit/decorators.js';

import type { TextElement } from '../../../../surface-block/index.js';
import type { SurfaceBlockComponent } from '../../../../surface-block/surface-block.js';
import type { EdgelessSelectionSlots } from '../../edgeless-page-block.js';

@customElement('edgeless-change-text-button')
export class EdgelessChangeTextButton extends WithDisposable(LitElement) {
Expand All @@ -31,16 +30,12 @@ export class EdgelessChangeTextButton extends WithDisposable(LitElement) {
@property({ attribute: false })
surface!: SurfaceBlockComponent;

@property({ attribute: false })
slots!: EdgelessSelectionSlots;

override render() {
return html`<div class="change-text-container">
<edgeless-change-text-menu
.elements=${this.texts}
.elementType=${'text'}
.surface=${this.surface}
.slots=${this.slots}
></edgeless-change-text-menu>
</div>`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
type TextElement,
} from '../../../../surface-block/index.js';
import type { SurfaceBlockComponent } from '../../../../surface-block/surface-block.js';
import type { EdgelessSelectionSlots } from '../../edgeless-page-block.js';
import type { EdgelessAlignPanel } from '../panel/align-panel.js';
import {
type ColorEvent,
Expand Down Expand Up @@ -151,9 +150,6 @@ export class EdgelessChangeTextMenu extends WithDisposable(LitElement) {
@property({ attribute: false })
surface!: SurfaceBlockComponent;

@property({ attribute: false })
slots!: EdgelessSelectionSlots;

@state()
private _textColorPopperShow = false;
@state()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ export class EdgelessComponentToolbar extends WithDisposable(LitElement) {
.elements=${shapeElements}
.page=${this.page}
.surface=${this.surface}
.slots=${this.slots}
>
</edgeless-change-shape-button>`
: nothing;
Expand All @@ -150,7 +149,6 @@ export class EdgelessComponentToolbar extends WithDisposable(LitElement) {
.elements=${brushElements}
.page=${this.page}
.surface=${this.surface}
.slots=${this.slots}
>
</edgeless-change-brush-button>`
: nothing;
Expand All @@ -173,7 +171,6 @@ export class EdgelessComponentToolbar extends WithDisposable(LitElement) {
? html`<edgeless-change-note-button
.notes=${notes}
.surface=${this.surface}
.slots=${this.slots}
>
</edgeless-change-note-button>`
: nothing;
Expand All @@ -186,7 +183,6 @@ export class EdgelessComponentToolbar extends WithDisposable(LitElement) {
.bookmark=${bookmarks[0]}
.page=${this.page}
.surface=${this.surface}
.slots=${this.slots}
></edgeless-change-bookmark-button>
`
: nothing;
Expand All @@ -198,7 +194,6 @@ export class EdgelessComponentToolbar extends WithDisposable(LitElement) {
.texts=${textElements}
.page=${this.page}
.surface=${this.surface}
.slots=${this.slots}
>
</edgeless-change-text-button>`
: nothing;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {
} from '../../../../../_common/icons/index.js';
import type { CssVariableName } from '../../../../../_common/theme/css-variables.js';
import type { EdgelessTool } from '../../../../../_common/utils/index.js';
import { DEFAULT_SHAPE_FILL_COLOR } from '../../../../../surface-block/elements/shape/consts.js';
import {
ShapeStyle,
type ShapeType,
} from '../../../../../surface-block/index.js';
import type { EdgelessPageBlockComponent } from '../../../edgeless-page-block.js';
import { DEFAULT_SHAPE_FILL_COLOR } from '../../component-toolbar/change-shape-button.js';
import type { ColorEvent } from '../../panel/color-panel.js';
import {
LINE_COLOR_PREFIX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import type {
EdgelessTool,
ShapeToolState,
} from '../../../../../_common/utils/index.js';
import { ShapeStyle } from '../../../../../surface-block/index.js';
import type { EdgelessPageBlockComponent } from '../../../edgeless-page-block.js';
import {
DEFAULT_SHAPE_FILL_COLOR,
DEFAULT_SHAPE_STROKE_COLOR,
} from '../../component-toolbar/change-shape-button.js';
} from '../../../../../surface-block/elements/shape/consts.js';
import { ShapeStyle } from '../../../../../surface-block/index.js';
import type { EdgelessPageBlockComponent } from '../../../edgeless-page-block.js';
import { getTooltipWithShortcut } from '../../utils.js';
import { createPopper, type MenuPopper } from '../common/create-popper.js';
import type { EdgelessShapeMenu } from './shape-menu.js';
Expand Down
Loading

1 comment on commit 993a889

@vercel
Copy link

@vercel vercel bot commented on 993a889 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blocksuite – ./packages/playground

blocksuite-toeverything.vercel.app
blocksuite-git-master-toeverything.vercel.app
try-blocksuite.vercel.app

Please sign in to comment.