mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 13:29:02 +08:00
fe5f0f62ec
This PR performs a significant architectural refactoring by extracting rich text functionality into a dedicated package. Here are the key changes: 1. **New Package Creation** - Created a new package `@blocksuite/affine-rich-text` to house rich text related functionality - Moved rich text components, utilities, and types from `@blocksuite/affine-components` to this new package 2. **Dependency Updates** - Updated multiple block packages to include the new `@blocksuite/affine-rich-text` as a direct dependency: - block-callout - block-code - block-database - block-edgeless-text - block-embed - block-list - block-note - block-paragraph 3. **Import Path Updates** - Refactored all imports that previously referenced rich text functionality from `@blocksuite/affine-components/rich-text` to now use `@blocksuite/affine-rich-text` - Updated imports for components like: - DefaultInlineManagerExtension - RichText types and interfaces - Text manipulation utilities (focusTextModel, textKeymap, etc.) - Reference node components and providers 4. **Build Configuration Updates** - Added references to the new rich text package in the `tsconfig.json` files of all affected packages - Maintained workspace dependencies using the `workspace:*` version specifier The primary motivation appears to be: 1. Better separation of concerns by isolating rich text functionality 2. Improved maintainability through more modular package structure 3. Clearer dependencies between packages 4. Potential for better tree-shaking and bundle optimization This is primarily an architectural improvement that should make the codebase more maintainable and better organized.
137 lines
3.1 KiB
TypeScript
137 lines
3.1 KiB
TypeScript
import {
|
|
BulletedListIcon,
|
|
CheckBoxIcon,
|
|
CodeBlockIcon,
|
|
DividerIcon,
|
|
Heading1Icon,
|
|
Heading2Icon,
|
|
Heading3Icon,
|
|
Heading4Icon,
|
|
Heading5Icon,
|
|
Heading6Icon,
|
|
NumberedListIcon,
|
|
QuoteIcon,
|
|
TextIcon,
|
|
} from '@blocksuite/affine-components/icons';
|
|
import type { TemplateResult } from 'lit';
|
|
|
|
/**
|
|
* Text primitive entries used in slash menu and format bar,
|
|
* which are also used for registering hotkeys for converting block flavours.
|
|
*/
|
|
export interface TextConversionConfig {
|
|
flavour: string;
|
|
type?: string;
|
|
name: string;
|
|
description?: string;
|
|
hotkey: string[] | null;
|
|
icon: TemplateResult<1>;
|
|
}
|
|
|
|
export const textConversionConfigs: TextConversionConfig[] = [
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'text',
|
|
name: 'Text',
|
|
description: 'Start typing with plain text.',
|
|
hotkey: [`Mod-Alt-0`, `Mod-Shift-0`],
|
|
icon: TextIcon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'h1',
|
|
name: 'Heading 1',
|
|
description: 'Headings in the largest font.',
|
|
hotkey: [`Mod-Alt-1`, `Mod-Shift-1`],
|
|
icon: Heading1Icon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'h2',
|
|
name: 'Heading 2',
|
|
description: 'Headings in the 2nd font size.',
|
|
hotkey: [`Mod-Alt-2`, `Mod-Shift-2`],
|
|
icon: Heading2Icon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'h3',
|
|
name: 'Heading 3',
|
|
description: 'Headings in the 3rd font size.',
|
|
hotkey: [`Mod-Alt-3`, `Mod-Shift-3`],
|
|
icon: Heading3Icon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'h4',
|
|
name: 'Heading 4',
|
|
description: 'Headings in the 4th font size.',
|
|
hotkey: [`Mod-Alt-4`, `Mod-Shift-4`],
|
|
icon: Heading4Icon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'h5',
|
|
name: 'Heading 5',
|
|
description: 'Headings in the 5th font size.',
|
|
hotkey: [`Mod-Alt-5`, `Mod-Shift-5`],
|
|
icon: Heading5Icon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'h6',
|
|
name: 'Heading 6',
|
|
description: 'Headings in the 6th font size.',
|
|
hotkey: [`Mod-Alt-6`, `Mod-Shift-6`],
|
|
icon: Heading6Icon,
|
|
},
|
|
{
|
|
flavour: 'affine:list',
|
|
type: 'bulleted',
|
|
name: 'Bulleted List',
|
|
description: 'Create a bulleted list.',
|
|
hotkey: [`Mod-Alt-8`, `Mod-Shift-8`],
|
|
icon: BulletedListIcon,
|
|
},
|
|
{
|
|
flavour: 'affine:list',
|
|
type: 'numbered',
|
|
name: 'Numbered List',
|
|
description: 'Create a numbered list.',
|
|
hotkey: [`Mod-Alt-9`, `Mod-Shift-9`],
|
|
icon: NumberedListIcon,
|
|
},
|
|
{
|
|
flavour: 'affine:list',
|
|
type: 'todo',
|
|
name: 'To-do List',
|
|
description: 'Add tasks to a to-do list.',
|
|
hotkey: null,
|
|
icon: CheckBoxIcon,
|
|
},
|
|
{
|
|
flavour: 'affine:code',
|
|
type: undefined,
|
|
name: 'Code Block',
|
|
description: 'Code snippet with formatting.',
|
|
hotkey: [`Mod-Alt-c`],
|
|
icon: CodeBlockIcon,
|
|
},
|
|
{
|
|
flavour: 'affine:paragraph',
|
|
type: 'quote',
|
|
name: 'Quote',
|
|
description: 'Add a blockquote for emphasis.',
|
|
hotkey: null,
|
|
icon: QuoteIcon,
|
|
},
|
|
{
|
|
flavour: 'affine:divider',
|
|
type: 'divider',
|
|
name: 'Divider',
|
|
description: 'Visually separate content.',
|
|
hotkey: [`Mod-Alt-d`, `Mod-Shift-d`],
|
|
icon: DividerIcon,
|
|
},
|
|
];
|