refactor(editor): separate lit and slot in global (#10666)

This commit is contained in:
Saul-Mirone
2025-03-06 10:24:59 +00:00
parent 56b842f2e1
commit 84e2dda3f8
322 changed files with 366 additions and 353 deletions

View File

@@ -1,4 +1,4 @@
import { SignalWatcher } from '@blocksuite/global/utils';
import { SignalWatcher } from '@blocksuite/global/lit';
import { css, LitElement, type PropertyValues } from 'lit';
import { property } from 'lit/decorators.js';

View File

@@ -7,7 +7,7 @@ import {
ShadowlessElement,
stdContext,
} from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import type { BlockModel, Store } from '@blocksuite/store';
import { Text } from '@blocksuite/store';
import { consume } from '@lit/context';

View File

@@ -8,7 +8,7 @@ import {
requiredProperties,
ShadowlessElement,
} from '@blocksuite/block-std';
import { SignalWatcher } from '@blocksuite/global/utils';
import { SignalWatcher } from '@blocksuite/global/lit';
import { PaletteIcon } from '@blocksuite/icons/lit';
import {
computed,

View File

@@ -1,7 +1,7 @@
import type { ColorScheme, Palette } from '@blocksuite/affine-model';
import { DefaultTheme, resolveColor } from '@blocksuite/affine-model';
import type { ColorEvent } from '@blocksuite/affine-shared/utils';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { html, LitElement } from 'lit';
import { property, query, state } from 'lit/decorators.js';
import { choose } from 'lit/directives/choose.js';

View File

@@ -1,7 +1,7 @@
import type { Color } from '@blocksuite/affine-model';
import { on, once, stopPropagation } from '@blocksuite/affine-shared/utils';
import { clamp } from '@blocksuite/global/gfx';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { batch, computed, signal } from '@preact/signals-core';
import { html, LitElement } from 'lit';
import { property, query } from 'lit/decorators.js';

View File

@@ -1,5 +1,5 @@
import { ShadowlessElement } from '@blocksuite/block-std';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { property } from 'lit/decorators.js';
import type { Menu } from './menu.js';

View File

@@ -1,7 +1,7 @@
import { unsafeCSSVar, unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import { ShadowlessElement } from '@blocksuite/block-std';
import { IS_MOBILE } from '@blocksuite/global/env';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import {
ArrowLeftBigIcon,
ArrowLeftSmallIcon,

View File

@@ -1,5 +1,5 @@
import { clamp } from '@blocksuite/global/gfx';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { isSameDay, isSameMonth, isToday } from 'date-fns';
import {
html,

View File

@@ -8,7 +8,7 @@ import {
} from '@blocksuite/affine-model';
import { matchModels } from '@blocksuite/affine-shared/utils';
import { ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import type { Store } from '@blocksuite/store';
import { effect } from '@preact/signals-core';
import { css, html } from 'lit';

View File

@@ -1,6 +1,6 @@
import { stopPropagation } from '@blocksuite/affine-shared/utils';
import { type BlockComponent, ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import type { BlockModel } from '@blocksuite/store';
import { html } from 'lit';
import { property, query } from 'lit/decorators.js';

View File

@@ -3,7 +3,7 @@ import { isValidUrl, stopPropagation } from '@blocksuite/affine-shared/utils';
import type { EditorHost } from '@blocksuite/block-std';
import { ShadowlessElement } from '@blocksuite/block-std';
import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import type { BlockModel } from '@blocksuite/store';
import { html } from 'lit';
import { property, query, state } from 'lit/decorators.js';

View File

@@ -20,11 +20,8 @@ import type {
BlockStdScope,
EditorHost,
} from '@blocksuite/block-std';
import {
nextTick,
SignalWatcher,
WithDisposable,
} from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { nextTick } from '@blocksuite/global/utils';
import { autoUpdate, computePosition, flip, offset } from '@floating-ui/dom';
import { computed, signal } from '@preact/signals-core';
import { css, html, LitElement } from 'lit';

View File

@@ -1,5 +1,5 @@
import { PAGE_HEADER_HEIGHT } from '@blocksuite/affine-shared/consts';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { DoneIcon, SearchIcon } from '@blocksuite/icons/lit';
import { autoPlacement, offset, type Placement, size } from '@floating-ui/dom';
import { html, LitElement, nothing } from 'lit';

View File

@@ -1,4 +1,4 @@
import { DisposableGroup } from '@blocksuite/global/utils';
import { DisposableGroup } from '@blocksuite/global/slot';
import type { ReactiveController, ReactiveElement } from 'lit';
import {

View File

@@ -1,5 +1,5 @@
import type { BlockComponent, BlockStdScope } from '@blocksuite/block-std';
import type { DisposableClass } from '@blocksuite/global/utils';
import type { DisposableClass } from '@blocksuite/global/lit';
import type { LitElement, TemplateResult } from 'lit';
export type PeekableClass = { std: BlockStdScope } & DisposableClass &

View File

@@ -1,5 +1,5 @@
import { BlockSuiteError } from '@blocksuite/global/exceptions';
import { Slot } from '@blocksuite/global/utils';
import { Slot } from '@blocksuite/global/slot';
import {
autoUpdate,
computePosition,

View File

@@ -1,4 +1,4 @@
import type { Slot } from '@blocksuite/global/utils';
import type { Slot } from '@blocksuite/global/slot';
import type {
AutoUpdateOptions,
ComputePositionConfig,

View File

@@ -1,5 +1,5 @@
import { createIdentifier } from '@blocksuite/global/di';
import { Slot } from '@blocksuite/global/utils';
import { Slot } from '@blocksuite/global/slot';
import type { ExtensionType } from '@blocksuite/store';
import type { RefNodeSlots } from '../inline/index.js';

View File

@@ -7,7 +7,7 @@ import {
ShadowlessElement,
TextSelection,
} from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import {
type DeltaInsert,
INLINE_ROOT_ATTR,

View File

@@ -6,7 +6,7 @@ import {
} from '@blocksuite/affine-shared/services';
import { unsafeCSSVar, unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import type { BlockStdScope } from '@blocksuite/block-std';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { DualLinkIcon, LinkIcon } from '@blocksuite/icons/lit';
import { computed, signal } from '@preact/signals-core';
import { css, html, LitElement, type TemplateResult } from 'lit';

View File

@@ -2,7 +2,8 @@ import { ColorScheme } from '@blocksuite/affine-model';
import { ThemeProvider } from '@blocksuite/affine-shared/services';
import { unsafeCSSVar } from '@blocksuite/affine-shared/theme';
import { type BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';
import { noop, SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { noop } from '@blocksuite/global/utils';
import { DoneIcon } from '@blocksuite/icons/lit';
import { effect, type Signal, signal } from '@preact/signals-core';
import { css, html } from 'lit';

View File

@@ -5,7 +5,7 @@ import {
type BlockStdScope,
ShadowlessElement,
} from '@blocksuite/block-std';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import {
type DeltaInsert,
type InlineEditor,

View File

@@ -6,7 +6,7 @@ import {
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import type { BlockComponent, BlockStdScope } from '@blocksuite/block-std';
import { BLOCK_ID_ATTR, ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import {
type DeltaInsert,
INLINE_ROOT_ATTR,

View File

@@ -4,7 +4,7 @@ import {
stopPropagation,
} from '@blocksuite/affine-shared/utils';
import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { DoneIcon } from '@blocksuite/icons/lit';
import type { InlineRange } from '@blocksuite/inline/types';
import { computePosition, inline, offset, shift } from '@floating-ui/dom';

View File

@@ -14,7 +14,7 @@ import {
} from '@blocksuite/affine-shared/utils';
import type { BlockComponent, BlockStdScope } from '@blocksuite/block-std';
import { BLOCK_ID_ATTR, ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { LinkedPageIcon } from '@blocksuite/icons/lit';
import {
type DeltaInsert,

View File

@@ -9,7 +9,7 @@ import { FONT_XS, PANEL_BASE } from '@blocksuite/affine-shared/styles';
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { stopPropagation } from '@blocksuite/affine-shared/utils';
import { type BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { DoneIcon, ResetIcon } from '@blocksuite/icons/lit';
import type { InlineRange } from '@blocksuite/inline';
import { computePosition, inline, offset, shift } from '@floating-ui/dom';

View File

@@ -1,7 +1,7 @@
import type { ReferenceInfo } from '@blocksuite/affine-model';
import type { OpenDocMode } from '@blocksuite/affine-shared/services';
import type { EditorHost } from '@blocksuite/block-std';
import type { Slot } from '@blocksuite/global/utils';
import type { Slot } from '@blocksuite/global/slot';
export type DocLinkClickedEvent = ReferenceInfo & {
// default is active view

View File

@@ -1,6 +1,6 @@
import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';
import { ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import {
type AttributeRenderer,
type DeltaInsert,

View File

@@ -1,5 +1,5 @@
import { ShadowlessElement } from '@blocksuite/block-std';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { ToggleDownIcon, ToggleRightIcon } from '@blocksuite/icons/lit';
import { css, unsafeCSS } from 'lit';
import { property } from 'lit/decorators.js';

View File

@@ -1,6 +1,6 @@
import { PANEL_BASE } from '@blocksuite/affine-shared/styles';
import { createButtonPopper } from '@blocksuite/affine-shared/utils';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import {
css,
html,

View File

@@ -1,6 +1,6 @@
import { PANEL_BASE } from '@blocksuite/affine-shared/styles';
import { stopPropagation } from '@blocksuite/affine-shared/utils';
import { WithDisposable } from '@blocksuite/global/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import { css, html, LitElement } from 'lit';
export class EditorToolbar extends WithDisposable(LitElement) {

View File

@@ -7,7 +7,7 @@ import {
requiredProperties,
ShadowlessElement,
} from '@blocksuite/block-std';
import { SignalWatcher } from '@blocksuite/global/utils';
import { SignalWatcher } from '@blocksuite/global/lit';
import { ArrowDownSmallIcon } from '@blocksuite/icons/lit';
import type { ReadonlySignal, Signal } from '@preact/signals-core';
import { property } from 'lit/decorators.js';