Commit Graph

98 Commits

Author SHA1 Message Date
Saul-Mirone
b8ecfbdae6 refactor(editor): remove assertExists (#10615) 2025-03-05 00:13:08 +00:00
Saul-Mirone
66d9d576e0 refactor(editor): add gfx entry in bs global package (#10612) 2025-03-04 12:46:50 +00:00
Saul-Mirone
5ad3d3c94a refactor(editor): move figma squircle to shared (#10610) 2025-03-04 10:26:58 +00:00
Saul-Mirone
fa5674166e refactor(editor): cleanup list icons (#10608) 2025-03-04 10:13:01 +00:00
Saul-Mirone
4c3c953a36 chore(editor): merge clamp functions (#10577)
Closes: [BS-2625](https://linear.app/affine-design/issue/BS-2625/合并clamp函数)
2025-03-03 10:33:38 +00:00
Flrande
5d3c365d97 fix(editor): format text in code block (#10575)
Closes: [BS-2724](https://linear.app/affine-design/issue/BS-2724/code-block%E9%87%8C%E4%B8%8D%E5%BA%94%E8%AF%A5%E6%98%BE%E7%A4%BAtoolbar)
2025-03-03 08:52:38 +00:00
Saul-Mirone
f23f29610c refactor(editor): remove stable feature flags (#10547) 2025-03-02 08:41:12 +00:00
renovate
b05315c6fa chore: bump up shiki version to v3 (#10534)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [shiki](https://redirect.github.com/shikijs/shiki) ([source](https://redirect.github.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`^2.0.0` -> `^3.0.0`](https://renovatebot.com/diffs/npm/shiki/2.5.0/3.1.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/3.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/3.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/2.5.0/3.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/2.5.0/3.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>shikijs/shiki (shiki)</summary>

### [`v3.1.0`](https://redirect.github.com/shikijs/shiki/releases/tag/v3.1.0)

[Compare Source](https://redirect.github.com/shikijs/shiki/compare/v3.0.0...v3.1.0)

#####    🚀 Features

-   **engine-js**: Bump deps to work around Safari bug with some grammars  -  by [@&#8203;slevithan](https://redirect.github.com/slevithan) in [https://github.com/shikijs/shiki/issues/941](https://redirect.github.com/shikijs/shiki/issues/941) [<samp>(47205)</samp>](https://redirect.github.com/shikijs/shiki/commit/4720501b)
-   **twoslash**: Upgrade twoslash v0.3, require typescript v5.5+, close [#&#8203;950](https://redirect.github.com/shikijs/shiki/issues/950), close [#&#8203;951](https://redirect.github.com/shikijs/shiki/issues/951)  -  by [@&#8203;antfu](https://redirect.github.com/antfu) in [https://github.com/shikijs/shiki/issues/950](https://redirect.github.com/shikijs/shiki/issues/950) and [https://github.com/shikijs/shiki/issues/951](https://redirect.github.com/shikijs/shiki/issues/951) [<samp>(5c6f9)</samp>](https://redirect.github.com/shikijs/shiki/commit/5c6f9e92)

#####    🐞 Bug Fixes

-   **monaco**: Handle missing settings in textmate theme func  -  by [@&#8203;felipetodev](https://redirect.github.com/felipetodev) in [https://github.com/shikijs/shiki/issues/939](https://redirect.github.com/shikijs/shiki/issues/939) [<samp>(19f75)</samp>](https://redirect.github.com/shikijs/shiki/commit/19f75f66)

#####     [View changes on GitHub](https://redirect.github.com/shikijs/shiki/compare/v3.0.0...v3.1.0)

### [`v3.0.0`](https://redirect.github.com/shikijs/shiki/releases/tag/v3.0.0)

[Compare Source](https://redirect.github.com/shikijs/shiki/compare/v2.5.0...v3.0.0)

#####    🚨 Breaking Changes

-   Remove deprecated apis for v3.0  -  by [@&#8203;antfu](https://redirect.github.com/antfu) in [https://github.com/shikijs/shiki/issues/900](https://redirect.github.com/shikijs/shiki/issues/900) [<samp>(55c15)</samp>](https://redirect.github.com/shikijs/shiki/commit/55c1554b)
-   Remove `node10` typescript resolution support  -  by [@&#8203;userquin](https://redirect.github.com/userquin) in [https://github.com/shikijs/shiki/issues/923](https://redirect.github.com/shikijs/shiki/issues/923) [<samp>(ccb58)</samp>](https://redirect.github.com/shikijs/shiki/commit/ccb5856b)
-   **twoslash**: Make default `moduleResolution` to `bundler`  -  by [@&#8203;antfu](https://redirect.github.com/antfu) in [https://github.com/shikijs/shiki/issues/936](https://redirect.github.com/shikijs/shiki/issues/936) [<samp>(e924d)</samp>](https://redirect.github.com/shikijs/shiki/commit/e924d4b1)

#####    🐞 Bug Fixes

-   **transformers**:
    -   Also remove extra newline token, fix [#&#8203;915](https://redirect.github.com/shikijs/shiki/issues/915)  -  by [@&#8203;antfu](https://redirect.github.com/antfu) in [https://github.com/shikijs/shiki/issues/915](https://redirect.github.com/shikijs/shiki/issues/915) [<samp>(cc591)</samp>](https://redirect.github.com/shikijs/shiki/commit/cc5913eb)
    -   Support matching comments in comments, fix [#&#8203;934](https://redirect.github.com/shikijs/shiki/issues/934)  -  by [@&#8203;antfu](https://redirect.github.com/antfu) in [https://github.com/shikijs/shiki/issues/934](https://redirect.github.com/shikijs/shiki/issues/934) [<samp>(6efc8)</samp>](https://redirect.github.com/shikijs/shiki/commit/6efc8979)
    -   Fix matching indices for word-highlight  -  by [@&#8203;artt](https://redirect.github.com/artt) in [https://github.com/shikijs/shiki/issues/909](https://redirect.github.com/shikijs/shiki/issues/909) [<samp>(57a09)</samp>](https://redirect.github.com/shikijs/shiki/commit/57a09ade)

#####     [View changes on GitHub](https://redirect.github.com/shikijs/shiki/compare/v2.5.0...v3.0.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNzYuMiIsInVwZGF0ZWRJblZlciI6IjM5LjE3Ni4yIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
2025-03-01 02:33:49 +00:00
L-Sun
d476d3b1df fix(editor): android keyboard can not be opened (#10502)
Close [BS-2674](https://linear.app/affine-design/issue/BS-2674/[android]-%E6%96%87%E6%9C%AC%E7%BC%96%E8%BE%91%E5%8C%BA%E5%9F%9F%E7%82%B9%E5%87%BB%E5%90%8E%E6%97%A0%E6%B3%95%E6%BF%80%E6%B4%BB%E9%94%AE%E7%9B%98) [BS-2609](https://linear.app/affine-design/issue/BS-2609/[android]-%E8%BE%93%E5%85%A5%E7%9A%84-toolbar-%E6%B2%A1%E6%9C%89%E4%BA%86)
2025-02-28 08:23:26 +00:00
fundon
caa4dfedfc fix(editor): adjust black and white in shape text color palettes to pure black and pure white (#10450)
Closes: [BS-2697](https://linear.app/affine-design/issue/BS-2697/检查shape-text-color黑白不映射的pr合并状态)

https://github.com/user-attachments/assets/732612e9-5e43-453f-aef2-5f32f5a08614
2025-02-27 06:05:42 +00:00
doodlewind
589622043c fix(editor): list toggle position offset (#10448)
Before:

![image](https://github.com/user-attachments/assets/fbddc396-1078-4c1e-8e2c-c26c6e4a6d61)

After:

<img width="579" alt="image" src="https://github.com/user-attachments/assets/7b049b53-269b-484e-ba76-fa6f46a2004c" />

This centering approach won't affect heading blocks:

<img width="267" alt="image" src="https://github.com/user-attachments/assets/3f3217e3-7e23-43fc-a7e5-33b6eadccc88" />
2025-02-26 12:09:00 +00:00
donteatfriedrice
d63f16da5e fix(editor): affine preview root style (#10420)
Fix [BS-2677](https://linear.app/affine-design/issue/BS-2677/linked-doc-embed-view样式错误)

1. Only show the border of embed synced doc block (in note) when hover.
2. Fix affine preview root padding style, set padding only when affine preview root in embed synced doc block (in surface).
3. Only add the footnote config extension to the chat panel and chat block center peek. For footnotes in other page preview scenarios, such as footnote nodes within embed synced doc blocks or embed linked doc blocks, the hover effect should be maintained.
2025-02-26 04:25:24 +00:00
fundon
abc3f9f23f chore(editor): bump @floating-ui/dom to 1.6.13 (#10425) 2025-02-25 07:06:27 +00:00
fundon
162b7adc1b fix(editor): should check text length and stop event propagation when adding a link (#10391) 2025-02-24 11:10:05 +00:00
donteatfriedrice
1b2a4377fd feat(editor): update footnote node style and config (#10392)
[BS-2581](https://linear.app/affine-design/issue/BS-2581/优化-footnote-node-正文样式)
2025-02-24 08:15:04 +00:00
forehalo
2e0f0c624a chore: set base version to 0.20 (#10382) 2025-02-24 04:44:42 +00:00
donteatfriedrice
2d41c2ff8d chore: bump theme (#10358) 2025-02-24 10:08:47 +08:00
Flrande
9fd1ca1c09 refactor(editor): remove inline editor keyboard utils and add markdown property in rich-text (#10375) 2025-02-23 19:57:56 +08:00
Saul-Mirone
f8cabe8bb1 refactor: move ai-item components to frontend core (#10369)
### TL;DR

Relocated AI item components from BlockSuite to the frontend codebase and updated related imports.

### What changed?

- Moved AI item components from `blocksuite/affine/components/src/ai-item` to `packages/frontend/core/src/blocksuite/presets/ai/_common/components/ai-item`
- Updated all imports referencing the old AI item component location to point to the new location
- Removed AI item exports from BlockSuite's package.json and effects registration
- Added AI item effects registration to frontend presets

### How to test?

1. Verify AI functionality works as expected in:
   - Chat panels
   - AI toolbars
   - Edgeless copilot
   - Slash menu
2. Confirm no AI-related console errors appear
3. Test error handling scenarios (unauthorized, payment required, network errors)

### Why make this change?

This change consolidates AI-related components into the frontend codebase where they are primarily used, rather than keeping them in BlockSuite. This improves code organization by placing components closer to their implementation and usage, while reducing unnecessary coupling between packages.
2025-02-22 17:03:07 +00:00
Saul-Mirone
22e4bd8c20 refactor: move image proxy middleware and adapter extensions (#10345)
### TL;DR
Moved image proxy middleware and adapter extensions to their respective packages and introduced a new spec provider for adapter registration.

### What changed?
- Relocated `defaultImageProxyMiddleware` from blocks to `@blocksuite/affine-block-image`
- Moved `PresentTool` from fragment-frame-panel to block-frame
- Created new adapter extension specs for HTML, Markdown, and Notion HTML
- Introduced a spec provider pattern for adapter registration
- Removed direct transformer references from RootService
- Updated imports across affected files to use new locations

### How to test?
1. Verify image proxy functionality works in exports and imports
2. Test HTML, Markdown, and Notion HTML adapters still function correctly
3. Confirm presentation mode works with the relocated PresentTool
4. Check that all file import/export operations continue to work as expected

### Why make this change?
This reorganization improves code modularity by placing features in their logical packages and introduces a more maintainable pattern for adapter registration. The spec provider pattern makes it easier to manage and extend adapter functionality while reducing coupling between components.
2025-02-21 09:01:57 +00:00
Flrande
50820482df fix(editor): auto focus after add inline latex (#10309)
https://github.com/user-attachments/assets/09e713ee-e600-464c-8614-d874d343cfb0

Close #10208
2025-02-20 05:52:06 +00:00
donteatfriedrice
2b11941c0e chore: bump theme (#10290) 2025-02-19 11:37:19 +00:00
donteatfriedrice
e67fd67a3c fix(core): copy more button group style (#10240) 2025-02-18 04:07:59 +00:00
fundon
34472fdfa9 fix(editor): make std stable in affine-link and affine-reference (#10207) 2025-02-17 05:09:53 +00:00
L-Sun
9d08f446cc refactor(editor): remove redundant edgeless icons (#10169)
Continue [BS-2240](https://linear.app/affine-design/issue/BS-2240/%E6%B8%85%E7%90%86%E9%87%8D%E5%A4%8D%E7%9A%84icon)

This PR removes `icons/edgeless.ts` and refactor with `@blocksuite/icons` for reducing redundant icons
2025-02-14 05:03:26 +00:00
Alexey Lysenko
769547c2d5 fix(editor): support more divider markdown shortcut (#10139) 2025-02-14 10:13:40 +08:00
Saul-Mirone
9321ce94a7 refactor(editor): remove global types in config (#10143)
Closes: [BS-2554](https://linear.app/affine-design/issue/BS-2554/remove-global-types-in-block-config)
2025-02-13 04:35:35 +00:00
doouding
ed0b25def0 fix: drop indicator in center peek (#10136) 2025-02-13 02:53:07 +00:00
donteatfriedrice
19f0eb1931 fix(core): use patched preview spec builder in ai chat (#10090)
[BS-2526](https://linear.app/affine-design/issue/BS-2526/chat-panel-里的-footnote-popup-需要支持交互)
2025-02-11 15:11:54 +00:00
Saul-Mirone
39eb8625d6 refactor(editor): remove block models global type (#10086) 2025-02-11 11:00:57 +00:00
Saul-Mirone
652865c7cf refactor(editor): remove global types in model (#10082)
Closes: [BS-2249](https://linear.app/affine-design/issue/BS-2249/remove-global-types-in-model)

```ts
// before
matchFlavours(model, ['affine:page']);
// after
matchFlavours(model, [PageBlockModel]);
```
2025-02-11 08:18:57 +00:00
L-Sun
23364b59a0 fix(editor): wrap doc title by default (#10052)
Close [AF-2195](https://linear.app/affine-design/issue/AF-2195/editor-的-title-overflow-时没有换行)
2025-02-10 11:30:14 +00:00
fundon
d03744688b refactor(editor): move embed-card-modal to components (#10037) 2025-02-10 10:56:13 +00:00
L-Sun
891d9df0b1 feat(editor): show doc title in page block (#9975)
Close [BS-2392](https://linear.app/affine-design/issue/BS-2392/page-block-需要显示文章title)

### What Changes
- Add `<doc-title>` to edgeless page block (a.k.a the first page visible note block)
- Refactors:
  - Move `<doc-title>` to `@blocksuite/affine-component`, but you can aslo import it from `@blocksuite/preset`
  - Extract `<edgeless-note-mask>` and `<edgeless-note-background>` from `<affine-edgeless-note>` to a seperate file
  - Rewrite styles of `<affine-edgeless-note>` with `@vanilla-extract/css`

https://github.com/user-attachments/assets/a0c03239-803e-4bfa-b30e-33b919213b12
2025-02-06 21:18:28 +00:00
doouding
02122098c7 fix: drag block issue (#9902)
### Changed
- Added support for changing the preview offset during dragging.
- Fixed the preview rendering for embed block and surface-ref block
- Resolved an issue where the host element might be reused in certain cases, which could cause unexpected behavior
- Moved viewport-related constants and methods to a more appropriate location
2025-02-05 07:25:53 +00:00
Saul-Mirone
17bf75e843 refactor(editor): remove dependency of command global types (#9903)
Closes: [BS-2216](https://linear.app/affine-design/issue/BS-2216/remove-global-types-in-command)
2025-01-27 12:28:46 +00:00
doouding
73b4437081 chore: dnd cleanup (#9899) 2025-01-27 04:29:14 +00:00
fundon
ffd54c6620 refactor(editor): use selected signal in block component (#9849) 2025-01-27 02:56:10 +00:00
zzj3720
5a5779c05a feat(editor): simple table block (#9740)
close: BS-2122, BS-2125, BS-2124, BS-2420, PD-2073, BS-2126, BS-2469, BS-2470, BS-2478, BS-2471
2025-01-24 10:07:57 +00:00
donteatfriedrice
bdc8dd8d5f feat(editor): add link preview to footnote popup (#9869)
[BS-2399](https://linear.app/affine-design/issue/BS-2399/ai-link-的预览支持:获取-fav-icon-标题)
2025-01-23 09:31:21 +00:00
pengx17
6ac6a8d6d6 feat(core): unused blob management in settings (#9795)
fix AF-2144, PD-2064, PD-2065, PD-2066
2025-01-23 07:12:17 +00:00
donteatfriedrice
bf797c7a0c feat(editor): support footnote adapter (#9844)
[BS-2373](https://linear.app/affine-design/issue/BS-2373/适配-footnote-adapter)
2025-01-22 06:42:35 +00:00
pengx17
4c665594d6 fix(editor): ref on click slots should not be global (#9830)
fix AF-2129
2025-01-22 05:20:55 +00:00
renovate
b715d2648e chore: bump up shiki version to v2 (#9793)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [shiki](https://redirect.github.com/shikijs/shiki) ([source](https://redirect.github.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`^1.14.1` -> `^2.0.0`](https://renovatebot.com/diffs/npm/shiki/1.29.1/2.0.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.29.1/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.29.1/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [shiki](https://redirect.github.com/shikijs/shiki) ([source](https://redirect.github.com/shikijs/shiki/tree/HEAD/packages/shiki)) | [`^1.12.0` -> `^2.0.0`](https://renovatebot.com/diffs/npm/shiki/1.29.1/2.0.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/shiki/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/shiki/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/shiki/1.29.1/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/shiki/1.29.1/2.0.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>shikijs/shiki (shiki)</summary>

### [`v2.0.3`](https://redirect.github.com/shikijs/shiki/releases/tag/v2.0.3)

[Compare Source](https://redirect.github.com/shikijs/shiki/compare/v2.0.2...v2.0.3)

#####    🐞 Bug Fixes

-   **core**: Soft require `engine` options  -  by [@&#8203;antfu](https://redirect.github.com/antfu) [<samp>(10a6f)</samp>](https://redirect.github.com/shikijs/shiki/commit/10a6f781)

#####     [View changes on GitHub](https://redirect.github.com/shikijs/shiki/compare/v2.0.2...v2.0.3)

### [`v2.0.2`](https://redirect.github.com/shikijs/shiki/releases/tag/v2.0.2)

[Compare Source](https://redirect.github.com/shikijs/shiki/compare/v2.0.1...v2.0.2)

#####    🐞 Bug Fixes

-   Mark `engine` required in `createHighlighterCore`  -  by [@&#8203;antfu](https://redirect.github.com/antfu) [<samp>(1212f)</samp>](https://redirect.github.com/shikijs/shiki/commit/1212f473)

#####     [View changes on GitHub](https://redirect.github.com/shikijs/shiki/compare/v2.0.1...v2.0.2)

### [`v2.0.1`](https://redirect.github.com/shikijs/shiki/releases/tag/v2.0.1)

[Compare Source](https://redirect.github.com/shikijs/shiki/compare/v2.0.0...v2.0.1)

#####    🚀 Features

-   Improve warning messages  -  by [@&#8203;antfu](https://redirect.github.com/antfu) [<samp>(0f27a)</samp>](https://redirect.github.com/shikijs/shiki/commit/0f27a20d)

#####    🐞 Bug Fixes

-   Warn about missing deprecation  -  by [@&#8203;antfu](https://redirect.github.com/antfu) [<samp>(708e3)</samp>](https://redirect.github.com/shikijs/shiki/commit/708e3f24)
-   **colorized-brackets**: Use object style `htmlStyle`  -  by [@&#8203;antfu](https://redirect.github.com/antfu) [<samp>(eab5b)</samp>](https://redirect.github.com/shikijs/shiki/commit/eab5bd18)

#####     [View changes on GitHub](https://redirect.github.com/shikijs/shiki/compare/v2.0.0...v2.0.1)

### [`v2.0.0`](https://redirect.github.com/shikijs/shiki/releases/tag/v2.0.0)

[Compare Source](https://redirect.github.com/shikijs/shiki/compare/v1.29.1...v2.0.0)

##### Read the announcement: [Shiki v2](https://shiki.style/blog/v2)

#####     [View changes on GitHub](https://redirect.github.com/shikijs/shiki/compare/v1.29.1...v2.0.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xMDcuMCIsInVwZGF0ZWRJblZlciI6IjM5LjEwNy4wIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
2025-01-21 14:46:19 +00:00
Saul-Mirone
5783580054 fix(editor): y reactive deep watch (#9818)
Closes: [BS-2193](https://linear.app/affine-design/issue/BS-2193/fix-deep-watcher-of-reactive-yjs-data)
2025-01-21 08:08:01 +00:00
donteatfriedrice
f995f216bd fix(editor): inline latex editor should not be shown when doc is readonly (#9794)
[BS-2442](https://linear.app/affine-design/issue/BS-2442/只读时-inline-latex-node-点击不应该弹出-modal)
2025-01-20 15:44:07 +00:00
doodlewind
14ca171a18 chore(web): bump theme (#9801) 2025-01-20 13:51:24 +00:00
fundon
7436c139ab fix(core): improve doc title and icon display (#9755)
Closes: [AF-2132](https://linear.app/affine-design/issue/AF-2132/优化-emoji-title-和-icon-显示)
2025-01-18 17:29:15 +08:00
donteatfriedrice
df910d7013 feat(editor): add affine inline footnote (#9745)
[BS-2369](https://linear.app/affine-design/issue/BS-2369/新增-affinetextattribute-footnote)  [BS-2370](https://linear.app/affine-design/issue/BS-2370/支持-footnote-自定义渲染行内内容) [BS-2372](https://linear.app/affine-design/issue/BS-2372/提供-footnoteconfigextension) [BS-2375](https://linear.app/affine-design/issue/BS-2375/footnote-自定义渲染-popup)

### Add new AffineTextAttribute: footnote

```
/**
 * FootNote is used to reference a doc, attachment or url.
 */
export interface AffineTextAttributes {
  ...
  footnote?: {
    label: string; // label of the footnote
    reference: {
      type: 'doc' | 'attachment' | 'url'; // type of reference
      docId?: string; // the id of the reference doc
      url?: string; //  the url of the reference network resource
      blobId?: string; // the id of the reference attachment
      fileName?: string; // the name of the reference attachment
      fileType?: string; // the type of the reference attachment
    }
  } | null
}
```

### FootNoteNodeConfigProvider Extension

#### FootNoteNodeConfig Type Definition

```
type FootNoteNodeRenderer = (
  footnote: FootNote,
  std: BlockStdScope
) => TemplateResult<1>;

type FootNotePopupRenderer = (
  footnote: FootNote,
  std: BlockStdScope,
  abortController: AbortController
) => TemplateResult<1>;

export interface FootNoteNodeConfig {
  customNodeRenderer?: FootNoteNodeRenderer;
  customPopupRenderer?: FootNotePopupRenderer;
  interactive?: boolean;
  hidePopup?: boolean;
}
```

#### FootNoteNodeConfigProvider Class

```
export class FootNoteNodeConfigProvider {
  private _customNodeRenderer?: FootNoteNodeRenderer;
  private _customPopupRenderer?: FootNotePopupRenderer;
  private _hidePopup: boolean;
  private _interactive: boolean;

  get customNodeRenderer() {
    return this._customNodeRenderer;
  }

  get customPopupRenderer() {
    return this._customPopupRenderer;
  }

  get doc() {
    return this.std.store;
  }

  get hidePopup() {
    return this._hidePopup;
  }

  get interactive() {
    return this._interactive;
  }

  constructor(
    config: FootNoteNodeConfig,
    readonly std: BlockStdScope
  ) {
    this._customNodeRenderer = config.customNodeRenderer;
    this._customPopupRenderer = config.customPopupRenderer;
    this._hidePopup = config.hidePopup ?? false;
    this._interactive = config.interactive ?? true;
  }

  setCustomNodeRenderer(renderer: FootNoteNodeRenderer) {
    this._customNodeRenderer = renderer;
  }

  setCustomPopupRenderer(renderer: FootNotePopupRenderer) {
    this._customPopupRenderer = renderer;
  }

  setHidePopup(hidePopup: boolean) {
    this._hidePopup = hidePopup;
  }

  setInteractive(interactive: boolean) {
    this._interactive = interactive;
  }
}
```

#### FootNoteNodeConfigProvider Extension

```
export const FootNoteNodeConfigIdentifier =
  createIdentifier<FootNoteNodeConfigProvider>('AffineFootNoteNodeConfig');

export function FootNoteNodeConfigExtension(
  config: FootNoteNodeConfig
): ExtensionType {
  return {
    setup: di => {
      di.addImpl(
        FootNoteNodeConfigIdentifier,
        provider =>
          new FootNoteNodeConfigProvider(config, provider.get(StdIdentifier))
      );
    },
  };
}
```

The footnote node can be extended by this extension.

### FootnoteInlineSpec

```
export const FootNoteInlineSpecExtension = InlineSpecExtension(
  'footnote',
  provider => {
    const std = provider.get(StdIdentifier);
    const config =
      provider.getOptional(FootNoteNodeConfigIdentifier) ?? undefined;
    return {
      name: 'footnote',
      schema: FootNoteSchema.optional().nullable().catch(undefined),
      match: delta => {
        return !!delta.attributes?.footnote;
      },
      renderer: ({ delta }) => {
        return html`<affine-footnote-node
          .delta=${delta}
          .std=${std}
          .config=${config}
        ></affine-footnote-node>`;
      },
      embed: true,
    };
  }
);
```
2025-01-17 09:38:43 +00:00
CatsJuice
7d1d167858 chore: bump theme (#9732) 2025-01-17 09:22:15 +00:00