@lark-project/openclaw-lark-project 2026.3.131
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/LICENSE +21 -0
- package/README.md +80 -0
- package/README.zh.md +80 -0
- package/dist/index.js +172 -0
- package/dist/index.js.map +7 -0
- package/dist/skills/feishu-bitable/SKILL.md +248 -0
- package/dist/skills/feishu-bitable/references/examples.md +813 -0
- package/dist/skills/feishu-bitable/references/field-properties.md +763 -0
- package/dist/skills/feishu-bitable/references/record-values.md +911 -0
- package/dist/skills/feishu-calendar/SKILL.md +244 -0
- package/dist/skills/feishu-channel-rules/SKILL.md +18 -0
- package/dist/skills/feishu-channel-rules/references/markdown-syntax.md +138 -0
- package/dist/skills/feishu-create-doc/SKILL.md +719 -0
- package/dist/skills/feishu-fetch-doc/SKILL.md +93 -0
- package/dist/skills/feishu-im-read/SKILL.md +163 -0
- package/dist/skills/feishu-project/SKILL.md +122 -0
- package/dist/skills/feishu-task/SKILL.md +293 -0
- package/dist/skills/feishu-troubleshoot/SKILL.md +70 -0
- package/dist/skills/feishu-update-doc/SKILL.md +285 -0
- package/dist/src/card/builder.js +293 -0
- package/dist/src/card/builder.js.map +7 -0
- package/dist/src/card/cardkit.js +126 -0
- package/dist/src/card/cardkit.js.map +7 -0
- package/dist/src/card/flush-controller.js +107 -0
- package/dist/src/card/flush-controller.js.map +7 -0
- package/dist/src/card/markdown-style.js +57 -0
- package/dist/src/card/markdown-style.js.map +7 -0
- package/dist/src/card/reply-dispatcher-types.js +39 -0
- package/dist/src/card/reply-dispatcher-types.js.map +7 -0
- package/dist/src/card/reply-dispatcher.js +245 -0
- package/dist/src/card/reply-dispatcher.js.map +7 -0
- package/dist/src/card/reply-mode.js +29 -0
- package/dist/src/card/reply-mode.js.map +7 -0
- package/dist/src/card/streaming-card-controller.js +653 -0
- package/dist/src/card/streaming-card-controller.js.map +7 -0
- package/dist/src/card/unavailable-guard.js +76 -0
- package/dist/src/card/unavailable-guard.js.map +7 -0
- package/dist/src/channel/abort-detect.js +79 -0
- package/dist/src/channel/abort-detect.js.map +7 -0
- package/dist/src/channel/chat-queue.js +50 -0
- package/dist/src/channel/chat-queue.js.map +7 -0
- package/dist/src/channel/config-adapter.js +89 -0
- package/dist/src/channel/config-adapter.js.map +7 -0
- package/dist/src/channel/directory.js +133 -0
- package/dist/src/channel/directory.js.map +7 -0
- package/dist/src/channel/event-handlers.js +175 -0
- package/dist/src/channel/event-handlers.js.map +7 -0
- package/dist/src/channel/monitor.js +108 -0
- package/dist/src/channel/monitor.js.map +7 -0
- package/dist/src/channel/onboarding-config.js +76 -0
- package/dist/src/channel/onboarding-config.js.map +7 -0
- package/dist/src/channel/onboarding-migrate.js +55 -0
- package/dist/src/channel/onboarding-migrate.js.map +7 -0
- package/dist/src/channel/onboarding.js +285 -0
- package/dist/src/channel/onboarding.js.map +7 -0
- package/dist/src/channel/plugin.js +260 -0
- package/dist/src/channel/plugin.js.map +7 -0
- package/dist/src/channel/probe.js +14 -0
- package/dist/src/channel/probe.js.map +7 -0
- package/dist/src/channel/types.js +1 -0
- package/dist/src/channel/types.js.map +7 -0
- package/dist/src/commands/auth.js +73 -0
- package/dist/src/commands/auth.js.map +7 -0
- package/dist/src/commands/diagnose.js +658 -0
- package/dist/src/commands/diagnose.js.map +7 -0
- package/dist/src/commands/doctor.js +327 -0
- package/dist/src/commands/doctor.js.map +7 -0
- package/dist/src/commands/index.js +124 -0
- package/dist/src/commands/index.js.map +7 -0
- package/dist/src/core/accounts.js +129 -0
- package/dist/src/core/accounts.js.map +7 -0
- package/dist/src/core/agent-config.js +60 -0
- package/dist/src/core/agent-config.js.map +7 -0
- package/dist/src/core/api-error.js +55 -0
- package/dist/src/core/api-error.js.map +7 -0
- package/dist/src/core/app-owner-fallback.js +17 -0
- package/dist/src/core/app-owner-fallback.js.map +7 -0
- package/dist/src/core/app-scope-checker.js +95 -0
- package/dist/src/core/app-scope-checker.js.map +7 -0
- package/dist/src/core/auth-errors.js +120 -0
- package/dist/src/core/auth-errors.js.map +7 -0
- package/dist/src/core/chat-info-cache.js +102 -0
- package/dist/src/core/chat-info-cache.js.map +7 -0
- package/dist/src/core/config-schema.js +150 -0
- package/dist/src/core/config-schema.js.map +7 -0
- package/dist/src/core/device-flow.js +174 -0
- package/dist/src/core/device-flow.js.map +7 -0
- package/dist/src/core/feishu-fetch.js +12 -0
- package/dist/src/core/feishu-fetch.js.map +7 -0
- package/dist/src/core/footer-config.js +16 -0
- package/dist/src/core/footer-config.js.map +7 -0
- package/dist/src/core/lark-client.js +322 -0
- package/dist/src/core/lark-client.js.map +7 -0
- package/dist/src/core/lark-logger.js +92 -0
- package/dist/src/core/lark-logger.js.map +7 -0
- package/dist/src/core/lark-ticket.js +18 -0
- package/dist/src/core/lark-ticket.js.map +7 -0
- package/dist/src/core/message-unavailable.js +119 -0
- package/dist/src/core/message-unavailable.js.map +7 -0
- package/dist/src/core/owner-policy.js +25 -0
- package/dist/src/core/owner-policy.js.map +7 -0
- package/dist/src/core/permission-url.js +37 -0
- package/dist/src/core/permission-url.js.map +7 -0
- package/dist/src/core/project-auth.js +177 -0
- package/dist/src/core/project-auth.js.map +7 -0
- package/dist/src/core/project-oauth-flow.js +124 -0
- package/dist/src/core/project-oauth-flow.js.map +7 -0
- package/dist/src/core/project-token-store.js +172 -0
- package/dist/src/core/project-token-store.js.map +7 -0
- package/dist/src/core/raw-request.js +45 -0
- package/dist/src/core/raw-request.js.map +7 -0
- package/dist/src/core/scope-manager.js +62 -0
- package/dist/src/core/scope-manager.js.map +7 -0
- package/dist/src/core/security-check.js +118 -0
- package/dist/src/core/security-check.js.map +7 -0
- package/dist/src/core/shutdown-hooks.js +37 -0
- package/dist/src/core/shutdown-hooks.js.map +7 -0
- package/dist/src/core/targets.js +55 -0
- package/dist/src/core/targets.js.map +7 -0
- package/dist/src/core/token-store.js +215 -0
- package/dist/src/core/token-store.js.map +7 -0
- package/dist/src/core/tool-client.js +335 -0
- package/dist/src/core/tool-client.js.map +7 -0
- package/dist/src/core/tool-scopes.js +207 -0
- package/dist/src/core/tool-scopes.js.map +7 -0
- package/dist/src/core/tools-config.js +57 -0
- package/dist/src/core/tools-config.js.map +7 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/core/types.js.map +7 -0
- package/dist/src/core/uat-client.js +124 -0
- package/dist/src/core/uat-client.js.map +7 -0
- package/dist/src/core/version.js +27 -0
- package/dist/src/core/version.js.map +7 -0
- package/dist/src/messaging/converters/audio.js +19 -0
- package/dist/src/messaging/converters/audio.js.map +7 -0
- package/dist/src/messaging/converters/calendar.js +46 -0
- package/dist/src/messaging/converters/calendar.js.map +7 -0
- package/dist/src/messaging/converters/content-converter.js +61 -0
- package/dist/src/messaging/converters/content-converter.js.map +7 -0
- package/dist/src/messaging/converters/file.js +18 -0
- package/dist/src/messaging/converters/file.js.map +7 -0
- package/dist/src/messaging/converters/folder.js +18 -0
- package/dist/src/messaging/converters/folder.js.map +7 -0
- package/dist/src/messaging/converters/hongbao.js +14 -0
- package/dist/src/messaging/converters/hongbao.js.map +7 -0
- package/dist/src/messaging/converters/image.js +16 -0
- package/dist/src/messaging/converters/image.js.map +7 -0
- package/dist/src/messaging/converters/index.js +48 -0
- package/dist/src/messaging/converters/index.js.map +7 -0
- package/dist/src/messaging/converters/interactive/card-converter.js +1040 -0
- package/dist/src/messaging/converters/interactive/card-converter.js.map +7 -0
- package/dist/src/messaging/converters/interactive/card-utils.js +36 -0
- package/dist/src/messaging/converters/interactive/card-utils.js.map +7 -0
- package/dist/src/messaging/converters/interactive/index.js +19 -0
- package/dist/src/messaging/converters/interactive/index.js.map +7 -0
- package/dist/src/messaging/converters/interactive/legacy.js +53 -0
- package/dist/src/messaging/converters/interactive/legacy.js.map +7 -0
- package/dist/src/messaging/converters/interactive/types.js +23 -0
- package/dist/src/messaging/converters/interactive/types.js.map +7 -0
- package/dist/src/messaging/converters/location.js +17 -0
- package/dist/src/messaging/converters/location.js.map +7 -0
- package/dist/src/messaging/converters/merge-forward.js +143 -0
- package/dist/src/messaging/converters/merge-forward.js.map +7 -0
- package/dist/src/messaging/converters/post.js +113 -0
- package/dist/src/messaging/converters/post.js.map +7 -0
- package/dist/src/messaging/converters/share.js +22 -0
- package/dist/src/messaging/converters/share.js.map +7 -0
- package/dist/src/messaging/converters/sticker.js +16 -0
- package/dist/src/messaging/converters/sticker.js.map +7 -0
- package/dist/src/messaging/converters/system.js +25 -0
- package/dist/src/messaging/converters/system.js.map +7 -0
- package/dist/src/messaging/converters/text.js +12 -0
- package/dist/src/messaging/converters/text.js.map +7 -0
- package/dist/src/messaging/converters/todo.js +37 -0
- package/dist/src/messaging/converters/todo.js.map +7 -0
- package/dist/src/messaging/converters/types.js +1 -0
- package/dist/src/messaging/converters/types.js.map +7 -0
- package/dist/src/messaging/converters/unknown.js +13 -0
- package/dist/src/messaging/converters/unknown.js.map +7 -0
- package/dist/src/messaging/converters/utils.js +35 -0
- package/dist/src/messaging/converters/utils.js.map +7 -0
- package/dist/src/messaging/converters/video-chat.js +21 -0
- package/dist/src/messaging/converters/video-chat.js.map +7 -0
- package/dist/src/messaging/converters/video.js +30 -0
- package/dist/src/messaging/converters/video.js.map +7 -0
- package/dist/src/messaging/converters/vote.js +24 -0
- package/dist/src/messaging/converters/vote.js.map +7 -0
- package/dist/src/messaging/inbound/dedup.js +82 -0
- package/dist/src/messaging/inbound/dedup.js.map +7 -0
- package/dist/src/messaging/inbound/dispatch-builders.js +98 -0
- package/dist/src/messaging/inbound/dispatch-builders.js.map +7 -0
- package/dist/src/messaging/inbound/dispatch-commands.js +94 -0
- package/dist/src/messaging/inbound/dispatch-commands.js.map +7 -0
- package/dist/src/messaging/inbound/dispatch-context.js +96 -0
- package/dist/src/messaging/inbound/dispatch-context.js.map +7 -0
- package/dist/src/messaging/inbound/dispatch.js +150 -0
- package/dist/src/messaging/inbound/dispatch.js.map +7 -0
- package/dist/src/messaging/inbound/enrich.js +137 -0
- package/dist/src/messaging/inbound/enrich.js.map +7 -0
- package/dist/src/messaging/inbound/gate-effects.js +28 -0
- package/dist/src/messaging/inbound/gate-effects.js.map +7 -0
- package/dist/src/messaging/inbound/gate.js +163 -0
- package/dist/src/messaging/inbound/gate.js.map +7 -0
- package/dist/src/messaging/inbound/handler.js +132 -0
- package/dist/src/messaging/inbound/handler.js.map +7 -0
- package/dist/src/messaging/inbound/media-resolver.js +70 -0
- package/dist/src/messaging/inbound/media-resolver.js.map +7 -0
- package/dist/src/messaging/inbound/mention.js +50 -0
- package/dist/src/messaging/inbound/mention.js.map +7 -0
- package/dist/src/messaging/inbound/parse-io.js +41 -0
- package/dist/src/messaging/inbound/parse-io.js.map +7 -0
- package/dist/src/messaging/inbound/parse.js +79 -0
- package/dist/src/messaging/inbound/parse.js.map +7 -0
- package/dist/src/messaging/inbound/permission.js +30 -0
- package/dist/src/messaging/inbound/permission.js.map +7 -0
- package/dist/src/messaging/inbound/policy.js +83 -0
- package/dist/src/messaging/inbound/policy.js.map +7 -0
- package/dist/src/messaging/inbound/reaction-handler.js +162 -0
- package/dist/src/messaging/inbound/reaction-handler.js.map +7 -0
- package/dist/src/messaging/inbound/user-name-cache.js +172 -0
- package/dist/src/messaging/inbound/user-name-cache.js.map +7 -0
- package/dist/src/messaging/outbound/actions.js +239 -0
- package/dist/src/messaging/outbound/actions.js.map +7 -0
- package/dist/src/messaging/outbound/chat-manage.js +74 -0
- package/dist/src/messaging/outbound/chat-manage.js.map +7 -0
- package/dist/src/messaging/outbound/deliver.js +162 -0
- package/dist/src/messaging/outbound/deliver.js.map +7 -0
- package/dist/src/messaging/outbound/fetch.js +7 -0
- package/dist/src/messaging/outbound/fetch.js.map +7 -0
- package/dist/src/messaging/outbound/forward.js +31 -0
- package/dist/src/messaging/outbound/forward.js.map +7 -0
- package/dist/src/messaging/outbound/media-url-utils.js +101 -0
- package/dist/src/messaging/outbound/media-url-utils.js.map +7 -0
- package/dist/src/messaging/outbound/media.js +463 -0
- package/dist/src/messaging/outbound/media.js.map +7 -0
- package/dist/src/messaging/outbound/outbound.js +95 -0
- package/dist/src/messaging/outbound/outbound.js.map +7 -0
- package/dist/src/messaging/outbound/reactions.js +312 -0
- package/dist/src/messaging/outbound/reactions.js.map +7 -0
- package/dist/src/messaging/outbound/send.js +194 -0
- package/dist/src/messaging/outbound/send.js.map +7 -0
- package/dist/src/messaging/outbound/typing.js +77 -0
- package/dist/src/messaging/outbound/typing.js.map +7 -0
- package/dist/src/messaging/shared/message-lookup.js +84 -0
- package/dist/src/messaging/shared/message-lookup.js.map +7 -0
- package/dist/src/messaging/types.js +1 -0
- package/dist/src/messaging/types.js.map +7 -0
- package/dist/src/tools/auto-auth.js +714 -0
- package/dist/src/tools/auto-auth.js.map +7 -0
- package/dist/src/tools/helpers.js +133 -0
- package/dist/src/tools/helpers.js.map +7 -0
- package/dist/src/tools/mcp/doc/create.js +35 -0
- package/dist/src/tools/mcp/doc/create.js.map +7 -0
- package/dist/src/tools/mcp/doc/fetch.js +33 -0
- package/dist/src/tools/mcp/doc/fetch.js.map +7 -0
- package/dist/src/tools/mcp/doc/index.js +32 -0
- package/dist/src/tools/mcp/doc/index.js.map +7 -0
- package/dist/src/tools/mcp/doc/update.js +61 -0
- package/dist/src/tools/mcp/doc/update.js.map +7 -0
- package/dist/src/tools/mcp/project/endpoint.js +25 -0
- package/dist/src/tools/mcp/project/endpoint.js.map +7 -0
- package/dist/src/tools/mcp/project/index.js +27 -0
- package/dist/src/tools/mcp/project/index.js.map +7 -0
- package/dist/src/tools/mcp/project/tools.js +579 -0
- package/dist/src/tools/mcp/project/tools.js.map +7 -0
- package/dist/src/tools/mcp/shared.js +170 -0
- package/dist/src/tools/mcp/shared.js.map +7 -0
- package/dist/src/tools/oapi/bitable/app-table-field.js +244 -0
- package/dist/src/tools/oapi/bitable/app-table-field.js.map +7 -0
- package/dist/src/tools/oapi/bitable/app-table-record.js +501 -0
- package/dist/src/tools/oapi/bitable/app-table-record.js.map +7 -0
- package/dist/src/tools/oapi/bitable/app-table-view.js +226 -0
- package/dist/src/tools/oapi/bitable/app-table-view.js.map +7 -0
- package/dist/src/tools/oapi/bitable/app-table.js +278 -0
- package/dist/src/tools/oapi/bitable/app-table.js.map +7 -0
- package/dist/src/tools/oapi/bitable/app.js +200 -0
- package/dist/src/tools/oapi/bitable/app.js.map +7 -0
- package/dist/src/tools/oapi/bitable/index.js +13 -0
- package/dist/src/tools/oapi/bitable/index.js.map +7 -0
- package/dist/src/tools/oapi/calendar/calendar.js +131 -0
- package/dist/src/tools/oapi/calendar/calendar.js.map +7 -0
- package/dist/src/tools/oapi/calendar/event-attendee.js +301 -0
- package/dist/src/tools/oapi/calendar/event-attendee.js.map +7 -0
- package/dist/src/tools/oapi/calendar/event.js +834 -0
- package/dist/src/tools/oapi/calendar/event.js.map +7 -0
- package/dist/src/tools/oapi/calendar/freebusy.js +111 -0
- package/dist/src/tools/oapi/calendar/freebusy.js.map +7 -0
- package/dist/src/tools/oapi/calendar/index.js +11 -0
- package/dist/src/tools/oapi/calendar/index.js.map +7 -0
- package/dist/src/tools/oapi/chat/chat.js +132 -0
- package/dist/src/tools/oapi/chat/chat.js.map +7 -0
- package/dist/src/tools/oapi/chat/index.js +11 -0
- package/dist/src/tools/oapi/chat/index.js.map +7 -0
- package/dist/src/tools/oapi/chat/members.js +83 -0
- package/dist/src/tools/oapi/chat/members.js.map +7 -0
- package/dist/src/tools/oapi/common/get-user.js +95 -0
- package/dist/src/tools/oapi/common/get-user.js.map +7 -0
- package/dist/src/tools/oapi/common/index.js +7 -0
- package/dist/src/tools/oapi/common/index.js.map +7 -0
- package/dist/src/tools/oapi/common/search-user.js +67 -0
- package/dist/src/tools/oapi/common/search-user.js.map +7 -0
- package/dist/src/tools/oapi/drive/doc-comments.js +310 -0
- package/dist/src/tools/oapi/drive/doc-comments.js.map +7 -0
- package/dist/src/tools/oapi/drive/doc-media.js +314 -0
- package/dist/src/tools/oapi/drive/doc-media.js.map +7 -0
- package/dist/src/tools/oapi/drive/file.js +548 -0
- package/dist/src/tools/oapi/drive/file.js.map +7 -0
- package/dist/src/tools/oapi/drive/index.js +29 -0
- package/dist/src/tools/oapi/drive/index.js.map +7 -0
- package/dist/src/tools/oapi/helpers.js +199 -0
- package/dist/src/tools/oapi/helpers.js.map +7 -0
- package/dist/src/tools/oapi/im/format-messages.js +128 -0
- package/dist/src/tools/oapi/im/format-messages.js.map +7 -0
- package/dist/src/tools/oapi/im/index.js +15 -0
- package/dist/src/tools/oapi/im/index.js.map +7 -0
- package/dist/src/tools/oapi/im/message-read.js +404 -0
- package/dist/src/tools/oapi/im/message-read.js.map +7 -0
- package/dist/src/tools/oapi/im/message.js +179 -0
- package/dist/src/tools/oapi/im/message.js.map +7 -0
- package/dist/src/tools/oapi/im/resource.js +126 -0
- package/dist/src/tools/oapi/im/resource.js.map +7 -0
- package/dist/src/tools/oapi/im/time-utils.js +169 -0
- package/dist/src/tools/oapi/im/time-utils.js.map +7 -0
- package/dist/src/tools/oapi/im/user-name-uat.js +103 -0
- package/dist/src/tools/oapi/im/user-name-uat.js.map +7 -0
- package/dist/src/tools/oapi/index.js +56 -0
- package/dist/src/tools/oapi/index.js.map +7 -0
- package/dist/src/tools/oapi/sdk-types.js +1 -0
- package/dist/src/tools/oapi/sdk-types.js.map +7 -0
- package/dist/src/tools/oapi/search/doc-search.js +215 -0
- package/dist/src/tools/oapi/search/doc-search.js.map +7 -0
- package/dist/src/tools/oapi/search/index.js +25 -0
- package/dist/src/tools/oapi/search/index.js.map +7 -0
- package/dist/src/tools/oapi/sheets/index.js +25 -0
- package/dist/src/tools/oapi/sheets/index.js.map +7 -0
- package/dist/src/tools/oapi/sheets/sheet.js +652 -0
- package/dist/src/tools/oapi/sheets/sheet.js.map +7 -0
- package/dist/src/tools/oapi/task/comment.js +151 -0
- package/dist/src/tools/oapi/task/comment.js.map +7 -0
- package/dist/src/tools/oapi/task/index.js +11 -0
- package/dist/src/tools/oapi/task/index.js.map +7 -0
- package/dist/src/tools/oapi/task/subtask.js +175 -0
- package/dist/src/tools/oapi/task/subtask.js.map +7 -0
- package/dist/src/tools/oapi/task/task.js +405 -0
- package/dist/src/tools/oapi/task/task.js.map +7 -0
- package/dist/src/tools/oapi/task/tasklist.js +366 -0
- package/dist/src/tools/oapi/task/tasklist.js.map +7 -0
- package/dist/src/tools/oapi/wiki/index.js +27 -0
- package/dist/src/tools/oapi/wiki/index.js.map +7 -0
- package/dist/src/tools/oapi/wiki/space-node.js +311 -0
- package/dist/src/tools/oapi/wiki/space-node.js.map +7 -0
- package/dist/src/tools/oapi/wiki/space.js +148 -0
- package/dist/src/tools/oapi/wiki/space.js.map +7 -0
- package/dist/src/tools/oauth-batch-auth.js +125 -0
- package/dist/src/tools/oauth-batch-auth.js.map +7 -0
- package/dist/src/tools/oauth-cards.js +269 -0
- package/dist/src/tools/oauth-cards.js.map +7 -0
- package/dist/src/tools/oauth.js +538 -0
- package/dist/src/tools/oauth.js.map +7 -0
- package/dist/src/tools/onboarding-auth.js +101 -0
- package/dist/src/tools/onboarding-auth.js.map +7 -0
- package/dist/src/tools/project-oauth.js +305 -0
- package/dist/src/tools/project-oauth.js.map +7 -0
- package/dist/src/tools/tat/im/index.js +9 -0
- package/dist/src/tools/tat/im/index.js.map +7 -0
- package/dist/src/tools/tat/im/resource.js +123 -0
- package/dist/src/tools/tat/im/resource.js.map +7 -0
- package/package.json +64 -0
|
@@ -0,0 +1,1040 @@
|
|
|
1
|
+
import { EMOJI_MAP, CHART_TYPE_NAMES } from "./types";
|
|
2
|
+
import { escapeAttr, formatMillisecondsToISO8601, normalizeTimeFormat } from "./card-utils";
|
|
3
|
+
import { safeParse } from "../utils";
|
|
4
|
+
const MODE = { Concise: 0, Detailed: 1 };
|
|
5
|
+
const elementConverters = /* @__PURE__ */ new Map([
|
|
6
|
+
["plain_text", (c, _elem, prop) => c.convertPlainText(prop)],
|
|
7
|
+
["markdown", (c, _elem, prop) => c.convertMarkdown(prop)],
|
|
8
|
+
["markdown_v1", (c, elem, prop) => c.convertMarkdownV1(elem, prop)],
|
|
9
|
+
["text", (c, _elem, prop) => c.convertPlainText(prop)],
|
|
10
|
+
["div", (c, _elem, prop, id) => c.convertDiv(prop, id)],
|
|
11
|
+
["note", (c, _elem, prop) => c.convertNote(prop)],
|
|
12
|
+
["hr", () => "---"],
|
|
13
|
+
["br", () => "\n"],
|
|
14
|
+
["column_set", (c, _elem, prop, _id, depth) => c.convertColumnSet(prop, depth)],
|
|
15
|
+
["column", (c, _elem, prop, _id, depth) => c.convertColumn(prop, depth)],
|
|
16
|
+
["person", (c, _elem, prop, id) => c.convertPerson(prop, id)],
|
|
17
|
+
["person_v1", (c, _elem, prop, id) => c.convertPersonV1(prop, id)],
|
|
18
|
+
["person_list", (c, _elem, prop) => c.convertPersonList(prop)],
|
|
19
|
+
["avatar", (c, _elem, prop, id) => c.convertAvatar(prop, id)],
|
|
20
|
+
["at", (c, _elem, prop) => c.convertAt(prop)],
|
|
21
|
+
["at_all", () => "@\u6240\u6709\u4EBA"],
|
|
22
|
+
["button", (c, _elem, prop, id) => c.convertButton(prop, id)],
|
|
23
|
+
["actions", (c, _elem, prop) => c.convertActions(prop)],
|
|
24
|
+
["action", (c, _elem, prop) => c.convertActions(prop)],
|
|
25
|
+
["overflow", (c, _elem, prop) => c.convertOverflow(prop)],
|
|
26
|
+
["select_static", (c, _elem, prop, id) => c.convertSelect(prop, id, false)],
|
|
27
|
+
["multi_select_static", (c, _elem, prop, id) => c.convertSelect(prop, id, true)],
|
|
28
|
+
["select_person", (c, _elem, prop, id) => c.convertSelect(prop, id, false)],
|
|
29
|
+
["multi_select_person", (c, _elem, prop, id) => c.convertSelect(prop, id, true)],
|
|
30
|
+
["select_img", (c, _elem, prop, id) => c.convertSelectImg(prop, id)],
|
|
31
|
+
["input", (c, _elem, prop, id) => c.convertInput(prop, id)],
|
|
32
|
+
["date_picker", (c, _elem, prop, id) => c.convertDatePicker(prop, id, "date")],
|
|
33
|
+
["picker_time", (c, _elem, prop, id) => c.convertDatePicker(prop, id, "time")],
|
|
34
|
+
["picker_datetime", (c, _elem, prop, id) => c.convertDatePicker(prop, id, "datetime")],
|
|
35
|
+
["checker", (c, _elem, prop, id) => c.convertChecker(prop, id)],
|
|
36
|
+
["img", (c, _elem, prop, id) => c.convertImage(prop, id)],
|
|
37
|
+
["image", (c, _elem, prop, id) => c.convertImage(prop, id)],
|
|
38
|
+
["img_combination", (c, _elem, prop) => c.convertImgCombination(prop)],
|
|
39
|
+
["table", (c, _elem, prop) => c.convertTable(prop)],
|
|
40
|
+
["chart", (c, _elem, prop, id) => c.convertChart(prop, id)],
|
|
41
|
+
["audio", (c, _elem, prop, id) => c.convertAudio(prop, id)],
|
|
42
|
+
["video", (c, _elem, prop, id) => c.convertVideo(prop, id)],
|
|
43
|
+
["collapsible_panel", (c, _elem, prop, id) => c.convertCollapsiblePanel(prop, id)],
|
|
44
|
+
["form", (c, _elem, prop, id) => c.convertForm(prop, id)],
|
|
45
|
+
["interactive_container", (c, _elem, prop, id) => c.convertInteractiveContainer(prop, id)],
|
|
46
|
+
["text_tag", (c, _elem, prop) => c.convertTextTag(prop)],
|
|
47
|
+
["number_tag", (c, _elem, prop) => c.convertNumberTag(prop)],
|
|
48
|
+
["link", (c, _elem, prop) => c.convertLink(prop)],
|
|
49
|
+
["emoji", (c, _elem, prop) => c.convertEmoji(prop)],
|
|
50
|
+
["local_datetime", (c, _elem, prop) => c.convertLocalDatetime(prop)],
|
|
51
|
+
["list", (c, _elem, prop) => c.convertList(prop)],
|
|
52
|
+
["blockquote", (c, _elem, prop) => c.convertBlockquote(prop)],
|
|
53
|
+
["code_block", (c, _elem, prop) => c.convertCodeBlock(prop)],
|
|
54
|
+
["code_span", (c, _elem, prop) => c.convertCodeSpan(prop)],
|
|
55
|
+
["heading", (c, _elem, prop) => c.convertHeading(prop)],
|
|
56
|
+
["fallback_text", (c, _elem, prop) => c.convertFallbackText(prop)],
|
|
57
|
+
["repeat", (c, _elem, prop) => c.convertRepeat(prop)],
|
|
58
|
+
["card_header", () => ""],
|
|
59
|
+
["custom_icon", () => ""],
|
|
60
|
+
["standard_icon", () => ""]
|
|
61
|
+
]);
|
|
62
|
+
class CardConverter {
|
|
63
|
+
mode;
|
|
64
|
+
attachment;
|
|
65
|
+
constructor(mode) {
|
|
66
|
+
this.mode = mode;
|
|
67
|
+
}
|
|
68
|
+
convert(input) {
|
|
69
|
+
const card = safeParse(input.json_card);
|
|
70
|
+
if (!card) {
|
|
71
|
+
return { content: "<card>\n[\u65E0\u6CD5\u89E3\u6790\u5361\u7247\u5185\u5BB9]\n</card>", schema: 0 };
|
|
72
|
+
}
|
|
73
|
+
if (input.json_attachment) {
|
|
74
|
+
this.attachment = safeParse(input.json_attachment);
|
|
75
|
+
}
|
|
76
|
+
let schema = input.card_schema ?? 0;
|
|
77
|
+
if (schema === 0) {
|
|
78
|
+
const s = card.schema;
|
|
79
|
+
schema = typeof s === "number" ? s : 1;
|
|
80
|
+
}
|
|
81
|
+
const header = card.header;
|
|
82
|
+
const title = header ? this.extractHeaderTitle(header, schema) : "";
|
|
83
|
+
const body = this.extractBody(card, schema);
|
|
84
|
+
const bodyContent = body ? this.convertBody(body, schema) : "";
|
|
85
|
+
let out = title ? `<card title="${escapeAttr(title)}">
|
|
86
|
+
` : "<card>\n";
|
|
87
|
+
if (bodyContent) out += bodyContent + "\n";
|
|
88
|
+
out += "</card>";
|
|
89
|
+
return { content: out, schema };
|
|
90
|
+
}
|
|
91
|
+
extractBody(card, _schema) {
|
|
92
|
+
if (card.body && typeof card.body === "object") {
|
|
93
|
+
return card.body;
|
|
94
|
+
}
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
extractHeaderTitle(header, _schema) {
|
|
98
|
+
const prop = header.property;
|
|
99
|
+
if (prop) {
|
|
100
|
+
const titleElem = prop.title;
|
|
101
|
+
if (titleElem) return this.extractTextContent(titleElem);
|
|
102
|
+
} else {
|
|
103
|
+
const titleElem = header.title;
|
|
104
|
+
if (titleElem) return this.extractTextContent(titleElem);
|
|
105
|
+
}
|
|
106
|
+
return "";
|
|
107
|
+
}
|
|
108
|
+
convertBody(body, _schema) {
|
|
109
|
+
let elements;
|
|
110
|
+
const prop = body.property;
|
|
111
|
+
if (prop) {
|
|
112
|
+
const e = prop.elements;
|
|
113
|
+
if (Array.isArray(e) && e.length > 0) elements = e;
|
|
114
|
+
}
|
|
115
|
+
if (!elements || elements.length === 0) {
|
|
116
|
+
const e = body.elements;
|
|
117
|
+
if (Array.isArray(e)) elements = e;
|
|
118
|
+
}
|
|
119
|
+
if (!elements || elements.length === 0) return "";
|
|
120
|
+
return this.convertElements(elements, 0);
|
|
121
|
+
}
|
|
122
|
+
convertElements(elements, depth) {
|
|
123
|
+
const results = [];
|
|
124
|
+
for (const elem of elements) {
|
|
125
|
+
if (typeof elem !== "object" || elem === null) continue;
|
|
126
|
+
const result = this.convertElement(elem, depth);
|
|
127
|
+
if (result) results.push(result);
|
|
128
|
+
}
|
|
129
|
+
return results.join("\n");
|
|
130
|
+
}
|
|
131
|
+
convertElement(elem, depth) {
|
|
132
|
+
const tag = elem.tag ?? "";
|
|
133
|
+
const id = elem.id ?? "";
|
|
134
|
+
const prop = this.extractProperty(elem);
|
|
135
|
+
const fn = elementConverters.get(tag);
|
|
136
|
+
if (fn) return fn(this, elem, prop, id, depth);
|
|
137
|
+
return this.convertUnknown(prop, tag);
|
|
138
|
+
}
|
|
139
|
+
extractProperty(elem) {
|
|
140
|
+
if (elem.property && typeof elem.property === "object") {
|
|
141
|
+
return elem.property;
|
|
142
|
+
}
|
|
143
|
+
return elem;
|
|
144
|
+
}
|
|
145
|
+
extractTextContent(textElem) {
|
|
146
|
+
if (textElem == null) return "";
|
|
147
|
+
if (typeof textElem === "string") return textElem;
|
|
148
|
+
if (typeof textElem === "object") {
|
|
149
|
+
const m = textElem;
|
|
150
|
+
if (m.property && typeof m.property === "object") {
|
|
151
|
+
return this.extractTextFromProperty(m.property);
|
|
152
|
+
}
|
|
153
|
+
return this.extractTextFromProperty(m);
|
|
154
|
+
}
|
|
155
|
+
return "";
|
|
156
|
+
}
|
|
157
|
+
extractTextFromProperty(prop) {
|
|
158
|
+
const i18n = prop.i18nContent;
|
|
159
|
+
if (i18n && typeof i18n === "object") {
|
|
160
|
+
for (const lang of ["zh_cn", "en_us", "ja_jp"]) {
|
|
161
|
+
const t = i18n[lang];
|
|
162
|
+
if (typeof t === "string" && t) return t;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (typeof prop.content === "string") return prop.content;
|
|
166
|
+
const elements = prop.elements;
|
|
167
|
+
if (Array.isArray(elements) && elements.length > 0) {
|
|
168
|
+
const texts = [];
|
|
169
|
+
for (const elem of elements) {
|
|
170
|
+
if (typeof elem === "object" && elem !== null) {
|
|
171
|
+
const t = this.extractTextContent(elem);
|
|
172
|
+
if (t) texts.push(t);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return texts.join("");
|
|
176
|
+
}
|
|
177
|
+
if (typeof prop.text === "string") return prop.text;
|
|
178
|
+
return "";
|
|
179
|
+
}
|
|
180
|
+
convertPlainText(prop) {
|
|
181
|
+
const content = prop.content;
|
|
182
|
+
if (!content) return "";
|
|
183
|
+
const style = this.extractTextStyle(prop);
|
|
184
|
+
return this.applyTextStyle(content, style);
|
|
185
|
+
}
|
|
186
|
+
convertMarkdown(prop) {
|
|
187
|
+
const elements = prop.elements;
|
|
188
|
+
if (Array.isArray(elements) && elements.length > 0) {
|
|
189
|
+
return this.convertMarkdownElements(elements);
|
|
190
|
+
}
|
|
191
|
+
if (typeof prop.content === "string") return prop.content;
|
|
192
|
+
return "";
|
|
193
|
+
}
|
|
194
|
+
convertMarkdownV1(elem, prop) {
|
|
195
|
+
const elements = prop.elements;
|
|
196
|
+
if (Array.isArray(elements) && elements.length > 0) {
|
|
197
|
+
return this.convertMarkdownElements(elements);
|
|
198
|
+
}
|
|
199
|
+
const fallback = elem.fallback;
|
|
200
|
+
if (fallback && typeof fallback === "object") {
|
|
201
|
+
return this.convertElement(fallback, 0);
|
|
202
|
+
}
|
|
203
|
+
if (typeof prop.content === "string") return prop.content;
|
|
204
|
+
return "";
|
|
205
|
+
}
|
|
206
|
+
convertMarkdownElements(elements) {
|
|
207
|
+
const parts = [];
|
|
208
|
+
for (const elem of elements) {
|
|
209
|
+
if (typeof elem !== "object" || elem === null) continue;
|
|
210
|
+
const result = this.convertElement(elem, 0);
|
|
211
|
+
if (result) parts.push(result);
|
|
212
|
+
}
|
|
213
|
+
return parts.join("");
|
|
214
|
+
}
|
|
215
|
+
convertDiv(prop, _id) {
|
|
216
|
+
const results = [];
|
|
217
|
+
const textElem = prop.text;
|
|
218
|
+
if (textElem && typeof textElem === "object") {
|
|
219
|
+
const text = this.convertElement(textElem, 0);
|
|
220
|
+
if (text) results.push(text);
|
|
221
|
+
}
|
|
222
|
+
const fields = prop.fields;
|
|
223
|
+
if (Array.isArray(fields) && fields.length > 0) {
|
|
224
|
+
const fieldTexts = [];
|
|
225
|
+
for (const field of fields) {
|
|
226
|
+
if (typeof field !== "object" || field === null) continue;
|
|
227
|
+
const fm = field;
|
|
228
|
+
const te = fm.text;
|
|
229
|
+
if (te && typeof te === "object") {
|
|
230
|
+
const ft = this.convertElement(te, 0);
|
|
231
|
+
if (ft) fieldTexts.push(ft);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (fieldTexts.length > 0) results.push(fieldTexts.join("\n"));
|
|
235
|
+
}
|
|
236
|
+
const extraElem = prop.extra;
|
|
237
|
+
if (extraElem && typeof extraElem === "object") {
|
|
238
|
+
const extra = this.convertElement(extraElem, 0);
|
|
239
|
+
if (extra) results.push(extra);
|
|
240
|
+
}
|
|
241
|
+
return results.join("\n");
|
|
242
|
+
}
|
|
243
|
+
convertNote(prop) {
|
|
244
|
+
const elements = prop.elements;
|
|
245
|
+
if (!Array.isArray(elements) || elements.length === 0) return "";
|
|
246
|
+
const texts = [];
|
|
247
|
+
for (const elem of elements) {
|
|
248
|
+
if (typeof elem !== "object" || elem === null) continue;
|
|
249
|
+
const text = this.convertElement(elem, 0);
|
|
250
|
+
if (text) texts.push(text);
|
|
251
|
+
}
|
|
252
|
+
if (texts.length === 0) return "";
|
|
253
|
+
return `\u{1F4DD} ${texts.join(" ")}`;
|
|
254
|
+
}
|
|
255
|
+
convertLink(prop) {
|
|
256
|
+
const content = prop.content || "\u94FE\u63A5";
|
|
257
|
+
let url = "";
|
|
258
|
+
const urlObj = prop.url;
|
|
259
|
+
if (urlObj && typeof urlObj === "object") {
|
|
260
|
+
url = urlObj.url || "";
|
|
261
|
+
}
|
|
262
|
+
if (url) return `[${content}](${url})`;
|
|
263
|
+
return content;
|
|
264
|
+
}
|
|
265
|
+
convertEmoji(prop) {
|
|
266
|
+
const key = prop.key || "";
|
|
267
|
+
return EMOJI_MAP[key] ?? `:${key}:`;
|
|
268
|
+
}
|
|
269
|
+
convertLocalDatetime(prop) {
|
|
270
|
+
const milliseconds = prop.milliseconds;
|
|
271
|
+
const fallbackText = prop.fallbackText;
|
|
272
|
+
if (milliseconds) {
|
|
273
|
+
const formatted = formatMillisecondsToISO8601(milliseconds);
|
|
274
|
+
if (formatted) return formatted;
|
|
275
|
+
}
|
|
276
|
+
return fallbackText || "";
|
|
277
|
+
}
|
|
278
|
+
convertList(prop) {
|
|
279
|
+
const items = prop.items;
|
|
280
|
+
if (!Array.isArray(items) || items.length === 0) return "";
|
|
281
|
+
const lines = [];
|
|
282
|
+
for (const item of items) {
|
|
283
|
+
if (typeof item !== "object" || item === null) continue;
|
|
284
|
+
const im = item;
|
|
285
|
+
const level = im.level || 0;
|
|
286
|
+
const listType = im.type || "";
|
|
287
|
+
const order = im.order || 0;
|
|
288
|
+
const indent = " ".repeat(level);
|
|
289
|
+
const marker = listType === "ol" ? `${Math.floor(order)}.` : "-";
|
|
290
|
+
const elements = im.elements;
|
|
291
|
+
if (Array.isArray(elements)) {
|
|
292
|
+
const content = this.convertMarkdownElements(elements);
|
|
293
|
+
lines.push(`${indent}${marker} ${content}`);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return lines.join("\n");
|
|
297
|
+
}
|
|
298
|
+
convertBlockquote(prop) {
|
|
299
|
+
let content = "";
|
|
300
|
+
if (typeof prop.content === "string") {
|
|
301
|
+
content = prop.content;
|
|
302
|
+
} else {
|
|
303
|
+
const elements = prop.elements;
|
|
304
|
+
if (Array.isArray(elements)) {
|
|
305
|
+
content = this.convertMarkdownElements(elements);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if (!content) return "";
|
|
309
|
+
return content.split("\n").map((line) => `> ${line}`).join("\n");
|
|
310
|
+
}
|
|
311
|
+
convertCodeBlock(prop) {
|
|
312
|
+
const language = prop.language || "plaintext";
|
|
313
|
+
let code = "";
|
|
314
|
+
const contents = prop.contents;
|
|
315
|
+
if (Array.isArray(contents)) {
|
|
316
|
+
for (const line of contents) {
|
|
317
|
+
if (typeof line !== "object" || line === null) continue;
|
|
318
|
+
const lm = line;
|
|
319
|
+
const lineContents = lm.contents;
|
|
320
|
+
if (Array.isArray(lineContents)) {
|
|
321
|
+
for (const c of lineContents) {
|
|
322
|
+
if (typeof c !== "object" || c === null) continue;
|
|
323
|
+
const cm = c;
|
|
324
|
+
if (typeof cm.content === "string") code += cm.content;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
return `\`\`\`${language}
|
|
330
|
+
${code}\`\`\``;
|
|
331
|
+
}
|
|
332
|
+
convertCodeSpan(prop) {
|
|
333
|
+
const content = prop.content || "";
|
|
334
|
+
return `\`${content}\``;
|
|
335
|
+
}
|
|
336
|
+
convertHeading(prop) {
|
|
337
|
+
let level = prop.level || 1;
|
|
338
|
+
if (level < 1) level = 1;
|
|
339
|
+
if (level > 6) level = 6;
|
|
340
|
+
let content = "";
|
|
341
|
+
if (typeof prop.content === "string") {
|
|
342
|
+
content = prop.content;
|
|
343
|
+
} else {
|
|
344
|
+
const elements = prop.elements;
|
|
345
|
+
if (Array.isArray(elements)) {
|
|
346
|
+
content = this.convertMarkdownElements(elements);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return `${"#".repeat(level)} ${content}`;
|
|
350
|
+
}
|
|
351
|
+
convertFallbackText(prop) {
|
|
352
|
+
const textElem = prop.text;
|
|
353
|
+
if (textElem && typeof textElem === "object") {
|
|
354
|
+
return this.extractTextContent(textElem);
|
|
355
|
+
}
|
|
356
|
+
const elements = prop.elements;
|
|
357
|
+
if (Array.isArray(elements)) {
|
|
358
|
+
return this.convertMarkdownElements(elements);
|
|
359
|
+
}
|
|
360
|
+
return "";
|
|
361
|
+
}
|
|
362
|
+
convertTextTag(prop) {
|
|
363
|
+
const textElem = prop.text;
|
|
364
|
+
let text = "";
|
|
365
|
+
if (textElem && typeof textElem === "object") {
|
|
366
|
+
text = this.extractTextContent(textElem);
|
|
367
|
+
}
|
|
368
|
+
if (!text) return "";
|
|
369
|
+
return `\u300C${text}\u300D`;
|
|
370
|
+
}
|
|
371
|
+
convertNumberTag(prop) {
|
|
372
|
+
const textElem = prop.text;
|
|
373
|
+
let text = "";
|
|
374
|
+
if (textElem && typeof textElem === "object") {
|
|
375
|
+
text = this.extractTextContent(textElem);
|
|
376
|
+
}
|
|
377
|
+
if (!text) return "";
|
|
378
|
+
const urlObj = prop.url;
|
|
379
|
+
if (urlObj && typeof urlObj === "object") {
|
|
380
|
+
const url = urlObj.url;
|
|
381
|
+
if (url) return `[${text}](${url})`;
|
|
382
|
+
}
|
|
383
|
+
return text;
|
|
384
|
+
}
|
|
385
|
+
convertUnknown(prop, tag) {
|
|
386
|
+
if (!prop) {
|
|
387
|
+
if (this.mode === MODE.Detailed) return `[\u672A\u77E5\u5185\u5BB9](tag:${tag})`;
|
|
388
|
+
return "[\u672A\u77E5\u5185\u5BB9]";
|
|
389
|
+
}
|
|
390
|
+
const paths = ["content", "text", "title", "label", "placeholder"];
|
|
391
|
+
for (const path of paths) {
|
|
392
|
+
if (prop[path] != null) {
|
|
393
|
+
const text = this.extractTextContent(prop[path]);
|
|
394
|
+
if (text) return text;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const elements = prop.elements;
|
|
398
|
+
if (Array.isArray(elements) && elements.length > 0) {
|
|
399
|
+
return this.convertElements(elements, 0);
|
|
400
|
+
}
|
|
401
|
+
if (this.mode === MODE.Detailed) return `[\u672A\u77E5\u5185\u5BB9](tag:${tag})`;
|
|
402
|
+
return "[\u672A\u77E5\u5185\u5BB9]";
|
|
403
|
+
}
|
|
404
|
+
convertColumnSet(prop, depth) {
|
|
405
|
+
const columns = prop.columns;
|
|
406
|
+
if (!Array.isArray(columns) || columns.length === 0) return "";
|
|
407
|
+
const results = [];
|
|
408
|
+
for (const col of columns) {
|
|
409
|
+
if (typeof col !== "object" || col === null) continue;
|
|
410
|
+
const result = this.convertElement(col, depth + 1);
|
|
411
|
+
if (result) results.push(result);
|
|
412
|
+
}
|
|
413
|
+
return results.join("\n\n");
|
|
414
|
+
}
|
|
415
|
+
convertColumn(prop, depth) {
|
|
416
|
+
const elements = prop.elements;
|
|
417
|
+
if (!Array.isArray(elements) || elements.length === 0) return "";
|
|
418
|
+
return this.convertElements(elements, depth);
|
|
419
|
+
}
|
|
420
|
+
convertForm(prop, _id) {
|
|
421
|
+
let out = "<form>\n";
|
|
422
|
+
const elements = prop.elements;
|
|
423
|
+
if (Array.isArray(elements)) {
|
|
424
|
+
out += this.convertElements(elements, 0);
|
|
425
|
+
}
|
|
426
|
+
out += "\n</form>";
|
|
427
|
+
return out;
|
|
428
|
+
}
|
|
429
|
+
convertCollapsiblePanel(prop, _id) {
|
|
430
|
+
const expanded = prop.expanded === true;
|
|
431
|
+
let title = "\u8BE6\u60C5";
|
|
432
|
+
const header = prop.header;
|
|
433
|
+
if (header && typeof header === "object") {
|
|
434
|
+
const titleElem = header.title;
|
|
435
|
+
if (titleElem) {
|
|
436
|
+
const t = this.extractTextContent(titleElem);
|
|
437
|
+
if (t) title = t;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
const shouldExpand = expanded || this.mode === MODE.Detailed;
|
|
441
|
+
if (shouldExpand) {
|
|
442
|
+
let out = `\u25BC ${title}
|
|
443
|
+
`;
|
|
444
|
+
const elements = prop.elements;
|
|
445
|
+
if (Array.isArray(elements)) {
|
|
446
|
+
const content = this.convertElements(elements, 1);
|
|
447
|
+
for (const line of content.split("\n")) {
|
|
448
|
+
if (line) out += ` ${line}
|
|
449
|
+
`;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
out += "\u25B2";
|
|
453
|
+
return out;
|
|
454
|
+
}
|
|
455
|
+
return `\u25B6 ${title}`;
|
|
456
|
+
}
|
|
457
|
+
convertInteractiveContainer(prop, _id) {
|
|
458
|
+
let url = "";
|
|
459
|
+
const actions = prop.actions;
|
|
460
|
+
if (Array.isArray(actions) && actions.length > 0) {
|
|
461
|
+
const action = actions[0];
|
|
462
|
+
if (action && typeof action === "object") {
|
|
463
|
+
const actionType = action.type;
|
|
464
|
+
if (actionType === "open_url") {
|
|
465
|
+
const actionData = action.action;
|
|
466
|
+
if (actionData && typeof actionData === "object") {
|
|
467
|
+
url = actionData.url || "";
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
let out = "<clickable";
|
|
473
|
+
if (url) out += ` url="${escapeAttr(url)}"`;
|
|
474
|
+
if (this.mode === MODE.Detailed && _id) out += ` id="${_id}"`;
|
|
475
|
+
out += ">\n";
|
|
476
|
+
const elements = prop.elements;
|
|
477
|
+
if (Array.isArray(elements)) {
|
|
478
|
+
out += this.convertElements(elements, 0);
|
|
479
|
+
}
|
|
480
|
+
out += "\n</clickable>";
|
|
481
|
+
return out;
|
|
482
|
+
}
|
|
483
|
+
convertRepeat(prop) {
|
|
484
|
+
const elements = prop.elements;
|
|
485
|
+
if (Array.isArray(elements)) {
|
|
486
|
+
return this.convertElements(elements, 0);
|
|
487
|
+
}
|
|
488
|
+
return "";
|
|
489
|
+
}
|
|
490
|
+
convertButton(prop, _id) {
|
|
491
|
+
let buttonText = "";
|
|
492
|
+
const textElem = prop.text;
|
|
493
|
+
if (textElem && typeof textElem === "object") {
|
|
494
|
+
buttonText = this.extractTextContent(textElem);
|
|
495
|
+
}
|
|
496
|
+
if (!buttonText) buttonText = "\u6309\u94AE";
|
|
497
|
+
const disabled = prop.disabled === true;
|
|
498
|
+
if (disabled && this.mode === MODE.Concise) {
|
|
499
|
+
return `[${buttonText} \u2717]`;
|
|
500
|
+
}
|
|
501
|
+
const actions = prop.actions;
|
|
502
|
+
if (Array.isArray(actions)) {
|
|
503
|
+
for (const action of actions) {
|
|
504
|
+
if (typeof action !== "object" || action === null) continue;
|
|
505
|
+
const am = action;
|
|
506
|
+
if (am.type === "open_url") {
|
|
507
|
+
const ad = am.action;
|
|
508
|
+
if (ad && typeof ad === "object") {
|
|
509
|
+
const url = ad.url;
|
|
510
|
+
if (url) return `[${buttonText}](${url})`;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
if (disabled && this.mode === MODE.Detailed) {
|
|
516
|
+
let result = `[${buttonText} \u2717]`;
|
|
517
|
+
const tips = prop.disabledTips;
|
|
518
|
+
if (tips && typeof tips === "object") {
|
|
519
|
+
const tipsText = this.extractTextContent(tips);
|
|
520
|
+
if (tipsText) result += `(tips:"${tipsText}")`;
|
|
521
|
+
}
|
|
522
|
+
return result;
|
|
523
|
+
}
|
|
524
|
+
return `[${buttonText}]`;
|
|
525
|
+
}
|
|
526
|
+
convertActions(prop) {
|
|
527
|
+
const actions = prop.actions;
|
|
528
|
+
if (!Array.isArray(actions) || actions.length === 0) return "";
|
|
529
|
+
const results = [];
|
|
530
|
+
for (const action of actions) {
|
|
531
|
+
if (typeof action !== "object" || action === null) continue;
|
|
532
|
+
const result = this.convertElement(action, 0);
|
|
533
|
+
if (result) results.push(result);
|
|
534
|
+
}
|
|
535
|
+
return results.join(" ");
|
|
536
|
+
}
|
|
537
|
+
convertSelect(prop, _id, isMulti) {
|
|
538
|
+
const options = prop.options || [];
|
|
539
|
+
const selectedValues = /* @__PURE__ */ new Set();
|
|
540
|
+
if (isMulti) {
|
|
541
|
+
const vals = prop.selectedValues;
|
|
542
|
+
if (Array.isArray(vals)) {
|
|
543
|
+
for (const v of vals) {
|
|
544
|
+
if (typeof v === "string") selectedValues.add(v);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
} else {
|
|
548
|
+
const initialOption = prop.initialOption;
|
|
549
|
+
if (typeof initialOption === "string") selectedValues.add(initialOption);
|
|
550
|
+
const initialIndex = prop.initialIndex;
|
|
551
|
+
if (typeof initialIndex === "number" && initialIndex >= 0 && initialIndex < options.length) {
|
|
552
|
+
const opt = options[initialIndex];
|
|
553
|
+
if (opt && typeof opt === "object") {
|
|
554
|
+
const val = opt.value;
|
|
555
|
+
if (val) selectedValues.add(val);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
const optionTexts = [];
|
|
560
|
+
let hasSelected = false;
|
|
561
|
+
for (const opt of options) {
|
|
562
|
+
if (typeof opt !== "object" || opt === null) continue;
|
|
563
|
+
const om = opt;
|
|
564
|
+
let optText = "";
|
|
565
|
+
const textElem = om.text;
|
|
566
|
+
if (textElem && typeof textElem === "object") {
|
|
567
|
+
optText = this.extractTextContent(textElem);
|
|
568
|
+
}
|
|
569
|
+
if (!optText) optText = om.value || "";
|
|
570
|
+
if (!optText) continue;
|
|
571
|
+
const value = om.value || "";
|
|
572
|
+
if (selectedValues.has(value)) {
|
|
573
|
+
optText = "\u2713" + optText;
|
|
574
|
+
hasSelected = true;
|
|
575
|
+
}
|
|
576
|
+
optionTexts.push(optText);
|
|
577
|
+
}
|
|
578
|
+
if (optionTexts.length === 0) {
|
|
579
|
+
let placeholder = "\u8BF7\u9009\u62E9";
|
|
580
|
+
const phElem = prop.placeholder;
|
|
581
|
+
if (phElem && typeof phElem === "object") {
|
|
582
|
+
const ph = this.extractTextContent(phElem);
|
|
583
|
+
if (ph) placeholder = ph;
|
|
584
|
+
}
|
|
585
|
+
optionTexts.push(placeholder + " \u25BC");
|
|
586
|
+
} else if (!hasSelected) {
|
|
587
|
+
optionTexts[optionTexts.length - 1] += " \u25BC";
|
|
588
|
+
}
|
|
589
|
+
let result = `{${optionTexts.join(" / ")}}`;
|
|
590
|
+
if (this.mode === MODE.Detailed) {
|
|
591
|
+
const attrs = [];
|
|
592
|
+
if (isMulti) attrs.push("multi");
|
|
593
|
+
if (_id.includes("person") || prop.type === "person") attrs.push("type:person");
|
|
594
|
+
if (attrs.length > 0) result += `(${attrs.join(" ")})`;
|
|
595
|
+
}
|
|
596
|
+
return result;
|
|
597
|
+
}
|
|
598
|
+
convertSelectImg(prop, _id) {
|
|
599
|
+
const options = prop.options;
|
|
600
|
+
if (!Array.isArray(options)) return "";
|
|
601
|
+
const selectedValues = /* @__PURE__ */ new Set();
|
|
602
|
+
const vals = prop.selectedValues;
|
|
603
|
+
if (Array.isArray(vals)) {
|
|
604
|
+
for (const v of vals) {
|
|
605
|
+
if (typeof v === "string") selectedValues.add(v);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
const optTexts = [];
|
|
609
|
+
for (let i = 0; i < options.length; i++) {
|
|
610
|
+
const opt = options[i];
|
|
611
|
+
if (!opt || typeof opt !== "object") continue;
|
|
612
|
+
const value = opt.value || "";
|
|
613
|
+
let text = `\u{1F5BC}\uFE0F\u56FE${i + 1}`;
|
|
614
|
+
if (selectedValues.has(value)) text = "\u2713" + text;
|
|
615
|
+
optTexts.push(text);
|
|
616
|
+
}
|
|
617
|
+
return `{${optTexts.join(" / ")}}`;
|
|
618
|
+
}
|
|
619
|
+
convertInput(prop, _id) {
|
|
620
|
+
let label = "";
|
|
621
|
+
const labelElem = prop.label;
|
|
622
|
+
if (labelElem && typeof labelElem === "object") {
|
|
623
|
+
label = this.extractTextContent(labelElem);
|
|
624
|
+
}
|
|
625
|
+
const defaultValue = prop.defaultValue || "";
|
|
626
|
+
let placeholder = "";
|
|
627
|
+
const phElem = prop.placeholder;
|
|
628
|
+
if (phElem && typeof phElem === "object") {
|
|
629
|
+
placeholder = this.extractTextContent(phElem);
|
|
630
|
+
}
|
|
631
|
+
let result;
|
|
632
|
+
if (defaultValue) {
|
|
633
|
+
result = defaultValue + "___";
|
|
634
|
+
} else if (placeholder) {
|
|
635
|
+
result = placeholder + "_____";
|
|
636
|
+
} else {
|
|
637
|
+
result = "_____";
|
|
638
|
+
}
|
|
639
|
+
if (label) result = label + ": " + result;
|
|
640
|
+
const inputType = prop.inputType;
|
|
641
|
+
if (inputType === "multiline_text") {
|
|
642
|
+
result = result.replace(/_____/g, "...");
|
|
643
|
+
}
|
|
644
|
+
return result;
|
|
645
|
+
}
|
|
646
|
+
convertDatePicker(prop, _id, pickerType) {
|
|
647
|
+
let emoji;
|
|
648
|
+
let value = "";
|
|
649
|
+
switch (pickerType) {
|
|
650
|
+
case "date":
|
|
651
|
+
emoji = "\u{1F4C5}";
|
|
652
|
+
value = prop.initialDate || "";
|
|
653
|
+
break;
|
|
654
|
+
case "time":
|
|
655
|
+
emoji = "\u{1F550}";
|
|
656
|
+
value = prop.initialTime || "";
|
|
657
|
+
break;
|
|
658
|
+
case "datetime":
|
|
659
|
+
emoji = "\u{1F4C5}";
|
|
660
|
+
value = prop.initialDatetime || "";
|
|
661
|
+
break;
|
|
662
|
+
default:
|
|
663
|
+
emoji = "\u{1F4C5}";
|
|
664
|
+
}
|
|
665
|
+
if (value) value = normalizeTimeFormat(value);
|
|
666
|
+
if (!value) {
|
|
667
|
+
let placeholder = "\u9009\u62E9";
|
|
668
|
+
const phElem = prop.placeholder;
|
|
669
|
+
if (phElem && typeof phElem === "object") {
|
|
670
|
+
const ph = this.extractTextContent(phElem);
|
|
671
|
+
if (ph) placeholder = ph;
|
|
672
|
+
}
|
|
673
|
+
value = placeholder;
|
|
674
|
+
}
|
|
675
|
+
return `${emoji} ${value}`;
|
|
676
|
+
}
|
|
677
|
+
convertChecker(prop, _id) {
|
|
678
|
+
const checked = prop.checked === true;
|
|
679
|
+
const checkMark = checked ? "[x]" : "[ ]";
|
|
680
|
+
let text = "";
|
|
681
|
+
const textElem = prop.text;
|
|
682
|
+
if (textElem && typeof textElem === "object") {
|
|
683
|
+
text = this.extractTextContent(textElem);
|
|
684
|
+
}
|
|
685
|
+
let result = `${checkMark} ${text}`;
|
|
686
|
+
if (this.mode === MODE.Detailed && _id) {
|
|
687
|
+
result += `(id:${_id})`;
|
|
688
|
+
}
|
|
689
|
+
return result;
|
|
690
|
+
}
|
|
691
|
+
convertOverflow(prop) {
|
|
692
|
+
const options = prop.options;
|
|
693
|
+
if (!Array.isArray(options) || options.length === 0) return "";
|
|
694
|
+
const optTexts = [];
|
|
695
|
+
for (const opt of options) {
|
|
696
|
+
if (typeof opt !== "object" || opt === null) continue;
|
|
697
|
+
const om = opt;
|
|
698
|
+
const textElem = om.text;
|
|
699
|
+
if (textElem && typeof textElem === "object") {
|
|
700
|
+
const text = this.extractTextContent(textElem);
|
|
701
|
+
if (text) optTexts.push(text);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
return `\u22EE ${optTexts.join(", ")}`;
|
|
705
|
+
}
|
|
706
|
+
convertPerson(prop, _id) {
|
|
707
|
+
const userID = prop.userID || "";
|
|
708
|
+
if (!userID) return "";
|
|
709
|
+
let personName = "";
|
|
710
|
+
if (this.attachment) {
|
|
711
|
+
const persons = this.attachment.persons;
|
|
712
|
+
if (persons && typeof persons === "object") {
|
|
713
|
+
const person = persons[userID];
|
|
714
|
+
if (person && typeof person === "object") {
|
|
715
|
+
const content = person.content;
|
|
716
|
+
if (content) personName = content;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
if (!personName) {
|
|
721
|
+
const notation = prop.notation;
|
|
722
|
+
if (notation && typeof notation === "object") {
|
|
723
|
+
personName = this.extractTextContent(notation);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
if (personName) {
|
|
727
|
+
if (this.mode === MODE.Detailed) return `@${personName}(open_id:${userID})`;
|
|
728
|
+
return `@${personName}`;
|
|
729
|
+
}
|
|
730
|
+
if (this.mode === MODE.Detailed) return `@\u7528\u6237(open_id:${userID})`;
|
|
731
|
+
return `@${userID}`;
|
|
732
|
+
}
|
|
733
|
+
convertPersonV1(prop, _id) {
|
|
734
|
+
const userID = prop.userID || "";
|
|
735
|
+
if (!userID) return "";
|
|
736
|
+
let personName = "";
|
|
737
|
+
if (this.attachment) {
|
|
738
|
+
const persons = this.attachment.persons;
|
|
739
|
+
if (persons && typeof persons === "object") {
|
|
740
|
+
const person = persons[userID];
|
|
741
|
+
if (person && typeof person === "object") {
|
|
742
|
+
const content = person.content;
|
|
743
|
+
if (content) personName = content;
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (personName) {
|
|
748
|
+
if (this.mode === MODE.Detailed) return `@${personName}(open_id:${userID})`;
|
|
749
|
+
return `@${personName}`;
|
|
750
|
+
}
|
|
751
|
+
if (this.mode === MODE.Detailed) return `@\u7528\u6237(open_id:${userID})`;
|
|
752
|
+
return `@${userID}`;
|
|
753
|
+
}
|
|
754
|
+
convertPersonList(prop) {
|
|
755
|
+
const persons = prop.persons;
|
|
756
|
+
if (!Array.isArray(persons) || persons.length === 0) return "";
|
|
757
|
+
const names = [];
|
|
758
|
+
for (const person of persons) {
|
|
759
|
+
if (typeof person !== "object" || person === null) continue;
|
|
760
|
+
const pm = person;
|
|
761
|
+
const personID = pm.id || "";
|
|
762
|
+
const name = "\u7528\u6237";
|
|
763
|
+
if (this.mode === MODE.Detailed && personID) {
|
|
764
|
+
names.push(`@${name}(id:${personID})`);
|
|
765
|
+
} else {
|
|
766
|
+
names.push(`@${name}`);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return names.join(", ");
|
|
770
|
+
}
|
|
771
|
+
convertAvatar(prop, _id) {
|
|
772
|
+
const userID = prop.userID || "";
|
|
773
|
+
let result = "\u{1F464}";
|
|
774
|
+
if (this.mode === MODE.Detailed && userID) {
|
|
775
|
+
result += `(id:${userID})`;
|
|
776
|
+
}
|
|
777
|
+
return result;
|
|
778
|
+
}
|
|
779
|
+
convertAt(prop) {
|
|
780
|
+
const userID = prop.userID || "";
|
|
781
|
+
if (!userID) return "";
|
|
782
|
+
let userName = "";
|
|
783
|
+
let actualUserID = "";
|
|
784
|
+
if (this.attachment) {
|
|
785
|
+
const atUsers = this.attachment.at_users;
|
|
786
|
+
if (atUsers && typeof atUsers === "object") {
|
|
787
|
+
const userInfo = atUsers[userID];
|
|
788
|
+
if (userInfo && typeof userInfo === "object") {
|
|
789
|
+
const content = userInfo.content;
|
|
790
|
+
if (content) userName = content;
|
|
791
|
+
const uid = userInfo.user_id;
|
|
792
|
+
if (uid) actualUserID = uid;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
if (userName) {
|
|
797
|
+
if (this.mode === MODE.Detailed) {
|
|
798
|
+
if (actualUserID) return `@${userName}(user_id:${actualUserID})`;
|
|
799
|
+
return `@${userName}(open_id:${userID})`;
|
|
800
|
+
}
|
|
801
|
+
return `@${userName}`;
|
|
802
|
+
}
|
|
803
|
+
if (this.mode === MODE.Detailed) {
|
|
804
|
+
if (actualUserID) return `@\u7528\u6237(user_id:${actualUserID})`;
|
|
805
|
+
return `@\u7528\u6237(open_id:${userID})`;
|
|
806
|
+
}
|
|
807
|
+
return `@${userID}`;
|
|
808
|
+
}
|
|
809
|
+
convertImage(prop, _id) {
|
|
810
|
+
let alt = "\u56FE\u7247";
|
|
811
|
+
const altElem = prop.alt;
|
|
812
|
+
if (altElem && typeof altElem === "object") {
|
|
813
|
+
const altText = this.extractTextContent(altElem);
|
|
814
|
+
if (altText) alt = altText;
|
|
815
|
+
}
|
|
816
|
+
const titleElem = prop.title;
|
|
817
|
+
if (titleElem && typeof titleElem === "object") {
|
|
818
|
+
const titleText = this.extractTextContent(titleElem);
|
|
819
|
+
if (titleText) alt = titleText;
|
|
820
|
+
}
|
|
821
|
+
let result = `\u{1F5BC}\uFE0F ${alt}`;
|
|
822
|
+
if (this.mode === MODE.Detailed) {
|
|
823
|
+
const imageID = prop.imageID;
|
|
824
|
+
if (imageID) {
|
|
825
|
+
const token = this.getImageToken(imageID);
|
|
826
|
+
if (token) {
|
|
827
|
+
result += `(img_token:${token})`;
|
|
828
|
+
} else {
|
|
829
|
+
result += `(img_key:${imageID})`;
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return result;
|
|
834
|
+
}
|
|
835
|
+
convertImgCombination(prop) {
|
|
836
|
+
const imgList = prop.imgList;
|
|
837
|
+
if (!Array.isArray(imgList) || imgList.length === 0) return "";
|
|
838
|
+
let result = `\u{1F5BC}\uFE0F ${imgList.length}\u5F20\u56FE\u7247`;
|
|
839
|
+
if (this.mode === MODE.Detailed) {
|
|
840
|
+
const keys = [];
|
|
841
|
+
for (const img of imgList) {
|
|
842
|
+
if (typeof img !== "object" || img === null) continue;
|
|
843
|
+
const im = img;
|
|
844
|
+
const imageID = im.imageID;
|
|
845
|
+
if (imageID) keys.push(imageID);
|
|
846
|
+
}
|
|
847
|
+
if (keys.length > 0) result += `(keys:${keys.join(",")})`;
|
|
848
|
+
}
|
|
849
|
+
return result;
|
|
850
|
+
}
|
|
851
|
+
convertChart(prop, _id) {
|
|
852
|
+
let title = "\u56FE\u8868";
|
|
853
|
+
let chartType = "";
|
|
854
|
+
const chartSpec = prop.chartSpec;
|
|
855
|
+
if (chartSpec && typeof chartSpec === "object") {
|
|
856
|
+
const titleObj = chartSpec.title;
|
|
857
|
+
if (titleObj && typeof titleObj === "object") {
|
|
858
|
+
const text = titleObj.text;
|
|
859
|
+
if (text) title = text;
|
|
860
|
+
}
|
|
861
|
+
const ct = chartSpec.type;
|
|
862
|
+
if (ct) {
|
|
863
|
+
chartType = ct;
|
|
864
|
+
const typeName = CHART_TYPE_NAMES[chartType];
|
|
865
|
+
if (typeName) title = `${title}${typeName}`;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
const summary = this.extractChartSummary(prop, chartType);
|
|
869
|
+
let result = `\u{1F4CA} ${title}`;
|
|
870
|
+
if (summary) result += `
|
|
871
|
+
\u6570\u636E\u6458\u8981: ${summary}`;
|
|
872
|
+
return result;
|
|
873
|
+
}
|
|
874
|
+
extractChartSummary(prop, chartType) {
|
|
875
|
+
const chartSpec = prop.chartSpec;
|
|
876
|
+
if (!chartSpec || typeof chartSpec !== "object") return "";
|
|
877
|
+
const dataObj = chartSpec.data;
|
|
878
|
+
if (!dataObj || typeof dataObj !== "object") return "";
|
|
879
|
+
const values = dataObj.values;
|
|
880
|
+
if (!Array.isArray(values) || values.length === 0) return "";
|
|
881
|
+
switch (chartType) {
|
|
882
|
+
case "line":
|
|
883
|
+
case "bar":
|
|
884
|
+
case "area":
|
|
885
|
+
return this.extractLineBarSummary(chartSpec, values);
|
|
886
|
+
case "pie":
|
|
887
|
+
return this.extractPieSummary(chartSpec, values);
|
|
888
|
+
default:
|
|
889
|
+
return this.extractGenericSummary(values);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
extractLineBarSummary(chartSpec, values) {
|
|
893
|
+
const xField = chartSpec.xField;
|
|
894
|
+
const yField = chartSpec.yField;
|
|
895
|
+
if (!xField || !yField || values.length === 0) {
|
|
896
|
+
return this.extractGenericSummary(values);
|
|
897
|
+
}
|
|
898
|
+
const parts = [];
|
|
899
|
+
for (const v of values) {
|
|
900
|
+
if (typeof v !== "object" || v === null) continue;
|
|
901
|
+
const vm = v;
|
|
902
|
+
parts.push(`${vm[xField]}:${vm[yField]}`);
|
|
903
|
+
}
|
|
904
|
+
return parts.length > 0 ? parts.join(", ") : this.extractGenericSummary(values);
|
|
905
|
+
}
|
|
906
|
+
extractPieSummary(chartSpec, values) {
|
|
907
|
+
const categoryField = chartSpec.categoryField;
|
|
908
|
+
const valueField = chartSpec.valueField;
|
|
909
|
+
if (!categoryField || !valueField || values.length === 0) {
|
|
910
|
+
return this.extractGenericSummary(values);
|
|
911
|
+
}
|
|
912
|
+
const parts = [];
|
|
913
|
+
for (const v of values) {
|
|
914
|
+
if (typeof v !== "object" || v === null) continue;
|
|
915
|
+
const vm = v;
|
|
916
|
+
parts.push(`${vm[categoryField]}:${vm[valueField]}`);
|
|
917
|
+
}
|
|
918
|
+
return parts.length > 0 ? parts.join(", ") : this.extractGenericSummary(values);
|
|
919
|
+
}
|
|
920
|
+
extractGenericSummary(values) {
|
|
921
|
+
return `${values.length}\u4E2A\u6570\u636E\u70B9`;
|
|
922
|
+
}
|
|
923
|
+
convertAudio(prop, _id) {
|
|
924
|
+
let result = "\u{1F3B5} \u97F3\u9891";
|
|
925
|
+
if (this.mode === MODE.Detailed) {
|
|
926
|
+
const fileID = prop.fileID || prop.audioID || "";
|
|
927
|
+
if (fileID) result += `(key:${fileID})`;
|
|
928
|
+
}
|
|
929
|
+
return result;
|
|
930
|
+
}
|
|
931
|
+
convertVideo(prop, _id) {
|
|
932
|
+
let result = "\u{1F3AC} \u89C6\u9891";
|
|
933
|
+
if (this.mode === MODE.Detailed) {
|
|
934
|
+
const fileID = prop.fileID || prop.videoID || "";
|
|
935
|
+
if (fileID) result += `(key:${fileID})`;
|
|
936
|
+
}
|
|
937
|
+
return result;
|
|
938
|
+
}
|
|
939
|
+
convertTable(prop) {
|
|
940
|
+
const columns = prop.columns;
|
|
941
|
+
if (!Array.isArray(columns) || columns.length === 0) return "";
|
|
942
|
+
const rows = prop.rows || [];
|
|
943
|
+
const colNames = [];
|
|
944
|
+
const colKeys = [];
|
|
945
|
+
for (const col of columns) {
|
|
946
|
+
if (typeof col !== "object" || col === null) continue;
|
|
947
|
+
const cm = col;
|
|
948
|
+
let displayName = cm.displayName || "";
|
|
949
|
+
const name = cm.name || "";
|
|
950
|
+
if (!displayName) displayName = name;
|
|
951
|
+
colNames.push(displayName);
|
|
952
|
+
colKeys.push(name);
|
|
953
|
+
}
|
|
954
|
+
const lines = [];
|
|
955
|
+
lines.push("| " + colNames.join(" | ") + " |");
|
|
956
|
+
lines.push("|" + colNames.map(() => "------|").join(""));
|
|
957
|
+
for (const row of rows) {
|
|
958
|
+
if (typeof row !== "object" || row === null) continue;
|
|
959
|
+
const rm = row;
|
|
960
|
+
const cells = [];
|
|
961
|
+
for (const key of colKeys) {
|
|
962
|
+
let cellValue = "";
|
|
963
|
+
const cellData = rm[key];
|
|
964
|
+
if (cellData && typeof cellData === "object") {
|
|
965
|
+
if (cellData.data != null) {
|
|
966
|
+
cellValue = this.extractTableCellValue(cellData.data);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
cells.push(cellValue);
|
|
970
|
+
}
|
|
971
|
+
lines.push("| " + cells.join(" | ") + " |");
|
|
972
|
+
}
|
|
973
|
+
return lines.join("\n");
|
|
974
|
+
}
|
|
975
|
+
extractTableCellValue(data) {
|
|
976
|
+
if (typeof data === "string") return data;
|
|
977
|
+
if (typeof data === "number") return data.toFixed(2);
|
|
978
|
+
if (Array.isArray(data)) {
|
|
979
|
+
const texts = [];
|
|
980
|
+
for (const item of data) {
|
|
981
|
+
if (typeof item === "object" && item !== null) {
|
|
982
|
+
const im = item;
|
|
983
|
+
if (typeof im.text === "string") texts.push(`\u300C${im.text}\u300D`);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
return texts.join(" ");
|
|
987
|
+
}
|
|
988
|
+
if (typeof data === "object" && data !== null) {
|
|
989
|
+
return this.extractTextContent(data);
|
|
990
|
+
}
|
|
991
|
+
return "";
|
|
992
|
+
}
|
|
993
|
+
extractTextStyle(prop) {
|
|
994
|
+
const style = {
|
|
995
|
+
bold: false,
|
|
996
|
+
italic: false,
|
|
997
|
+
strikethrough: false
|
|
998
|
+
};
|
|
999
|
+
const textStyle = prop.textStyle;
|
|
1000
|
+
if (!textStyle || typeof textStyle !== "object") return style;
|
|
1001
|
+
const attrs = textStyle.attributes;
|
|
1002
|
+
if (Array.isArray(attrs)) {
|
|
1003
|
+
for (const attr of attrs) {
|
|
1004
|
+
if (typeof attr !== "string") continue;
|
|
1005
|
+
switch (attr) {
|
|
1006
|
+
case "bold":
|
|
1007
|
+
style.bold = true;
|
|
1008
|
+
break;
|
|
1009
|
+
case "italic":
|
|
1010
|
+
style.italic = true;
|
|
1011
|
+
break;
|
|
1012
|
+
case "strikethrough":
|
|
1013
|
+
style.strikethrough = true;
|
|
1014
|
+
break;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
return style;
|
|
1019
|
+
}
|
|
1020
|
+
applyTextStyle(content, style) {
|
|
1021
|
+
if (!content) return content;
|
|
1022
|
+
if (style.strikethrough) content = `~~${content}~~`;
|
|
1023
|
+
if (style.italic) content = `*${content}*`;
|
|
1024
|
+
if (style.bold) content = `**${content}**`;
|
|
1025
|
+
return content;
|
|
1026
|
+
}
|
|
1027
|
+
getImageToken(imageID) {
|
|
1028
|
+
if (!this.attachment) return "";
|
|
1029
|
+
const images = this.attachment.images;
|
|
1030
|
+
if (!images || typeof images !== "object") return "";
|
|
1031
|
+
const imageInfo = images[imageID];
|
|
1032
|
+
if (!imageInfo || typeof imageInfo !== "object") return "";
|
|
1033
|
+
return imageInfo.token || "";
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
export {
|
|
1037
|
+
CardConverter,
|
|
1038
|
+
MODE
|
|
1039
|
+
};
|
|
1040
|
+
//# sourceMappingURL=card-converter.js.map
|