@open-file-viewer/core 0.1.23 → 0.1.24
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 +9 -0
- package/dist/cpp-EDJNJWGR.js +4 -0
- package/dist/cpp-EDJNJWGR.js.map +1 -0
- package/dist/index.cjs +254 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +195 -97
- package/dist/index.js.map +1 -1
- package/dist/json5-EAGAEIPM.js +4 -0
- package/dist/json5-EAGAEIPM.js.map +1 -0
- package/dist/php-TTFBGZ5Q.js +4 -0
- package/dist/php-TTFBGZ5Q.js.map +1 -0
- package/dist/scala-V5QQ35QA.js +4 -0
- package/dist/scala-V5QQ35QA.js.map +1 -0
- package/dist/tsx-A26VGWUK.js +5 -0
- package/dist/tsx-A26VGWUK.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,6 +24,15 @@ PDF preview requires `pdfjs-dist`:
|
|
|
24
24
|
npm install pdfjs-dist
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
### Vite / Rollup dependency chunks
|
|
28
|
+
|
|
29
|
+
Text grammars, Markdown, and email parsers load asynchronously when their plugins are first used.
|
|
30
|
+
Prism language chunks are loaded in dependency order, so applications do not need to preload parent
|
|
31
|
+
grammars such as Java before Scala. In monorepos, `resolve.dedupe: ["prismjs"]` prevents duplicate
|
|
32
|
+
Prism runtimes. Keep `/prismjs/components/` out of catch-all vendor `manualChunks` rules so the
|
|
33
|
+
side-effectful language modules remain separate on-demand chunks and execute in dependency order.
|
|
34
|
+
`postal-mime` and `@kenjiuno/msgreader` may optionally share an `ofv-email` chunk.
|
|
35
|
+
|
|
27
36
|
DWG geometry preview uses optional LibreDWG WASM. The package can be installed by applications that want the default built-in DWG linework path:
|
|
28
37
|
|
|
29
38
|
```bash
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/plugins/prism-languages/cpp.ts"],"sourcesContent":["import \"prismjs/components/prism-c\";\nimport \"prismjs/components/prism-cpp\";\n"],"mappings":";AAAA,OAAO;AACP,OAAO;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -27,6 +30,62 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
30
|
));
|
|
28
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
32
|
|
|
33
|
+
// src/plugins/prism-languages/tsx.ts
|
|
34
|
+
var tsx_exports = {};
|
|
35
|
+
var import_prism_jsx, import_prism_typescript, import_prism_tsx;
|
|
36
|
+
var init_tsx = __esm({
|
|
37
|
+
"src/plugins/prism-languages/tsx.ts"() {
|
|
38
|
+
"use strict";
|
|
39
|
+
import_prism_jsx = require("prismjs/components/prism-jsx");
|
|
40
|
+
import_prism_typescript = require("prismjs/components/prism-typescript");
|
|
41
|
+
import_prism_tsx = require("prismjs/components/prism-tsx");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// src/plugins/prism-languages/json5.ts
|
|
46
|
+
var json5_exports = {};
|
|
47
|
+
var import_prism_json, import_prism_json5;
|
|
48
|
+
var init_json5 = __esm({
|
|
49
|
+
"src/plugins/prism-languages/json5.ts"() {
|
|
50
|
+
"use strict";
|
|
51
|
+
import_prism_json = require("prismjs/components/prism-json");
|
|
52
|
+
import_prism_json5 = require("prismjs/components/prism-json5");
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// src/plugins/prism-languages/scala.ts
|
|
57
|
+
var scala_exports = {};
|
|
58
|
+
var import_prism_java, import_prism_scala;
|
|
59
|
+
var init_scala = __esm({
|
|
60
|
+
"src/plugins/prism-languages/scala.ts"() {
|
|
61
|
+
"use strict";
|
|
62
|
+
import_prism_java = require("prismjs/components/prism-java");
|
|
63
|
+
import_prism_scala = require("prismjs/components/prism-scala");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// src/plugins/prism-languages/cpp.ts
|
|
68
|
+
var cpp_exports = {};
|
|
69
|
+
var import_prism_c, import_prism_cpp;
|
|
70
|
+
var init_cpp = __esm({
|
|
71
|
+
"src/plugins/prism-languages/cpp.ts"() {
|
|
72
|
+
"use strict";
|
|
73
|
+
import_prism_c = require("prismjs/components/prism-c");
|
|
74
|
+
import_prism_cpp = require("prismjs/components/prism-cpp");
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// src/plugins/prism-languages/php.ts
|
|
79
|
+
var php_exports = {};
|
|
80
|
+
var import_prism_markup_templating, import_prism_php;
|
|
81
|
+
var init_php = __esm({
|
|
82
|
+
"src/plugins/prism-languages/php.ts"() {
|
|
83
|
+
"use strict";
|
|
84
|
+
import_prism_markup_templating = require("prismjs/components/prism-markup-templating");
|
|
85
|
+
import_prism_php = require("prismjs/components/prism-php");
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
30
89
|
// src/index.ts
|
|
31
90
|
var index_exports = {};
|
|
32
91
|
__export(index_exports, {
|
|
@@ -4291,6 +4350,7 @@ var mimeLangMap = {
|
|
|
4291
4350
|
};
|
|
4292
4351
|
var MAX_HIGHLIGHT_CHARS = 18e4;
|
|
4293
4352
|
var MAX_RENDER_CHARS = 6e5;
|
|
4353
|
+
var prismLanguageLoads = /* @__PURE__ */ new Map();
|
|
4294
4354
|
function textPlugin() {
|
|
4295
4355
|
return {
|
|
4296
4356
|
name: "text",
|
|
@@ -4322,10 +4382,10 @@ function textPlugin() {
|
|
|
4322
4382
|
]);
|
|
4323
4383
|
const parseMarkdown = markedModule.marked?.parse || markedModule.parse || markedModule.default?.parse;
|
|
4324
4384
|
const Prism2 = PrismModule2.default || PrismModule2;
|
|
4325
|
-
const
|
|
4385
|
+
const DOMPurify3 = DOMPurifyModule.default || DOMPurifyModule;
|
|
4326
4386
|
const container = document.createElement("div");
|
|
4327
4387
|
container.className = "ofv-markdown-body";
|
|
4328
|
-
container.innerHTML =
|
|
4388
|
+
container.innerHTML = DOMPurify3.sanitize(parseMarkdown(text), {
|
|
4329
4389
|
USE_PROFILES: { html: true },
|
|
4330
4390
|
ADD_ATTR: ["target"]
|
|
4331
4391
|
});
|
|
@@ -4334,6 +4394,14 @@ function textPlugin() {
|
|
|
4334
4394
|
try {
|
|
4335
4395
|
const codeBlocks = container.querySelectorAll("pre code");
|
|
4336
4396
|
if (codeBlocks.length > 0) {
|
|
4397
|
+
const languages = /* @__PURE__ */ new Set();
|
|
4398
|
+
codeBlocks.forEach((block) => {
|
|
4399
|
+
const language = getPrismLanguageFromElement(block) || getPrismLanguageFromElement(block.parentElement);
|
|
4400
|
+
if (language) {
|
|
4401
|
+
languages.add(language);
|
|
4402
|
+
}
|
|
4403
|
+
});
|
|
4404
|
+
await Promise.all([...languages].map((language) => loadPrismLanguage(language)));
|
|
4337
4405
|
codeBlocks.forEach((block) => {
|
|
4338
4406
|
const parent = block.parentElement;
|
|
4339
4407
|
if (parent && !parent.className.includes("language-")) {
|
|
@@ -4362,97 +4430,7 @@ function textPlugin() {
|
|
|
4362
4430
|
const Prism = PrismModule.default || PrismModule;
|
|
4363
4431
|
if (lang !== "none") {
|
|
4364
4432
|
try {
|
|
4365
|
-
|
|
4366
|
-
await import("prismjs/components/prism-typescript");
|
|
4367
|
-
} else if (lang === "python") {
|
|
4368
|
-
await import("prismjs/components/prism-python");
|
|
4369
|
-
} else if (lang === "json") {
|
|
4370
|
-
await import("prismjs/components/prism-json");
|
|
4371
|
-
} else if (lang === "json5") {
|
|
4372
|
-
await import("prismjs/components/prism-json5");
|
|
4373
|
-
} else if (lang === "yaml") {
|
|
4374
|
-
await import("prismjs/components/prism-yaml");
|
|
4375
|
-
} else if (lang === "toml") {
|
|
4376
|
-
await import("prismjs/components/prism-toml");
|
|
4377
|
-
} else if (lang === "ini") {
|
|
4378
|
-
await import("prismjs/components/prism-ini");
|
|
4379
|
-
} else if (lang === "properties") {
|
|
4380
|
-
await import("prismjs/components/prism-properties");
|
|
4381
|
-
} else if (lang === "editorconfig") {
|
|
4382
|
-
await import("prismjs/components/prism-editorconfig");
|
|
4383
|
-
} else if (lang === "ignore") {
|
|
4384
|
-
await import("prismjs/components/prism-ignore");
|
|
4385
|
-
} else if (lang === "protobuf") {
|
|
4386
|
-
await import("prismjs/components/prism-protobuf");
|
|
4387
|
-
} else if (lang === "hcl") {
|
|
4388
|
-
await import("prismjs/components/prism-hcl");
|
|
4389
|
-
} else if (lang === "latex") {
|
|
4390
|
-
await import("prismjs/components/prism-latex");
|
|
4391
|
-
} else if (lang === "dot") {
|
|
4392
|
-
await import("prismjs/components/prism-dot");
|
|
4393
|
-
} else if (lang === "http") {
|
|
4394
|
-
await import("prismjs/components/prism-http");
|
|
4395
|
-
} else if (lang === "bash") {
|
|
4396
|
-
await import("prismjs/components/prism-bash");
|
|
4397
|
-
} else if (lang === "powershell") {
|
|
4398
|
-
await import("prismjs/components/prism-powershell");
|
|
4399
|
-
} else if (lang === "batch") {
|
|
4400
|
-
await import("prismjs/components/prism-batch");
|
|
4401
|
-
} else if (lang === "docker") {
|
|
4402
|
-
await import("prismjs/components/prism-docker");
|
|
4403
|
-
} else if (lang === "makefile") {
|
|
4404
|
-
await import("prismjs/components/prism-makefile");
|
|
4405
|
-
} else if (lang === "ruby") {
|
|
4406
|
-
await import("prismjs/components/prism-ruby");
|
|
4407
|
-
} else if (lang === "nginx") {
|
|
4408
|
-
await import("prismjs/components/prism-nginx");
|
|
4409
|
-
} else if (lang === "groovy") {
|
|
4410
|
-
await import("prismjs/components/prism-groovy");
|
|
4411
|
-
} else if (lang === "graphql") {
|
|
4412
|
-
await import("prismjs/components/prism-graphql");
|
|
4413
|
-
} else if (lang === "csharp") {
|
|
4414
|
-
await import("prismjs/components/prism-csharp");
|
|
4415
|
-
} else if (lang === "rust") {
|
|
4416
|
-
await import("prismjs/components/prism-rust");
|
|
4417
|
-
} else if (lang === "go") {
|
|
4418
|
-
await import("prismjs/components/prism-go");
|
|
4419
|
-
} else if (lang === "ruby") {
|
|
4420
|
-
await import("prismjs/components/prism-ruby");
|
|
4421
|
-
} else if (lang === "swift") {
|
|
4422
|
-
await import("prismjs/components/prism-swift");
|
|
4423
|
-
} else if (lang === "kotlin") {
|
|
4424
|
-
await import("prismjs/components/prism-kotlin");
|
|
4425
|
-
} else if (lang === "scala") {
|
|
4426
|
-
await import("prismjs/components/prism-scala");
|
|
4427
|
-
} else if (lang === "lua") {
|
|
4428
|
-
await import("prismjs/components/prism-lua");
|
|
4429
|
-
} else if (lang === "r") {
|
|
4430
|
-
await import("prismjs/components/prism-r");
|
|
4431
|
-
} else if (lang === "dart") {
|
|
4432
|
-
await import("prismjs/components/prism-dart");
|
|
4433
|
-
} else if (lang === "elm") {
|
|
4434
|
-
await import("prismjs/components/prism-elm");
|
|
4435
|
-
} else if (lang === "elixir") {
|
|
4436
|
-
await import("prismjs/components/prism-elixir");
|
|
4437
|
-
} else if (lang === "clojure") {
|
|
4438
|
-
await import("prismjs/components/prism-clojure");
|
|
4439
|
-
} else if (lang === "erlang") {
|
|
4440
|
-
await import("prismjs/components/prism-erlang");
|
|
4441
|
-
} else if (lang === "fsharp") {
|
|
4442
|
-
await import("prismjs/components/prism-fsharp");
|
|
4443
|
-
} else if (lang === "haskell") {
|
|
4444
|
-
await import("prismjs/components/prism-haskell");
|
|
4445
|
-
} else if (lang === "sql") {
|
|
4446
|
-
await import("prismjs/components/prism-sql");
|
|
4447
|
-
} else if (lang === "cpp") {
|
|
4448
|
-
await import("prismjs/components/prism-c");
|
|
4449
|
-
await import("prismjs/components/prism-cpp");
|
|
4450
|
-
} else if (lang === "java") {
|
|
4451
|
-
await import("prismjs/components/prism-java");
|
|
4452
|
-
} else if (lang === "php") {
|
|
4453
|
-
await import("prismjs/components/prism-markup-templating");
|
|
4454
|
-
await import("prismjs/components/prism-php");
|
|
4455
|
-
}
|
|
4433
|
+
await loadPrismLanguage(lang);
|
|
4456
4434
|
} catch (e) {
|
|
4457
4435
|
console.warn(`Prism failed to load language component for: ${lang}`, e);
|
|
4458
4436
|
}
|
|
@@ -4577,6 +4555,183 @@ function textPlugin() {
|
|
|
4577
4555
|
}
|
|
4578
4556
|
};
|
|
4579
4557
|
}
|
|
4558
|
+
function getPrismLanguageFromElement(element) {
|
|
4559
|
+
if (!element) {
|
|
4560
|
+
return void 0;
|
|
4561
|
+
}
|
|
4562
|
+
for (const className of element.classList) {
|
|
4563
|
+
if (className.startsWith("language-") && className.length > 9) {
|
|
4564
|
+
return className.slice(9).toLowerCase();
|
|
4565
|
+
}
|
|
4566
|
+
}
|
|
4567
|
+
return void 0;
|
|
4568
|
+
}
|
|
4569
|
+
async function loadPrismLanguage(language) {
|
|
4570
|
+
if (["none", "plain", "plaintext", "text", "markup", "css", "clike", "javascript"].includes(language)) {
|
|
4571
|
+
return;
|
|
4572
|
+
}
|
|
4573
|
+
const existing = prismLanguageLoads.get(language);
|
|
4574
|
+
if (existing) {
|
|
4575
|
+
return existing;
|
|
4576
|
+
}
|
|
4577
|
+
const loading = loadPrismLanguageComponent(language).catch((error) => {
|
|
4578
|
+
prismLanguageLoads.delete(language);
|
|
4579
|
+
throw error;
|
|
4580
|
+
});
|
|
4581
|
+
prismLanguageLoads.set(language, loading);
|
|
4582
|
+
return loading;
|
|
4583
|
+
}
|
|
4584
|
+
async function loadPrismLanguageComponent(language) {
|
|
4585
|
+
switch (language) {
|
|
4586
|
+
case "typescript":
|
|
4587
|
+
await import("prismjs/components/prism-typescript");
|
|
4588
|
+
break;
|
|
4589
|
+
case "jsx":
|
|
4590
|
+
await import("prismjs/components/prism-jsx");
|
|
4591
|
+
break;
|
|
4592
|
+
case "tsx":
|
|
4593
|
+
await Promise.resolve().then(() => (init_tsx(), tsx_exports));
|
|
4594
|
+
break;
|
|
4595
|
+
case "python":
|
|
4596
|
+
await import("prismjs/components/prism-python");
|
|
4597
|
+
break;
|
|
4598
|
+
case "json":
|
|
4599
|
+
await import("prismjs/components/prism-json");
|
|
4600
|
+
break;
|
|
4601
|
+
case "json5":
|
|
4602
|
+
await Promise.resolve().then(() => (init_json5(), json5_exports));
|
|
4603
|
+
break;
|
|
4604
|
+
case "yaml":
|
|
4605
|
+
await import("prismjs/components/prism-yaml");
|
|
4606
|
+
break;
|
|
4607
|
+
case "toml":
|
|
4608
|
+
await import("prismjs/components/prism-toml");
|
|
4609
|
+
break;
|
|
4610
|
+
case "ini":
|
|
4611
|
+
await import("prismjs/components/prism-ini");
|
|
4612
|
+
break;
|
|
4613
|
+
case "properties":
|
|
4614
|
+
await import("prismjs/components/prism-properties");
|
|
4615
|
+
break;
|
|
4616
|
+
case "editorconfig":
|
|
4617
|
+
await import("prismjs/components/prism-editorconfig");
|
|
4618
|
+
break;
|
|
4619
|
+
case "ignore":
|
|
4620
|
+
await import("prismjs/components/prism-ignore");
|
|
4621
|
+
break;
|
|
4622
|
+
case "protobuf":
|
|
4623
|
+
await import("prismjs/components/prism-protobuf");
|
|
4624
|
+
break;
|
|
4625
|
+
case "hcl":
|
|
4626
|
+
await import("prismjs/components/prism-hcl");
|
|
4627
|
+
break;
|
|
4628
|
+
case "latex":
|
|
4629
|
+
await import("prismjs/components/prism-latex");
|
|
4630
|
+
break;
|
|
4631
|
+
case "dot":
|
|
4632
|
+
await import("prismjs/components/prism-dot");
|
|
4633
|
+
break;
|
|
4634
|
+
case "http":
|
|
4635
|
+
await import("prismjs/components/prism-http");
|
|
4636
|
+
break;
|
|
4637
|
+
case "bash":
|
|
4638
|
+
await import("prismjs/components/prism-bash");
|
|
4639
|
+
break;
|
|
4640
|
+
case "powershell":
|
|
4641
|
+
await import("prismjs/components/prism-powershell");
|
|
4642
|
+
break;
|
|
4643
|
+
case "batch":
|
|
4644
|
+
await import("prismjs/components/prism-batch");
|
|
4645
|
+
break;
|
|
4646
|
+
case "docker":
|
|
4647
|
+
await import("prismjs/components/prism-docker");
|
|
4648
|
+
break;
|
|
4649
|
+
case "makefile":
|
|
4650
|
+
await import("prismjs/components/prism-makefile");
|
|
4651
|
+
break;
|
|
4652
|
+
case "ruby":
|
|
4653
|
+
await import("prismjs/components/prism-ruby");
|
|
4654
|
+
break;
|
|
4655
|
+
case "nginx":
|
|
4656
|
+
await import("prismjs/components/prism-nginx");
|
|
4657
|
+
break;
|
|
4658
|
+
case "groovy":
|
|
4659
|
+
await import("prismjs/components/prism-groovy");
|
|
4660
|
+
break;
|
|
4661
|
+
case "graphql":
|
|
4662
|
+
await import("prismjs/components/prism-graphql");
|
|
4663
|
+
break;
|
|
4664
|
+
case "csharp":
|
|
4665
|
+
await import("prismjs/components/prism-csharp");
|
|
4666
|
+
break;
|
|
4667
|
+
case "rust":
|
|
4668
|
+
await import("prismjs/components/prism-rust");
|
|
4669
|
+
break;
|
|
4670
|
+
case "go":
|
|
4671
|
+
await import("prismjs/components/prism-go");
|
|
4672
|
+
break;
|
|
4673
|
+
case "swift":
|
|
4674
|
+
await import("prismjs/components/prism-swift");
|
|
4675
|
+
break;
|
|
4676
|
+
case "kotlin":
|
|
4677
|
+
await import("prismjs/components/prism-kotlin");
|
|
4678
|
+
break;
|
|
4679
|
+
case "java":
|
|
4680
|
+
await import("prismjs/components/prism-java");
|
|
4681
|
+
break;
|
|
4682
|
+
case "scala":
|
|
4683
|
+
await Promise.resolve().then(() => (init_scala(), scala_exports));
|
|
4684
|
+
break;
|
|
4685
|
+
case "lua":
|
|
4686
|
+
await import("prismjs/components/prism-lua");
|
|
4687
|
+
break;
|
|
4688
|
+
case "r":
|
|
4689
|
+
await import("prismjs/components/prism-r");
|
|
4690
|
+
break;
|
|
4691
|
+
case "dart":
|
|
4692
|
+
await import("prismjs/components/prism-dart");
|
|
4693
|
+
break;
|
|
4694
|
+
case "elm":
|
|
4695
|
+
await import("prismjs/components/prism-elm");
|
|
4696
|
+
break;
|
|
4697
|
+
case "elixir":
|
|
4698
|
+
await import("prismjs/components/prism-elixir");
|
|
4699
|
+
break;
|
|
4700
|
+
case "clojure":
|
|
4701
|
+
await import("prismjs/components/prism-clojure");
|
|
4702
|
+
break;
|
|
4703
|
+
case "erlang":
|
|
4704
|
+
await import("prismjs/components/prism-erlang");
|
|
4705
|
+
break;
|
|
4706
|
+
case "fsharp":
|
|
4707
|
+
await import("prismjs/components/prism-fsharp");
|
|
4708
|
+
break;
|
|
4709
|
+
case "haskell":
|
|
4710
|
+
await import("prismjs/components/prism-haskell");
|
|
4711
|
+
break;
|
|
4712
|
+
case "sql":
|
|
4713
|
+
await import("prismjs/components/prism-sql");
|
|
4714
|
+
break;
|
|
4715
|
+
case "c":
|
|
4716
|
+
await import("prismjs/components/prism-c");
|
|
4717
|
+
break;
|
|
4718
|
+
case "cpp":
|
|
4719
|
+
await Promise.resolve().then(() => (init_cpp(), cpp_exports));
|
|
4720
|
+
break;
|
|
4721
|
+
case "scss":
|
|
4722
|
+
await import("prismjs/components/prism-scss");
|
|
4723
|
+
break;
|
|
4724
|
+
case "less":
|
|
4725
|
+
await import("prismjs/components/prism-less");
|
|
4726
|
+
break;
|
|
4727
|
+
case "markup-templating":
|
|
4728
|
+
await import("prismjs/components/prism-markup-templating");
|
|
4729
|
+
break;
|
|
4730
|
+
case "php":
|
|
4731
|
+
await Promise.resolve().then(() => (init_php(), php_exports));
|
|
4732
|
+
break;
|
|
4733
|
+
}
|
|
4734
|
+
}
|
|
4580
4735
|
function createTextZoomController(target, cssVariable, ctx) {
|
|
4581
4736
|
let zoom = getInitialZoom(ctx, 0.5, 3);
|
|
4582
4737
|
const apply = () => {
|
|
@@ -12988,9 +13143,9 @@ function getIcon(name, dir) {
|
|
|
12988
13143
|
}
|
|
12989
13144
|
|
|
12990
13145
|
// src/plugins/email.ts
|
|
12991
|
-
var import_dompurify3 = __toESM(require("dompurify"), 1);
|
|
12992
13146
|
var emailExtensions = /* @__PURE__ */ new Set(["eml", "msg", "mbox"]);
|
|
12993
13147
|
var emailMimeTypes = /* @__PURE__ */ new Set(["message/rfc822", "application/vnd.ms-outlook", "application/mbox"]);
|
|
13148
|
+
var domPurifyLoader;
|
|
12994
13149
|
var emailMimeFormatMap = {
|
|
12995
13150
|
"message/rfc822": "eml",
|
|
12996
13151
|
"application/vnd.ms-outlook": "msg",
|
|
@@ -13003,6 +13158,8 @@ function emailPlugin() {
|
|
|
13003
13158
|
return emailExtensions.has(file.extension) || emailMimeTypes.has(file.mimeType);
|
|
13004
13159
|
},
|
|
13005
13160
|
async render(ctx) {
|
|
13161
|
+
const DOMPurifyModule = await (domPurifyLoader ||= import("dompurify"));
|
|
13162
|
+
const DOMPurify3 = DOMPurifyModule.default;
|
|
13006
13163
|
const panel = createPanel("ofv-email");
|
|
13007
13164
|
ctx.viewport.append(panel);
|
|
13008
13165
|
const url = createObjectUrl(ctx.file);
|
|
@@ -13136,7 +13293,7 @@ function emailPlugin() {
|
|
|
13136
13293
|
}
|
|
13137
13294
|
});
|
|
13138
13295
|
html = nextHtml;
|
|
13139
|
-
const sanitizedHtml = sanitizeEmailHtml(html);
|
|
13296
|
+
const sanitizedHtml = sanitizeEmailHtml(html, DOMPurify3);
|
|
13140
13297
|
const iframe = document.createElement("iframe");
|
|
13141
13298
|
iframe.className = "ofv-email-body-iframe";
|
|
13142
13299
|
iframe.setAttribute("sandbox", "allow-same-origin allow-popups allow-popups-to-escape-sandbox");
|
|
@@ -13429,8 +13586,8 @@ function getMimeType(name) {
|
|
|
13429
13586
|
};
|
|
13430
13587
|
return ext ? map[ext] || "application/octet-stream" : "application/octet-stream";
|
|
13431
13588
|
}
|
|
13432
|
-
function sanitizeEmailHtml(html) {
|
|
13433
|
-
return
|
|
13589
|
+
function sanitizeEmailHtml(html, purifier) {
|
|
13590
|
+
return purifier.sanitize(html, {
|
|
13434
13591
|
USE_PROFILES: { html: true },
|
|
13435
13592
|
ADD_ATTR: ["target"],
|
|
13436
13593
|
ALLOWED_URI_REGEXP: /^(?:(?:https?|mailto|tel|blob|cid):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))/i
|