mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-22 20:41:50 +08:00
refactor(editor): move text toolbar config and components to its package (#11083)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import { frameToolbarExtension } from '@blocksuite/affine-block-frame';
|
import { frameToolbarExtension } from '@blocksuite/affine-block-frame';
|
||||||
|
import { textToolbarConfig } from '@blocksuite/affine-gfx-text';
|
||||||
import { ToolbarModuleExtension } from '@blocksuite/affine-shared/services';
|
import { ToolbarModuleExtension } from '@blocksuite/affine-shared/services';
|
||||||
import { BlockFlavourIdentifier } from '@blocksuite/block-std';
|
import { BlockFlavourIdentifier } from '@blocksuite/block-std';
|
||||||
import type { ExtensionType } from '@blocksuite/store';
|
import type { ExtensionType } from '@blocksuite/store';
|
||||||
@@ -10,7 +11,6 @@ import { builtinGroupToolbarConfig } from './group';
|
|||||||
import { builtinMindmapToolbarConfig } from './mindmap';
|
import { builtinMindmapToolbarConfig } from './mindmap';
|
||||||
import { builtinLockedToolbarConfig, builtinMiscToolbarConfig } from './misc';
|
import { builtinLockedToolbarConfig, builtinMiscToolbarConfig } from './misc';
|
||||||
import { builtinShapeToolbarConfig } from './shape';
|
import { builtinShapeToolbarConfig } from './shape';
|
||||||
import { builtinTextToolbarConfig } from './text';
|
|
||||||
|
|
||||||
export const EdgelessElementToolbarExtension: ExtensionType[] = [
|
export const EdgelessElementToolbarExtension: ExtensionType[] = [
|
||||||
frameToolbarExtension,
|
frameToolbarExtension,
|
||||||
@@ -37,7 +37,7 @@ export const EdgelessElementToolbarExtension: ExtensionType[] = [
|
|||||||
|
|
||||||
ToolbarModuleExtension({
|
ToolbarModuleExtension({
|
||||||
id: BlockFlavourIdentifier('affine:surface:text'),
|
id: BlockFlavourIdentifier('affine:surface:text'),
|
||||||
config: builtinTextToolbarConfig,
|
config: textToolbarConfig,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
ToolbarModuleExtension({
|
ToolbarModuleExtension({
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ import { OverlayScrollbar } from './edgeless/components/toolbar/template/overlay
|
|||||||
import { AffineTemplateLoading } from './edgeless/components/toolbar/template/template-loading.js';
|
import { AffineTemplateLoading } from './edgeless/components/toolbar/template/template-loading.js';
|
||||||
import { EdgelessTemplatePanel } from './edgeless/components/toolbar/template/template-panel.js';
|
import { EdgelessTemplatePanel } from './edgeless/components/toolbar/template/template-panel.js';
|
||||||
import { EdgelessTemplateButton } from './edgeless/components/toolbar/template/template-tool-button.js';
|
import { EdgelessTemplateButton } from './edgeless/components/toolbar/template/template-tool-button.js';
|
||||||
import { EdgelessTextMenu } from './edgeless/components/toolbar/text/text-menu.js';
|
|
||||||
import {
|
import {
|
||||||
AffineImageToolbarWidget,
|
AffineImageToolbarWidget,
|
||||||
AffineModalWidget,
|
AffineModalWidget,
|
||||||
@@ -174,7 +173,6 @@ function registerEdgelessToolbarComponents() {
|
|||||||
customElements.define('edgeless-frame-menu', EdgelessFrameMenu);
|
customElements.define('edgeless-frame-menu', EdgelessFrameMenu);
|
||||||
customElements.define('edgeless-mindmap-menu', EdgelessMindmapMenu);
|
customElements.define('edgeless-mindmap-menu', EdgelessMindmapMenu);
|
||||||
customElements.define('edgeless-note-menu', EdgelessNoteMenu);
|
customElements.define('edgeless-note-menu', EdgelessNoteMenu);
|
||||||
customElements.define('edgeless-text-menu', EdgelessTextMenu);
|
|
||||||
customElements.define('edgeless-slide-menu', EdgelessSlideMenu);
|
customElements.define('edgeless-slide-menu', EdgelessSlideMenu);
|
||||||
|
|
||||||
// Toolbar components
|
// Toolbar components
|
||||||
@@ -318,7 +316,6 @@ declare global {
|
|||||||
'overlay-scrollbar': OverlayScrollbar;
|
'overlay-scrollbar': OverlayScrollbar;
|
||||||
'affine-template-loading': AffineTemplateLoading;
|
'affine-template-loading': AffineTemplateLoading;
|
||||||
'edgeless-templates-panel': EdgelessTemplatePanel;
|
'edgeless-templates-panel': EdgelessTemplatePanel;
|
||||||
'edgeless-text-menu': EdgelessTextMenu;
|
|
||||||
'affine-page-root': PageRootBlockComponent;
|
'affine-page-root': PageRootBlockComponent;
|
||||||
'zoom-bar-toggle-button': ZoomBarToggleButton;
|
'zoom-bar-toggle-button': ZoomBarToggleButton;
|
||||||
'edgeless-zoom-toolbar': EdgelessZoomToolbar;
|
'edgeless-zoom-toolbar': EdgelessZoomToolbar;
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
|
export * from './config';
|
||||||
export * from './icons';
|
export * from './icons';
|
||||||
export * from './shape';
|
|
||||||
export * from './shape-menu-config';
|
export * from './shape-menu-config';
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"@blocksuite/affine-model": "workspace:*",
|
"@blocksuite/affine-model": "workspace:*",
|
||||||
"@blocksuite/affine-rich-text": "workspace:*",
|
"@blocksuite/affine-rich-text": "workspace:*",
|
||||||
"@blocksuite/affine-shared": "workspace:*",
|
"@blocksuite/affine-shared": "workspace:*",
|
||||||
|
"@blocksuite/affine-widget-edgeless-toolbar": "workspace:*",
|
||||||
"@blocksuite/block-std": "workspace:*",
|
"@blocksuite/block-std": "workspace:*",
|
||||||
"@blocksuite/global": "workspace:*",
|
"@blocksuite/global": "workspace:*",
|
||||||
"@blocksuite/icons": "^2.2.6",
|
"@blocksuite/icons": "^2.2.6",
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import { EdgelessTextEditor } from './edgeless-text-editor';
|
import { EdgelessTextEditor } from './edgeless-text-editor';
|
||||||
|
import { EdgelessTextMenu } from './toolbar/text-menu';
|
||||||
|
|
||||||
export function effects() {
|
export function effects() {
|
||||||
customElements.define('edgeless-text-editor', EdgelessTextEditor);
|
customElements.define('edgeless-text-editor', EdgelessTextEditor);
|
||||||
|
customElements.define('edgeless-text-menu', EdgelessTextMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
'edgeless-text-editor': EdgelessTextEditor;
|
'edgeless-text-editor': EdgelessTextEditor;
|
||||||
|
'edgeless-text-menu': EdgelessTextMenu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
export * from './edgeless-text-editor';
|
export * from './edgeless-text-editor';
|
||||||
export * from './mount-text-editor';
|
export * from './mount-text-editor';
|
||||||
export * from './tool';
|
export * from './tool';
|
||||||
|
export * from './toolbar';
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ import { type ToolbarModuleConfig } from '@blocksuite/affine-shared/services';
|
|||||||
import { createTextActions } from '@blocksuite/affine-widget-edgeless-toolbar';
|
import { createTextActions } from '@blocksuite/affine-widget-edgeless-toolbar';
|
||||||
import { Bound } from '@blocksuite/global/gfx';
|
import { Bound } from '@blocksuite/global/gfx';
|
||||||
|
|
||||||
export const builtinTextToolbarConfig = {
|
export const textToolbarConfig = {
|
||||||
actions: createTextActions(TextElementModel, 'text', (ctx, model, props) => {
|
actions: createTextActions(TextElementModel, 'text', (ctx, model, props) => {
|
||||||
// No need to adjust element bounds
|
// No need to adjust element bounds
|
||||||
if (props['textAlign']) {
|
if (props['textAlign']) {
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './config';
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
{ "path": "../../model" },
|
{ "path": "../../model" },
|
||||||
{ "path": "../../rich-text" },
|
{ "path": "../../rich-text" },
|
||||||
{ "path": "../../shared" },
|
{ "path": "../../shared" },
|
||||||
|
{ "path": "../../widgets/widget-edgeless-toolbar" },
|
||||||
{ "path": "../../../framework/block-std" },
|
{ "path": "../../../framework/block-std" },
|
||||||
{ "path": "../../../framework/global" },
|
{ "path": "../../../framework/global" },
|
||||||
{ "path": "../../../framework/store" }
|
{ "path": "../../../framework/store" }
|
||||||
|
|||||||
@@ -464,6 +464,7 @@ export const PackageList = [
|
|||||||
'blocksuite/affine/model',
|
'blocksuite/affine/model',
|
||||||
'blocksuite/affine/rich-text',
|
'blocksuite/affine/rich-text',
|
||||||
'blocksuite/affine/shared',
|
'blocksuite/affine/shared',
|
||||||
|
'blocksuite/affine/widgets/widget-edgeless-toolbar',
|
||||||
'blocksuite/framework/block-std',
|
'blocksuite/framework/block-std',
|
||||||
'blocksuite/framework/global',
|
'blocksuite/framework/global',
|
||||||
'blocksuite/framework/store',
|
'blocksuite/framework/store',
|
||||||
|
|||||||
@@ -3011,6 +3011,7 @@ __metadata:
|
|||||||
"@blocksuite/affine-model": "workspace:*"
|
"@blocksuite/affine-model": "workspace:*"
|
||||||
"@blocksuite/affine-rich-text": "workspace:*"
|
"@blocksuite/affine-rich-text": "workspace:*"
|
||||||
"@blocksuite/affine-shared": "workspace:*"
|
"@blocksuite/affine-shared": "workspace:*"
|
||||||
|
"@blocksuite/affine-widget-edgeless-toolbar": "workspace:*"
|
||||||
"@blocksuite/block-std": "workspace:*"
|
"@blocksuite/block-std": "workspace:*"
|
||||||
"@blocksuite/global": "workspace:*"
|
"@blocksuite/global": "workspace:*"
|
||||||
"@blocksuite/icons": "npm:^2.2.6"
|
"@blocksuite/icons": "npm:^2.2.6"
|
||||||
|
|||||||
Reference in New Issue
Block a user