Commit Graph

8708 Commits

Author SHA1 Message Date
Saul-Mirone
dc047aa1a4 feat(editor): allow undefined default props (#10701)
Closes: [BS-2771](https://linear.app/affine-design/issue/BS-2771/%E6%84%9F%E8%A7%89%E5%BE%97%E6%94%AF%E6%8C%81%E5%8F%AF%E9%80%89%E5%AD%97%E6%AE%B5[mirone]1f862b1b-8523-4487-a948-fef9174e8825)
2025-03-07 15:57:12 +00:00
L-Sun
05a6845962 refactor(editor): data view slash menu config extension (#10684) 2025-03-07 15:22:41 +00:00
L-Sun
46466e2c3a refactor(editor): code block slash menu config extension (#10683) 2025-03-07 15:22:41 +00:00
L-Sun
63bf2b80c1 refactor(editor): linked doc slash menu config extension (#10682) 2025-03-07 14:42:56 +00:00
CatsJuice
9f3580263a feat(core): support removing journal template from right sidebar (#10571) 2025-03-07 12:32:42 +00:00
L-Sun
83b05aca4d refactor(editor): surface-ref slash menu config extension (#10681) 2025-03-07 09:05:04 +00:00
L-Sun
d37868d97a refactor(editor): ai slash menu config extension (#10680) 2025-03-07 09:05:03 +00:00
Flrande
264f0dd2be fix(editor): improve backspace ux for callout block (#10696) 2025-03-07 08:50:31 +00:00
L-Sun
8d9746e0cc refactor(editor): embed slash menu config extension (#10679) 2025-03-07 08:21:19 +00:00
L-Sun
37a13032ed refactor(editor): note slash menu config extension (#10678) 2025-03-07 08:21:18 +00:00
L-Sun
4be80d87ff refactor(editor): latex slash menu config extension (#10677) 2025-03-07 08:21:18 +00:00
EYHN
4677049b5c feat(core): add public user service (#10695) 2025-03-07 08:00:27 +00:00
Hwang
a08e76c3b5 chore: update project name (#10658)
Co-authored-by: EYHN <cneyhn@gmail.com>
2025-03-07 15:59:26 +08:00
fengmk2
4446100150 fix(server): correct "Administrators" typo in permissions (#10690) 2025-03-07 07:13:36 +00:00
L-Sun
ea20751b9b refactor(editor): attachment slash menu config extension (#10676) 2025-03-07 05:48:41 +00:00
L-Sun
34e777e043 refactor(editor): bookmark slash menu config extension (#10675) 2025-03-07 05:48:40 +00:00
L-Sun
4e80ecd591 refactor(editor): image slash menu config extension (#10674) 2025-03-07 05:48:40 +00:00
L-Sun
66ad87c84a refactor(editor): table slash menu config extension (#10673) 2025-03-07 05:48:39 +00:00
doouding
460e088873 fix: block should not be selectable when dragged into note (#10664)
### Changed
- Fixed the issue that block can still be selected when dragged into note
- Rewrite grid and layer with extension infra
2025-03-07 04:40:05 +00:00
L-Sun
0a234fa263 refactor(editor): callout slash menu config extension (#10672) 2025-03-07 04:24:09 +00:00
Saul-Mirone
fe5f0f62ec feat(editor): rich text package (#10689)
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.
2025-03-07 04:08:47 +00:00
fundon
8da12025af fix(core): should invoke cleanup fn when ai sub item list is removed (#10685)
Closes: [BS-2755](https://linear.app/affine-design/issue/BS-2755/ai-translate-死循环报错)
2025-03-07 03:35:59 +00:00
fundon
916134b1da fix(editor): should update icon status when formatting the entire block text (#10508)
Closes: [BS-2718](https://linear.app/affine-design/issue/BS-2718/当处于-block-selection-状态且对整段进行-formatting-时,应该更新对应图标状态)
2025-03-07 03:22:01 +00:00
L-Sun
98d44d5be5 refactor(editor): move focus block commands to blocksuite/shared (#10671) 2025-03-07 03:07:49 +00:00
L-Sun
43ce609cba refactor(editor): database slash menu config extension (#10670) 2025-03-07 02:50:27 +00:00
L-Sun
490a191a11 refactor(editor): replace icons with blocksuite/icons (#10655) 2025-03-07 02:50:26 +00:00
L-Sun
750c8a44dc refactor(editor): add slash menu config extension entry (#10641)
Close [BS-2744](https://linear.app/affine-design/issue/BS-2744/slash-menu%E6%8F%92%E4%BB%B6%E5%8C%96%EF%BC%9Aaction%E6%B3%A8%E5%86%8C%E5%85%A5%E5%8F%A3)

This PR mainly focus  on providing an entry point for configuring the SlashMenu feature. Therefore, it strives to retain the original code to ensure that the modifications are simple and easy to review. Subsequent PRs will focus on moving different configurations into separate blocks.

### How to use?
Here is the type definition for the slash menu configuration.  An important change is the new field `group`, which indicates the sorting and grouping of the menu item. See the comments for details.

```ts
// types.ts
export type SlashMenuContext = {
  std: BlockStdScope;
  model: BlockModel;
};

export type SlashMenuItemBase = {
  name: string;
  description?: string;
  icon?: TemplateResult;
  /**
   * This field defines sorting and grouping of menu items like VSCode.
   * The first number indicates the group index, the second number indicates the item index in the group.
   * The group name is the string between `_` and `@`.
   * You can find an example figure in https://code.visualstudio.com/api/references/contribution-points#menu-example
   */
  group?: `${number}_${string}@${number}`;

  /**
   * The condition to show the menu item.
   */
  when?: (ctx: SlashMenuContext) => boolean;
};

export type SlashMenuActionItem = SlashMenuItemBase & {
  action: (ctx: SlashMenuContext) => void;
  tooltip?: SlashMenuTooltip;

  /**
   * The alias of the menu item for search.
   */
  searchAlias?: string[];
};

export type SlashMenuSubMenu = SlashMenuItemBase & {
  subMenu: SlashMenuItem[];
};

export type SlashMenuItem = SlashMenuActionItem | SlashMenuSubMenu;

export type SlashMenuConfig = {
  /**
   * The items in the slash menu. It can be generated dynamically with the context.
   */
  items: SlashMenuItem[] | ((ctx: SlashMenuContext) => SlashMenuItem[]);

  /**
   * Slash menu will not be triggered when the condition is true.
   */
  disableWhen?: (ctx: SlashMenuContext) => boolean;
};

// extensions.ts

/**
 * The extension to add a slash menu items or configure.
 */
export function SlashMenuConfigExtension(ext: {
  id: string;
  config: SlashMenuConfig;
}): ExtensionType {
  return {
    setup: di => {
      di.addImpl(SlashMenuConfigIdentifier(ext.id), ext.config);
    },
  };
}
```

Here is an example, `XXXSlashMenuConfig` adds a `Delete` action to the slash menu, which is assigned to the 8th group named `Actions` at position 0.
```ts
import { SlashMenuConfigExtension, type SlashMenuConfig } from '@blocksuite/affine-widget-slash-menu';

const XXXSlashMenuConfig = SlashMenuConfigExtension({
  id: 'XXX',
  config: {
    items: [
      {
        name: 'Delete',
        description: 'Remove a block.',
        searchAlias: ['remove'],
        icon: DeleteIcon,
        group: '8_Actions@0',
        action: ({ std, model }) => {
          std.host.doc.deleteBlock(model);
        },
      },
    ],
  },
});
```
2025-03-06 16:12:06 +00:00
L-Sun
62d8c0c7cb refactor(editor): adjust folder structure for slash menu extension (#10588)
Close [BS-2743](https://linear.app/affine-design/issue/BS-2743/slash-menu插件化:调整文件夹结构)

This PR move slash menu from `affine-root-block` to `widget-affine-slash-menu`, and make it as a `WidgetViewExtension`
2025-03-06 16:12:06 +00:00
fengmk2
289d3cd20e feat(server): get public user by id (#10434)
close CLOUD-160
2025-03-06 15:25:06 +00:00
fengmk2
7302c4f954 feat(server): notification system (#10053)
closes CLOUD-52
2025-03-06 15:25:05 +00:00
fengmk2
81694a1144 feat(server): add workspace name and avatarKey to database (#10513)
close CLOUD-153
2025-03-06 15:25:05 +00:00
fengmk2
c76b2504fe feat(server): add doc title and summary to database (#10505)
close CLOUD-152
2025-03-06 14:27:42 +00:00
Saul-Mirone
8d10b40b72 feat(editor): add loaded and disposed hook for store extension (#10669) 2025-03-06 13:31:09 +00:00
forehalo
e02fb4fa94 refactor(core): standardize frontend error handling (#10667) 2025-03-06 13:10:18 +00:00
Saul-Mirone
2e86bfffae feat(editor): life cycle ext (#10668) 2025-03-06 12:28:55 +00:00
Flrande
b85812d8dd fix(editor): disable slash menu in callout (#10656) 2025-03-06 11:07:10 +00:00
fengmk2
d2b45783ea feat(server): use zod parse to impl input validation (#10566)
close CLOUD-124
2025-03-06 10:40:01 +00:00
Saul-Mirone
84e2dda3f8 refactor(editor): separate lit and slot in global (#10666) 2025-03-06 10:24:59 +00:00
forehalo
56b842f2e1 fix(core): runtime control of telemetry (#10663) 2025-03-06 09:56:13 +00:00
fundon
93920f9895 fix(editor): circular dependencies (#10661)
Closes: [BS-2766](https://linear.app/affine-design/issue/BS-2766/把-converttodatabase-移到-root-block-中,避免循环依赖)
2025-03-06 09:41:01 +00:00
L-Sun
797e63f86f chore(editor): remove unexpected bottom padding of code block (#10660)
Close [BS-2765](https://linear.app/affine-design/issue/BS-2765/代码块在字数超出宽度时,下巴变大)

https://github.com/user-attachments/assets/1dc53528-6d36-4b2a-861c-9ca06381c681
2025-03-06 09:26:00 +00:00
Saul-Mirone
7ae9daa6f6 refactor(editor): use lodash (#10657) 2025-03-06 17:11:12 +08:00
darkskygit
8062893603 test(web): rename e2e test name (#10654) 2025-03-06 08:28:07 +00:00
EYHN
eaaf4bebef feat(core): awareness change event instead of update event (#10649) 2025-03-06 08:05:50 +00:00
fundon
8bfaa2502e fix(editor): should shift toolbar to keep in view when selected area exceeds view (#10642)
Closes: [BS-2757](https://linear.app/affine-design/issue/BS-2757/体验优化:pageedgeless-下,有超长选区时,toolbar-flip-后浮动在下方)

![Screenshot 2025-03-06 at 10.50.39.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/8ypiIKZXudF5a0tIgIzf/e92c586c-4bf0-4196-b2f5-ffaa09adcf14.png)

![Screenshot 2025-03-06 at 10.52.22.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/8ypiIKZXudF5a0tIgIzf/c24204df-5249-4a22-bde8-90cb8fa368c9.png)

![Screenshot 2025-03-06 at 10.50.58.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/8ypiIKZXudF5a0tIgIzf/22746460-5bb4-4f65-b96c-cbac7f189bdb.png)
2025-03-06 07:48:04 +00:00
darkskygit
91adc533a8 fix(server): reuse params in retry (#10653)
fix BS-2484
2025-03-06 07:32:26 +00:00
akumatus
cd884312ea fix(core): missing clean up subscription (#10636) 2025-03-06 07:00:58 +00:00
fundon
ec9bd1f383 feat(editor): add toolbar registry extension (#9572)
### What's Changed!

#### Added
Manage various types of toolbars uniformly in one place.

* `affine-toolbar-widget`
* `ToolbarRegistryExtension`

The toolbar currently supports and handles several scenarios:

1.  Select blocks: `BlockSelection`
2. Select text: `TextSelection` or `NativeSelection`
3. Hover a link: `affine-link` and `affine-reference`

#### Removed
Remove redundant toolbar implementations.

* `attachment` toolbar
* `bookmark` toolbar
* `embed` toolbar
* `formatting` toolbar
* `affine-link` toolbar
* `affine-reference` toolbar

### How to migrate?

Here is an example that can help us migrate some unrefactored toolbars:

Check out the more detailed types of [`ToolbarModuleConfig`](c178debf2d/blocksuite/affine/shared/src/services/toolbar-service/config.ts).

1.  Add toolbar configuration file to a block type, such as bookmark block: [`config.ts`](c178debf2d/blocksuite/affine/block-bookmark/src/configs/toolbar.ts)

```ts
export const builtinToolbarConfig = {
  actions: [
    {
      id: 'a.preview',
      content(ctx) {
        const model = ctx.getCurrentModelBy(BlockSelection, BookmarkBlockModel);
        if (!model) return null;

        const { url } = model;

        return html`<affine-link-preview .url=${url}></affine-link-preview>`;
      },
    },
    {
      id: 'b.conversions',
      actions: [
        {
          id: 'inline',
          label: 'Inline view',
          run(ctx) {
          },
        },
        {
          id: 'card',
          label: 'Card view',
          disabled: true,
        },
        {
          id: 'embed',
          label: 'Embed view',
          disabled(ctx) {
          },
          run(ctx) {
          },
        },
      ],
      content(ctx) {
      },
    } satisfies ToolbarActionGroup<ToolbarAction>,
    {
      id: 'c.style',
      actions: [
        {
          id: 'horizontal',
          label: 'Large horizontal style',
        },
        {
          id: 'list',
          label: 'Small horizontal style',
        },
      ],
      content(ctx) {
      },
    } satisfies ToolbarActionGroup<ToolbarAction>,
    {
      id: 'd.caption',
      tooltip: 'Caption',
      icon: CaptionIcon(),
      run(ctx) {
      },
    },
    {
      placement: ActionPlacement.More,
      id: 'a.clipboard',
      actions: [
        {
          id: 'copy',
          label: 'Copy',
          icon: CopyIcon(),
          run(ctx) {
          },
        },
        {
          id: 'duplicate',
          label: 'Duplicate',
          icon: DuplicateIcon(),
          run(ctx) {
          },
        },
      ],
    },
    {
      placement: ActionPlacement.More,
      id: 'b.refresh',
      label: 'Reload',
      icon: ResetIcon(),
      run(ctx) {
      },
    },
    {
      placement: ActionPlacement.More,
      id: 'c.delete',
      label: 'Delete',
      icon: DeleteIcon(),
      variant: 'destructive',
      run(ctx) {
      },
    },
  ],
} as const satisfies ToolbarModuleConfig;
```

2. Add configuration extension to a block spec: [bookmark's spec](c178debf2d/blocksuite/affine/block-bookmark/src/bookmark-spec.ts)

```ts
const flavour = BookmarkBlockSchema.model.flavour;

export const BookmarkBlockSpec: ExtensionType[] = [
  ...,
  ToolbarModuleExtension({
    id: BlockFlavourIdentifier(flavour),
    config: builtinToolbarConfig,
  }),
].flat();
```

3. If the bock type already has a toolbar configuration built in, we can customize it in the following ways:

Check out the [editor's config](c178debf2d/packages/frontend/core/src/blocksuite/extensions/editor-config/index.ts (L51C4-L54C8)) file.

```ts
// Defines a toolbar configuration for the bookmark block type
const customBookmarkToolbarConfig = {
  actions: [
    ...
  ]
} as const satisfies ToolbarModuleConfig;

// Adds it into the editor's config
 ToolbarModuleExtension({
    id: BlockFlavourIdentifier('custom:affine:bookmark'),
    config: customBookmarkToolbarConfig,
 }),
```

4. If we want to extend the global:

```ts
// Defines a toolbar configuration
const customWildcardToolbarConfig = {
  actions: [
    ...
  ]
} as const satisfies ToolbarModuleConfig;

// Adds it into the editor's config
 ToolbarModuleExtension({
    id: BlockFlavourIdentifier('custom:affine:*'),
    config: customWildcardToolbarConfig,
 }),
```

Currently, only most toolbars in page mode have been refactored. Next is edgeless mode.
2025-03-06 06:46:03 +00:00
Flrande
06e4bd9aed chore(editor): remove log (#10650) 2025-03-06 06:31:15 +00:00
EYHN
5c8b81581c feat(core): doc level awareness (#10646) 2025-03-06 06:05:45 +00:00