Files
AFFiNE-Mirror/blocksuite/playground/apps/starter/utils/extensions.ts
L-Sun 1d865f16fe feat(editor): comment for edgeless element (#13098)
#### PR Dependency Tree


* **PR #13098** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added support for comments on graphical elements, allowing users to
comment on both blocks and graphical elements within surfaces.
* Enhanced comment previews to include graphical elements in selection
summaries.
* Improved editor navigation to focus on commented graphical elements in
addition to blocks and inline texts.

* **Bug Fixes**
* Updated comment highlighting and management to consistently use the
new comment manager across all block and element types.

* **Refactor**
* Renamed and extended the comment manager to handle both block and
element comments.
* Streamlined toolbar configurations by removing outdated comment button
entries and adding a consolidated comment button in the root toolbar.

* **Tests**
* Disabled the mock comment provider integration in the test editor
environment to refine testing setup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-07-08 10:33:09 +00:00

67 lines
1.9 KiB
TypeScript

import { RefNodeSlotsProvider } from '@blocksuite/affine/inlines/reference';
import {
CommunityCanvasTextFonts,
DocModeProvider,
EditorSettingExtension,
FeatureFlagService,
FontConfigExtension,
ParseDocUrlExtension,
} from '@blocksuite/affine/shared/services';
import type { ExtensionType, Store, Workspace } from '@blocksuite/affine/store';
import { type TestAffineEditorContainer } from '@blocksuite/integration-test';
import { getTestViewManager } from '@blocksuite/integration-test/view';
import {
mockDocModeService,
mockEditorSetting,
mockParseDocUrlService,
} from '../../_common/mock-services';
const viewManager = getTestViewManager();
export function getTestCommonExtensions(
editor: TestAffineEditorContainer
): ExtensionType[] {
return [
FontConfigExtension(CommunityCanvasTextFonts),
EditorSettingExtension({
setting$: mockEditorSetting(),
}),
ParseDocUrlExtension(mockParseDocUrlService(editor.doc.workspace)),
{
setup: di => {
di.override(DocModeProvider, mockDocModeService(editor));
},
},
// CommentProviderExtension(mockCommentProvider()),
];
}
export function createTestEditor(store: Store, workspace: Workspace) {
store
.get(FeatureFlagService)
.setFlag('enable_advanced_block_visibility', true);
const editor = document.createElement('affine-editor-container');
editor.autofocus = true;
editor.doc = store;
const defaultExtensions = getTestCommonExtensions(editor);
editor.pageSpecs = [...viewManager.get('page'), ...defaultExtensions];
editor.edgelessSpecs = [...viewManager.get('edgeless'), ...defaultExtensions];
editor.std
.get(RefNodeSlotsProvider)
.docLinkClicked.subscribe(({ pageId: docId }) => {
const target = workspace.getDoc(docId)?.getStore();
if (!target) {
throw new Error(`Failed to jump to doc ${docId}`);
}
target.load();
editor.doc = target;
});
return editor;
}