@4399ywkf/editor 0.9.0 → 0.9.2
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/dist/{DocView-WEKRSKRU.js → DocView-YBRD4V4E.js} +6 -5
- package/dist/DocView-YBRD4V4E.js.map +1 -0
- package/dist/chunk-4MQS76M2.js +51666 -0
- package/dist/chunk-4MQS76M2.js.map +1 -0
- package/dist/chunk-ABMZOL26.js +116 -0
- package/dist/chunk-ABMZOL26.js.map +1 -0
- package/dist/{chunk-QMYT5WXO.js → chunk-MGSVKKK7.js} +2 -2
- package/dist/{chunk-QMYT5WXO.js.map → chunk-MGSVKKK7.js.map} +1 -1
- package/dist/chunk-UD6MDBTN.js +1192 -0
- package/dist/chunk-UD6MDBTN.js.map +1 -0
- package/dist/{code-types-Dqmit3xx.d.ts → code-types-BTrUO25D.d.ts} +9 -1
- package/dist/diagram-canvas-22ANCGUV.js +261 -0
- package/dist/diagram-canvas-22ANCGUV.js.map +1 -0
- package/dist/doc-runtime.js +45 -7
- package/dist/doc-runtime.js.map +1 -1
- package/dist/doc.d.ts +540 -58
- package/dist/doc.js +4 -3
- package/dist/doc.js.map +1 -1
- package/dist/docx.js +115 -13
- package/dist/docx.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/pdf.d.ts +2 -2
- package/dist/plugins/ai.js +1 -1
- package/dist/pptx.d.ts +2 -2
- package/dist/{registry-BQ5T1Yko.d.ts → registry-ByvNr_Fa.d.ts} +1 -1
- package/dist/sheet.d.ts +3 -3
- package/dist/style.css +1049 -5990
- package/package.json +21 -5
- package/dist/DocView-WEKRSKRU.js.map +0 -1
- package/dist/chunk-SGLNT6Z2.js +0 -23517
- package/dist/chunk-SGLNT6Z2.js.map +0 -1
- package/dist/chunk-ZY5KLA7T.js +0 -258
- package/dist/chunk-ZY5KLA7T.js.map +0 -1
package/dist/doc.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, DEFAULT_MAX_FILE_SIZES, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, FileAttachment, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, Video, defaultUiState, detectMediaKind, findSelectionPosition, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, renderHighlightedHTML, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, serializeEditorMarkdown, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useWindowSize } from './chunk-
|
|
2
|
-
export { Button, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useTiptapEditor } from './chunk-
|
|
3
|
-
import './chunk-
|
|
1
|
+
export { ApiParamExtension, ArticleViewer, Audio, CalloutExtension, CodeBlockExtension, CodeGroupExtension, CollabContext, CollabProvider, Column, Columns, DEFAULT_DOC_PERMISSIONS, DEFAULT_MAX_FILE_SIZES, DOC_WIDTHS, DetailsExtension, DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EditorConfigProvider, EditorContentArea, EditorThemeStyle, FileAttachment, FileInline, FloatingElement, HIDE_FLOATING_META, LoadingSpinner, MediaUploadButton, MediaUploadPlaceholder, NotionEditor, NotionEditorContent, EditorProvider as NotionEditorInner, PasteDropMedia, Separator, Spacer, Toolbar, ToolbarGroup, ToolbarSeparator, UiState, UserContext, UserProvider, VIEW_MODE_TOAST, Video, ViewModeSwitch, WidthModeMenu, countDocument, countRange, countText, defaultUiState, detectMediaKind, findSelectionPosition, getDocPermissions, getEditorMarkdown, hasContentAbove, markHideFloatingOnNext, parseEditorContent, pickFile, printDocument, renderHighlightedHTML, resolveEditorTheme, resolveMaxSize, runMediaUpload, selectNodeAndHideFloating, serializeEditorMarkdown, useCollab, useCollaboration, useComposedRef, useCursorVisibility, useEditorConfig, useElementRect, useFloatingElement, useFloatingToolbarVisibility, useIsBreakpoint, useIsomorphicLayoutEffect, useMenuNavigation, useOnClickOutside, useThrottledCallback, useUiEditorState, use_ui_editor_state_default as useUiEditorStateDefault, useUnmount, useUser, useViewMode, useWidthMode, useWindowSize } from './chunk-4MQS76M2.js';
|
|
2
|
+
export { Button, MAC_SYMBOLS, MAX_FILE_SIZE, Popover, PopoverContent, PopoverTrigger, SR_ONLY, clamp, cn, findNodeAtPosition, findNodePosition, focusNextNode, formatShortcutKey, getAvatar, getElementOverflowPosition, getNodeDisplayName, getSelectedBlockNodes, getSelectedNodesOfType, getSelectionBoundingRect, getUrlParam, handleImageUpload, isAllowedUri, isExtensionAvailable, isMac, isMarkInSchema, isNodeInSchema, isNodeTypeSelected, isSelectionValid, isTextSelectionValid, isValidPosition, parseShortcutKeys, removeEmptyParagraphs, sanitizeUrl, selectCurrentBlockContent, selectionWithinConvertibleTypes, updateNodesAttr, useTiptapEditor } from './chunk-MGSVKKK7.js';
|
|
3
|
+
import './chunk-UD6MDBTN.js';
|
|
4
|
+
import './chunk-ABMZOL26.js';
|
|
4
5
|
import { useState, useEffect } from 'react';
|
|
5
6
|
|
|
6
7
|
function useScrolling(target, options = {}) {
|
package/dist/doc.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/use-scrolling.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-scrolling.ts"],"names":[],"mappings":";;;;;;AAWO,SAAS,YAAA,CACd,MAAA,EACA,OAAA,GAA+B,EAAC,EACvB;AACT,EAAA,MAAM,EAAE,QAAA,GAAW,GAAA,EAAK,kBAAA,GAAqB,MAAK,GAAI,OAAA;AACtD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,KAAK,CAAA;AAEpD,EAAA,SAAA,CAAU,MAAM;AAEd,IAAA,MAAM,OAAA,GACJ,UAAU,OAAO,MAAA,KAAW,eAAe,MAAA,YAAkB,MAAA,GACzD,MAAA,GACE,MAAA,EAAmC,OAAA,IAAW,MAAA;AAGtD,IAAA,MAAM,cACJ,kBAAA,IACA,OAAA,KAAY,UACZ,OAAO,QAAA,KAAa,cAChB,QAAA,GACA,OAAA;AAEN,IAAA,MAAM,EAAA,GAAK,CACT,EAAA,EACA,KAAA,EACA,YACG,EAAA,CAAG,gBAAA,CAAiB,KAAA,EAAO,OAAA,EAAS,IAAI,CAAA;AAE7C,IAAA,MAAM,GAAA,GAAM,CACV,EAAA,EACA,KAAA,EACA,YACG,EAAA,CAAG,mBAAA,CAAoB,OAAO,OAAO,CAAA;AAE1C,IAAA,IAAI,OAAA;AACJ,IAAA,MAAM,iBAAA,GAAoB,OAAA,KAAY,MAAA,IAAU,aAAA,IAAiB,MAAA;AAEjE,IAAA,MAAM,eAA8B,MAAM;AACxC,MAAA,IAAI,CAAC,WAAA,EAAa,cAAA,CAAe,IAAI,CAAA;AAErC,MAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,QAAA,YAAA,CAAa,OAAO,CAAA;AACpB,QAAA,OAAA,GAAU,UAAA,CAAW,MAAM,cAAA,CAAe,KAAK,GAAG,QAAQ,CAAA;AAAA,MAC5D;AAAA,IACF,CAAA;AAEA,IAAA,MAAM,eAAA,GAAiC,MAAM,cAAA,CAAe,KAAK,CAAA;AAEjE,IAAA,EAAA,CAAG,WAAA,EAAa,UAAU,YAAY,CAAA;AACtC,IAAA,IAAI,iBAAA,EAAmB;AACrB,MAAA,EAAA,CAAG,WAAA,EAAa,aAAa,eAAe,CAAA;AAAA,IAC9C;AAEA,IAAA,OAAO,MAAM;AACX,MAAA,GAAA,CAAI,WAAA,EAAa,UAAU,YAAY,CAAA;AACvC,MAAA,IAAI,iBAAA,EAAmB;AACrB,QAAA,GAAA,CAAI,WAAA,EAAa,aAAa,eAAe,CAAA;AAAA,MAC/C;AACA,MAAA,YAAA,CAAa,OAAO,CAAA;AAAA,IACtB,CAAA;AAAA,EACF,GAAG,CAAC,MAAA,EAAQ,QAAA,EAAU,kBAAA,EAAoB,WAAW,CAAC,CAAA;AAEtD,EAAA,OAAO,WAAA;AACT","file":"doc.js","sourcesContent":["import type { RefObject } from \"react\"\nimport { useEffect, useState } from \"react\"\n\ntype ScrollTarget = RefObject<HTMLElement> | Window | null | undefined\ntype EventTargetWithScroll = Window | HTMLElement | Document\n\ninterface UseScrollingOptions {\n debounce?: number\n fallbackToDocument?: boolean\n}\n\nexport function useScrolling(\n target?: ScrollTarget,\n options: UseScrollingOptions = {}\n): boolean {\n const { debounce = 150, fallbackToDocument = true } = options\n const [isScrolling, setIsScrolling] = useState(false)\n\n useEffect(() => {\n // Resolve element or window\n const element: EventTargetWithScroll =\n target && typeof Window !== \"undefined\" && target instanceof Window\n ? target\n : ((target as RefObject<HTMLElement>)?.current ?? window)\n\n // Mobile: fallback to document when using window\n const eventTarget: EventTargetWithScroll =\n fallbackToDocument &&\n element === window &&\n typeof document !== \"undefined\"\n ? document\n : element\n\n const on = (\n el: EventTargetWithScroll,\n event: string,\n handler: EventListener\n ) => el.addEventListener(event, handler, true)\n\n const off = (\n el: EventTargetWithScroll,\n event: string,\n handler: EventListener\n ) => el.removeEventListener(event, handler)\n\n let timeout: ReturnType<typeof setTimeout>\n const supportsScrollEnd = element === window && \"onscrollend\" in window\n\n const handleScroll: EventListener = () => {\n if (!isScrolling) setIsScrolling(true)\n\n if (!supportsScrollEnd) {\n clearTimeout(timeout)\n timeout = setTimeout(() => setIsScrolling(false), debounce)\n }\n }\n\n const handleScrollEnd: EventListener = () => setIsScrolling(false)\n\n on(eventTarget, \"scroll\", handleScroll)\n if (supportsScrollEnd) {\n on(eventTarget, \"scrollend\", handleScrollEnd)\n }\n\n return () => {\n off(eventTarget, \"scroll\", handleScroll)\n if (supportsScrollEnd) {\n off(eventTarget, \"scrollend\", handleScrollEnd)\n }\n clearTimeout(timeout)\n }\n }, [target, debounce, fallbackToDocument, isScrolling])\n\n return isScrolling\n}\n"]}
|
package/dist/docx.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getCodeBlockTitle } from './chunk-
|
|
1
|
+
import { computeHeadingOrdersFromJson, resolveCalloutLook, reminderColor, reminderText, getCodeBlockTitle, resolveColorToHex } from './chunk-UD6MDBTN.js';
|
|
2
|
+
import { toOutline, normalizeDiagram } from './chunk-ABMZOL26.js';
|
|
2
3
|
import { Node, mergeAttributes, Extension } from '@tiptap/core';
|
|
3
4
|
import { unzipSync, zipSync } from 'fflate';
|
|
4
5
|
|
|
@@ -898,6 +899,7 @@ function bytesToBase64(bytes) {
|
|
|
898
899
|
}
|
|
899
900
|
|
|
900
901
|
// src/docx/serialize.ts
|
|
902
|
+
var docxHex = (v) => resolveColorToHex(typeof v === "string" ? v : null)?.slice(1).toUpperCase() ?? null;
|
|
901
903
|
var EMU_PER_PX2 = 9525;
|
|
902
904
|
var PX_TO_DXA = 15;
|
|
903
905
|
var enc = new TextEncoder();
|
|
@@ -914,6 +916,7 @@ var NS = [
|
|
|
914
916
|
].join(" ");
|
|
915
917
|
function serializeDocx(doc, opts = {}) {
|
|
916
918
|
const warnings = [];
|
|
919
|
+
const headingOrders = computeHeadingOrdersFromJson(doc);
|
|
917
920
|
const stats = {
|
|
918
921
|
paragraphs: 0,
|
|
919
922
|
headings: 0,
|
|
@@ -1028,13 +1031,13 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1028
1031
|
if (has("bold")) p.push("<w:b/>");
|
|
1029
1032
|
if (has("italic")) p.push("<w:i/>");
|
|
1030
1033
|
if (has("strike")) p.push("<w:strike/>");
|
|
1031
|
-
const color = ts.color;
|
|
1032
|
-
if (color) p.push(`<w:color w:val="${
|
|
1034
|
+
const color = docxHex(ts.color);
|
|
1035
|
+
if (color) p.push(`<w:color w:val="${color}"/>`);
|
|
1033
1036
|
const halfPt = cssToHalfPoints(ts.fontSize);
|
|
1034
1037
|
if (halfPt) p.push(`<w:sz w:val="${halfPt}"/><w:szCs w:val="${halfPt}"/>`);
|
|
1035
1038
|
if (has("underline")) p.push('<w:u w:val="single"/>');
|
|
1036
|
-
const hl = marks.find((m) => m.type === "highlight")?.attrs?.color;
|
|
1037
|
-
if (hl) p.push(`<w:shd w:val="clear" w:fill="${
|
|
1039
|
+
const hl = docxHex(marks.find((m) => m.type === "highlight")?.attrs?.color);
|
|
1040
|
+
if (hl) p.push(`<w:shd w:val="clear" w:fill="${hl}"/>`);
|
|
1038
1041
|
if (has("superscript")) p.push('<w:vertAlign w:val="superscript"/>');
|
|
1039
1042
|
if (has("subscript")) p.push('<w:vertAlign w:val="subscript"/>');
|
|
1040
1043
|
return p.length ? `<w:rPr>${p.join("")}</w:rPr>` : "";
|
|
@@ -1092,16 +1095,55 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1092
1095
|
}
|
|
1093
1096
|
continue;
|
|
1094
1097
|
}
|
|
1098
|
+
if (n.type === "mention") {
|
|
1099
|
+
const label = String(n.attrs?.label ?? n.attrs?.id ?? "");
|
|
1100
|
+
if (label) out += `<w:r><w:t xml:space="preserve">${esc(`@${label}`)}</w:t></w:r>`;
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
if (n.type === "fileInline") {
|
|
1104
|
+
const name = String(n.attrs?.name || "未命名文件");
|
|
1105
|
+
const run = `<w:r><w:rPr><w:color w:val="3370FF"/></w:rPr><w:t xml:space="preserve">${esc(name)}</w:t></w:r>`;
|
|
1106
|
+
out += n.attrs?.src ? `<w:hyperlink w:tooltip="${esc(String(n.attrs.src))}">${run}</w:hyperlink>` : run;
|
|
1107
|
+
continue;
|
|
1108
|
+
}
|
|
1109
|
+
if (n.type === "inlineButton") {
|
|
1110
|
+
const text = String(n.attrs?.text || "");
|
|
1111
|
+
if (!text) continue;
|
|
1112
|
+
const run = `<w:r><w:rPr><w:color w:val="1456F0"/></w:rPr><w:t xml:space="preserve">${esc(`[${text}]`)}</w:t></w:r>`;
|
|
1113
|
+
out += n.attrs?.action === "OpenLink" && n.attrs?.href ? `<w:hyperlink w:tooltip="${esc(String(n.attrs.href))}">${run}</w:hyperlink>` : run;
|
|
1114
|
+
continue;
|
|
1115
|
+
}
|
|
1116
|
+
if (n.type === "reminder") {
|
|
1117
|
+
const exp = Number(n.attrs?.expireTime) || Date.now();
|
|
1118
|
+
const now = Date.now();
|
|
1119
|
+
const color = reminderColor(exp, now) === "red" ? "F54A45" : reminderColor(exp, now) === "orange" ? "ED6D0C" : "1456F0";
|
|
1120
|
+
out += `<w:r><w:rPr><w:color w:val="${color}"/></w:rPr><w:t xml:space="preserve">${esc(reminderText(exp, n.attrs?.isWholeDay === true, now))}</w:t></w:r>`;
|
|
1121
|
+
continue;
|
|
1122
|
+
}
|
|
1123
|
+
if (n.type === "mentionDoc") {
|
|
1124
|
+
const title = String(n.attrs?.title || "未命名文档");
|
|
1125
|
+
const run = `<w:r><w:rPr><w:color w:val="3370FF"/></w:rPr><w:t xml:space="preserve">${esc(title)}</w:t></w:r>`;
|
|
1126
|
+
out += n.attrs?.url ? `<w:hyperlink w:tooltip="${esc(String(n.attrs.url))}">${run}</w:hyperlink>` : run;
|
|
1127
|
+
continue;
|
|
1128
|
+
}
|
|
1129
|
+
if (n.type === "inlineMath") {
|
|
1130
|
+
out += mathRun(String(n.attrs?.latex ?? ""));
|
|
1131
|
+
continue;
|
|
1132
|
+
}
|
|
1095
1133
|
const t = collectText(n);
|
|
1096
1134
|
if (t) out += `<w:r><w:t xml:space="preserve">${esc(t)}</w:t></w:r>`;
|
|
1097
1135
|
else warnings.push(`未知内联节点 "${n.type}",已跳过`);
|
|
1098
1136
|
}
|
|
1099
1137
|
return out;
|
|
1100
1138
|
}
|
|
1139
|
+
function mathRun(latex) {
|
|
1140
|
+
if (!latex) return "";
|
|
1141
|
+
return `<w:r><w:rPr><w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/><w:i/></w:rPr><w:t xml:space="preserve">${esc(latex)}</w:t></w:r>`;
|
|
1142
|
+
}
|
|
1101
1143
|
function paraProps(node, lead = [], indentTwips) {
|
|
1102
1144
|
const p = [...lead];
|
|
1103
|
-
const bg = node.attrs?.backgroundColor;
|
|
1104
|
-
if (bg) p.push(`<w:shd w:val="clear" w:fill="${
|
|
1145
|
+
const bg = docxHex(node.attrs?.backgroundColor);
|
|
1146
|
+
if (bg) p.push(`<w:shd w:val="clear" w:fill="${bg}"/>`);
|
|
1105
1147
|
const sp = [];
|
|
1106
1148
|
const before = cssToTwips(node.attrs?.spaceBefore);
|
|
1107
1149
|
if (before !== null) sp.push(`w:before="${before}"`);
|
|
@@ -1131,7 +1173,9 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1131
1173
|
function heading(node) {
|
|
1132
1174
|
stats.headings += 1;
|
|
1133
1175
|
const lv = Math.min(9, Math.max(1, Number(node.attrs?.level ?? 1)));
|
|
1134
|
-
|
|
1176
|
+
const order = headingOrders.get(node);
|
|
1177
|
+
const orderRun = order ? `<w:r><w:t xml:space="preserve">${esc(order)} </w:t></w:r>` : "";
|
|
1178
|
+
return `<w:p>${paraProps(node, [`<w:pStyle w:val="Heading${lv}"/>`])}${orderRun}${inlineToRuns(node.content)}</w:p>`;
|
|
1135
1179
|
}
|
|
1136
1180
|
function list(node, level, out) {
|
|
1137
1181
|
const ordered = node.type === "orderedList";
|
|
@@ -1208,8 +1252,8 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1208
1252
|
continue;
|
|
1209
1253
|
}
|
|
1210
1254
|
if (Number(cell.attrs?.rowspan ?? 1) > 1) props.push('<w:vMerge w:val="restart"/>');
|
|
1211
|
-
const bg = cell.attrs?.backgroundColor;
|
|
1212
|
-
if (bg) props.push(`<w:shd w:val="clear" w:fill="${
|
|
1255
|
+
const bg = docxHex(cell.attrs?.backgroundColor);
|
|
1256
|
+
if (bg) props.push(`<w:shd w:val="clear" w:fill="${bg}"/>`);
|
|
1213
1257
|
const va = cell.attrs?.nodeVerticalAlign;
|
|
1214
1258
|
if (va) props.push(`<w:vAlign w:val="${esc(va)}"/>`);
|
|
1215
1259
|
const inner = blocks(cell.content ?? []);
|
|
@@ -1271,14 +1315,28 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1271
1315
|
out.push(codeBlock(child));
|
|
1272
1316
|
}
|
|
1273
1317
|
break;
|
|
1318
|
+
case "syncedBlock":
|
|
1319
|
+
out.push(blocks(n.content ?? [], indent));
|
|
1320
|
+
break;
|
|
1321
|
+
case "agenda":
|
|
1322
|
+
for (const item of n.content ?? []) {
|
|
1323
|
+
const [title, body] = item.content ?? [];
|
|
1324
|
+
const minutes = Math.round((Number(item.attrs?.duration) || 0) / 60);
|
|
1325
|
+
const head = (title ? collectText(title) : "") || "未命名议程";
|
|
1326
|
+
out.push(boldParagraph(minutes ? `${head}(${minutes} 分钟)` : head, indent));
|
|
1327
|
+
out.push(blocks(body?.content ?? [], indent));
|
|
1328
|
+
}
|
|
1329
|
+
break;
|
|
1274
1330
|
case "details":
|
|
1275
1331
|
out.push(boldParagraph(String(n.attrs?.title ?? "") || "详情", indent));
|
|
1276
1332
|
out.push(blocks(n.content ?? [], indent));
|
|
1277
1333
|
break;
|
|
1278
1334
|
case "callout": {
|
|
1279
1335
|
const type = String(n.attrs?.type ?? "info");
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1336
|
+
const look = resolveCalloutLook({ type, emoji: n.attrs?.emoji ?? null });
|
|
1337
|
+
const title = n.attrs?.title == null ? "" : String(n.attrs.title) || calloutDefaultTitle(type);
|
|
1338
|
+
const head = [look.emoji, title].filter(Boolean).join(" ");
|
|
1339
|
+
if (head) out.push(boldParagraph(head, indent));
|
|
1282
1340
|
out.push(blocks(n.content ?? [], indent + 720));
|
|
1283
1341
|
break;
|
|
1284
1342
|
}
|
|
@@ -1286,6 +1344,50 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1286
1344
|
out.push(apiParamHeader(n, indent));
|
|
1287
1345
|
out.push(blocks(n.content ?? [], indent + 720));
|
|
1288
1346
|
break;
|
|
1347
|
+
case "pageHeader": {
|
|
1348
|
+
const icon = n.attrs?.icon ? `<w:r><w:t xml:space="preserve">${esc(String(n.attrs.icon))} </w:t></w:r>` : "";
|
|
1349
|
+
const runs = inlineToRuns(n.content ?? []);
|
|
1350
|
+
if (icon || runs) out.push(`<w:p><w:pPr><w:pStyle w:val="Title"/></w:pPr>${icon}${runs}</w:p>`);
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
case "embed": {
|
|
1354
|
+
const url = String(n.attrs?.url ?? "");
|
|
1355
|
+
if (url) out.push(`<w:p><w:r><w:t xml:space="preserve">${esc(`嵌入网页:${url}`)}</w:t></w:r></w:p>`);
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
case "fileAttachment": {
|
|
1359
|
+
const name = String(n.attrs?.name || "未命名文件");
|
|
1360
|
+
const src = String(n.attrs?.src ?? "");
|
|
1361
|
+
const run = `<w:r><w:rPr><w:color w:val="3370FF"/></w:rPr><w:t xml:space="preserve">${esc(`📎 ${name}`)}</w:t></w:r>`;
|
|
1362
|
+
out.push(`<w:p>${src ? `<w:hyperlink w:tooltip="${esc(src)}">${run}</w:hyperlink>` : run}</w:p>`);
|
|
1363
|
+
break;
|
|
1364
|
+
}
|
|
1365
|
+
case "bookmark": {
|
|
1366
|
+
const url = String(n.attrs?.url ?? "");
|
|
1367
|
+
if (url) {
|
|
1368
|
+
const title = String(n.attrs?.title || url);
|
|
1369
|
+
out.push(`<w:p><w:hyperlink w:tooltip="${esc(url)}"><w:r><w:rPr><w:color w:val="3370FF"/><w:u w:val="single"/></w:rPr><w:t xml:space="preserve">${esc(title)}</w:t></w:r></w:hyperlink></w:p>`);
|
|
1370
|
+
}
|
|
1371
|
+
break;
|
|
1372
|
+
}
|
|
1373
|
+
case "poll": {
|
|
1374
|
+
const title = String(n.attrs?.title ?? "");
|
|
1375
|
+
const options = Array.isArray(n.attrs?.options) ? n.attrs.options : [];
|
|
1376
|
+
out.push(`<w:p><w:r><w:rPr><w:b/></w:rPr><w:t xml:space="preserve">${esc(`投票:${title}`)}</w:t></w:r></w:p>`);
|
|
1377
|
+
for (const o of options) out.push(`<w:p><w:r><w:t xml:space="preserve">${esc(`○ ${o.text ?? ""}`)}</w:t></w:r></w:p>`);
|
|
1378
|
+
break;
|
|
1379
|
+
}
|
|
1380
|
+
case "diagram": {
|
|
1381
|
+
const lines = toOutline(normalizeDiagram(n.attrs?.data));
|
|
1382
|
+
out.push(`<w:p><w:r><w:rPr><w:b/></w:rPr><w:t xml:space="preserve">流程图</w:t></w:r></w:p>`);
|
|
1383
|
+
for (const line of lines) out.push(`<w:p><w:r><w:t xml:space="preserve">${esc(line)}</w:t></w:r></w:p>`);
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
case "blockMath": {
|
|
1387
|
+
const run = mathRun(String(n.attrs?.latex ?? ""));
|
|
1388
|
+
if (run) out.push(`<w:p><w:pPr><w:jc w:val="center"/></w:pPr>${run}</w:p>`);
|
|
1389
|
+
break;
|
|
1390
|
+
}
|
|
1289
1391
|
case "horizontalRule":
|
|
1290
1392
|
out.push('<w:p><w:pPr><w:pBdr><w:bottom w:val="single" w:sz="6" w:color="auto"/></w:pBdr></w:pPr></w:p>');
|
|
1291
1393
|
break;
|
|
@@ -1327,7 +1429,7 @@ function serializeDocx(doc, opts = {}) {
|
|
|
1327
1429
|
}).join("");
|
|
1328
1430
|
const dflt = opts.styleOverrides ?? {};
|
|
1329
1431
|
files["word/styles.xml"] = enc.encode(
|
|
1330
|
-
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles ${NS}><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="${esc(dflt.defaultFont ?? "Calibri")}" w:eastAsia="${esc(dflt.defaultFont ?? "等线")}"/><w:sz w:val="${(dflt.defaultSizePt ?? 11) * 2}"/></w:rPr></w:rPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/></w:style><w:style w:type="paragraph" w:styleId="Code"><w:name w:val="Code"/><w:basedOn w:val="Normal"/></w:style>` + headingStyles + `</w:styles>`
|
|
1432
|
+
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles ${NS}><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="${esc(dflt.defaultFont ?? "Calibri")}" w:eastAsia="${esc(dflt.defaultFont ?? "等线")}"/><w:sz w:val="${(dflt.defaultSizePt ?? 11) * 2}"/></w:rPr></w:rPrDefault></w:docDefaults><w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/></w:style><w:style w:type="paragraph" w:styleId="Code"><w:name w:val="Code"/><w:basedOn w:val="Normal"/></w:style><w:style w:type="paragraph" w:styleId="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:pPr><w:spacing w:after="240"/></w:pPr><w:rPr><w:b/><w:sz w:val="52"/></w:rPr></w:style>` + headingStyles + `</w:styles>`
|
|
1331
1433
|
);
|
|
1332
1434
|
const abstractNums = numDefs.map((d, i) => {
|
|
1333
1435
|
const levels = Array.from(
|