@smartdoca/markdown 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -1
- package/README.zh-CN.md +10 -1
- package/dist/chunks/index-Cd3grnUT.js +2815 -0
- package/dist/chunks/index-DQLDZhUI.cjs +86 -0
- package/dist/chunks/pdf-file-impl-CMlXt-sQ.cjs +8 -0
- package/dist/chunks/pdf-file-impl-Hh_4oE89.js +622 -0
- package/dist/index.cjs +1 -51
- package/dist/index.js +48 -2351
- package/dist/style.css +1 -1
- package/dist/types/components/ImageLightbox.d.ts +13 -0
- package/dist/types/components/ImageLightbox.d.ts.map +1 -0
- package/dist/types/components/MarkdownPreview.d.ts +4 -1
- package/dist/types/components/MarkdownPreview.d.ts.map +1 -1
- package/dist/types/components/MermaidDiagram.d.ts.map +1 -1
- package/dist/types/editor/i18n.d.ts +777 -3
- package/dist/types/editor/i18n.d.ts.map +1 -1
- package/dist/types/editor/image-preview.d.ts +30 -0
- package/dist/types/editor/image-preview.d.ts.map +1 -0
- package/dist/types/editor/locales/es.d.ts +130 -0
- package/dist/types/editor/locales/es.d.ts.map +1 -0
- package/dist/types/editor/locales/fr.d.ts +130 -0
- package/dist/types/editor/locales/fr.d.ts.map +1 -0
- package/dist/types/editor/locales/ja.d.ts +130 -0
- package/dist/types/editor/locales/ja.d.ts.map +1 -0
- package/dist/types/editor/locales/ko.d.ts +130 -0
- package/dist/types/editor/locales/ko.d.ts.map +1 -0
- package/dist/types/editor/locales/ru.d.ts +130 -0
- package/dist/types/editor/locales/ru.d.ts.map +1 -0
- package/dist/types/editor/locales/zh-Hant.d.ts +130 -0
- package/dist/types/editor/locales/zh-Hant.d.ts.map +1 -0
- package/dist/types/editor/locales.d.ts +771 -0
- package/dist/types/editor/locales.d.ts.map +1 -0
- package/dist/types/editor/pdf-contract.d.ts +77 -0
- package/dist/types/editor/pdf-contract.d.ts.map +1 -0
- package/dist/types/editor/pdf-file-impl.d.ts +7 -0
- package/dist/types/editor/pdf-file-impl.d.ts.map +1 -0
- package/dist/types/editor/pdf-file.d.ts +4 -78
- package/dist/types/editor/pdf-file.d.ts.map +1 -1
- package/dist/types/lib/CollaborativeMarkdownEditor.d.ts +3 -0
- package/dist/types/lib/CollaborativeMarkdownEditor.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/index.d.ts.map +1 -1
- package/docs/COLLABORATION.md +4 -0
- package/docs/IMAGE_PREVIEW.md +62 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ A host-managed session replaces `roomId` and `websocketUrl`. Without `collaborat
|
|
|
36
36
|
| `user` | `CollaborationUser` | Display identity for the built-in transport. |
|
|
37
37
|
| `mode` | `EditorMode` | `readonly` stops editing. |
|
|
38
38
|
| `resources` | `EditorResources` | Host asset callbacks. Keep the object reference stable for the session. |
|
|
39
|
+
| `onImagePreview` | `(event: MarkdownImagePreviewEvent) => void` | Takes over image/diagram preview with the current item and document gallery. |
|
|
39
40
|
| `uploadImage` | `(file) => Promise<string>` | Image upload. Defaults to a data URL. |
|
|
40
41
|
| `onChange` | `(markdown) => void` | Local markdown text. |
|
|
41
42
|
| `onConnectionChange` | `(state) => void` | Connection state. |
|
|
@@ -46,7 +47,7 @@ A host-managed session replaces `roomId` and `websocketUrl`. Without `collaborat
|
|
|
46
47
|
| `defaultViewMode` | `ViewMode` | Initial editor, preview, or split view. |
|
|
47
48
|
| `syncScroll` | `boolean` | Scrolls the preview with the editor. Defaults to `true`. |
|
|
48
49
|
| `previewDebounceMs` | `number` | Preview debounce. Automatic timing is 150ms for large documents, otherwise 0. |
|
|
49
|
-
| `locale` | `string` | `zh`
|
|
50
|
+
| `locale` | `string` | `zh`, `en`, `zh-Hant`, `ja`, `fr`, `ko`, `es`, `ru`. Omitted uses Simplified Chinese. Unknown codes use English. |
|
|
50
51
|
| `messages` | `EditorMessages` | Replaces individual catalog entries. |
|
|
51
52
|
| `title`, `className`, `height` | | Chrome and layout. `height` defaults to `100vh`. |
|
|
52
53
|
| `persistence`, `persistenceKey` | | Built-in IndexedDB for the demo transport. Leave them off for a host session. |
|
|
@@ -61,3 +62,11 @@ Give the host `collaboration` session to the editor and keep that object for the
|
|
|
61
62
|
- `locale` and `messages` change interface copy only.
|
|
62
63
|
|
|
63
64
|
Other entry points on the package root include `MarkdownPreview`, `importMarkdownFile`, `exportMarkdownFile`, `importPdfFile`, and `exportPdfFile`.
|
|
65
|
+
|
|
66
|
+
Import `katex/dist/katex.min.css` in the host when displaying math. PDF runtimes load only when `importPdfFile` or `exportPdfFile` is explicitly called.
|
|
67
|
+
|
|
68
|
+
## Image preview
|
|
69
|
+
|
|
70
|
+
Click an image or Mermaid diagram to open the built-in gallery. Drag to pan, use the wheel or buttons to zoom, and switch images with the previous/next buttons, arrow keys, or a horizontal touch swipe at the initial zoom. Escape closes the gallery. Preview also works in readonly mode and never changes Markdown or collaboration state.
|
|
71
|
+
|
|
72
|
+
Both `CollaborativeMarkdownEditor` and `MarkdownPreview` accept `onImagePreview`. Supplying it delegates the complete preview to the host. Custom `components.Preview` wrappers must forward this prop. The exported `MarkdownImagePreviewEvent` includes `image`, `images` in document order, and `index`; each `MarkdownPreviewImage` retains its original `path`, display metadata, and current resolved `src`. Keep resource authorization and URL resolution in the host. See [the event contract](docs/IMAGE_PREVIEW.md).
|
package/README.zh-CN.md
CHANGED
|
@@ -36,6 +36,7 @@ export function Markdown({ markdown }: { markdown: string }) {
|
|
|
36
36
|
| `user` | `CollaborationUser` | 内建传输使用的显示身份。 |
|
|
37
37
|
| `mode` | `EditorMode` | `readonly` 停止编辑。 |
|
|
38
38
|
| `resources` | `EditorResources` | 宿主资源回调。会话期间保持对象引用不变。 |
|
|
39
|
+
| `onImagePreview` | `(event: MarkdownImagePreviewEvent) => void` | 接管图片/图表预览,获得当前项及同文档图集。 |
|
|
39
40
|
| `uploadImage` | `(file) => Promise<string>` | 图片上传。默认转为 data URL。 |
|
|
40
41
|
| `onChange` | `(markdown) => void` | 本地 Markdown 文本。 |
|
|
41
42
|
| `onConnectionChange` | `(state) => void` | 连接状态。 |
|
|
@@ -46,7 +47,7 @@ export function Markdown({ markdown }: { markdown: string }) {
|
|
|
46
47
|
| `defaultViewMode` | `ViewMode` | 初始的编辑、预览或分屏。 |
|
|
47
48
|
| `syncScroll` | `boolean` | 预览跟随编辑器滚动。默认 `true`。 |
|
|
48
49
|
| `previewDebounceMs` | `number` | 预览防抖。大文档自动为 150ms,否则为 0。 |
|
|
49
|
-
| `locale` | `string` | `zh`
|
|
50
|
+
| `locale` | `string` | `zh`, `en`, `zh-Hant`, `ja`, `fr`, `ko`, `es`, `ru`。缺省使用简体中文,未知代码使用英文。 |
|
|
50
51
|
| `messages` | `EditorMessages` | 替换单个文案。 |
|
|
51
52
|
| `title`、`className`、`height` | | 界面和布局。`height` 默认 `100vh`。 |
|
|
52
53
|
| `persistence`、`persistenceKey` | | 演示传输的 IndexedDB。宿主会话不要开启。 |
|
|
@@ -61,3 +62,11 @@ export function Markdown({ markdown }: { markdown: string }) {
|
|
|
61
62
|
- `locale` 和 `messages` 只改变界面文案。
|
|
62
63
|
|
|
63
64
|
包根路径还导出 `MarkdownPreview`、`importMarkdownFile`、`exportMarkdownFile`、`importPdfFile` 和 `exportPdfFile`。
|
|
65
|
+
|
|
66
|
+
显示数学公式时,宿主需导入 `katex/dist/katex.min.css`。PDF 运行时仅在显式调用 `importPdfFile` 或 `exportPdfFile` 时加载。
|
|
67
|
+
|
|
68
|
+
## 图片预览
|
|
69
|
+
|
|
70
|
+
点击图片或 Mermaid 图表打开内置图集。拖动可平移,滚轮或按钮可缩放,上一张/下一张按钮、左右方向键或初始缩放下的触控横滑可切图。Escape 关闭。只读模式也支持预览;所有预览操作只改变界面状态,不修改 Markdown 或协同文档。
|
|
71
|
+
|
|
72
|
+
`CollaborativeMarkdownEditor` 和 `MarkdownPreview` 都接受 `onImagePreview`;传入后由宿主完全接管预览。自定义 `components.Preview` 包装组件需要转发该属性。包根导出 `MarkdownImagePreviewEvent`(`image`、按文档顺序排列的 `images`、`index`)和 `MarkdownPreviewImage` 类型。图片保留原始 `path`、显示元数据及当前解析的 `src`;资源权限和 URL 解析始终由宿主负责。详细说明见[事件契约](docs/IMAGE_PREVIEW.md)。
|