@files-preview-app/preview-file 1.3.8 → 1.3.9
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/dist/angular.cjs +374 -124
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.js +374 -124
- package/dist/angular.js.map +1 -1
- package/dist/index.cjs +373 -123
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +373 -123
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +374 -124
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +374 -124
- package/dist/react.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/vue.cjs +374 -124
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +2 -2
- package/dist/vue.d.ts +2 -2
- package/dist/vue.js +374 -124
- package/dist/vue.js.map +1 -1
- package/package.json +1 -1
package/dist/angular.js
CHANGED
|
@@ -1646,19 +1646,85 @@ var FilePreviewViewer = class _FilePreviewViewer {
|
|
|
1646
1646
|
if (this.wrapperEl?.parentNode) {
|
|
1647
1647
|
this.wrapperEl.parentNode.removeChild(this.wrapperEl);
|
|
1648
1648
|
}
|
|
1649
|
+
if (typeof document !== "undefined" && !document.getElementById("fp-core-injected-styles")) {
|
|
1650
|
+
const styleEl = document.createElement("style");
|
|
1651
|
+
styleEl.id = "fp-core-injected-styles";
|
|
1652
|
+
styleEl.textContent = `
|
|
1653
|
+
.fp-viewer {
|
|
1654
|
+
display: flex !important;
|
|
1655
|
+
flex-direction: column !important;
|
|
1656
|
+
width: 100% !important;
|
|
1657
|
+
height: 100% !important;
|
|
1658
|
+
overflow: hidden !important;
|
|
1659
|
+
position: relative !important;
|
|
1660
|
+
box-sizing: border-box !important;
|
|
1661
|
+
}
|
|
1662
|
+
.fp-body {
|
|
1663
|
+
display: flex !important;
|
|
1664
|
+
flex: 1 1 0% !important;
|
|
1665
|
+
min-height: 0 !important;
|
|
1666
|
+
min-width: 0 !important;
|
|
1667
|
+
width: 100% !important;
|
|
1668
|
+
height: 100% !important;
|
|
1669
|
+
overflow: hidden !important;
|
|
1670
|
+
position: relative !important;
|
|
1671
|
+
box-sizing: border-box !important;
|
|
1672
|
+
}
|
|
1673
|
+
.fp-content {
|
|
1674
|
+
flex: 1 1 0% !important;
|
|
1675
|
+
position: relative !important;
|
|
1676
|
+
overflow: auto !important;
|
|
1677
|
+
display: flex !important;
|
|
1678
|
+
flex-direction: column !important;
|
|
1679
|
+
align-items: stretch !important;
|
|
1680
|
+
justify-content: flex-start !important;
|
|
1681
|
+
width: 100% !important;
|
|
1682
|
+
height: 100% !important;
|
|
1683
|
+
min-width: 0 !important;
|
|
1684
|
+
min-height: 0 !important;
|
|
1685
|
+
box-sizing: border-box !important;
|
|
1686
|
+
}
|
|
1687
|
+
`;
|
|
1688
|
+
document.head.appendChild(styleEl);
|
|
1689
|
+
}
|
|
1649
1690
|
const themeClass = options.theme === "dark" ? "fp-theme-dark" : "";
|
|
1650
1691
|
const toolbarPos = options.toolbarPosition ?? "top";
|
|
1651
1692
|
this.wrapperEl = document.createElement("div");
|
|
1652
1693
|
this.wrapperEl.className = `fp-viewer ${themeClass} ${options.className ?? ""}`.trim();
|
|
1653
1694
|
this.wrapperEl.tabIndex = 0;
|
|
1695
|
+
this.wrapperEl.style.display = "flex";
|
|
1696
|
+
this.wrapperEl.style.flexDirection = "column";
|
|
1697
|
+
this.wrapperEl.style.width = "100%";
|
|
1698
|
+
this.wrapperEl.style.height = "100%";
|
|
1699
|
+
this.wrapperEl.style.overflow = "hidden";
|
|
1700
|
+
this.wrapperEl.style.position = "relative";
|
|
1654
1701
|
const toolbarEl = document.createElement("div");
|
|
1655
1702
|
toolbarEl.className = "fp-toolbar-container";
|
|
1656
1703
|
this.contentEl = document.createElement("div");
|
|
1657
1704
|
this.contentEl.className = "fp-content";
|
|
1705
|
+
this.contentEl.style.flex = "1 1 0%";
|
|
1706
|
+
this.contentEl.style.position = "relative";
|
|
1707
|
+
this.contentEl.style.overflow = "auto";
|
|
1708
|
+
this.contentEl.style.display = "flex";
|
|
1709
|
+
this.contentEl.style.flexDirection = "column";
|
|
1710
|
+
this.contentEl.style.alignItems = "stretch";
|
|
1711
|
+
this.contentEl.style.justifyContent = "flex-start";
|
|
1712
|
+
this.contentEl.style.width = "100%";
|
|
1713
|
+
this.contentEl.style.height = "100%";
|
|
1714
|
+
this.contentEl.style.minWidth = "0";
|
|
1715
|
+
this.contentEl.style.minHeight = "0";
|
|
1716
|
+
this.contentEl.style.boxSizing = "border-box";
|
|
1658
1717
|
const thumbnailEl = document.createElement("div");
|
|
1659
1718
|
thumbnailEl.className = "fp-thumbnail-container";
|
|
1660
1719
|
const bodyEl = document.createElement("div");
|
|
1661
1720
|
bodyEl.className = "fp-body";
|
|
1721
|
+
bodyEl.style.display = "flex";
|
|
1722
|
+
bodyEl.style.flex = "1 1 0%";
|
|
1723
|
+
bodyEl.style.minHeight = "0";
|
|
1724
|
+
bodyEl.style.minWidth = "0";
|
|
1725
|
+
bodyEl.style.width = "100%";
|
|
1726
|
+
bodyEl.style.overflow = "hidden";
|
|
1727
|
+
bodyEl.style.position = "relative";
|
|
1662
1728
|
bodyEl.appendChild(thumbnailEl);
|
|
1663
1729
|
bodyEl.appendChild(this.contentEl);
|
|
1664
1730
|
const titleBarEl = document.createElement("div");
|
|
@@ -4452,31 +4518,80 @@ function csvPlugin() {
|
|
|
4452
4518
|
}
|
|
4453
4519
|
var CODE_EXTENSIONS = [
|
|
4454
4520
|
".txt",
|
|
4521
|
+
".log",
|
|
4522
|
+
".ini",
|
|
4523
|
+
".cfg",
|
|
4524
|
+
".conf",
|
|
4525
|
+
".env",
|
|
4455
4526
|
".json",
|
|
4527
|
+
".jsonc",
|
|
4528
|
+
".json5",
|
|
4456
4529
|
".js",
|
|
4457
|
-
".
|
|
4530
|
+
".mjs",
|
|
4531
|
+
".cjs",
|
|
4458
4532
|
".jsx",
|
|
4533
|
+
".ts",
|
|
4534
|
+
".mts",
|
|
4535
|
+
".cts",
|
|
4459
4536
|
".tsx",
|
|
4460
4537
|
".html",
|
|
4538
|
+
".htm",
|
|
4539
|
+
".xhtml",
|
|
4461
4540
|
".css",
|
|
4462
4541
|
".scss",
|
|
4542
|
+
".sass",
|
|
4463
4543
|
".less",
|
|
4464
4544
|
".md",
|
|
4545
|
+
".markdown",
|
|
4465
4546
|
".xml",
|
|
4547
|
+
".svg",
|
|
4548
|
+
".xaml",
|
|
4466
4549
|
".yml",
|
|
4467
4550
|
".yaml",
|
|
4551
|
+
".toml",
|
|
4468
4552
|
".sh",
|
|
4469
4553
|
".bash",
|
|
4554
|
+
".zsh",
|
|
4555
|
+
".fish",
|
|
4556
|
+
".bat",
|
|
4557
|
+
".cmd",
|
|
4558
|
+
".ps1",
|
|
4470
4559
|
".py",
|
|
4560
|
+
".pyw",
|
|
4471
4561
|
".java",
|
|
4562
|
+
".class",
|
|
4472
4563
|
".c",
|
|
4473
4564
|
".cpp",
|
|
4565
|
+
".cc",
|
|
4566
|
+
".cxx",
|
|
4474
4567
|
".h",
|
|
4568
|
+
".hpp",
|
|
4569
|
+
".hxx",
|
|
4475
4570
|
".cs",
|
|
4571
|
+
".csx",
|
|
4476
4572
|
".go",
|
|
4477
4573
|
".rs",
|
|
4478
4574
|
".sql",
|
|
4479
|
-
".php"
|
|
4575
|
+
".php",
|
|
4576
|
+
".phtml",
|
|
4577
|
+
".rb",
|
|
4578
|
+
".swift",
|
|
4579
|
+
".kt",
|
|
4580
|
+
".kts",
|
|
4581
|
+
".scala",
|
|
4582
|
+
".r",
|
|
4583
|
+
".lua",
|
|
4584
|
+
".pl",
|
|
4585
|
+
".pm",
|
|
4586
|
+
".dart",
|
|
4587
|
+
".graphql",
|
|
4588
|
+
".gql",
|
|
4589
|
+
".proto",
|
|
4590
|
+
".diff",
|
|
4591
|
+
".patch",
|
|
4592
|
+
".dockerfile",
|
|
4593
|
+
".properties",
|
|
4594
|
+
".gradle"
|
|
4480
4595
|
];
|
|
4481
4596
|
var CodePlugin = class {
|
|
4482
4597
|
id = "code";
|
|
@@ -4494,34 +4609,36 @@ var CodePlugin = class {
|
|
|
4494
4609
|
getToolbarActions(instance) {
|
|
4495
4610
|
const totalPages = instance.getPageCount?.() ?? 1;
|
|
4496
4611
|
const actions = [];
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
if (
|
|
4518
|
-
|
|
4519
|
-
if (
|
|
4520
|
-
|
|
4521
|
-
|
|
4612
|
+
if (totalPages > 1) {
|
|
4613
|
+
actions.push({
|
|
4614
|
+
id: "thumbnails",
|
|
4615
|
+
icon: "thumbnails",
|
|
4616
|
+
label: "Page Thumbnails",
|
|
4617
|
+
type: "button",
|
|
4618
|
+
group: "navigation",
|
|
4619
|
+
execute: () => instance.toggleThumbnails?.()
|
|
4620
|
+
});
|
|
4621
|
+
actions.push({
|
|
4622
|
+
id: "page-nav",
|
|
4623
|
+
icon: "",
|
|
4624
|
+
label: "Page Navigation",
|
|
4625
|
+
type: "page-nav",
|
|
4626
|
+
group: "navigation",
|
|
4627
|
+
value: instance.getCurrentPage?.() ?? 1,
|
|
4628
|
+
max: totalPages,
|
|
4629
|
+
execute: (action, page) => {
|
|
4630
|
+
const cur = instance.getCurrentPage?.() ?? 1;
|
|
4631
|
+
const max = instance.getPageCount?.() ?? 1;
|
|
4632
|
+
if (action === "prev") {
|
|
4633
|
+
if (cur > 1) instance.goToPage?.(cur - 1);
|
|
4634
|
+
} else if (action === "next") {
|
|
4635
|
+
if (cur < max) instance.goToPage?.(cur + 1);
|
|
4636
|
+
} else if (typeof page === "number") {
|
|
4637
|
+
instance.goToPage?.(page);
|
|
4638
|
+
}
|
|
4522
4639
|
}
|
|
4523
|
-
}
|
|
4524
|
-
}
|
|
4640
|
+
});
|
|
4641
|
+
}
|
|
4525
4642
|
actions.push(
|
|
4526
4643
|
{
|
|
4527
4644
|
id: "zoom-out",
|
|
@@ -4658,10 +4775,6 @@ var CodePlugin = class {
|
|
|
4658
4775
|
}
|
|
4659
4776
|
const totalPages = Math.max(1, rawPages.length);
|
|
4660
4777
|
let currentPage = 1;
|
|
4661
|
-
const container = document.createElement("div");
|
|
4662
|
-
container.style.width = "100%";
|
|
4663
|
-
container.style.height = "100%";
|
|
4664
|
-
container.style.overflow = "auto";
|
|
4665
4778
|
let fontSize = 13;
|
|
4666
4779
|
let rotation = 0;
|
|
4667
4780
|
let zoomLevel = 1;
|
|
@@ -4670,9 +4783,10 @@ var CodePlugin = class {
|
|
|
4670
4783
|
const code = document.createElement("code");
|
|
4671
4784
|
const sizer = document.createElement("div");
|
|
4672
4785
|
const scrollWrapper = document.createElement("div");
|
|
4786
|
+
const lineGutter = document.createElement("div");
|
|
4787
|
+
ctx.container.style.overflow = "auto";
|
|
4673
4788
|
if (isTxt) {
|
|
4674
|
-
container.style.
|
|
4675
|
-
container.style.backgroundColor = "#f1f5f9";
|
|
4789
|
+
ctx.container.style.backgroundColor = "#f1f5f9";
|
|
4676
4790
|
scrollWrapper.className = "fp-code-scroll-wrapper";
|
|
4677
4791
|
scrollWrapper.style.minWidth = "100%";
|
|
4678
4792
|
scrollWrapper.style.minHeight = "100%";
|
|
@@ -4707,18 +4821,42 @@ var CodePlugin = class {
|
|
|
4707
4821
|
pre.style.transition = "transform 0.15s ease";
|
|
4708
4822
|
pre.style.flexShrink = "0";
|
|
4709
4823
|
} else {
|
|
4710
|
-
container.style.
|
|
4711
|
-
container.style.
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4824
|
+
ctx.container.style.backgroundColor = "#1e1e1e";
|
|
4825
|
+
ctx.container.style.color = "#d4d4d4";
|
|
4826
|
+
scrollWrapper.className = "fp-code-scroll-wrapper";
|
|
4827
|
+
scrollWrapper.style.minWidth = "100%";
|
|
4828
|
+
scrollWrapper.style.minHeight = "100%";
|
|
4829
|
+
scrollWrapper.style.width = "max-content";
|
|
4830
|
+
scrollWrapper.style.height = "max-content";
|
|
4831
|
+
scrollWrapper.style.display = "flex";
|
|
4832
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
4833
|
+
scrollWrapper.style.padding = "16px";
|
|
4834
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
4835
|
+
const lineCount = fullText.split(/\r?\n/).length || 1;
|
|
4836
|
+
const gutterLines = [];
|
|
4837
|
+
for (let i = 1; i <= lineCount; i++) {
|
|
4838
|
+
gutterLines.push(String(i));
|
|
4839
|
+
}
|
|
4840
|
+
lineGutter.className = "fp-code-gutter";
|
|
4841
|
+
lineGutter.style.userSelect = "none";
|
|
4842
|
+
lineGutter.style.textAlign = "right";
|
|
4843
|
+
lineGutter.style.paddingRight = "16px";
|
|
4844
|
+
lineGutter.style.marginRight = "16px";
|
|
4845
|
+
lineGutter.style.borderRight = "1px solid #333333";
|
|
4846
|
+
lineGutter.style.color = "#858585";
|
|
4847
|
+
lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
|
|
4848
|
+
lineGutter.style.fontSize = `${fontSize}px`;
|
|
4849
|
+
lineGutter.style.lineHeight = "1.6";
|
|
4850
|
+
lineGutter.style.flexShrink = "0";
|
|
4851
|
+
lineGutter.textContent = gutterLines.join("\n");
|
|
4715
4852
|
pre.style.margin = "0";
|
|
4716
|
-
pre.style.fontFamily = "Consolas, Menlo, Monaco, monospace";
|
|
4853
|
+
pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
|
|
4717
4854
|
pre.style.fontSize = `${fontSize}px`;
|
|
4718
|
-
pre.style.lineHeight = "1.
|
|
4719
|
-
pre.style.whiteSpace = "pre
|
|
4720
|
-
pre.style.wordBreak = "
|
|
4721
|
-
pre.style.
|
|
4855
|
+
pre.style.lineHeight = "1.6";
|
|
4856
|
+
pre.style.whiteSpace = "pre";
|
|
4857
|
+
pre.style.wordBreak = "normal";
|
|
4858
|
+
pre.style.overflowWrap = "normal";
|
|
4859
|
+
pre.style.flex = "1";
|
|
4722
4860
|
}
|
|
4723
4861
|
const ext = (ctx.metadata.extension || "").replace(".", "");
|
|
4724
4862
|
const renderCodePage = (text) => {
|
|
@@ -4738,25 +4876,27 @@ var CodePlugin = class {
|
|
|
4738
4876
|
};
|
|
4739
4877
|
renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
|
|
4740
4878
|
pre.appendChild(code);
|
|
4879
|
+
ctx.container.innerHTML = "";
|
|
4741
4880
|
if (isTxt) {
|
|
4742
4881
|
sizer.appendChild(pre);
|
|
4743
4882
|
scrollWrapper.appendChild(sizer);
|
|
4744
|
-
container.appendChild(scrollWrapper);
|
|
4883
|
+
ctx.container.appendChild(scrollWrapper);
|
|
4745
4884
|
} else {
|
|
4746
|
-
|
|
4885
|
+
scrollWrapper.appendChild(lineGutter);
|
|
4886
|
+
scrollWrapper.appendChild(pre);
|
|
4887
|
+
ctx.container.appendChild(scrollWrapper);
|
|
4747
4888
|
}
|
|
4748
4889
|
const showPage = (pageNum) => {
|
|
4749
4890
|
currentPage = Math.max(1, Math.min(totalPages, pageNum));
|
|
4750
4891
|
renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
|
|
4751
|
-
container.scrollTop = 0;
|
|
4892
|
+
ctx.container.scrollTop = 0;
|
|
4752
4893
|
ctx.emit("page-change", { page: currentPage, total: totalPages });
|
|
4753
4894
|
};
|
|
4754
4895
|
if (totalPages > 1) {
|
|
4755
4896
|
showPage(1);
|
|
4756
4897
|
}
|
|
4757
|
-
ctx.container.appendChild(container);
|
|
4758
4898
|
const calculateTxtFit = () => {
|
|
4759
|
-
const availW = Math.max(280, container.clientWidth - 32);
|
|
4899
|
+
const availW = Math.max(280, ctx.container.clientWidth - 32);
|
|
4760
4900
|
return Math.max(0.4, Math.min(3, availW / 816));
|
|
4761
4901
|
};
|
|
4762
4902
|
const updateTransform = () => {
|
|
@@ -4774,6 +4914,7 @@ var CodePlugin = class {
|
|
|
4774
4914
|
} else {
|
|
4775
4915
|
pre.style.transform = `rotate(${rotation}deg)`;
|
|
4776
4916
|
pre.style.fontSize = `${fontSize}px`;
|
|
4917
|
+
lineGutter.style.fontSize = `${fontSize}px`;
|
|
4777
4918
|
}
|
|
4778
4919
|
};
|
|
4779
4920
|
let resizeObserver = null;
|
|
@@ -4788,11 +4929,11 @@ var CodePlugin = class {
|
|
|
4788
4929
|
updateTransform();
|
|
4789
4930
|
}
|
|
4790
4931
|
}) : null;
|
|
4791
|
-
resizeObserver?.observe(container);
|
|
4932
|
+
resizeObserver?.observe(ctx.container);
|
|
4792
4933
|
}
|
|
4793
4934
|
const cleanup = () => {
|
|
4794
4935
|
resizeObserver?.disconnect();
|
|
4795
|
-
|
|
4936
|
+
scrollWrapper.remove();
|
|
4796
4937
|
ctx.container.innerHTML = "";
|
|
4797
4938
|
};
|
|
4798
4939
|
ctx.signal.addEventListener("abort", cleanup);
|
|
@@ -4837,7 +4978,7 @@ var CodePlugin = class {
|
|
|
4837
4978
|
if (isTxt) {
|
|
4838
4979
|
zoomLevel = Math.min(3.5, zoomLevel + 0.15);
|
|
4839
4980
|
} else {
|
|
4840
|
-
fontSize = Math.min(
|
|
4981
|
+
fontSize = Math.min(48, fontSize + 2);
|
|
4841
4982
|
}
|
|
4842
4983
|
updateTransform();
|
|
4843
4984
|
},
|
|
@@ -4846,7 +4987,7 @@ var CodePlugin = class {
|
|
|
4846
4987
|
if (isTxt) {
|
|
4847
4988
|
zoomLevel = Math.max(0.1, zoomLevel - 0.15);
|
|
4848
4989
|
} else {
|
|
4849
|
-
fontSize = Math.max(
|
|
4990
|
+
fontSize = Math.max(9, fontSize - 2);
|
|
4850
4991
|
}
|
|
4851
4992
|
updateTransform();
|
|
4852
4993
|
},
|
|
@@ -4879,8 +5020,8 @@ var CodePlugin = class {
|
|
|
4879
5020
|
fontSize = 13;
|
|
4880
5021
|
rotation = 0;
|
|
4881
5022
|
zoomLevel = isTxt ? calculateTxtFit() : 1;
|
|
4882
|
-
container.scrollTop = 0;
|
|
4883
|
-
container.scrollLeft = 0;
|
|
5023
|
+
ctx.container.scrollTop = 0;
|
|
5024
|
+
ctx.container.scrollLeft = 0;
|
|
4884
5025
|
updateTransform();
|
|
4885
5026
|
},
|
|
4886
5027
|
rotateCW: () => {
|
|
@@ -5202,7 +5343,7 @@ var MarkdownPlugin = class {
|
|
|
5202
5343
|
{
|
|
5203
5344
|
id: "zoom-out",
|
|
5204
5345
|
icon: "zoom-out",
|
|
5205
|
-
label: "
|
|
5346
|
+
label: "Zoom Out",
|
|
5206
5347
|
type: "button",
|
|
5207
5348
|
group: "zoom",
|
|
5208
5349
|
execute: () => instance.zoomOut?.()
|
|
@@ -5210,19 +5351,11 @@ var MarkdownPlugin = class {
|
|
|
5210
5351
|
{
|
|
5211
5352
|
id: "zoom-in",
|
|
5212
5353
|
icon: "zoom-in",
|
|
5213
|
-
label: "
|
|
5354
|
+
label: "Zoom In",
|
|
5214
5355
|
type: "button",
|
|
5215
5356
|
group: "zoom",
|
|
5216
5357
|
execute: () => instance.zoomIn?.()
|
|
5217
5358
|
},
|
|
5218
|
-
{
|
|
5219
|
-
id: "fit-page",
|
|
5220
|
-
icon: "fit-page",
|
|
5221
|
-
label: "Default Size",
|
|
5222
|
-
type: "button",
|
|
5223
|
-
group: "zoom",
|
|
5224
|
-
execute: () => instance.fitToPage?.()
|
|
5225
|
-
},
|
|
5226
5359
|
{
|
|
5227
5360
|
id: "reset-zoom",
|
|
5228
5361
|
icon: "reset-zoom",
|
|
@@ -5239,6 +5372,14 @@ var MarkdownPlugin = class {
|
|
|
5239
5372
|
group: "zoom",
|
|
5240
5373
|
execute: () => instance.fitToWidth?.()
|
|
5241
5374
|
},
|
|
5375
|
+
{
|
|
5376
|
+
id: "fit-page",
|
|
5377
|
+
icon: "fit-page",
|
|
5378
|
+
label: "Fit to Page",
|
|
5379
|
+
type: "button",
|
|
5380
|
+
group: "zoom",
|
|
5381
|
+
execute: () => instance.fitToPage?.()
|
|
5382
|
+
},
|
|
5242
5383
|
{
|
|
5243
5384
|
id: "copy",
|
|
5244
5385
|
icon: "copy",
|
|
@@ -5262,6 +5403,14 @@ var MarkdownPlugin = class {
|
|
|
5262
5403
|
type: "button",
|
|
5263
5404
|
group: "actions",
|
|
5264
5405
|
execute: () => instance.print?.()
|
|
5406
|
+
},
|
|
5407
|
+
{
|
|
5408
|
+
id: "open-window",
|
|
5409
|
+
icon: "open-window",
|
|
5410
|
+
label: "Open in Separate Full Window",
|
|
5411
|
+
type: "button",
|
|
5412
|
+
group: "actions",
|
|
5413
|
+
execute: () => instance.openInSeparateWindow?.()
|
|
5265
5414
|
}
|
|
5266
5415
|
];
|
|
5267
5416
|
}
|
|
@@ -5274,35 +5423,57 @@ var MarkdownPlugin = class {
|
|
|
5274
5423
|
const cleanHtml = DOMPurify6.sanitize(rawHtml, {
|
|
5275
5424
|
USE_PROFILES: { html: true }
|
|
5276
5425
|
});
|
|
5277
|
-
const
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5426
|
+
const scrollWrapper = document.createElement("div");
|
|
5427
|
+
scrollWrapper.className = "fp-markdown-scroll-wrapper";
|
|
5428
|
+
scrollWrapper.style.minWidth = "100%";
|
|
5429
|
+
scrollWrapper.style.minHeight = "100%";
|
|
5430
|
+
scrollWrapper.style.width = "max-content";
|
|
5431
|
+
scrollWrapper.style.height = "max-content";
|
|
5432
|
+
scrollWrapper.style.display = "flex";
|
|
5433
|
+
scrollWrapper.style.justifyContent = "center";
|
|
5434
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
5435
|
+
scrollWrapper.style.padding = "24px 16px";
|
|
5436
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
5437
|
+
const sizer = document.createElement("div");
|
|
5438
|
+
sizer.className = "fp-markdown-sizer";
|
|
5439
|
+
sizer.style.position = "relative";
|
|
5440
|
+
sizer.style.flexShrink = "0";
|
|
5441
|
+
sizer.style.display = "flex";
|
|
5442
|
+
sizer.style.justifyContent = "center";
|
|
5443
|
+
sizer.style.alignItems = "flex-start";
|
|
5444
|
+
const docCard = document.createElement("div");
|
|
5445
|
+
docCard.className = "fp-markdown-doc-card";
|
|
5446
|
+
docCard.style.cssText = `
|
|
5447
|
+
width: 860px;
|
|
5448
|
+
min-height: 600px;
|
|
5449
|
+
padding: 40px 48px;
|
|
5284
5450
|
box-sizing: border-box;
|
|
5285
5451
|
line-height: 1.6;
|
|
5286
5452
|
font-size: 15px;
|
|
5287
5453
|
color: var(--fp-text, #24292f);
|
|
5288
5454
|
background: var(--fp-bg, #ffffff);
|
|
5455
|
+
border-radius: 6px;
|
|
5456
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
|
5289
5457
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
|
|
5458
|
+
transform-origin: top center;
|
|
5459
|
+
transition: transform 0.15s ease;
|
|
5460
|
+
flex-shrink: 0;
|
|
5290
5461
|
`;
|
|
5291
|
-
|
|
5462
|
+
docCard.innerHTML = `
|
|
5292
5463
|
<style>
|
|
5293
|
-
.fp-markdown-
|
|
5294
|
-
.fp-markdown-
|
|
5464
|
+
.fp-markdown-doc-card h1, .fp-markdown-doc-card h2, .fp-markdown-doc-card h3,
|
|
5465
|
+
.fp-markdown-doc-card h4, .fp-markdown-doc-card h5, .fp-markdown-doc-card h6 {
|
|
5295
5466
|
margin-top: 24px;
|
|
5296
5467
|
margin-bottom: 16px;
|
|
5297
5468
|
font-weight: 600;
|
|
5298
5469
|
line-height: 1.25;
|
|
5299
5470
|
color: var(--fp-text, #1f2328);
|
|
5300
5471
|
}
|
|
5301
|
-
.fp-markdown-
|
|
5302
|
-
.fp-markdown-
|
|
5303
|
-
.fp-markdown-
|
|
5304
|
-
.fp-markdown-
|
|
5305
|
-
.fp-markdown-
|
|
5472
|
+
.fp-markdown-doc-card h1 { font-size: 2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--fp-border, #d0d7de); }
|
|
5473
|
+
.fp-markdown-doc-card h2 { font-size: 1.5em; padding-bottom: 0.3em; border-bottom: 1px solid var(--fp-border, #d0d7de); }
|
|
5474
|
+
.fp-markdown-doc-card h3 { font-size: 1.25em; }
|
|
5475
|
+
.fp-markdown-doc-card p { margin-top: 0; margin-bottom: 16px; }
|
|
5476
|
+
.fp-markdown-doc-card table {
|
|
5306
5477
|
border-spacing: 0;
|
|
5307
5478
|
border-collapse: collapse;
|
|
5308
5479
|
margin-top: 0;
|
|
@@ -5310,20 +5481,20 @@ var MarkdownPlugin = class {
|
|
|
5310
5481
|
width: 100%;
|
|
5311
5482
|
overflow: auto;
|
|
5312
5483
|
}
|
|
5313
|
-
.fp-markdown-
|
|
5484
|
+
.fp-markdown-doc-card table th, .fp-markdown-doc-card table td {
|
|
5314
5485
|
padding: 6px 13px;
|
|
5315
5486
|
border: 1px solid var(--fp-border, #d0d7de);
|
|
5316
5487
|
}
|
|
5317
|
-
.fp-markdown-
|
|
5488
|
+
.fp-markdown-doc-card table tr:nth-child(2n) {
|
|
5318
5489
|
background-color: var(--fp-toolbar-bg, #f6f8fa);
|
|
5319
5490
|
}
|
|
5320
|
-
.fp-markdown-
|
|
5491
|
+
.fp-markdown-doc-card blockquote {
|
|
5321
5492
|
margin: 0 0 16px 0;
|
|
5322
5493
|
padding: 0 1em;
|
|
5323
5494
|
color: var(--fp-text-muted, #59636e);
|
|
5324
5495
|
border-left: 0.25em solid var(--fp-border, #d0d7de);
|
|
5325
5496
|
}
|
|
5326
|
-
.fp-markdown-
|
|
5497
|
+
.fp-markdown-doc-card pre {
|
|
5327
5498
|
padding: 16px;
|
|
5328
5499
|
overflow: auto;
|
|
5329
5500
|
font-size: 85%;
|
|
@@ -5332,7 +5503,7 @@ var MarkdownPlugin = class {
|
|
|
5332
5503
|
border-radius: 6px;
|
|
5333
5504
|
border: 1px solid var(--fp-border, #d0d7de);
|
|
5334
5505
|
}
|
|
5335
|
-
.fp-markdown-
|
|
5506
|
+
.fp-markdown-doc-card code {
|
|
5336
5507
|
padding: 0.2em 0.4em;
|
|
5337
5508
|
margin: 0;
|
|
5338
5509
|
font-size: 85%;
|
|
@@ -5340,16 +5511,16 @@ var MarkdownPlugin = class {
|
|
|
5340
5511
|
border-radius: 4px;
|
|
5341
5512
|
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
5342
5513
|
}
|
|
5343
|
-
.fp-markdown-
|
|
5514
|
+
.fp-markdown-doc-card pre code {
|
|
5344
5515
|
padding: 0;
|
|
5345
5516
|
background: transparent;
|
|
5346
5517
|
}
|
|
5347
|
-
.fp-markdown-
|
|
5518
|
+
.fp-markdown-doc-card ul, .fp-markdown-doc-card ol {
|
|
5348
5519
|
padding-left: 2em;
|
|
5349
5520
|
margin-top: 0;
|
|
5350
5521
|
margin-bottom: 16px;
|
|
5351
5522
|
}
|
|
5352
|
-
.fp-markdown-
|
|
5523
|
+
.fp-markdown-doc-card hr {
|
|
5353
5524
|
height: 0.25em;
|
|
5354
5525
|
padding: 0;
|
|
5355
5526
|
margin: 24px 0;
|
|
@@ -5357,50 +5528,95 @@ var MarkdownPlugin = class {
|
|
|
5357
5528
|
border: 0;
|
|
5358
5529
|
}
|
|
5359
5530
|
</style>
|
|
5360
|
-
<div class="fp-markdown-
|
|
5531
|
+
<div class="fp-markdown-body">
|
|
5361
5532
|
${cleanHtml}
|
|
5362
5533
|
</div>
|
|
5363
5534
|
`;
|
|
5364
|
-
|
|
5535
|
+
docCard.querySelectorAll("pre code").forEach((block) => {
|
|
5365
5536
|
hljs.highlightElement(block);
|
|
5366
5537
|
});
|
|
5538
|
+
sizer.appendChild(docCard);
|
|
5539
|
+
scrollWrapper.appendChild(sizer);
|
|
5367
5540
|
ctx.container.innerHTML = "";
|
|
5368
5541
|
ctx.container.style.overflow = "auto";
|
|
5369
|
-
ctx.container.
|
|
5370
|
-
|
|
5542
|
+
ctx.container.style.backgroundColor = "#f1f5f9";
|
|
5543
|
+
ctx.container.appendChild(scrollWrapper);
|
|
5544
|
+
let scale = 1;
|
|
5545
|
+
let isUserZoomed = false;
|
|
5546
|
+
const calculateFitScale = () => {
|
|
5547
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
5548
|
+
if (availW < 860) {
|
|
5549
|
+
return Math.max(0.35, availW / 860);
|
|
5550
|
+
}
|
|
5551
|
+
return 1;
|
|
5552
|
+
};
|
|
5553
|
+
const applyTransform = () => {
|
|
5554
|
+
const baseW = 860;
|
|
5555
|
+
const baseH = docCard.offsetHeight || 600;
|
|
5556
|
+
const scaledW = Math.round(baseW * scale);
|
|
5557
|
+
const scaledH = Math.round(baseH * scale);
|
|
5558
|
+
sizer.style.width = `${scaledW}px`;
|
|
5559
|
+
sizer.style.height = `${scaledH}px`;
|
|
5560
|
+
docCard.style.width = `${baseW}px`;
|
|
5561
|
+
docCard.style.transform = `scale(${scale})`;
|
|
5562
|
+
docCard.style.transformOrigin = scaledW > ctx.container.clientWidth - 32 ? "top left" : "top center";
|
|
5563
|
+
};
|
|
5564
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
5565
|
+
if (!isUserZoomed) {
|
|
5566
|
+
scale = calculateFitScale();
|
|
5567
|
+
applyTransform();
|
|
5568
|
+
}
|
|
5569
|
+
}) : null;
|
|
5570
|
+
ro?.observe(ctx.container);
|
|
5571
|
+
requestAnimationFrame(() => {
|
|
5572
|
+
if (!isUserZoomed) {
|
|
5573
|
+
scale = calculateFitScale();
|
|
5574
|
+
}
|
|
5575
|
+
applyTransform();
|
|
5576
|
+
});
|
|
5371
5577
|
const cleanup = () => {
|
|
5372
|
-
|
|
5578
|
+
ro?.disconnect();
|
|
5579
|
+
scrollWrapper.remove();
|
|
5373
5580
|
ctx.container.innerHTML = "";
|
|
5374
5581
|
};
|
|
5375
5582
|
ctx.signal.addEventListener("abort", cleanup);
|
|
5376
5583
|
return {
|
|
5377
5584
|
destroy: cleanup,
|
|
5378
5585
|
zoomIn: () => {
|
|
5379
|
-
|
|
5380
|
-
|
|
5586
|
+
isUserZoomed = true;
|
|
5587
|
+
scale = Math.min(3.5, scale + 0.15);
|
|
5588
|
+
applyTransform();
|
|
5381
5589
|
},
|
|
5382
5590
|
zoomOut: () => {
|
|
5383
|
-
|
|
5384
|
-
|
|
5591
|
+
isUserZoomed = true;
|
|
5592
|
+
scale = Math.max(0.25, scale - 0.15);
|
|
5593
|
+
applyTransform();
|
|
5385
5594
|
},
|
|
5386
|
-
getZoom: () =>
|
|
5595
|
+
getZoom: () => scale,
|
|
5387
5596
|
setZoom: (level) => {
|
|
5388
|
-
|
|
5389
|
-
|
|
5597
|
+
isUserZoomed = true;
|
|
5598
|
+
scale = level;
|
|
5599
|
+
applyTransform();
|
|
5390
5600
|
},
|
|
5391
5601
|
fitToPage: () => {
|
|
5392
|
-
|
|
5393
|
-
|
|
5602
|
+
isUserZoomed = false;
|
|
5603
|
+
scale = calculateFitScale();
|
|
5604
|
+
applyTransform();
|
|
5394
5605
|
},
|
|
5395
5606
|
fitToWidth: () => {
|
|
5396
|
-
|
|
5397
|
-
|
|
5607
|
+
isUserZoomed = false;
|
|
5608
|
+
scale = calculateFitScale();
|
|
5609
|
+
applyTransform();
|
|
5398
5610
|
},
|
|
5399
5611
|
resetZoom: () => {
|
|
5400
|
-
|
|
5401
|
-
|
|
5612
|
+
isUserZoomed = false;
|
|
5613
|
+
scale = calculateFitScale();
|
|
5402
5614
|
ctx.container.scrollTop = 0;
|
|
5403
5615
|
ctx.container.scrollLeft = 0;
|
|
5616
|
+
applyTransform();
|
|
5617
|
+
},
|
|
5618
|
+
openInSeparateWindow: () => {
|
|
5619
|
+
ctx?.openInSeparateWindow?.();
|
|
5404
5620
|
},
|
|
5405
5621
|
download: () => {
|
|
5406
5622
|
downloadFile(ctx.buffer, ctx.metadata.name || "document.md", "text/markdown");
|
|
@@ -6716,14 +6932,6 @@ var HtmlPreviewPlugin = class {
|
|
|
6716
6932
|
group: "zoom",
|
|
6717
6933
|
execute: () => instance.zoomIn?.()
|
|
6718
6934
|
},
|
|
6719
|
-
{
|
|
6720
|
-
id: "fit-page",
|
|
6721
|
-
icon: "fit-page",
|
|
6722
|
-
label: "Fit to Page",
|
|
6723
|
-
type: "button",
|
|
6724
|
-
group: "zoom",
|
|
6725
|
-
execute: () => instance.fitToPage?.()
|
|
6726
|
-
},
|
|
6727
6935
|
{
|
|
6728
6936
|
id: "reset-zoom",
|
|
6729
6937
|
icon: "reset-zoom",
|
|
@@ -6740,6 +6948,14 @@ var HtmlPreviewPlugin = class {
|
|
|
6740
6948
|
group: "zoom",
|
|
6741
6949
|
execute: () => instance.fitToWidth?.()
|
|
6742
6950
|
},
|
|
6951
|
+
{
|
|
6952
|
+
id: "fit-page",
|
|
6953
|
+
icon: "fit-page",
|
|
6954
|
+
label: "Fit to Page",
|
|
6955
|
+
type: "button",
|
|
6956
|
+
group: "zoom",
|
|
6957
|
+
execute: () => instance.fitToPage?.()
|
|
6958
|
+
},
|
|
6743
6959
|
{
|
|
6744
6960
|
id: "copy",
|
|
6745
6961
|
icon: "copy",
|
|
@@ -6763,6 +6979,14 @@ var HtmlPreviewPlugin = class {
|
|
|
6763
6979
|
type: "button",
|
|
6764
6980
|
group: "actions",
|
|
6765
6981
|
execute: () => instance.print?.()
|
|
6982
|
+
},
|
|
6983
|
+
{
|
|
6984
|
+
id: "open-window",
|
|
6985
|
+
icon: "open-window",
|
|
6986
|
+
label: "Open in Separate Full Window",
|
|
6987
|
+
type: "button",
|
|
6988
|
+
group: "actions",
|
|
6989
|
+
execute: () => instance.openInSeparateWindow?.()
|
|
6766
6990
|
}
|
|
6767
6991
|
];
|
|
6768
6992
|
}
|
|
@@ -6773,27 +6997,39 @@ var HtmlPreviewPlugin = class {
|
|
|
6773
6997
|
ADD_TAGS: ["style", "link"],
|
|
6774
6998
|
ADD_ATTR: ["target", "rel"]
|
|
6775
6999
|
});
|
|
7000
|
+
const scrollWrapper = document.createElement("div");
|
|
7001
|
+
scrollWrapper.className = "fp-html-scroll-wrapper";
|
|
7002
|
+
scrollWrapper.style.minWidth = "100%";
|
|
7003
|
+
scrollWrapper.style.minHeight = "100%";
|
|
7004
|
+
scrollWrapper.style.width = "max-content";
|
|
7005
|
+
scrollWrapper.style.height = "max-content";
|
|
7006
|
+
scrollWrapper.style.display = "flex";
|
|
7007
|
+
scrollWrapper.style.justifyContent = "flex-start";
|
|
7008
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
7009
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
6776
7010
|
const sizer = document.createElement("div");
|
|
6777
7011
|
sizer.className = "fp-html-sizer";
|
|
6778
7012
|
sizer.style.position = "relative";
|
|
7013
|
+
sizer.style.flexShrink = "0";
|
|
6779
7014
|
const iframe = document.createElement("iframe");
|
|
6780
7015
|
iframe.className = "fp-html-iframe";
|
|
6781
7016
|
iframe.style.border = "none";
|
|
6782
7017
|
iframe.style.backgroundColor = "#ffffff";
|
|
6783
7018
|
iframe.style.transformOrigin = "top left";
|
|
6784
|
-
iframe.style.transition = "transform 0.
|
|
7019
|
+
iframe.style.transition = "transform 0.15s ease";
|
|
6785
7020
|
iframe.sandbox.add("allow-same-origin");
|
|
6786
7021
|
sizer.appendChild(iframe);
|
|
7022
|
+
scrollWrapper.appendChild(sizer);
|
|
6787
7023
|
ctx.container.style.overflow = "auto";
|
|
6788
7024
|
ctx.container.style.width = "100%";
|
|
6789
7025
|
ctx.container.style.height = "100%";
|
|
6790
7026
|
ctx.container.innerHTML = "";
|
|
6791
|
-
ctx.container.appendChild(
|
|
7027
|
+
ctx.container.appendChild(scrollWrapper);
|
|
6792
7028
|
iframe.srcdoc = sanitized;
|
|
6793
7029
|
let scale = 1;
|
|
7030
|
+
let baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7031
|
+
let baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6794
7032
|
const applyTransform = () => {
|
|
6795
|
-
const baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
6796
|
-
const baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6797
7033
|
const scaledW = Math.round(baseW * scale);
|
|
6798
7034
|
const scaledH = Math.round(baseH * scale);
|
|
6799
7035
|
sizer.style.width = `${scaledW}px`;
|
|
@@ -6806,22 +7042,33 @@ var HtmlPreviewPlugin = class {
|
|
|
6806
7042
|
iframe.style.transform = `scale(${scale})`;
|
|
6807
7043
|
iframe.style.transformOrigin = "top left";
|
|
6808
7044
|
};
|
|
7045
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
7046
|
+
if (Math.abs(scale - 1) < 0.05) {
|
|
7047
|
+
baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7048
|
+
baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
7049
|
+
applyTransform();
|
|
7050
|
+
}
|
|
7051
|
+
}) : null;
|
|
7052
|
+
ro?.observe(ctx.container);
|
|
6809
7053
|
requestAnimationFrame(() => {
|
|
7054
|
+
baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7055
|
+
baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6810
7056
|
applyTransform();
|
|
6811
7057
|
});
|
|
6812
7058
|
const cleanup = () => {
|
|
6813
|
-
|
|
7059
|
+
ro?.disconnect();
|
|
7060
|
+
scrollWrapper.remove();
|
|
6814
7061
|
ctx.container.innerHTML = "";
|
|
6815
7062
|
};
|
|
6816
7063
|
ctx.signal.addEventListener("abort", cleanup);
|
|
6817
7064
|
return {
|
|
6818
7065
|
destroy: cleanup,
|
|
6819
7066
|
zoomIn: () => {
|
|
6820
|
-
scale
|
|
7067
|
+
scale = Math.min(3.5, scale + 0.15);
|
|
6821
7068
|
applyTransform();
|
|
6822
7069
|
},
|
|
6823
7070
|
zoomOut: () => {
|
|
6824
|
-
scale = Math.max(0.
|
|
7071
|
+
scale = Math.max(0.25, scale - 0.15);
|
|
6825
7072
|
applyTransform();
|
|
6826
7073
|
},
|
|
6827
7074
|
getZoom: () => scale,
|
|
@@ -6843,8 +7090,11 @@ var HtmlPreviewPlugin = class {
|
|
|
6843
7090
|
ctx.container.scrollLeft = 0;
|
|
6844
7091
|
applyTransform();
|
|
6845
7092
|
},
|
|
7093
|
+
openInSeparateWindow: () => {
|
|
7094
|
+
ctx?.openInSeparateWindow?.();
|
|
7095
|
+
},
|
|
6846
7096
|
copy: () => {
|
|
6847
|
-
navigator.clipboard
|
|
7097
|
+
navigator.clipboard?.writeText(rawHtml);
|
|
6848
7098
|
},
|
|
6849
7099
|
download: () => {
|
|
6850
7100
|
const blob = new Blob([ctx.buffer], { type: "text/html" });
|
|
@@ -8906,7 +9156,7 @@ _FilePreviewComponent_decorators = [Component({
|
|
|
8906
9156
|
selector: "fp-file-preview",
|
|
8907
9157
|
standalone: true,
|
|
8908
9158
|
imports: [CommonModule],
|
|
8909
|
-
template: `<div #container [style.width]="'100%'" [style.height]="'100%'"></div>`,
|
|
9159
|
+
template: `<div #container [style.width]="'100%'" [style.height]="'100%'" [style.position]="'relative'" [style.overflow]="'hidden'"></div>`,
|
|
8910
9160
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
8911
9161
|
})], _src_dec = [Input({ required: true })], _plugins_dec = [Input()], _options_dec = [Input()], _loading_dec = [Output()], _loaded_dec = [Output()], _error_dec = [Output()], _pageChange_dec = [Output()], _zoomChange_dec = [Output()], _rotate_dec = [Output()], _destroyed_dec = [Output()], _container_dec = [ViewChild("container", { static: true })];
|
|
8912
9162
|
var FilePreviewComponent = class {
|