mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 05:58:56 +08:00
refactor(editor): remove AbstractEditor type and feature flags in test (#10308)
This commit is contained in:
@@ -12,7 +12,9 @@ effects();
|
||||
import {
|
||||
CommunityCanvasTextFonts,
|
||||
type DocMode,
|
||||
EdgelessEditorBlockSpecs,
|
||||
FontConfigExtension,
|
||||
PageEditorBlockSpecs,
|
||||
StoreExtensions,
|
||||
} from '@blocksuite/blocks';
|
||||
import { AffineSchemas } from '@blocksuite/blocks/schemas';
|
||||
@@ -71,14 +73,16 @@ async function createEditor(
|
||||
const editor = new AffineEditorContainer();
|
||||
editor.doc = doc;
|
||||
editor.mode = mode;
|
||||
editor.pageSpecs = editor.pageSpecs.concat([
|
||||
editor.pageSpecs = [
|
||||
...PageEditorBlockSpecs,
|
||||
FontConfigExtension(CommunityCanvasTextFonts),
|
||||
...extensions,
|
||||
]);
|
||||
editor.edgelessSpecs = editor.edgelessSpecs.concat([
|
||||
];
|
||||
editor.edgelessSpecs = [
|
||||
...EdgelessEditorBlockSpecs,
|
||||
FontConfigExtension(CommunityCanvasTextFonts),
|
||||
...extensions,
|
||||
]);
|
||||
];
|
||||
app.append(editor);
|
||||
|
||||
window.editor = editor;
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
import { BlockStdScope, ShadowlessElement } from '@blocksuite/block-std';
|
||||
import {
|
||||
type AbstractEditor,
|
||||
type DocMode,
|
||||
EdgelessEditorBlockSpecs,
|
||||
PageEditorBlockSpecs,
|
||||
ThemeProvider,
|
||||
} from '@blocksuite/blocks';
|
||||
import { type DocMode, ThemeProvider } from '@blocksuite/blocks';
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';
|
||||
import {
|
||||
type BlockModel,
|
||||
@@ -18,10 +12,9 @@ import { property } from 'lit/decorators.js';
|
||||
import { keyed } from 'lit/directives/keyed.js';
|
||||
import { when } from 'lit/directives/when.js';
|
||||
|
||||
export class AffineEditorContainer
|
||||
extends SignalWatcher(WithDisposable(ShadowlessElement))
|
||||
implements AbstractEditor
|
||||
{
|
||||
export class AffineEditorContainer extends SignalWatcher(
|
||||
WithDisposable(ShadowlessElement)
|
||||
) {
|
||||
static override styles = css`
|
||||
.affine-page-viewport {
|
||||
position: relative;
|
||||
@@ -90,13 +83,11 @@ export class AffineEditorContainer
|
||||
|
||||
private readonly _doc = signal<Store>();
|
||||
|
||||
private readonly _edgelessSpecs = signal<ExtensionType[]>(
|
||||
EdgelessEditorBlockSpecs
|
||||
);
|
||||
private readonly _edgelessSpecs = signal<ExtensionType[]>([]);
|
||||
|
||||
private readonly _mode = signal<DocMode>('page');
|
||||
|
||||
private readonly _pageSpecs = signal<ExtensionType[]>(PageEditorBlockSpecs);
|
||||
private readonly _pageSpecs = signal<ExtensionType[]>([]);
|
||||
|
||||
private readonly _specs = computed(() =>
|
||||
this._mode.value === 'page'
|
||||
@@ -163,9 +154,6 @@ export class AffineEditorContainer
|
||||
return this._std.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated need to refactor
|
||||
*/
|
||||
override connectedCallback() {
|
||||
super.connectedCallback();
|
||||
|
||||
|
||||
@@ -77,12 +77,7 @@ export class PageEditor extends SignalWatcher(
|
||||
const std = this.std;
|
||||
const theme = std.get(ThemeProvider).app$.value;
|
||||
return html`
|
||||
<div
|
||||
data-theme=${theme}
|
||||
class=${this.hasViewport
|
||||
? 'affine-page-viewport'
|
||||
: 'page-editor-container'}
|
||||
>
|
||||
<div data-theme=${theme} class="page-editor-container">
|
||||
${guard([std], () => std.render())}
|
||||
</div>
|
||||
`;
|
||||
@@ -103,9 +98,6 @@ export class PageEditor extends SignalWatcher(
|
||||
@property({ attribute: false })
|
||||
accessor doc!: Store;
|
||||
|
||||
@property({ type: Boolean })
|
||||
accessor hasViewport = true;
|
||||
|
||||
@property({ attribute: false })
|
||||
accessor specs = PageEditorBlockSpecs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user