File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 - excalidraw
77 - obsidian
88 - astro
9- slug : excalidraw-component-test
9+ slug : wasd
1010---
1111
1212import { Excalidraw } from ' @/components/mdx/Excalidraw'
@@ -20,27 +20,9 @@ import IconLink from '@/components/IconLink.astro'
2020
2121## 处理流程
2222
23- 下图展示了组件加载和渲染核心流程:
24-
25- ``` mermaid
26- graph TD
27- A[组件加载] --> B{获取 snapshotUrl};
28- B -->|成功| C{正则匹配 Markdown};
29- B -->|失败| Z[显示错误];
30-
31- C -->|发现 compressed-json| D[提取并解压];
32- C -->|纯 JSON| E[直接解析];
33-
34- D --> E;
35-
36- E --> G[提取 Elements & Frames];
37- G --> H[过滤已删除元素];
38- H --> I[Excalidraw exportToSvg];
39-
40- I --> J[生成 SVG DOM];
41- J --> K[注入组件容器];
42- K --> L[计算 ViewBox & 初始化摄像机];
43- ```
23+ 1 . 在 obsidian 里编辑 excalidraw 源文件
24+ 2 . 复制该文件到 ` public/excalidraw/ ` 文件夹下
25+ 3 . 在 mdx 或者任意页面使用 ` Excalidraw ` 组件引用
4426
4527## 核心功能
4628
@@ -108,4 +90,5 @@ graph TD
108901 . ** 数据流** : 组件通过异步 ` fetch ` 获取文本,利用正则高效提取 ` compressed-json ` 代码块。
109912 . ** 透明渲染** : 利用官方 ` @excalidraw/excalidraw ` 库的导出接口,在浏览器端生成精准的 SVG DOM。
110923 . ** 坐标对齐** : 自动计算所有可见元素的边界框(Bounding Box),并应用偏移修正,确保 SVG ` viewBox ` 与实际绘图坐标系完美对齐。
111- 4 . ** 运镜系统** : 采用摄像机插值算法,在切换 Frame 时通过 ` requestAnimationFrame ` 实现平滑的缩放和位移。
93+ 4 . ** 运镜系统** : 采用摄像机插值算法,在切换 Frame 时通过 ` requestAnimationFrame ` 实现平滑的缩放和位移。
94+
You can’t perform that action at this time.
0 commit comments