@skrillex1224/chrome-article-publish-extension 1.0.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 +226 -0
- package/dist/adapters/index.d.ts +1125 -0
- package/dist/adapters/index.js +1900 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/chunk-7Q3KKWUB.js +602 -0
- package/dist/chunk-7Q3KKWUB.js.map +1 -0
- package/dist/chunk-IUAZAMKF.js +123 -0
- package/dist/chunk-IUAZAMKF.js.map +1 -0
- package/dist/chunk-QM2T4VGM.js +6688 -0
- package/dist/chunk-QM2T4VGM.js.map +1 -0
- package/dist/chunk-UO6CDRC5.js +322 -0
- package/dist/chunk-UO6CDRC5.js.map +1 -0
- package/dist/converter/index.d.ts +2 -0
- package/dist/converter/index.html +10 -0
- package/dist/converter/index.js +432 -0
- package/dist/converter/index.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +192 -0
- package/dist/index.js.map +1 -0
- package/dist/interface-BlLeWXzS.d.ts +265 -0
- package/dist/preprocessor/index.html +10 -0
- package/dist/runtime/index.d.ts +90 -0
- package/dist/runtime/index.js +9 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/types-BAnNlLpy.d.ts +140 -0
- package/package.json +54 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import "../chunk-IUAZAMKF.js";
|
|
2
|
+
import {
|
|
3
|
+
markdownToHtml
|
|
4
|
+
} from "../chunk-7Q3KKWUB.js";
|
|
5
|
+
|
|
6
|
+
// src/converter/markdown-renderer.ts
|
|
7
|
+
import html2canvas from "html2canvas";
|
|
8
|
+
var DEFAULT_WIDTH = 1080;
|
|
9
|
+
var DEFAULT_HEIGHT = 1440;
|
|
10
|
+
var DEFAULT_SCALE = 1;
|
|
11
|
+
var DEFAULT_MAX_PAGES = 12;
|
|
12
|
+
var DEFAULT_THEME = "clean";
|
|
13
|
+
var STYLE_ELEMENT_ID = "ws-markdown-image-renderer-style";
|
|
14
|
+
var THEMES = {
|
|
15
|
+
clean: {
|
|
16
|
+
colors: {
|
|
17
|
+
background: "#fbfaf7",
|
|
18
|
+
text: "#1d2433",
|
|
19
|
+
heading: "#111827",
|
|
20
|
+
muted: "#6d7480",
|
|
21
|
+
accent: "#2f6f73",
|
|
22
|
+
mark: "#d7a84f",
|
|
23
|
+
subtle: "#f0eee7",
|
|
24
|
+
border: "#ded8c8",
|
|
25
|
+
codeText: "#8a4b17",
|
|
26
|
+
codeBackground: "#f3ead9"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var CARD_CSS = `
|
|
31
|
+
* {
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ws-md-card {
|
|
36
|
+
width: var(--ws-card-width);
|
|
37
|
+
height: var(--ws-card-height);
|
|
38
|
+
color: var(--ws-color-text);
|
|
39
|
+
background: var(--ws-color-background);
|
|
40
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
padding: 68px 76px 54px;
|
|
44
|
+
position: relative;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.ws-md-card::before {
|
|
49
|
+
content: "";
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 0;
|
|
52
|
+
top: 0;
|
|
53
|
+
width: 16px;
|
|
54
|
+
height: 100%;
|
|
55
|
+
background: var(--ws-color-accent);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.ws-md-card::after {
|
|
59
|
+
content: "";
|
|
60
|
+
position: absolute;
|
|
61
|
+
right: 76px;
|
|
62
|
+
top: 0;
|
|
63
|
+
width: 116px;
|
|
64
|
+
height: 12px;
|
|
65
|
+
background: var(--ws-color-mark);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.ws-md-page {
|
|
69
|
+
flex: 1;
|
|
70
|
+
min-height: 0;
|
|
71
|
+
overflow: hidden;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ws-md-footer {
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
align-items: center;
|
|
78
|
+
gap: 24px;
|
|
79
|
+
padding-top: 24px;
|
|
80
|
+
color: var(--ws-color-muted);
|
|
81
|
+
font-size: 24px;
|
|
82
|
+
line-height: 1;
|
|
83
|
+
border-top: 1px solid var(--ws-color-border);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.ws-md-footer span:first-child {
|
|
87
|
+
color: var(--ws-color-accent);
|
|
88
|
+
font-weight: 700;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.ws-md-title {
|
|
92
|
+
margin: 0 0 28px;
|
|
93
|
+
color: var(--ws-color-heading);
|
|
94
|
+
font-size: 58px;
|
|
95
|
+
line-height: 1.16;
|
|
96
|
+
font-weight: 800;
|
|
97
|
+
letter-spacing: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.ws-md-content {
|
|
101
|
+
font-size: 33px;
|
|
102
|
+
line-height: 1.72;
|
|
103
|
+
letter-spacing: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.ws-md-content h1,
|
|
107
|
+
.ws-md-content h2,
|
|
108
|
+
.ws-md-content h3 {
|
|
109
|
+
color: var(--ws-color-heading);
|
|
110
|
+
line-height: 1.22;
|
|
111
|
+
letter-spacing: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.ws-md-content h1 {
|
|
115
|
+
font-size: 48px;
|
|
116
|
+
margin: 0 0 24px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.ws-md-content h2 {
|
|
120
|
+
font-size: 42px;
|
|
121
|
+
margin: 28px 0 16px;
|
|
122
|
+
padding-left: 18px;
|
|
123
|
+
border-left: 8px solid var(--ws-color-accent);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.ws-md-content h3 {
|
|
127
|
+
font-size: 36px;
|
|
128
|
+
margin: 24px 0 12px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.ws-md-content p {
|
|
132
|
+
margin: 0 0 20px;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.ws-md-content strong {
|
|
136
|
+
color: var(--ws-color-heading);
|
|
137
|
+
font-weight: 800;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.ws-md-content em {
|
|
141
|
+
color: var(--ws-color-accent);
|
|
142
|
+
font-style: normal;
|
|
143
|
+
font-weight: 700;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.ws-md-content ul,
|
|
147
|
+
.ws-md-content ol {
|
|
148
|
+
margin: 0 0 22px;
|
|
149
|
+
padding-left: 40px;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.ws-md-content li {
|
|
153
|
+
margin: 8px 0;
|
|
154
|
+
padding-left: 4px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.ws-md-content blockquote {
|
|
158
|
+
margin: 24px 0;
|
|
159
|
+
padding: 20px 28px;
|
|
160
|
+
color: var(--ws-color-text);
|
|
161
|
+
background: var(--ws-color-subtle);
|
|
162
|
+
border-left: 8px solid var(--ws-color-accent);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.ws-md-content code {
|
|
166
|
+
color: var(--ws-color-code-text);
|
|
167
|
+
background: var(--ws-color-code-background);
|
|
168
|
+
border-radius: 6px;
|
|
169
|
+
padding: 3px 8px;
|
|
170
|
+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
|
|
171
|
+
font-size: 0.86em;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.ws-md-content pre {
|
|
175
|
+
margin: 22px 0;
|
|
176
|
+
padding: 22px 24px;
|
|
177
|
+
color: var(--ws-color-text);
|
|
178
|
+
background: var(--ws-color-subtle);
|
|
179
|
+
border: 1px solid var(--ws-color-border);
|
|
180
|
+
border-radius: 10px;
|
|
181
|
+
overflow: hidden;
|
|
182
|
+
white-space: pre-wrap;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.ws-md-content pre code {
|
|
186
|
+
padding: 0;
|
|
187
|
+
color: inherit;
|
|
188
|
+
background: transparent;
|
|
189
|
+
font-size: 26px;
|
|
190
|
+
line-height: 1.55;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.ws-md-content table {
|
|
194
|
+
width: 100%;
|
|
195
|
+
border-collapse: collapse;
|
|
196
|
+
margin: 24px 0;
|
|
197
|
+
font-size: 26px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.ws-md-content th,
|
|
201
|
+
.ws-md-content td {
|
|
202
|
+
border: 1px solid var(--ws-color-border);
|
|
203
|
+
padding: 12px 14px;
|
|
204
|
+
text-align: left;
|
|
205
|
+
vertical-align: top;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.ws-md-content th {
|
|
209
|
+
color: var(--ws-color-heading);
|
|
210
|
+
background: var(--ws-color-subtle);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.ws-md-image-placeholder {
|
|
214
|
+
margin: 22px 0;
|
|
215
|
+
padding: 18px 22px;
|
|
216
|
+
color: var(--ws-color-muted);
|
|
217
|
+
background: var(--ws-color-subtle);
|
|
218
|
+
border: 1px dashed var(--ws-color-border);
|
|
219
|
+
border-radius: 10px;
|
|
220
|
+
font-size: 26px;
|
|
221
|
+
}
|
|
222
|
+
`;
|
|
223
|
+
async function renderMarkdownToImages(request) {
|
|
224
|
+
const config = normalizeRequest(request);
|
|
225
|
+
ensureCardStyle();
|
|
226
|
+
const stage = createStage(config);
|
|
227
|
+
document.body.appendChild(stage);
|
|
228
|
+
try {
|
|
229
|
+
const pages = paginateMarkdown(config, stage);
|
|
230
|
+
await document.fonts?.ready;
|
|
231
|
+
const outputs = [];
|
|
232
|
+
for (let i = 0; i < pages.length; i += 1) {
|
|
233
|
+
setFooter(pages[i], i + 1, pages.length);
|
|
234
|
+
outputs.push({
|
|
235
|
+
src: await renderCardToDataUrl(pages[i], config),
|
|
236
|
+
width: config.width * config.scale,
|
|
237
|
+
height: config.height * config.scale,
|
|
238
|
+
index: i
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return outputs;
|
|
242
|
+
} finally {
|
|
243
|
+
stage.remove();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
function normalizeRequest(request) {
|
|
247
|
+
const markdown = request.markdown?.trim();
|
|
248
|
+
if (!markdown) {
|
|
249
|
+
throw new Error("Markdown \u5185\u5BB9\u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u751F\u6210\u56FE\u6587\u56FE\u7247");
|
|
250
|
+
}
|
|
251
|
+
return {
|
|
252
|
+
title: request.title?.trim() || "",
|
|
253
|
+
markdown,
|
|
254
|
+
theme: resolveTheme(request.theme),
|
|
255
|
+
width: clampInteger(request.width, 720, 1600, DEFAULT_WIDTH),
|
|
256
|
+
height: clampInteger(request.height, 960, 2400, DEFAULT_HEIGHT),
|
|
257
|
+
scale: clampInteger(request.scale, 1, 3, DEFAULT_SCALE),
|
|
258
|
+
maxPages: clampInteger(request.maxPages, 1, 35, DEFAULT_MAX_PAGES)
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
function resolveTheme(theme) {
|
|
262
|
+
return THEMES[theme || DEFAULT_THEME] || THEMES[DEFAULT_THEME];
|
|
263
|
+
}
|
|
264
|
+
function clampInteger(value, min, max, fallback) {
|
|
265
|
+
if (!Number.isFinite(value)) return fallback;
|
|
266
|
+
return Math.max(min, Math.min(max, Math.round(value)));
|
|
267
|
+
}
|
|
268
|
+
function createStage(config) {
|
|
269
|
+
const stage = document.createElement("div");
|
|
270
|
+
stage.style.cssText = [
|
|
271
|
+
"position: fixed",
|
|
272
|
+
"left: 0",
|
|
273
|
+
"top: 0",
|
|
274
|
+
`width: ${config.width}px`,
|
|
275
|
+
"background: transparent",
|
|
276
|
+
"pointer-events: none",
|
|
277
|
+
"z-index: 2147483647"
|
|
278
|
+
].join(";");
|
|
279
|
+
return stage;
|
|
280
|
+
}
|
|
281
|
+
function paginateMarkdown(config, stage) {
|
|
282
|
+
const nodes = createArticleNodes(config);
|
|
283
|
+
const pages = [];
|
|
284
|
+
let page = createPage(config);
|
|
285
|
+
let body = getPageBody(page);
|
|
286
|
+
stage.appendChild(page);
|
|
287
|
+
pages.push(page);
|
|
288
|
+
for (const sourceNode of nodes) {
|
|
289
|
+
const node = sourceNode.cloneNode(true);
|
|
290
|
+
body.appendChild(node);
|
|
291
|
+
if (body.scrollHeight > body.clientHeight && body.childNodes.length > 1) {
|
|
292
|
+
body.removeChild(node);
|
|
293
|
+
if (pages.length >= config.maxPages) {
|
|
294
|
+
throw new Error(`Markdown \u5185\u5BB9\u8D85\u8FC7 ${config.maxPages} \u5F20\u56FE\u7684\u9650\u5236`);
|
|
295
|
+
}
|
|
296
|
+
page = createPage(config);
|
|
297
|
+
body = getPageBody(page);
|
|
298
|
+
stage.appendChild(page);
|
|
299
|
+
pages.push(page);
|
|
300
|
+
body.appendChild(node);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return pages;
|
|
304
|
+
}
|
|
305
|
+
function createArticleNodes(config) {
|
|
306
|
+
const nodes = [];
|
|
307
|
+
if (config.title) {
|
|
308
|
+
const title = document.createElement("h1");
|
|
309
|
+
title.className = "ws-md-title";
|
|
310
|
+
title.textContent = config.title;
|
|
311
|
+
nodes.push(title);
|
|
312
|
+
}
|
|
313
|
+
const content = document.createElement("div");
|
|
314
|
+
content.className = "ws-md-content";
|
|
315
|
+
content.innerHTML = sanitizeHtml(markdownToHtml(config.markdown));
|
|
316
|
+
for (const child of Array.from(content.childNodes)) {
|
|
317
|
+
if (child.nodeType === Node.TEXT_NODE && !child.textContent?.trim()) continue;
|
|
318
|
+
nodes.push(child);
|
|
319
|
+
}
|
|
320
|
+
return nodes;
|
|
321
|
+
}
|
|
322
|
+
function sanitizeHtml(html) {
|
|
323
|
+
const template = document.createElement("template");
|
|
324
|
+
template.innerHTML = html;
|
|
325
|
+
template.content.querySelectorAll("script, style, iframe, object, embed, link, meta, form, input, button, svg, video, audio").forEach((node) => node.remove());
|
|
326
|
+
template.content.querySelectorAll("img").forEach((img) => {
|
|
327
|
+
const placeholder = document.createElement("div");
|
|
328
|
+
placeholder.className = "ws-md-image-placeholder";
|
|
329
|
+
const alt = img.getAttribute("alt")?.trim();
|
|
330
|
+
placeholder.textContent = alt ? `\u56FE\u7247\u5360\u4F4D\uFF1A${alt}` : "\u56FE\u7247\u5360\u4F4D";
|
|
331
|
+
img.replaceWith(placeholder);
|
|
332
|
+
});
|
|
333
|
+
const walker = document.createTreeWalker(template.content, NodeFilter.SHOW_ELEMENT);
|
|
334
|
+
const elements = [];
|
|
335
|
+
while (walker.nextNode()) {
|
|
336
|
+
elements.push(walker.currentNode);
|
|
337
|
+
}
|
|
338
|
+
for (const element of elements) {
|
|
339
|
+
for (const attr of Array.from(element.attributes)) {
|
|
340
|
+
const name = attr.name.toLowerCase();
|
|
341
|
+
const value = attr.value.trim().toLowerCase();
|
|
342
|
+
if (name.startsWith("on") || name === "style") {
|
|
343
|
+
element.removeAttribute(attr.name);
|
|
344
|
+
}
|
|
345
|
+
if ((name === "href" || name === "src") && value.startsWith("javascript:")) {
|
|
346
|
+
element.removeAttribute(attr.name);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return Array.from(template.content.childNodes).map((node) => {
|
|
351
|
+
const container = document.createElement("div");
|
|
352
|
+
container.appendChild(node.cloneNode(true));
|
|
353
|
+
return container.innerHTML;
|
|
354
|
+
}).join("");
|
|
355
|
+
}
|
|
356
|
+
function createPage(config) {
|
|
357
|
+
const card = document.createElement("article");
|
|
358
|
+
card.className = "ws-md-card";
|
|
359
|
+
card.style.setProperty("--ws-card-width", `${config.width}px`);
|
|
360
|
+
card.style.setProperty("--ws-card-height", `${config.height}px`);
|
|
361
|
+
applyTheme(card, config.theme);
|
|
362
|
+
card.style.width = `${config.width}px`;
|
|
363
|
+
card.style.height = `${config.height}px`;
|
|
364
|
+
const body = document.createElement("div");
|
|
365
|
+
body.className = "ws-md-page ws-md-content";
|
|
366
|
+
card.appendChild(body);
|
|
367
|
+
const footer = document.createElement("footer");
|
|
368
|
+
footer.className = "ws-md-footer";
|
|
369
|
+
card.appendChild(footer);
|
|
370
|
+
return card;
|
|
371
|
+
}
|
|
372
|
+
function getPageBody(page) {
|
|
373
|
+
const body = page.querySelector(".ws-md-page");
|
|
374
|
+
if (!body) throw new Error("\u6E32\u67D3\u9875\u9762\u7ED3\u6784\u9519\u8BEF");
|
|
375
|
+
return body;
|
|
376
|
+
}
|
|
377
|
+
function setFooter(page, current, total) {
|
|
378
|
+
const footer = page.querySelector(".ws-md-footer");
|
|
379
|
+
if (!footer) return;
|
|
380
|
+
footer.replaceChildren(span("Article Publish"), span(`${current} / ${total}`));
|
|
381
|
+
}
|
|
382
|
+
async function renderCardToDataUrl(page, config) {
|
|
383
|
+
const canvas = await html2canvas(page, {
|
|
384
|
+
backgroundColor: config.theme.colors.background,
|
|
385
|
+
width: config.width,
|
|
386
|
+
height: config.height,
|
|
387
|
+
scale: config.scale,
|
|
388
|
+
useCORS: true,
|
|
389
|
+
allowTaint: false,
|
|
390
|
+
logging: false,
|
|
391
|
+
windowWidth: config.width,
|
|
392
|
+
windowHeight: config.height
|
|
393
|
+
});
|
|
394
|
+
return canvas.toDataURL("image/png");
|
|
395
|
+
}
|
|
396
|
+
function applyTheme(card, theme) {
|
|
397
|
+
card.style.setProperty("--ws-color-background", theme.colors.background);
|
|
398
|
+
card.style.setProperty("--ws-color-text", theme.colors.text);
|
|
399
|
+
card.style.setProperty("--ws-color-heading", theme.colors.heading);
|
|
400
|
+
card.style.setProperty("--ws-color-muted", theme.colors.muted);
|
|
401
|
+
card.style.setProperty("--ws-color-accent", theme.colors.accent);
|
|
402
|
+
card.style.setProperty("--ws-color-mark", theme.colors.mark);
|
|
403
|
+
card.style.setProperty("--ws-color-subtle", theme.colors.subtle);
|
|
404
|
+
card.style.setProperty("--ws-color-border", theme.colors.border);
|
|
405
|
+
card.style.setProperty("--ws-color-code-text", theme.colors.codeText);
|
|
406
|
+
card.style.setProperty("--ws-color-code-background", theme.colors.codeBackground);
|
|
407
|
+
}
|
|
408
|
+
function span(text) {
|
|
409
|
+
const element = document.createElement("span");
|
|
410
|
+
element.textContent = text;
|
|
411
|
+
return element;
|
|
412
|
+
}
|
|
413
|
+
function ensureCardStyle() {
|
|
414
|
+
if (document.getElementById(STYLE_ELEMENT_ID)) return;
|
|
415
|
+
const style = document.createElement("style");
|
|
416
|
+
style.id = STYLE_ELEMENT_ID;
|
|
417
|
+
style.textContent = CARD_CSS;
|
|
418
|
+
document.head.appendChild(style);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// src/converter/index.ts
|
|
422
|
+
chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
|
|
423
|
+
if (message.type !== "RENDER_MARKDOWN_TO_IMAGES" || message.target !== "markdown-image-converter") {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
renderMarkdownToImages(message.payload).then((images) => sendResponse({ requestId: message.requestId, images })).catch((error) => sendResponse({
|
|
427
|
+
requestId: message.requestId,
|
|
428
|
+
error: error instanceof Error ? error.message : String(error)
|
|
429
|
+
}));
|
|
430
|
+
return true;
|
|
431
|
+
});
|
|
432
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/converter/markdown-renderer.ts","../../src/converter/index.ts"],"sourcesContent":["import { markdownToHtml } from '../lib'\nimport html2canvas from 'html2canvas'\n\nexport interface MarkdownImageRenderRequest {\n markdown: string\n title?: string\n theme?: string\n width?: number\n height?: number\n scale?: number\n maxPages?: number\n}\n\nexport interface MarkdownImageRenderOutput {\n src: string\n width: number\n height: number\n index: number\n}\n\ninterface RenderConfig {\n title: string\n markdown: string\n theme: RenderTheme\n width: number\n height: number\n scale: number\n maxPages: number\n}\n\ninterface RenderTheme {\n colors: {\n background: string\n text: string\n heading: string\n muted: string\n accent: string\n mark: string\n subtle: string\n border: string\n codeText: string\n codeBackground: string\n }\n}\n\nconst DEFAULT_WIDTH = 1080\nconst DEFAULT_HEIGHT = 1440\nconst DEFAULT_SCALE = 1\nconst DEFAULT_MAX_PAGES = 12\nconst DEFAULT_THEME = 'clean'\nconst STYLE_ELEMENT_ID = 'ws-markdown-image-renderer-style'\n\nconst THEMES: Record<string, RenderTheme> = {\n clean: {\n colors: {\n background: '#fbfaf7',\n text: '#1d2433',\n heading: '#111827',\n muted: '#6d7480',\n accent: '#2f6f73',\n mark: '#d7a84f',\n subtle: '#f0eee7',\n border: '#ded8c8',\n codeText: '#8a4b17',\n codeBackground: '#f3ead9',\n },\n },\n}\n\nconst CARD_CSS = `\n* {\n box-sizing: border-box;\n}\n\n.ws-md-card {\n width: var(--ws-card-width);\n height: var(--ws-card-height);\n color: var(--ws-color-text);\n background: var(--ws-color-background);\n font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft YaHei\", Arial, sans-serif;\n display: flex;\n flex-direction: column;\n padding: 68px 76px 54px;\n position: relative;\n overflow: hidden;\n}\n\n.ws-md-card::before {\n content: \"\";\n position: absolute;\n left: 0;\n top: 0;\n width: 16px;\n height: 100%;\n background: var(--ws-color-accent);\n}\n\n.ws-md-card::after {\n content: \"\";\n position: absolute;\n right: 76px;\n top: 0;\n width: 116px;\n height: 12px;\n background: var(--ws-color-mark);\n}\n\n.ws-md-page {\n flex: 1;\n min-height: 0;\n overflow: hidden;\n}\n\n.ws-md-footer {\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 24px;\n padding-top: 24px;\n color: var(--ws-color-muted);\n font-size: 24px;\n line-height: 1;\n border-top: 1px solid var(--ws-color-border);\n}\n\n.ws-md-footer span:first-child {\n color: var(--ws-color-accent);\n font-weight: 700;\n}\n\n.ws-md-title {\n margin: 0 0 28px;\n color: var(--ws-color-heading);\n font-size: 58px;\n line-height: 1.16;\n font-weight: 800;\n letter-spacing: 0;\n}\n\n.ws-md-content {\n font-size: 33px;\n line-height: 1.72;\n letter-spacing: 0;\n}\n\n.ws-md-content h1,\n.ws-md-content h2,\n.ws-md-content h3 {\n color: var(--ws-color-heading);\n line-height: 1.22;\n letter-spacing: 0;\n}\n\n.ws-md-content h1 {\n font-size: 48px;\n margin: 0 0 24px;\n}\n\n.ws-md-content h2 {\n font-size: 42px;\n margin: 28px 0 16px;\n padding-left: 18px;\n border-left: 8px solid var(--ws-color-accent);\n}\n\n.ws-md-content h3 {\n font-size: 36px;\n margin: 24px 0 12px;\n}\n\n.ws-md-content p {\n margin: 0 0 20px;\n}\n\n.ws-md-content strong {\n color: var(--ws-color-heading);\n font-weight: 800;\n}\n\n.ws-md-content em {\n color: var(--ws-color-accent);\n font-style: normal;\n font-weight: 700;\n}\n\n.ws-md-content ul,\n.ws-md-content ol {\n margin: 0 0 22px;\n padding-left: 40px;\n}\n\n.ws-md-content li {\n margin: 8px 0;\n padding-left: 4px;\n}\n\n.ws-md-content blockquote {\n margin: 24px 0;\n padding: 20px 28px;\n color: var(--ws-color-text);\n background: var(--ws-color-subtle);\n border-left: 8px solid var(--ws-color-accent);\n}\n\n.ws-md-content code {\n color: var(--ws-color-code-text);\n background: var(--ws-color-code-background);\n border-radius: 6px;\n padding: 3px 8px;\n font-family: \"SFMono-Regular\", Consolas, \"Liberation Mono\", Menlo, monospace;\n font-size: 0.86em;\n}\n\n.ws-md-content pre {\n margin: 22px 0;\n padding: 22px 24px;\n color: var(--ws-color-text);\n background: var(--ws-color-subtle);\n border: 1px solid var(--ws-color-border);\n border-radius: 10px;\n overflow: hidden;\n white-space: pre-wrap;\n}\n\n.ws-md-content pre code {\n padding: 0;\n color: inherit;\n background: transparent;\n font-size: 26px;\n line-height: 1.55;\n}\n\n.ws-md-content table {\n width: 100%;\n border-collapse: collapse;\n margin: 24px 0;\n font-size: 26px;\n}\n\n.ws-md-content th,\n.ws-md-content td {\n border: 1px solid var(--ws-color-border);\n padding: 12px 14px;\n text-align: left;\n vertical-align: top;\n}\n\n.ws-md-content th {\n color: var(--ws-color-heading);\n background: var(--ws-color-subtle);\n}\n\n.ws-md-image-placeholder {\n margin: 22px 0;\n padding: 18px 22px;\n color: var(--ws-color-muted);\n background: var(--ws-color-subtle);\n border: 1px dashed var(--ws-color-border);\n border-radius: 10px;\n font-size: 26px;\n}\n`\n\nexport async function renderMarkdownToImages(\n request: MarkdownImageRenderRequest,\n): Promise<MarkdownImageRenderOutput[]> {\n const config = normalizeRequest(request)\n ensureCardStyle()\n const stage = createStage(config)\n document.body.appendChild(stage)\n\n try {\n const pages = paginateMarkdown(config, stage)\n await document.fonts?.ready\n\n const outputs: MarkdownImageRenderOutput[] = []\n for (let i = 0; i < pages.length; i += 1) {\n setFooter(pages[i], i + 1, pages.length)\n outputs.push({\n src: await renderCardToDataUrl(pages[i], config),\n width: config.width * config.scale,\n height: config.height * config.scale,\n index: i,\n })\n }\n return outputs\n } finally {\n stage.remove()\n }\n}\n\nfunction normalizeRequest(request: MarkdownImageRenderRequest): RenderConfig {\n const markdown = request.markdown?.trim()\n if (!markdown) {\n throw new Error('Markdown 内容为空,无法生成图文图片')\n }\n\n return {\n title: request.title?.trim() || '',\n markdown,\n theme: resolveTheme(request.theme),\n width: clampInteger(request.width, 720, 1600, DEFAULT_WIDTH),\n height: clampInteger(request.height, 960, 2400, DEFAULT_HEIGHT),\n scale: clampInteger(request.scale, 1, 3, DEFAULT_SCALE),\n maxPages: clampInteger(request.maxPages, 1, 35, DEFAULT_MAX_PAGES),\n }\n}\n\nfunction resolveTheme(theme: string | undefined): RenderTheme {\n return THEMES[theme || DEFAULT_THEME] || THEMES[DEFAULT_THEME]\n}\n\nfunction clampInteger(value: number | undefined, min: number, max: number, fallback: number): number {\n if (!Number.isFinite(value)) return fallback\n return Math.max(min, Math.min(max, Math.round(value as number)))\n}\n\nfunction createStage(config: RenderConfig): HTMLDivElement {\n const stage = document.createElement('div')\n stage.style.cssText = [\n 'position: fixed',\n 'left: 0',\n 'top: 0',\n `width: ${config.width}px`,\n 'background: transparent',\n 'pointer-events: none',\n 'z-index: 2147483647',\n ].join(';')\n return stage\n}\n\nfunction paginateMarkdown(config: RenderConfig, stage: HTMLElement): HTMLElement[] {\n const nodes = createArticleNodes(config)\n const pages: HTMLElement[] = []\n let page = createPage(config)\n let body = getPageBody(page)\n stage.appendChild(page)\n pages.push(page)\n\n for (const sourceNode of nodes) {\n const node = sourceNode.cloneNode(true)\n body.appendChild(node)\n\n if (body.scrollHeight > body.clientHeight && body.childNodes.length > 1) {\n body.removeChild(node)\n if (pages.length >= config.maxPages) {\n throw new Error(`Markdown 内容超过 ${config.maxPages} 张图的限制`)\n }\n page = createPage(config)\n body = getPageBody(page)\n stage.appendChild(page)\n pages.push(page)\n body.appendChild(node)\n }\n }\n\n return pages\n}\n\nfunction createArticleNodes(config: RenderConfig): Node[] {\n const nodes: Node[] = []\n if (config.title) {\n const title = document.createElement('h1')\n title.className = 'ws-md-title'\n title.textContent = config.title\n nodes.push(title)\n }\n\n const content = document.createElement('div')\n content.className = 'ws-md-content'\n content.innerHTML = sanitizeHtml(markdownToHtml(config.markdown))\n\n for (const child of Array.from(content.childNodes)) {\n if (child.nodeType === Node.TEXT_NODE && !child.textContent?.trim()) continue\n nodes.push(child)\n }\n return nodes\n}\n\nfunction sanitizeHtml(html: string): string {\n const template = document.createElement('template')\n template.innerHTML = html\n\n template.content\n .querySelectorAll('script, style, iframe, object, embed, link, meta, form, input, button, svg, video, audio')\n .forEach((node) => node.remove())\n\n template.content.querySelectorAll('img').forEach((img) => {\n const placeholder = document.createElement('div')\n placeholder.className = 'ws-md-image-placeholder'\n const alt = img.getAttribute('alt')?.trim()\n placeholder.textContent = alt ? `图片占位:${alt}` : '图片占位'\n img.replaceWith(placeholder)\n })\n\n const walker = document.createTreeWalker(template.content, NodeFilter.SHOW_ELEMENT)\n const elements: Element[] = []\n while (walker.nextNode()) {\n elements.push(walker.currentNode as Element)\n }\n\n for (const element of elements) {\n for (const attr of Array.from(element.attributes)) {\n const name = attr.name.toLowerCase()\n const value = attr.value.trim().toLowerCase()\n if (name.startsWith('on') || name === 'style') {\n element.removeAttribute(attr.name)\n }\n if ((name === 'href' || name === 'src') && value.startsWith('javascript:')) {\n element.removeAttribute(attr.name)\n }\n }\n }\n\n return Array.from(template.content.childNodes)\n .map((node) => {\n const container = document.createElement('div')\n container.appendChild(node.cloneNode(true))\n return container.innerHTML\n })\n .join('')\n}\n\nfunction createPage(config: RenderConfig): HTMLElement {\n const card = document.createElement('article')\n card.className = 'ws-md-card'\n card.style.setProperty('--ws-card-width', `${config.width}px`)\n card.style.setProperty('--ws-card-height', `${config.height}px`)\n applyTheme(card, config.theme)\n card.style.width = `${config.width}px`\n card.style.height = `${config.height}px`\n\n const body = document.createElement('div')\n body.className = 'ws-md-page ws-md-content'\n card.appendChild(body)\n\n const footer = document.createElement('footer')\n footer.className = 'ws-md-footer'\n card.appendChild(footer)\n\n return card\n}\n\nfunction getPageBody(page: HTMLElement): HTMLElement {\n const body = page.querySelector<HTMLElement>('.ws-md-page')\n if (!body) throw new Error('渲染页面结构错误')\n return body\n}\n\nfunction setFooter(page: HTMLElement, current: number, total: number): void {\n const footer = page.querySelector<HTMLElement>('.ws-md-footer')\n if (!footer) return\n footer.replaceChildren(span('Article Publish'), span(`${current} / ${total}`))\n}\n\nasync function renderCardToDataUrl(page: HTMLElement, config: RenderConfig): Promise<string> {\n const canvas = await html2canvas(page, {\n backgroundColor: config.theme.colors.background,\n width: config.width,\n height: config.height,\n scale: config.scale,\n useCORS: true,\n allowTaint: false,\n logging: false,\n windowWidth: config.width,\n windowHeight: config.height,\n })\n return canvas.toDataURL('image/png')\n}\n\nfunction applyTheme(card: HTMLElement, theme: RenderTheme): void {\n card.style.setProperty('--ws-color-background', theme.colors.background)\n card.style.setProperty('--ws-color-text', theme.colors.text)\n card.style.setProperty('--ws-color-heading', theme.colors.heading)\n card.style.setProperty('--ws-color-muted', theme.colors.muted)\n card.style.setProperty('--ws-color-accent', theme.colors.accent)\n card.style.setProperty('--ws-color-mark', theme.colors.mark)\n card.style.setProperty('--ws-color-subtle', theme.colors.subtle)\n card.style.setProperty('--ws-color-border', theme.colors.border)\n card.style.setProperty('--ws-color-code-text', theme.colors.codeText)\n card.style.setProperty('--ws-color-code-background', theme.colors.codeBackground)\n}\n\nfunction span(text: string): HTMLSpanElement {\n const element = document.createElement('span')\n element.textContent = text\n return element\n}\n\nfunction ensureCardStyle(): void {\n if (document.getElementById(STYLE_ELEMENT_ID)) return\n const style = document.createElement('style')\n style.id = STYLE_ELEMENT_ID\n style.textContent = CARD_CSS\n document.head.appendChild(style)\n}\n","import { renderMarkdownToImages, type MarkdownImageRenderRequest } from './markdown-renderer'\n\ninterface RenderMessage {\n type: 'RENDER_MARKDOWN_TO_IMAGES'\n target?: 'markdown-image-converter'\n requestId?: string\n payload: MarkdownImageRenderRequest\n}\n\nchrome.runtime.onMessage.addListener((message: RenderMessage, _sender, sendResponse) => {\n if (message.type !== 'RENDER_MARKDOWN_TO_IMAGES' || message.target !== 'markdown-image-converter') {\n return false\n }\n\n renderMarkdownToImages(message.payload)\n .then((images) => sendResponse({ requestId: message.requestId, images }))\n .catch((error) => sendResponse({\n requestId: message.requestId,\n error: error instanceof Error ? error.message : String(error),\n }))\n\n return true\n})\n"],"mappings":";;;;;;AACA,OAAO,iBAAiB;AA4CxB,IAAM,gBAAgB;AACtB,IAAM,iBAAiB;AACvB,IAAM,gBAAgB;AACtB,IAAM,oBAAoB;AAC1B,IAAM,gBAAgB;AACtB,IAAM,mBAAmB;AAEzB,IAAM,SAAsC;AAAA,EAC1C,OAAO;AAAA,IACL,QAAQ;AAAA,MACN,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAA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,MAAM,CAAC,UAAU,aAAa;AAAA,IAC7B,WAAW,QAAQ;AAAA,IACnB,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,EAC9D,CAAC,CAAC;AAEJ,SAAO;AACT,CAAC;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { R as RuntimeInterface, c as PublishStatusRef, a as Article, b as PublishEventHandler, A as AuthResult, d as PublishStatusResult, e as PublishResult } from './interface-BlLeWXzS.js';
|
|
2
|
+
export { M as MarkdownImageRenderOptions, f as MarkdownImageRenderResult, g as PublishError, h as PublishEvent, i as PublishState, j as PublishStatusState, k as RuntimeConfig } from './interface-BlLeWXzS.js';
|
|
3
|
+
import { I as ImageProgressCallback } from './types-BAnNlLpy.js';
|
|
4
|
+
export { createExtensionRuntime } from './runtime/index.js';
|
|
5
|
+
|
|
6
|
+
interface PublishArticleInput {
|
|
7
|
+
title: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
body?: string;
|
|
10
|
+
content?: string;
|
|
11
|
+
markdown?: string;
|
|
12
|
+
html?: string;
|
|
13
|
+
cover?: string;
|
|
14
|
+
tags?: string[];
|
|
15
|
+
category?: string;
|
|
16
|
+
source?: Article['source'];
|
|
17
|
+
}
|
|
18
|
+
interface PublishRequestOptions {
|
|
19
|
+
onImageProgress?: ImageProgressCallback;
|
|
20
|
+
}
|
|
21
|
+
interface PublishRequest {
|
|
22
|
+
platform: string;
|
|
23
|
+
article: Article | PublishArticleInput;
|
|
24
|
+
runtime: RuntimeInterface;
|
|
25
|
+
onEvent?: PublishEventHandler;
|
|
26
|
+
options?: PublishRequestOptions;
|
|
27
|
+
}
|
|
28
|
+
interface GetStatusRequest {
|
|
29
|
+
platform: string;
|
|
30
|
+
runtime: RuntimeInterface;
|
|
31
|
+
statusRef: PublishStatusRef;
|
|
32
|
+
}
|
|
33
|
+
interface CheckAuthRequest {
|
|
34
|
+
platform: string;
|
|
35
|
+
runtime: RuntimeInterface;
|
|
36
|
+
}
|
|
37
|
+
declare function publish(request: PublishRequest): Promise<PublishResult>;
|
|
38
|
+
declare function checkAuth(request: CheckAuthRequest): Promise<AuthResult>;
|
|
39
|
+
declare function getStatus(request: GetStatusRequest): Promise<PublishStatusResult>;
|
|
40
|
+
|
|
41
|
+
declare const VERSION = "1.0.0";
|
|
42
|
+
|
|
43
|
+
export { Article, AuthResult, type CheckAuthRequest, type GetStatusRequest, type PublishArticleInput, PublishEventHandler, type PublishRequest, type PublishRequestOptions, PublishResult, PublishStatusRef, PublishStatusResult, RuntimeInterface, VERSION, checkAuth, getStatus, publish };
|