md2x 0.1.0
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 +43 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +128069 -0
- package/dist/md2x.mjs +128296 -0
- package/dist/renderer/puppeteer-render-worker.js +815 -0
- package/dist/renderer/puppeteer-render.html +2829 -0
- package/dist/themes/code-themes/business-contrast.json +31 -0
- package/dist/themes/code-themes/colorful.json +32 -0
- package/dist/themes/code-themes/cool-modern.json +31 -0
- package/dist/themes/code-themes/high-contrast.json +31 -0
- package/dist/themes/code-themes/light-clean.json +31 -0
- package/dist/themes/code-themes/warm-book.json +31 -0
- package/dist/themes/color-schemes/candy.json +34 -0
- package/dist/themes/color-schemes/cool.json +34 -0
- package/dist/themes/color-schemes/coral.json +34 -0
- package/dist/themes/color-schemes/dino.json +34 -0
- package/dist/themes/color-schemes/forest.json +34 -0
- package/dist/themes/color-schemes/garden.json +34 -0
- package/dist/themes/color-schemes/neutral.json +34 -0
- package/dist/themes/color-schemes/ocean.json +34 -0
- package/dist/themes/color-schemes/rainbow.json +43 -0
- package/dist/themes/color-schemes/sakura.json +34 -0
- package/dist/themes/color-schemes/sepia.json +34 -0
- package/dist/themes/color-schemes/space.json +34 -0
- package/dist/themes/color-schemes/starry.json +34 -0
- package/dist/themes/color-schemes/sunset.json +34 -0
- package/dist/themes/color-schemes/warm.json +34 -0
- package/dist/themes/font-config.json +184 -0
- package/dist/themes/layout-schemes/academic.json +40 -0
- package/dist/themes/layout-schemes/book.json +40 -0
- package/dist/themes/layout-schemes/document.json +40 -0
- package/dist/themes/layout-schemes/magazine.json +40 -0
- package/dist/themes/layout-schemes/student.json +40 -0
- package/dist/themes/layout-schemes/technical.json +40 -0
- package/dist/themes/presets/academic.json +24 -0
- package/dist/themes/presets/business.json +22 -0
- package/dist/themes/presets/candy.json +23 -0
- package/dist/themes/presets/century.json +22 -0
- package/dist/themes/presets/coral.json +22 -0
- package/dist/themes/presets/default.json +22 -0
- package/dist/themes/presets/dinosaur.json +23 -0
- package/dist/themes/presets/elegant.json +22 -0
- package/dist/themes/presets/forest.json +22 -0
- package/dist/themes/presets/garamond.json +22 -0
- package/dist/themes/presets/garden.json +23 -0
- package/dist/themes/presets/handwritten.json +23 -0
- package/dist/themes/presets/heiti.json +22 -0
- package/dist/themes/presets/magazine.json +24 -0
- package/dist/themes/presets/manuscript.json +22 -0
- package/dist/themes/presets/minimal.json +22 -0
- package/dist/themes/presets/mixed.json +24 -0
- package/dist/themes/presets/newspaper.json +24 -0
- package/dist/themes/presets/ocean.json +22 -0
- package/dist/themes/presets/palatino.json +22 -0
- package/dist/themes/presets/rainbow.json +23 -0
- package/dist/themes/presets/space.json +23 -0
- package/dist/themes/presets/starry.json +23 -0
- package/dist/themes/presets/sunset.json +22 -0
- package/dist/themes/presets/swiss.json +22 -0
- package/dist/themes/presets/technical.json +22 -0
- package/dist/themes/presets/typewriter.json +23 -0
- package/dist/themes/presets/verdana.json +22 -0
- package/dist/themes/presets/water.json +22 -0
- package/dist/themes/registry.json +270 -0
- package/dist/themes/table-styles/academic.json +30 -0
- package/dist/themes/table-styles/borderless.json +26 -0
- package/dist/themes/table-styles/compact.json +24 -0
- package/dist/themes/table-styles/grid.json +22 -0
- package/dist/themes/table-styles/high-contrast.json +22 -0
- package/dist/themes/table-styles/minimal-gray.json +26 -0
- package/dist/themes/table-styles/modern-tech.json +34 -0
- package/dist/themes/table-styles/professional.json +34 -0
- package/dist/themes/table-styles/zebra.json +22 -0
- package/dist/types/node/src/host/browser-renderer.d.ts +40 -0
- package/dist/types/node/src/host/node-exporter.d.ts +63 -0
- package/dist/types/node/src/host/node-platform.d.ts +30 -0
- package/dist/types/node/src/index.d.ts +8 -0
- package/dist/types/src/core/markdown-block-splitter.d.ts +16 -0
- package/dist/types/src/core/markdown-document.d.ts +286 -0
- package/dist/types/src/core/markdown-processor.d.ts +228 -0
- package/dist/types/src/core/viewer/viewer-controller.d.ts +85 -0
- package/dist/types/src/exporters/docx-blockquote-converter.d.ts +24 -0
- package/dist/types/src/exporters/docx-code-highlighter.d.ts +14 -0
- package/dist/types/src/exporters/docx-download.d.ts +27 -0
- package/dist/types/src/exporters/docx-exporter.d.ts +77 -0
- package/dist/types/src/exporters/docx-image-utils.d.ts +71 -0
- package/dist/types/src/exporters/docx-inline-converter.d.ts +124 -0
- package/dist/types/src/exporters/docx-list-converter.d.ts +50 -0
- package/dist/types/src/exporters/docx-math-converter.d.ts +11 -0
- package/dist/types/src/exporters/docx-table-converter.d.ts +22 -0
- package/dist/types/src/exporters/mml2omml.d.ts +2 -0
- package/dist/types/src/exporters/theme-to-docx.d.ts +144 -0
- package/dist/types/src/plugins/base-plugin.d.ts +67 -0
- package/dist/types/src/plugins/canvas-plugin.d.ts +9 -0
- package/dist/types/src/plugins/dot-plugin.d.ts +9 -0
- package/dist/types/src/plugins/html-plugin.d.ts +28 -0
- package/dist/types/src/plugins/index.d.ts +56 -0
- package/dist/types/src/plugins/infographic-plugin.d.ts +9 -0
- package/dist/types/src/plugins/mermaid-plugin.d.ts +9 -0
- package/dist/types/src/plugins/plugin-content-utils.d.ts +40 -0
- package/dist/types/src/plugins/plugin-html-utils.d.ts +23 -0
- package/dist/types/src/plugins/rehype-image-uri.d.ts +13 -0
- package/dist/types/src/plugins/remark-super-sub.d.ts +17 -0
- package/dist/types/src/plugins/remark-toc-filter.d.ts +10 -0
- package/dist/types/src/plugins/svg-plugin.d.ts +51 -0
- package/dist/types/src/plugins/vega-plugin.d.ts +10 -0
- package/dist/types/src/plugins/vegalite-plugin.d.ts +23 -0
- package/dist/types/src/types/cache.d.ts +85 -0
- package/dist/types/src/types/core.d.ts +99 -0
- package/dist/types/src/types/docx.d.ts +240 -0
- package/dist/types/src/types/index.d.ts +18 -0
- package/dist/types/src/types/messaging.d.ts +142 -0
- package/dist/types/src/types/platform.d.ts +203 -0
- package/dist/types/src/types/plugin.d.ts +101 -0
- package/dist/types/src/types/render.d.ts +57 -0
- package/dist/types/src/types/theme.d.ts +234 -0
- package/dist/types/src/types/toolbar.d.ts +53 -0
- package/dist/types/src/ui/popup/i18n-helpers.d.ts +21 -0
- package/dist/types/src/ui/popup/settings-tab.d.ts +56 -0
- package/dist/types/src/ui/popup/storage-helper.d.ts +12 -0
- package/dist/types/src/utils/fetch-utils.d.ts +12 -0
- package/dist/types/src/utils/hash.d.ts +17 -0
- package/dist/types/src/utils/html-sanitizer.d.ts +26 -0
- package/dist/types/src/utils/localization.d.ts +49 -0
- package/dist/types/src/utils/theme-manager.d.ts +152 -0
- package/dist/types/src/utils/theme-to-css.d.ts +171 -0
- package/package.json +47 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin Content Script Utilities
|
|
3
|
+
* Handles content script specific logic for plugins (HTML generation, remark integration)
|
|
4
|
+
*/
|
|
5
|
+
import type { BasePlugin } from './base-plugin';
|
|
6
|
+
import type { TranslateFunction, EscapeHtmlFunction, AsyncTaskQueueManager, ASTNode, PluginRenderer } from '../types/index';
|
|
7
|
+
/**
|
|
8
|
+
* Create async placeholder element HTML (before rendering)
|
|
9
|
+
* @param id - Placeholder element ID
|
|
10
|
+
* @param pluginType - Plugin type identifier
|
|
11
|
+
* @param isInline - Whether to render inline or block
|
|
12
|
+
* @param translate - Translation function
|
|
13
|
+
* @param sourceHash - Content hash for DOM diff matching
|
|
14
|
+
* @returns Placeholder HTML
|
|
15
|
+
*/
|
|
16
|
+
export declare function createPlaceholderElement(id: string, pluginType: string, isInline: boolean, translate: TranslateFunction, sourceHash?: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Create error HTML
|
|
19
|
+
* @param errorMessage - Localized error message
|
|
20
|
+
* @returns Error HTML
|
|
21
|
+
*/
|
|
22
|
+
export declare function createErrorHTML(errorMessage: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Visit function type from unist-util-visit
|
|
25
|
+
*/
|
|
26
|
+
type VisitFn = (tree: unknown, nodeType: string, visitor: (node: ASTNode, index: number | undefined, parent: {
|
|
27
|
+
children?: unknown[];
|
|
28
|
+
} | undefined) => void) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Create remark plugin function for a plugin
|
|
31
|
+
* @param plugin - Plugin instance
|
|
32
|
+
* @param renderer - Renderer instance
|
|
33
|
+
* @param asyncTask - Async task creator
|
|
34
|
+
* @param translate - Translation function
|
|
35
|
+
* @param escapeHtml - HTML escape function
|
|
36
|
+
* @param visit - unist-util-visit function
|
|
37
|
+
* @returns Remark plugin function
|
|
38
|
+
*/
|
|
39
|
+
export declare function createRemarkPlugin(plugin: BasePlugin, renderer: PluginRenderer, asyncTask: AsyncTaskQueueManager['asyncTask'], translate: TranslateFunction, escapeHtml: EscapeHtmlFunction, visit: VisitFn): () => (tree: unknown) => void;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin HTML Utilities
|
|
3
|
+
* Converts unified plugin render results to HTML
|
|
4
|
+
*/
|
|
5
|
+
import type { PluginRenderResult, UnifiedRenderResult } from '../types/index';
|
|
6
|
+
/**
|
|
7
|
+
* Convert unified plugin render result to HTML string
|
|
8
|
+
* @param id - Placeholder element ID
|
|
9
|
+
* @param renderResult - Unified render result from plugin.renderToCommon()
|
|
10
|
+
* @param pluginType - Plugin type for alt text
|
|
11
|
+
* @param sourceHash - Content hash for DOM diff matching
|
|
12
|
+
* @returns HTML string
|
|
13
|
+
*/
|
|
14
|
+
export declare function convertPluginResultToHTML(id: string, renderResult: UnifiedRenderResult, pluginType?: string, sourceHash?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Replace placeholder with rendered content in DOM
|
|
17
|
+
* @param id - Placeholder element ID
|
|
18
|
+
* @param result - Render result with base64, width, height, format
|
|
19
|
+
* @param pluginType - Plugin type
|
|
20
|
+
* @param isInline - Whether to render inline or block
|
|
21
|
+
* @param expectedSourceHash - Source hash to validate against placeholder (prevents race conditions)
|
|
22
|
+
*/
|
|
23
|
+
export declare function replacePlaceholderWithImage(id: string, result: PluginRenderResult, pluginType: string, isInline: boolean, expectedSourceHash: string): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rehype plugin to rewrite relative image paths to absolute URIs.
|
|
3
|
+
*
|
|
4
|
+
* This plugin is primarily used in VS Code webview context where relative
|
|
5
|
+
* image paths need to be converted to vscode-webview-resource: URIs.
|
|
6
|
+
*
|
|
7
|
+
* The base URI is obtained from DocumentService.
|
|
8
|
+
*/
|
|
9
|
+
import type { Root } from 'hast';
|
|
10
|
+
/**
|
|
11
|
+
* Rehype plugin to rewrite image src attributes
|
|
12
|
+
*/
|
|
13
|
+
export default function rehypeImageUri(): (tree: Root) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remark plugin to support superscript (^text^) and subscript (~text~) syntax.
|
|
3
|
+
* Compatible with unified 11 / remark-parse 11 / micromark architecture.
|
|
4
|
+
*
|
|
5
|
+
* Syntax:
|
|
6
|
+
* - Superscript: ^text^ → <sup>text</sup>
|
|
7
|
+
* - Subscript: ~text~ → <sub>text</sub>
|
|
8
|
+
*
|
|
9
|
+
* Note: Single ~ is used for subscript (different from GFM's ~~ for strikethrough)
|
|
10
|
+
*/
|
|
11
|
+
import type { Plugin } from 'unified';
|
|
12
|
+
import type { Root } from 'mdast';
|
|
13
|
+
/**
|
|
14
|
+
* Remark plugin to support superscript and subscript syntax.
|
|
15
|
+
*/
|
|
16
|
+
declare const remarkSuperSub: Plugin<[], Root>;
|
|
17
|
+
export default remarkSuperSub;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remark plugin to filter out [toc] markers in rendered HTML
|
|
3
|
+
* The [toc] marker is used in DOCX export but should not be visible in HTML rendering
|
|
4
|
+
*/
|
|
5
|
+
import type { Node } from 'unist';
|
|
6
|
+
/**
|
|
7
|
+
* Plugin to remove [toc] markers from the AST
|
|
8
|
+
* Removes paragraphs that contain only [toc] or variations like [TOC]
|
|
9
|
+
*/
|
|
10
|
+
export default function remarkTocFilter(): (tree: Node) => void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SVG Plugin
|
|
3
|
+
*
|
|
4
|
+
* Handles SVG code blocks and SVG image files in content script and DOCX export
|
|
5
|
+
*/
|
|
6
|
+
import { BasePlugin } from './base-plugin';
|
|
7
|
+
/**
|
|
8
|
+
* AST node interface for SVG plugin
|
|
9
|
+
*/
|
|
10
|
+
interface AstNode {
|
|
11
|
+
type: string;
|
|
12
|
+
lang?: string;
|
|
13
|
+
value?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class SvgPlugin extends BasePlugin {
|
|
17
|
+
private _currentNodeType;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Extract content from AST node
|
|
21
|
+
* Handles both SVG code blocks and SVG image files
|
|
22
|
+
* @param node - AST node
|
|
23
|
+
* @returns SVG content or URL, or null if not applicable
|
|
24
|
+
*/
|
|
25
|
+
extractContent(node: AstNode): string | null;
|
|
26
|
+
/**
|
|
27
|
+
* SVG uses inline rendering for images, block for code blocks
|
|
28
|
+
* @returns True for inline rendering (images), false for block (code blocks)
|
|
29
|
+
*/
|
|
30
|
+
isInline(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Check if content is a URL (for image nodes)
|
|
33
|
+
* @param content - Extracted content
|
|
34
|
+
* @returns True if content is a URL
|
|
35
|
+
*/
|
|
36
|
+
isUrl(content: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch SVG content from URL
|
|
39
|
+
* Uses DocumentService for unified file access across all platforms.
|
|
40
|
+
* @param url - URL to fetch (http://, https://, file://, data:, or relative path)
|
|
41
|
+
* @returns SVG content
|
|
42
|
+
*/
|
|
43
|
+
fetchContent(url: string): Promise<string>;
|
|
44
|
+
/**
|
|
45
|
+
* Get AST node selector(s) for remark visit
|
|
46
|
+
* SVG plugin handles both code blocks and image nodes
|
|
47
|
+
* @returns Array of node types ['code', 'image']
|
|
48
|
+
*/
|
|
49
|
+
get nodeSelector(): string[];
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vega-Lite Plugin using BasePlugin architecture
|
|
3
|
+
*/
|
|
4
|
+
import { BasePlugin } from './base-plugin';
|
|
5
|
+
/**
|
|
6
|
+
* AST node interface
|
|
7
|
+
*/
|
|
8
|
+
interface AstNode {
|
|
9
|
+
type: string;
|
|
10
|
+
lang?: string;
|
|
11
|
+
value?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Vega-Lite Plugin implementation
|
|
15
|
+
*/
|
|
16
|
+
export declare class VegaLitePlugin extends BasePlugin {
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Override extractContent to support both 'vega-lite' and 'vegalite'
|
|
20
|
+
*/
|
|
21
|
+
extractContent(node: AstNode): string | null;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cache Type Definitions
|
|
3
|
+
* Types for caching system
|
|
4
|
+
*/
|
|
5
|
+
import type { RendererThemeConfig } from './render';
|
|
6
|
+
/**
|
|
7
|
+
* Individual cache item stored in IndexedDB
|
|
8
|
+
*/
|
|
9
|
+
export interface CacheItem<T = unknown> {
|
|
10
|
+
key: string;
|
|
11
|
+
value: T;
|
|
12
|
+
type: string;
|
|
13
|
+
size: number;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
accessTime: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* IndexedDB cache statistics
|
|
19
|
+
*/
|
|
20
|
+
export interface IndexedDBCacheStats {
|
|
21
|
+
itemCount: number;
|
|
22
|
+
maxItems: number;
|
|
23
|
+
totalSize: number;
|
|
24
|
+
totalSizeMB: string;
|
|
25
|
+
items: Array<{
|
|
26
|
+
key: string;
|
|
27
|
+
type: string;
|
|
28
|
+
size: number;
|
|
29
|
+
sizeMB: string;
|
|
30
|
+
created: string;
|
|
31
|
+
lastAccess: string;
|
|
32
|
+
}>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Full cache statistics (for detailed view)
|
|
36
|
+
*/
|
|
37
|
+
export interface CacheStats {
|
|
38
|
+
indexedDBCache: IndexedDBCacheStats;
|
|
39
|
+
combined: {
|
|
40
|
+
totalItems: number;
|
|
41
|
+
totalSizeMB: string;
|
|
42
|
+
};
|
|
43
|
+
databaseInfo: {
|
|
44
|
+
dbName: string;
|
|
45
|
+
storeName: string;
|
|
46
|
+
version: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Simple cache stats for popup/background communication
|
|
51
|
+
*/
|
|
52
|
+
export interface SimpleCacheStats {
|
|
53
|
+
itemCount: number;
|
|
54
|
+
maxItems: number;
|
|
55
|
+
totalSize: number;
|
|
56
|
+
totalSizeMB: string;
|
|
57
|
+
items: CacheItem[];
|
|
58
|
+
message?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Cache manager interface for content scripts
|
|
62
|
+
*/
|
|
63
|
+
export interface ICacheManager {
|
|
64
|
+
ensureDB?(): Promise<unknown>;
|
|
65
|
+
get(key: string): Promise<unknown>;
|
|
66
|
+
set(key: string, value: unknown, type?: string): Promise<boolean>;
|
|
67
|
+
delete(key: string): Promise<boolean>;
|
|
68
|
+
clear(): Promise<boolean>;
|
|
69
|
+
cleanup?(): Promise<void>;
|
|
70
|
+
getStats(): Promise<CacheStats | SimpleCacheStats | null>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Cache manager interface for renderers.
|
|
74
|
+
* Used by both the extension-side cache manager and the background proxy.
|
|
75
|
+
*/
|
|
76
|
+
export interface RendererCacheManager {
|
|
77
|
+
ensureDB(): Promise<unknown>;
|
|
78
|
+
generateKey(content: string, type: string, themeConfig?: RendererThemeConfig | null, outputFormat?: string): Promise<string>;
|
|
79
|
+
get(key: string): Promise<unknown>;
|
|
80
|
+
set(key: string, value: unknown, type: string): Promise<void>;
|
|
81
|
+
delete?(key: string): Promise<boolean>;
|
|
82
|
+
cleanup?(): Promise<void>;
|
|
83
|
+
getStats(): Promise<CacheStats | SimpleCacheStats | null>;
|
|
84
|
+
clear(): Promise<void>;
|
|
85
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core Type Definitions
|
|
3
|
+
* Basic types used throughout the application
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Translation function - supports both single string and array substitutions
|
|
7
|
+
*/
|
|
8
|
+
export type TranslateFunction = (key: string, substitutions?: string | string[]) => string;
|
|
9
|
+
/**
|
|
10
|
+
* HTML escape function
|
|
11
|
+
*/
|
|
12
|
+
export type EscapeHtmlFunction = (str: string) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Per-file UI state (scroll position, TOC visibility, zoom, etc.)
|
|
15
|
+
*/
|
|
16
|
+
export interface FileState {
|
|
17
|
+
/** Line-based scroll position (stable during content changes) */
|
|
18
|
+
scrollLine?: number;
|
|
19
|
+
tocVisible?: boolean;
|
|
20
|
+
zoom?: number;
|
|
21
|
+
layoutMode?: string;
|
|
22
|
+
lastModified?: number;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* All file states storage - keyed by URL
|
|
27
|
+
*/
|
|
28
|
+
export interface AllFileStates {
|
|
29
|
+
[url: string]: FileState;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* History entry for recently viewed files
|
|
33
|
+
*/
|
|
34
|
+
export interface HistoryEntry {
|
|
35
|
+
url: string;
|
|
36
|
+
title: string;
|
|
37
|
+
lastAccess: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Background script message
|
|
41
|
+
*
|
|
42
|
+
* @deprecated Use RequestEnvelope from src/types/messaging.ts instead.
|
|
43
|
+
* This flat message format is being phased out in favor of the standardized
|
|
44
|
+
* envelope format: { id, type, payload, timestamp, source? }
|
|
45
|
+
*
|
|
46
|
+
* Migration guide:
|
|
47
|
+
* - Move all flat fields (action, url, state, etc.) into the `payload` object
|
|
48
|
+
* - Use ServiceChannel.send() or ServiceChannel.post() for message passing
|
|
49
|
+
* - See docs/dev/messaging-audit.md for details
|
|
50
|
+
*/
|
|
51
|
+
export interface BackgroundMessage {
|
|
52
|
+
type?: string;
|
|
53
|
+
action?: string;
|
|
54
|
+
url?: string;
|
|
55
|
+
state?: FileState;
|
|
56
|
+
position?: number;
|
|
57
|
+
operation?: string;
|
|
58
|
+
key?: string;
|
|
59
|
+
value?: unknown;
|
|
60
|
+
dataType?: string;
|
|
61
|
+
limit?: number;
|
|
62
|
+
renderType?: string;
|
|
63
|
+
input?: string | object;
|
|
64
|
+
themeConfig?: unknown;
|
|
65
|
+
config?: unknown;
|
|
66
|
+
extraParams?: unknown;
|
|
67
|
+
filePath?: string;
|
|
68
|
+
binary?: boolean;
|
|
69
|
+
payload?: {
|
|
70
|
+
purpose?: string;
|
|
71
|
+
encoding?: string;
|
|
72
|
+
metadata?: Record<string, unknown>;
|
|
73
|
+
expectedSize?: number;
|
|
74
|
+
chunkSize?: number;
|
|
75
|
+
};
|
|
76
|
+
token?: string;
|
|
77
|
+
chunk?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Generic message handler
|
|
81
|
+
*/
|
|
82
|
+
export type MessageHandler = (message: unknown) => void;
|
|
83
|
+
/**
|
|
84
|
+
* Upload session for chunked file uploads
|
|
85
|
+
*/
|
|
86
|
+
export interface UploadSession {
|
|
87
|
+
purpose: string;
|
|
88
|
+
encoding: 'text' | 'base64';
|
|
89
|
+
metadata: Record<string, unknown>;
|
|
90
|
+
expectedSize: number | null;
|
|
91
|
+
chunkSize: number;
|
|
92
|
+
chunks: string[];
|
|
93
|
+
receivedBytes: number;
|
|
94
|
+
createdAt: number;
|
|
95
|
+
completed: boolean;
|
|
96
|
+
data?: string;
|
|
97
|
+
lastChunkTime?: number;
|
|
98
|
+
completedAt?: number;
|
|
99
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOCX Export Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file defines types for DOCX export functionality.
|
|
5
|
+
*
|
|
6
|
+
* IMPORTANT: These types are INTERNAL types for theme configuration and conversion.
|
|
7
|
+
* They are NOT the same as docx library types. The conversion layer (theme-to-docx.ts)
|
|
8
|
+
* is responsible for converting these internal types to docx library types.
|
|
9
|
+
*/
|
|
10
|
+
import { BorderStyle, AlignmentType, type IFontAttributesProperties } from 'docx';
|
|
11
|
+
/**
|
|
12
|
+
* Alignment type values from docx library
|
|
13
|
+
* Use this type when you need to store alignment values
|
|
14
|
+
*/
|
|
15
|
+
export type AlignmentTypeValue = (typeof AlignmentType)[keyof typeof AlignmentType];
|
|
16
|
+
/**
|
|
17
|
+
* Border style values from docx library
|
|
18
|
+
* Use this type when you need to store border style values
|
|
19
|
+
*/
|
|
20
|
+
export type BorderStyleValue = (typeof BorderStyle)[keyof typeof BorderStyle];
|
|
21
|
+
/**
|
|
22
|
+
* Emoji font style options for DOCX export
|
|
23
|
+
* - 'apple': Use Apple Color Emoji (iOS/macOS style, 3D glossy)
|
|
24
|
+
* - 'windows': Use Segoe UI Emoji (Windows/WPS style, flat design)
|
|
25
|
+
* - 'system': Use system emoji (no font processing, preserve original)
|
|
26
|
+
*/
|
|
27
|
+
export type EmojiStyle = 'apple' | 'windows' | 'system';
|
|
28
|
+
/**
|
|
29
|
+
* Internal run style for theme configuration
|
|
30
|
+
* This is converted to IRunStylePropertiesOptions when creating DOCX
|
|
31
|
+
*/
|
|
32
|
+
export interface DOCXRunStyle {
|
|
33
|
+
font: string | IFontAttributesProperties;
|
|
34
|
+
size: number;
|
|
35
|
+
bold?: boolean;
|
|
36
|
+
color?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Internal paragraph spacing for theme configuration
|
|
40
|
+
* Values are in twips (twentieth of a point, 1440 twips = 1 inch)
|
|
41
|
+
*/
|
|
42
|
+
export interface DOCXParagraphSpacing {
|
|
43
|
+
line?: number;
|
|
44
|
+
before?: number;
|
|
45
|
+
after?: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Internal paragraph style for theme configuration
|
|
49
|
+
* Note: alignment is stored as string for flexibility in theme files,
|
|
50
|
+
* converted to AlignmentTypeValue at runtime
|
|
51
|
+
*/
|
|
52
|
+
export interface DOCXParagraphStyle {
|
|
53
|
+
spacing?: DOCXParagraphSpacing;
|
|
54
|
+
alignment?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Internal heading style for theme configuration
|
|
58
|
+
*/
|
|
59
|
+
export interface DOCXHeadingStyle {
|
|
60
|
+
id: string;
|
|
61
|
+
name: string;
|
|
62
|
+
basedOn: string;
|
|
63
|
+
next: string;
|
|
64
|
+
run: DOCXRunStyle;
|
|
65
|
+
paragraph: DOCXParagraphStyle;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Internal character style for code blocks
|
|
69
|
+
*/
|
|
70
|
+
export interface DOCXCharacterStyle {
|
|
71
|
+
font: string | IFontAttributesProperties;
|
|
72
|
+
size: number;
|
|
73
|
+
background: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Internal border style
|
|
77
|
+
* Note: style is BorderStyleValue from docx library
|
|
78
|
+
*/
|
|
79
|
+
export interface DOCXBorder {
|
|
80
|
+
style: BorderStyleValue;
|
|
81
|
+
size: number;
|
|
82
|
+
color: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Internal table borders configuration
|
|
86
|
+
*/
|
|
87
|
+
export interface DOCXTableBorders {
|
|
88
|
+
all?: DOCXBorder;
|
|
89
|
+
headerTop?: DOCXBorder;
|
|
90
|
+
headerBottom?: DOCXBorder;
|
|
91
|
+
insideHorizontal?: DOCXBorder;
|
|
92
|
+
lastRowBottom?: DOCXBorder;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Internal table style configuration
|
|
96
|
+
*/
|
|
97
|
+
export interface DOCXTableStyle {
|
|
98
|
+
borders: DOCXTableBorders;
|
|
99
|
+
header: {
|
|
100
|
+
shading?: {
|
|
101
|
+
fill: string;
|
|
102
|
+
};
|
|
103
|
+
color?: string;
|
|
104
|
+
bold?: boolean;
|
|
105
|
+
};
|
|
106
|
+
cell: {
|
|
107
|
+
margins?: {
|
|
108
|
+
top: number;
|
|
109
|
+
bottom: number;
|
|
110
|
+
left: number;
|
|
111
|
+
right: number;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
zebra: boolean | {
|
|
115
|
+
even: string;
|
|
116
|
+
odd: string;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Code syntax highlighting colors
|
|
121
|
+
*/
|
|
122
|
+
export interface DOCXCodeColors {
|
|
123
|
+
background: string;
|
|
124
|
+
foreground: string;
|
|
125
|
+
colors: Record<string, string>;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Complete internal DOCX theme styles configuration
|
|
129
|
+
* Used throughout the DOCX export system
|
|
130
|
+
*/
|
|
131
|
+
export interface DOCXThemeStyles {
|
|
132
|
+
default: {
|
|
133
|
+
run: DOCXRunStyle;
|
|
134
|
+
paragraph: DOCXParagraphStyle;
|
|
135
|
+
};
|
|
136
|
+
paragraphStyles: Record<string, DOCXHeadingStyle>;
|
|
137
|
+
characterStyles: {
|
|
138
|
+
code: DOCXCharacterStyle;
|
|
139
|
+
};
|
|
140
|
+
tableStyles: DOCXTableStyle;
|
|
141
|
+
codeColors: DOCXCodeColors;
|
|
142
|
+
linkColor: string;
|
|
143
|
+
blockquoteColor: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Link definition from markdown reference links
|
|
147
|
+
*/
|
|
148
|
+
export interface LinkDefinition {
|
|
149
|
+
url: string;
|
|
150
|
+
title: string | null;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Image buffer result from fetching
|
|
154
|
+
*/
|
|
155
|
+
export interface ImageBufferResult {
|
|
156
|
+
buffer: Uint8Array;
|
|
157
|
+
contentType: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Supported image types for DOCX
|
|
161
|
+
*/
|
|
162
|
+
export type DOCXImageType = 'png' | 'jpg' | 'gif' | 'bmp';
|
|
163
|
+
/**
|
|
164
|
+
* Fetch image result with dimensions
|
|
165
|
+
*/
|
|
166
|
+
export interface FetchImageResult {
|
|
167
|
+
buffer: Uint8Array;
|
|
168
|
+
width: number;
|
|
169
|
+
height: number;
|
|
170
|
+
type: DOCXImageType;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* DOCX export result
|
|
174
|
+
*/
|
|
175
|
+
export interface DOCXExportResult {
|
|
176
|
+
success: boolean;
|
|
177
|
+
error?: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Progress callback type
|
|
181
|
+
*/
|
|
182
|
+
export type DOCXProgressCallback = (processed: number, total: number) => void;
|
|
183
|
+
/**
|
|
184
|
+
* Public DOCX exporter interface
|
|
185
|
+
* Implemented by the DocxExporter class in src/exporters/docx-exporter.ts
|
|
186
|
+
*/
|
|
187
|
+
export interface DocxExporter {
|
|
188
|
+
exportToDocx(markdown: string, filename?: string, onProgress?: DOCXProgressCallback | null): Promise<DOCXExportResult>;
|
|
189
|
+
setBaseUrl?(url: string): void;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Base AST node interface
|
|
193
|
+
*/
|
|
194
|
+
export interface DOCXASTNode {
|
|
195
|
+
type: string;
|
|
196
|
+
children?: DOCXASTNode[];
|
|
197
|
+
value?: string;
|
|
198
|
+
depth?: number;
|
|
199
|
+
lang?: string;
|
|
200
|
+
url?: string;
|
|
201
|
+
title?: string;
|
|
202
|
+
identifier?: string;
|
|
203
|
+
ordered?: boolean;
|
|
204
|
+
start?: number;
|
|
205
|
+
[key: string]: unknown;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* List node with ordering info
|
|
209
|
+
*/
|
|
210
|
+
export interface DOCXListNode extends DOCXASTNode {
|
|
211
|
+
type: 'list';
|
|
212
|
+
ordered: boolean;
|
|
213
|
+
start?: number;
|
|
214
|
+
children: DOCXASTNode[];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Blockquote node
|
|
218
|
+
*/
|
|
219
|
+
export interface DOCXBlockquoteNode extends DOCXASTNode {
|
|
220
|
+
type: 'blockquote';
|
|
221
|
+
children: DOCXASTNode[];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Table node
|
|
225
|
+
*/
|
|
226
|
+
export interface DOCXTableNode extends DOCXASTNode {
|
|
227
|
+
type: 'table';
|
|
228
|
+
children: DOCXASTNode[];
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Inline node (text, link, emphasis, etc.)
|
|
232
|
+
*/
|
|
233
|
+
export interface DOCXInlineNode extends DOCXASTNode {
|
|
234
|
+
type: 'text' | 'link' | 'emphasis' | 'strong' | 'inlineCode' | 'image' | 'linkReference' | 'inlineMath' | 'break' | 'html';
|
|
235
|
+
url?: string;
|
|
236
|
+
title?: string;
|
|
237
|
+
identifier?: string;
|
|
238
|
+
alt?: string;
|
|
239
|
+
}
|
|
240
|
+
export { BorderStyle, AlignmentType };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* All shared types should be imported from this file.
|
|
5
|
+
* This is the single source of truth for type definitions.
|
|
6
|
+
*/
|
|
7
|
+
import './platform.d';
|
|
8
|
+
export type { TranslateFunction, EscapeHtmlFunction, FileState, AllFileStates, HistoryEntry, BackgroundMessage, MessageHandler, UploadSession, } from './core';
|
|
9
|
+
export type { CacheItem, IndexedDBCacheStats, CacheStats, SimpleCacheStats, ICacheManager, RendererCacheManager, } from './cache';
|
|
10
|
+
export type { RenderResult, RenderResultType, RenderResultContent, RenderResultDisplay, UnifiedRenderResult, RendererThemeConfig, } from './render';
|
|
11
|
+
export type { ColorScheme, HeadingConfig, FontScheme, BorderConfig, TableStyleConfig, CodeThemeConfig, LayoutHeadingConfig, LayoutBlockConfig, LayoutScheme, Theme, ThemeDefinition, ThemeCategoryInfo, ThemeRegistry, ThemeRegistryInfo, } from './theme';
|
|
12
|
+
export type { PlatformType, PlatformMessageAPI, PlatformStorageAPI, PlatformResourceAPI, PlatformI18nAPI, PlatformBridgeAPI, DownloadOptions, CacheService, RendererService, StorageService, FileService, ResourceService, I18nService, MessageService, PlatformAPI, } from './platform';
|
|
13
|
+
export type { RenderMessageType, ServiceMessageType, CommonMessageType, AnyMessageType, RenderPayloadMap, ServicePayloadMap, RequestEnvelope, ResponseEnvelope, RenderRequestEnvelope, ServiceRequestEnvelope, RenderResponseData, } from './messaging';
|
|
14
|
+
export { RenderMessageType as RenderMessageTypes, ServiceMessageType as ServiceMessageTypes, CommonMessageType as CommonMessageTypes, } from './messaging';
|
|
15
|
+
export type { TaskStatus, TaskData, AsyncTaskObject, PlaceholderResult, AsyncTaskResult, AsyncTaskPlugin, AsyncTaskQueueManager, ASTNode, IPlugin, PluginRenderer, PluginRenderResult, } from './plugin';
|
|
16
|
+
export type { AlignmentTypeValue, BorderStyleValue, DOCXRunStyle, DOCXParagraphSpacing, DOCXParagraphStyle, DOCXHeadingStyle, DOCXCharacterStyle, DOCXBorder, DOCXTableBorders, DOCXTableStyle, DOCXCodeColors, DOCXThemeStyles, LinkDefinition, ImageBufferResult, DOCXImageType, FetchImageResult, DOCXExportResult, DOCXProgressCallback, DocxExporter, DOCXASTNode, DOCXListNode, DOCXBlockquoteNode, DOCXTableNode, DOCXInlineNode, } from './docx';
|
|
17
|
+
export { BorderStyle, AlignmentType } from './docx';
|
|
18
|
+
export type { LayoutConfig, ToolbarManagerOptions, GenerateToolbarHTMLOptions, ToolbarManagerInstance, } from './toolbar';
|