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,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Type Definitions
|
|
3
|
+
* Types for theme system
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Color scheme configuration
|
|
7
|
+
* Manages all color-related settings for a theme
|
|
8
|
+
*/
|
|
9
|
+
export interface ColorScheme {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
name_en: string;
|
|
13
|
+
description: string;
|
|
14
|
+
description_en?: string;
|
|
15
|
+
text: {
|
|
16
|
+
primary: string;
|
|
17
|
+
secondary: string;
|
|
18
|
+
muted: string;
|
|
19
|
+
};
|
|
20
|
+
accent: {
|
|
21
|
+
link: string;
|
|
22
|
+
linkHover: string;
|
|
23
|
+
};
|
|
24
|
+
background: {
|
|
25
|
+
code: string;
|
|
26
|
+
};
|
|
27
|
+
blockquote: {
|
|
28
|
+
border: string;
|
|
29
|
+
};
|
|
30
|
+
table: {
|
|
31
|
+
border: string;
|
|
32
|
+
headerBackground: string;
|
|
33
|
+
headerText: string;
|
|
34
|
+
zebraEven: string;
|
|
35
|
+
zebraOdd: string;
|
|
36
|
+
};
|
|
37
|
+
/** Optional per-heading colors for colorful themes like rainbow */
|
|
38
|
+
headings?: {
|
|
39
|
+
h1?: string;
|
|
40
|
+
h2?: string;
|
|
41
|
+
h3?: string;
|
|
42
|
+
h4?: string;
|
|
43
|
+
h5?: string;
|
|
44
|
+
h6?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Heading style configuration (font-related properties only)
|
|
49
|
+
* Layout properties (fontSize, alignment, spacing) are in LayoutScheme
|
|
50
|
+
*/
|
|
51
|
+
export interface HeadingConfig {
|
|
52
|
+
fontFamily?: string;
|
|
53
|
+
fontWeight?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Font scheme configuration (font-related properties only)
|
|
57
|
+
* Layout properties (fontSize, lineHeight, spacing) are in LayoutScheme
|
|
58
|
+
* Color properties are in ColorScheme
|
|
59
|
+
*/
|
|
60
|
+
export interface FontScheme {
|
|
61
|
+
body: {
|
|
62
|
+
fontFamily: string;
|
|
63
|
+
};
|
|
64
|
+
headings: HeadingsConfig;
|
|
65
|
+
code: {
|
|
66
|
+
fontFamily: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Headings font configuration
|
|
71
|
+
* Top-level fontFamily/fontWeight apply to all headings (h1-h6)
|
|
72
|
+
* Individual h1-h6 configs can override the defaults
|
|
73
|
+
*/
|
|
74
|
+
export interface HeadingsConfig {
|
|
75
|
+
/** Default font family for all headings (h1-h6) */
|
|
76
|
+
fontFamily?: string;
|
|
77
|
+
/** Default font weight for all headings (h1-h6) */
|
|
78
|
+
fontWeight?: string;
|
|
79
|
+
/** Individual heading overrides */
|
|
80
|
+
h1?: HeadingConfig;
|
|
81
|
+
h2?: HeadingConfig;
|
|
82
|
+
h3?: HeadingConfig;
|
|
83
|
+
h4?: HeadingConfig;
|
|
84
|
+
h5?: HeadingConfig;
|
|
85
|
+
h6?: HeadingConfig;
|
|
86
|
+
/** Allow dynamic access by level name */
|
|
87
|
+
[key: string]: HeadingConfig | string | undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Border configuration (layout properties only)
|
|
91
|
+
* Color is from ColorScheme
|
|
92
|
+
*/
|
|
93
|
+
export interface BorderConfig {
|
|
94
|
+
style: string;
|
|
95
|
+
width: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Table style configuration (layout properties only)
|
|
99
|
+
* Color properties are in ColorScheme
|
|
100
|
+
*/
|
|
101
|
+
export interface TableStyleConfig {
|
|
102
|
+
border?: {
|
|
103
|
+
all?: BorderConfig;
|
|
104
|
+
headerTop?: BorderConfig;
|
|
105
|
+
headerBottom?: BorderConfig;
|
|
106
|
+
rowBottom?: BorderConfig;
|
|
107
|
+
lastRowBottom?: BorderConfig;
|
|
108
|
+
};
|
|
109
|
+
header: {
|
|
110
|
+
fontWeight?: string;
|
|
111
|
+
};
|
|
112
|
+
cell: {
|
|
113
|
+
padding: string;
|
|
114
|
+
};
|
|
115
|
+
zebra?: {
|
|
116
|
+
enabled: boolean;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Code theme color configuration
|
|
121
|
+
*/
|
|
122
|
+
export interface CodeThemeConfig {
|
|
123
|
+
colors: Record<string, string>;
|
|
124
|
+
foreground?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Layout scheme heading configuration
|
|
128
|
+
*/
|
|
129
|
+
export interface LayoutHeadingConfig {
|
|
130
|
+
fontSize: string;
|
|
131
|
+
spacingBefore: string;
|
|
132
|
+
spacingAfter: string;
|
|
133
|
+
alignment?: 'left' | 'center' | 'right';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Layout scheme block configuration
|
|
137
|
+
*/
|
|
138
|
+
export interface LayoutBlockConfig {
|
|
139
|
+
spacingBefore?: string;
|
|
140
|
+
spacingAfter?: string;
|
|
141
|
+
paddingVertical?: string;
|
|
142
|
+
paddingHorizontal?: string;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Layout scheme configuration (absolute pt values)
|
|
146
|
+
*/
|
|
147
|
+
export interface LayoutScheme {
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
name_en: string;
|
|
151
|
+
description: string;
|
|
152
|
+
description_en?: string;
|
|
153
|
+
body: {
|
|
154
|
+
fontSize: string;
|
|
155
|
+
lineHeight: number;
|
|
156
|
+
};
|
|
157
|
+
headings: {
|
|
158
|
+
h1: LayoutHeadingConfig;
|
|
159
|
+
h2: LayoutHeadingConfig;
|
|
160
|
+
h3: LayoutHeadingConfig;
|
|
161
|
+
h4: LayoutHeadingConfig;
|
|
162
|
+
h5: LayoutHeadingConfig;
|
|
163
|
+
h6: LayoutHeadingConfig;
|
|
164
|
+
};
|
|
165
|
+
code: {
|
|
166
|
+
fontSize: string;
|
|
167
|
+
};
|
|
168
|
+
blocks: {
|
|
169
|
+
paragraph: LayoutBlockConfig;
|
|
170
|
+
list: LayoutBlockConfig;
|
|
171
|
+
listItem: LayoutBlockConfig;
|
|
172
|
+
blockquote: LayoutBlockConfig;
|
|
173
|
+
codeBlock: LayoutBlockConfig;
|
|
174
|
+
table: LayoutBlockConfig;
|
|
175
|
+
horizontalRule: LayoutBlockConfig;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Complete theme definition (loaded from theme files)
|
|
180
|
+
*/
|
|
181
|
+
export interface Theme {
|
|
182
|
+
id: string;
|
|
183
|
+
name: string;
|
|
184
|
+
name_en?: string;
|
|
185
|
+
description?: string;
|
|
186
|
+
description_en?: string;
|
|
187
|
+
author?: string;
|
|
188
|
+
version?: string;
|
|
189
|
+
fontScheme: FontScheme;
|
|
190
|
+
layoutScheme: string;
|
|
191
|
+
colorScheme: string;
|
|
192
|
+
tableStyle: string;
|
|
193
|
+
codeTheme: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Theme definition from registry
|
|
197
|
+
*/
|
|
198
|
+
export interface ThemeDefinition {
|
|
199
|
+
id: string;
|
|
200
|
+
name: string;
|
|
201
|
+
name_en: string;
|
|
202
|
+
description?: string;
|
|
203
|
+
description_en?: string;
|
|
204
|
+
category: string;
|
|
205
|
+
featured?: boolean;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Theme category info
|
|
209
|
+
*/
|
|
210
|
+
export interface ThemeCategoryInfo {
|
|
211
|
+
name: string;
|
|
212
|
+
name_en: string;
|
|
213
|
+
order?: number;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Theme registry structure
|
|
217
|
+
*/
|
|
218
|
+
export interface ThemeRegistry {
|
|
219
|
+
categories: Record<string, ThemeCategoryInfo>;
|
|
220
|
+
themes: Array<{
|
|
221
|
+
id: string;
|
|
222
|
+
file: string;
|
|
223
|
+
category: string;
|
|
224
|
+
featured?: boolean;
|
|
225
|
+
}>;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Theme registry info (cached version)
|
|
229
|
+
*/
|
|
230
|
+
export interface ThemeRegistryInfo {
|
|
231
|
+
id: string;
|
|
232
|
+
name: string;
|
|
233
|
+
category: string;
|
|
234
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar Type Definitions
|
|
3
|
+
* Types for UI toolbar
|
|
4
|
+
*/
|
|
5
|
+
import type { TranslateFunction, EscapeHtmlFunction, FileState } from './core';
|
|
6
|
+
import type { DocxExporter } from './docx';
|
|
7
|
+
/**
|
|
8
|
+
* Layout configuration
|
|
9
|
+
*/
|
|
10
|
+
export interface LayoutConfig {
|
|
11
|
+
maxWidth: string;
|
|
12
|
+
icon: string;
|
|
13
|
+
title: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Toolbar manager options
|
|
17
|
+
*/
|
|
18
|
+
export interface ToolbarManagerOptions {
|
|
19
|
+
translate: TranslateFunction;
|
|
20
|
+
escapeHtml: EscapeHtmlFunction;
|
|
21
|
+
saveFileState: (state: FileState) => void;
|
|
22
|
+
getFileState: () => Promise<FileState>;
|
|
23
|
+
rawMarkdown: string;
|
|
24
|
+
docxExporter: DocxExporter;
|
|
25
|
+
cancelScrollRestore: () => void;
|
|
26
|
+
updateActiveTocItem: () => void;
|
|
27
|
+
toolbarPrintDisabledTitle: string;
|
|
28
|
+
/** Called before zoom changes to lock scroll position */
|
|
29
|
+
onBeforeZoom?: () => void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate toolbar HTML options
|
|
33
|
+
*/
|
|
34
|
+
export interface GenerateToolbarHTMLOptions {
|
|
35
|
+
translate: TranslateFunction;
|
|
36
|
+
escapeHtml: EscapeHtmlFunction;
|
|
37
|
+
initialTocClass: string;
|
|
38
|
+
initialMaxWidth: string;
|
|
39
|
+
initialZoom: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Toolbar manager instance interface
|
|
43
|
+
*/
|
|
44
|
+
export interface ToolbarManagerInstance {
|
|
45
|
+
layoutIcons: Record<string, string>;
|
|
46
|
+
layoutConfigs: Record<string, LayoutConfig>;
|
|
47
|
+
applyZoom: (newLevel: number, saveState?: boolean) => void;
|
|
48
|
+
getZoomLevel: () => number;
|
|
49
|
+
setInitialZoom: (level: number) => void;
|
|
50
|
+
initializeToolbar: () => void;
|
|
51
|
+
setupToolbarButtons: () => Promise<void>;
|
|
52
|
+
setupKeyboardShortcuts: () => void;
|
|
53
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internationalization helpers for popup
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Translate a key to localized string
|
|
6
|
+
* @param key - Translation key
|
|
7
|
+
* @param substitutions - Optional substitutions
|
|
8
|
+
* @returns Translated string
|
|
9
|
+
*/
|
|
10
|
+
export declare const translate: (key: string, substitutions?: string | string[]) => string;
|
|
11
|
+
/**
|
|
12
|
+
* Get the current UI locale
|
|
13
|
+
* @returns Locale code (e.g., 'en', 'zh-CN')
|
|
14
|
+
*/
|
|
15
|
+
export declare const getUiLocale: () => string;
|
|
16
|
+
/**
|
|
17
|
+
* Apply internationalized text to DOM elements
|
|
18
|
+
* Elements with data-i18n attribute will have their text content replaced
|
|
19
|
+
* Elements with data-i18n-attr attribute will have specified attributes set
|
|
20
|
+
*/
|
|
21
|
+
export declare const applyI18nText: () => void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings Tab Manager
|
|
3
|
+
* Manages settings panel functionality including themes and cache settings
|
|
4
|
+
*/
|
|
5
|
+
import type { EmojiStyle } from '../../types/docx.js';
|
|
6
|
+
/**
|
|
7
|
+
* Supported file extensions
|
|
8
|
+
*/
|
|
9
|
+
interface SupportedExtensions {
|
|
10
|
+
mermaid: boolean;
|
|
11
|
+
vega: boolean;
|
|
12
|
+
vegaLite: boolean;
|
|
13
|
+
dot: boolean;
|
|
14
|
+
infographic: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Frontmatter display mode
|
|
18
|
+
*/
|
|
19
|
+
export type FrontmatterDisplay = 'hide' | 'table' | 'raw';
|
|
20
|
+
/**
|
|
21
|
+
* User settings structure
|
|
22
|
+
*/
|
|
23
|
+
interface Settings {
|
|
24
|
+
maxCacheItems: number;
|
|
25
|
+
preferredLocale: string;
|
|
26
|
+
docxHrAsPageBreak: boolean;
|
|
27
|
+
docxEmojiStyle?: EmojiStyle;
|
|
28
|
+
supportedExtensions?: SupportedExtensions;
|
|
29
|
+
frontmatterDisplay?: FrontmatterDisplay;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Settings tab manager options
|
|
33
|
+
*/
|
|
34
|
+
interface SettingsTabManagerOptions {
|
|
35
|
+
showMessage: (message: string, type: 'success' | 'error' | 'info') => void;
|
|
36
|
+
showConfirm: (title: string, message: string) => Promise<boolean>;
|
|
37
|
+
onReloadCacheData?: () => void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Settings tab manager interface
|
|
41
|
+
*/
|
|
42
|
+
export interface SettingsTabManager {
|
|
43
|
+
loadSettings: () => Promise<void>;
|
|
44
|
+
loadSettingsUI: () => void;
|
|
45
|
+
saveSettings: () => Promise<void>;
|
|
46
|
+
resetSettings: () => Promise<void>;
|
|
47
|
+
getSettings: () => Settings;
|
|
48
|
+
loadThemes: () => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a settings tab manager
|
|
52
|
+
* @param options - Configuration options
|
|
53
|
+
* @returns Settings tab manager instance
|
|
54
|
+
*/
|
|
55
|
+
export declare function createSettingsTabManager({ showMessage, showConfirm, onReloadCacheData }: SettingsTabManagerOptions): SettingsTabManager;
|
|
56
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage helper using message channel to background
|
|
3
|
+
* Works with both Chrome (MV3) and Firefox (MV2)
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get items from local storage via background
|
|
7
|
+
*/
|
|
8
|
+
export declare function storageGet(keys: string[]): Promise<Record<string, unknown>>;
|
|
9
|
+
/**
|
|
10
|
+
* Set items to local storage via background
|
|
11
|
+
*/
|
|
12
|
+
export declare function storageSet(items: Record<string, unknown>): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch JSON from asset path
|
|
3
|
+
* @param path - Asset path (can be URL or relative path)
|
|
4
|
+
* @returns Parsed JSON
|
|
5
|
+
*/
|
|
6
|
+
export declare function fetchJSON<T = unknown>(path: string): Promise<T>;
|
|
7
|
+
/**
|
|
8
|
+
* Fetch text content from asset path
|
|
9
|
+
* @param path - Asset path (can be URL or relative path)
|
|
10
|
+
* @returns Text content
|
|
11
|
+
*/
|
|
12
|
+
export declare function fetchText(path: string): Promise<string>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple hash utilities for content-based identification
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Generate a simple hash code from a string.
|
|
6
|
+
* Uses djb2 algorithm - fast and produces good distribution.
|
|
7
|
+
* @param str - String to hash
|
|
8
|
+
* @returns Hash code as hex string
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashCode(str: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a content hash combining type and content.
|
|
13
|
+
* @param type - Plugin type (e.g., 'mermaid', 'vega')
|
|
14
|
+
* @param content - Source content
|
|
15
|
+
* @returns Combined hash string
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateContentHash(type: string, content: string): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTML Sanitizer
|
|
3
|
+
*
|
|
4
|
+
* Shared utility for sanitizing HTML content and checking if it has meaningful content
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize HTML content to remove dangerous elements and attributes
|
|
8
|
+
* @param html - Raw HTML content
|
|
9
|
+
* @returns Sanitized HTML
|
|
10
|
+
*/
|
|
11
|
+
export declare function sanitizeHtml(html: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Check if sanitized HTML has any meaningful content
|
|
14
|
+
* @param sanitizedHtml - Sanitized HTML string
|
|
15
|
+
* @returns True if has content, false if empty or only whitespace
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasHtmlContent(sanitizedHtml: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Sanitize HTML and check if it has content in one step
|
|
20
|
+
* @param html - Raw HTML content
|
|
21
|
+
* @returns Sanitized HTML and content check result
|
|
22
|
+
*/
|
|
23
|
+
export declare function sanitizeAndCheck(html: string): {
|
|
24
|
+
sanitized: string;
|
|
25
|
+
hasContent: boolean;
|
|
26
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Localization manager providing user-selectable locales.
|
|
3
|
+
* Note: Comments in English per instructions.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Locale message entry structure
|
|
7
|
+
*/
|
|
8
|
+
interface LocaleMessageEntry {
|
|
9
|
+
message: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
placeholders?: Record<string, {
|
|
12
|
+
content: string;
|
|
13
|
+
example?: string;
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Locale messages object
|
|
18
|
+
*/
|
|
19
|
+
interface LocaleMessages {
|
|
20
|
+
[key: string]: LocaleMessageEntry;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Storage settings structure
|
|
24
|
+
*/
|
|
25
|
+
interface StorageSettings {
|
|
26
|
+
preferredLocale?: string;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}
|
|
29
|
+
declare const DEFAULT_SETTING_LOCALE = "auto";
|
|
30
|
+
declare class LocalizationManager {
|
|
31
|
+
private messages;
|
|
32
|
+
private locale;
|
|
33
|
+
private ready;
|
|
34
|
+
private loadingPromise;
|
|
35
|
+
private fallbackMessages;
|
|
36
|
+
constructor();
|
|
37
|
+
init(): Promise<void>;
|
|
38
|
+
getStorageSettings(): Promise<StorageSettings | null>;
|
|
39
|
+
setPreferredLocale(locale: string): Promise<void>;
|
|
40
|
+
ensureFallbackMessages(): Promise<void>;
|
|
41
|
+
loadLocale(locale: string): Promise<void>;
|
|
42
|
+
fetchLocaleData(locale: string): Promise<LocaleMessages | null>;
|
|
43
|
+
translate(key: string, substitutions?: string | string[]): string;
|
|
44
|
+
lookupMessage(source: LocaleMessages | null, key: string, substitutions?: string | string[]): string | null;
|
|
45
|
+
getLocale(): string;
|
|
46
|
+
}
|
|
47
|
+
declare const Localization: LocalizationManager;
|
|
48
|
+
export default Localization;
|
|
49
|
+
export { DEFAULT_SETTING_LOCALE };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme Manager for Markdown Viewer Extension
|
|
3
|
+
* Handles loading, applying, and managing themes
|
|
4
|
+
*/
|
|
5
|
+
import type { Theme } from '../types/theme';
|
|
6
|
+
/**
|
|
7
|
+
* Font configuration for a single font
|
|
8
|
+
*/
|
|
9
|
+
interface FontConfig {
|
|
10
|
+
webFallback: string;
|
|
11
|
+
docx?: {
|
|
12
|
+
ascii: string;
|
|
13
|
+
eastAsia: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Font configuration file structure
|
|
18
|
+
*/
|
|
19
|
+
export interface FontConfigFile {
|
|
20
|
+
fonts: Record<string, FontConfig>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* DOCX font configuration
|
|
24
|
+
*/
|
|
25
|
+
interface DocxFont {
|
|
26
|
+
ascii: string;
|
|
27
|
+
eastAsia: string;
|
|
28
|
+
hAnsi: string;
|
|
29
|
+
cs: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Category info in registry
|
|
33
|
+
*/
|
|
34
|
+
interface CategoryInfo {
|
|
35
|
+
name: string;
|
|
36
|
+
name_en?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Theme metadata
|
|
41
|
+
*/
|
|
42
|
+
interface ThemeMetadata {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
name_en?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
description_en?: string;
|
|
48
|
+
category: string;
|
|
49
|
+
featured: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Category with themes
|
|
53
|
+
*/
|
|
54
|
+
interface CategoryWithThemes extends CategoryInfo {
|
|
55
|
+
themes: ThemeMetadata[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Theme Manager Class
|
|
59
|
+
*/
|
|
60
|
+
declare class ThemeManager {
|
|
61
|
+
private currentTheme;
|
|
62
|
+
private fontConfig;
|
|
63
|
+
private registry;
|
|
64
|
+
private initialized;
|
|
65
|
+
constructor();
|
|
66
|
+
/**
|
|
67
|
+
* Initialize theme manager with data from Flutter
|
|
68
|
+
* Used on mobile platform where Flutter loads assets and sends to WebView
|
|
69
|
+
* @param fontConfig - Font configuration object
|
|
70
|
+
* @param theme - Theme object
|
|
71
|
+
*/
|
|
72
|
+
initializeWithData(fontConfig: FontConfigFile, theme?: Theme | null): void;
|
|
73
|
+
/**
|
|
74
|
+
* Initialize theme manager by loading font config and registry
|
|
75
|
+
*/
|
|
76
|
+
initialize(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Get font config for a given font name
|
|
79
|
+
* @param fontName - Font name (e.g., 'SimSun', 'Times New Roman')
|
|
80
|
+
* @returns Font fallback chain (CSS font-family string)
|
|
81
|
+
*/
|
|
82
|
+
getFontFallback(fontName: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Build complete font family stack
|
|
85
|
+
* @param fontName - Font name
|
|
86
|
+
* @returns Complete CSS font-family string
|
|
87
|
+
*/
|
|
88
|
+
buildFontFamily(fontName: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Get DOCX font configuration for a given font name
|
|
91
|
+
* @param fontName - Font name
|
|
92
|
+
* @returns Complete DOCX font object with ascii, eastAsia, hAnsi, cs properties
|
|
93
|
+
*/
|
|
94
|
+
getDocxFont(fontName: string): DocxFont;
|
|
95
|
+
/**
|
|
96
|
+
* Load a theme configuration from a JSON file
|
|
97
|
+
* @param themeId - Theme ID (e.g., 'default', 'academic')
|
|
98
|
+
* @returns Theme configuration object
|
|
99
|
+
*/
|
|
100
|
+
loadTheme(themeId: string): Promise<Theme>;
|
|
101
|
+
/**
|
|
102
|
+
* Load theme from storage
|
|
103
|
+
* @returns Theme ID
|
|
104
|
+
*/
|
|
105
|
+
loadSelectedTheme(): Promise<string>;
|
|
106
|
+
/**
|
|
107
|
+
* Save selected theme to storage
|
|
108
|
+
* @param themeId - Theme ID to save
|
|
109
|
+
*/
|
|
110
|
+
saveSelectedTheme(themeId: string): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Get current theme configuration
|
|
113
|
+
* @returns Current theme object
|
|
114
|
+
*/
|
|
115
|
+
getCurrentTheme(): Theme | null;
|
|
116
|
+
/**
|
|
117
|
+
* Convert point size to pixels (for CSS)
|
|
118
|
+
* @param ptSize - Size in points (e.g., '12pt')
|
|
119
|
+
* @returns Size in pixels (e.g., '16px')
|
|
120
|
+
*/
|
|
121
|
+
ptToPx(ptSize: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Convert point size to half-points (for DOCX)
|
|
124
|
+
* @param ptSize - Size in points (e.g., '12pt')
|
|
125
|
+
* @returns Size in half-points (e.g., 24)
|
|
126
|
+
*/
|
|
127
|
+
ptToHalfPt(ptSize: string): number;
|
|
128
|
+
/**
|
|
129
|
+
* Convert point size to twips (for DOCX spacing)
|
|
130
|
+
* @param ptSize - Size in points (e.g., '13pt')
|
|
131
|
+
* @returns Size in twips (e.g., 260)
|
|
132
|
+
*/
|
|
133
|
+
ptToTwips(ptSize: string): number;
|
|
134
|
+
/**
|
|
135
|
+
* Get all available themes from registry
|
|
136
|
+
* @returns List of theme metadata
|
|
137
|
+
*/
|
|
138
|
+
getAvailableThemes(): Promise<ThemeMetadata[]>;
|
|
139
|
+
/**
|
|
140
|
+
* Get themes grouped by category
|
|
141
|
+
* @returns Themes grouped by category
|
|
142
|
+
*/
|
|
143
|
+
getThemesByCategory(): Promise<Record<string, CategoryWithThemes>>;
|
|
144
|
+
/**
|
|
145
|
+
* Switch to a different theme
|
|
146
|
+
* @param themeId - Theme ID to switch to
|
|
147
|
+
* @returns The loaded theme
|
|
148
|
+
*/
|
|
149
|
+
switchTheme(themeId: string): Promise<Theme>;
|
|
150
|
+
}
|
|
151
|
+
declare const themeManager: ThemeManager;
|
|
152
|
+
export default themeManager;
|