@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/vue.cjs
CHANGED
|
@@ -1631,19 +1631,85 @@ var FilePreviewViewer = class _FilePreviewViewer {
|
|
|
1631
1631
|
if (this.wrapperEl?.parentNode) {
|
|
1632
1632
|
this.wrapperEl.parentNode.removeChild(this.wrapperEl);
|
|
1633
1633
|
}
|
|
1634
|
+
if (typeof document !== "undefined" && !document.getElementById("fp-core-injected-styles")) {
|
|
1635
|
+
const styleEl = document.createElement("style");
|
|
1636
|
+
styleEl.id = "fp-core-injected-styles";
|
|
1637
|
+
styleEl.textContent = `
|
|
1638
|
+
.fp-viewer {
|
|
1639
|
+
display: flex !important;
|
|
1640
|
+
flex-direction: column !important;
|
|
1641
|
+
width: 100% !important;
|
|
1642
|
+
height: 100% !important;
|
|
1643
|
+
overflow: hidden !important;
|
|
1644
|
+
position: relative !important;
|
|
1645
|
+
box-sizing: border-box !important;
|
|
1646
|
+
}
|
|
1647
|
+
.fp-body {
|
|
1648
|
+
display: flex !important;
|
|
1649
|
+
flex: 1 1 0% !important;
|
|
1650
|
+
min-height: 0 !important;
|
|
1651
|
+
min-width: 0 !important;
|
|
1652
|
+
width: 100% !important;
|
|
1653
|
+
height: 100% !important;
|
|
1654
|
+
overflow: hidden !important;
|
|
1655
|
+
position: relative !important;
|
|
1656
|
+
box-sizing: border-box !important;
|
|
1657
|
+
}
|
|
1658
|
+
.fp-content {
|
|
1659
|
+
flex: 1 1 0% !important;
|
|
1660
|
+
position: relative !important;
|
|
1661
|
+
overflow: auto !important;
|
|
1662
|
+
display: flex !important;
|
|
1663
|
+
flex-direction: column !important;
|
|
1664
|
+
align-items: stretch !important;
|
|
1665
|
+
justify-content: flex-start !important;
|
|
1666
|
+
width: 100% !important;
|
|
1667
|
+
height: 100% !important;
|
|
1668
|
+
min-width: 0 !important;
|
|
1669
|
+
min-height: 0 !important;
|
|
1670
|
+
box-sizing: border-box !important;
|
|
1671
|
+
}
|
|
1672
|
+
`;
|
|
1673
|
+
document.head.appendChild(styleEl);
|
|
1674
|
+
}
|
|
1634
1675
|
const themeClass = options.theme === "dark" ? "fp-theme-dark" : "";
|
|
1635
1676
|
const toolbarPos = options.toolbarPosition ?? "top";
|
|
1636
1677
|
this.wrapperEl = document.createElement("div");
|
|
1637
1678
|
this.wrapperEl.className = `fp-viewer ${themeClass} ${options.className ?? ""}`.trim();
|
|
1638
1679
|
this.wrapperEl.tabIndex = 0;
|
|
1680
|
+
this.wrapperEl.style.display = "flex";
|
|
1681
|
+
this.wrapperEl.style.flexDirection = "column";
|
|
1682
|
+
this.wrapperEl.style.width = "100%";
|
|
1683
|
+
this.wrapperEl.style.height = "100%";
|
|
1684
|
+
this.wrapperEl.style.overflow = "hidden";
|
|
1685
|
+
this.wrapperEl.style.position = "relative";
|
|
1639
1686
|
const toolbarEl = document.createElement("div");
|
|
1640
1687
|
toolbarEl.className = "fp-toolbar-container";
|
|
1641
1688
|
this.contentEl = document.createElement("div");
|
|
1642
1689
|
this.contentEl.className = "fp-content";
|
|
1690
|
+
this.contentEl.style.flex = "1 1 0%";
|
|
1691
|
+
this.contentEl.style.position = "relative";
|
|
1692
|
+
this.contentEl.style.overflow = "auto";
|
|
1693
|
+
this.contentEl.style.display = "flex";
|
|
1694
|
+
this.contentEl.style.flexDirection = "column";
|
|
1695
|
+
this.contentEl.style.alignItems = "stretch";
|
|
1696
|
+
this.contentEl.style.justifyContent = "flex-start";
|
|
1697
|
+
this.contentEl.style.width = "100%";
|
|
1698
|
+
this.contentEl.style.height = "100%";
|
|
1699
|
+
this.contentEl.style.minWidth = "0";
|
|
1700
|
+
this.contentEl.style.minHeight = "0";
|
|
1701
|
+
this.contentEl.style.boxSizing = "border-box";
|
|
1643
1702
|
const thumbnailEl = document.createElement("div");
|
|
1644
1703
|
thumbnailEl.className = "fp-thumbnail-container";
|
|
1645
1704
|
const bodyEl = document.createElement("div");
|
|
1646
1705
|
bodyEl.className = "fp-body";
|
|
1706
|
+
bodyEl.style.display = "flex";
|
|
1707
|
+
bodyEl.style.flex = "1 1 0%";
|
|
1708
|
+
bodyEl.style.minHeight = "0";
|
|
1709
|
+
bodyEl.style.minWidth = "0";
|
|
1710
|
+
bodyEl.style.width = "100%";
|
|
1711
|
+
bodyEl.style.overflow = "hidden";
|
|
1712
|
+
bodyEl.style.position = "relative";
|
|
1647
1713
|
bodyEl.appendChild(thumbnailEl);
|
|
1648
1714
|
bodyEl.appendChild(this.contentEl);
|
|
1649
1715
|
const titleBarEl = document.createElement("div");
|
|
@@ -4437,31 +4503,80 @@ function csvPlugin() {
|
|
|
4437
4503
|
}
|
|
4438
4504
|
var CODE_EXTENSIONS = [
|
|
4439
4505
|
".txt",
|
|
4506
|
+
".log",
|
|
4507
|
+
".ini",
|
|
4508
|
+
".cfg",
|
|
4509
|
+
".conf",
|
|
4510
|
+
".env",
|
|
4440
4511
|
".json",
|
|
4512
|
+
".jsonc",
|
|
4513
|
+
".json5",
|
|
4441
4514
|
".js",
|
|
4442
|
-
".
|
|
4515
|
+
".mjs",
|
|
4516
|
+
".cjs",
|
|
4443
4517
|
".jsx",
|
|
4518
|
+
".ts",
|
|
4519
|
+
".mts",
|
|
4520
|
+
".cts",
|
|
4444
4521
|
".tsx",
|
|
4445
4522
|
".html",
|
|
4523
|
+
".htm",
|
|
4524
|
+
".xhtml",
|
|
4446
4525
|
".css",
|
|
4447
4526
|
".scss",
|
|
4527
|
+
".sass",
|
|
4448
4528
|
".less",
|
|
4449
4529
|
".md",
|
|
4530
|
+
".markdown",
|
|
4450
4531
|
".xml",
|
|
4532
|
+
".svg",
|
|
4533
|
+
".xaml",
|
|
4451
4534
|
".yml",
|
|
4452
4535
|
".yaml",
|
|
4536
|
+
".toml",
|
|
4453
4537
|
".sh",
|
|
4454
4538
|
".bash",
|
|
4539
|
+
".zsh",
|
|
4540
|
+
".fish",
|
|
4541
|
+
".bat",
|
|
4542
|
+
".cmd",
|
|
4543
|
+
".ps1",
|
|
4455
4544
|
".py",
|
|
4545
|
+
".pyw",
|
|
4456
4546
|
".java",
|
|
4547
|
+
".class",
|
|
4457
4548
|
".c",
|
|
4458
4549
|
".cpp",
|
|
4550
|
+
".cc",
|
|
4551
|
+
".cxx",
|
|
4459
4552
|
".h",
|
|
4553
|
+
".hpp",
|
|
4554
|
+
".hxx",
|
|
4460
4555
|
".cs",
|
|
4556
|
+
".csx",
|
|
4461
4557
|
".go",
|
|
4462
4558
|
".rs",
|
|
4463
4559
|
".sql",
|
|
4464
|
-
".php"
|
|
4560
|
+
".php",
|
|
4561
|
+
".phtml",
|
|
4562
|
+
".rb",
|
|
4563
|
+
".swift",
|
|
4564
|
+
".kt",
|
|
4565
|
+
".kts",
|
|
4566
|
+
".scala",
|
|
4567
|
+
".r",
|
|
4568
|
+
".lua",
|
|
4569
|
+
".pl",
|
|
4570
|
+
".pm",
|
|
4571
|
+
".dart",
|
|
4572
|
+
".graphql",
|
|
4573
|
+
".gql",
|
|
4574
|
+
".proto",
|
|
4575
|
+
".diff",
|
|
4576
|
+
".patch",
|
|
4577
|
+
".dockerfile",
|
|
4578
|
+
".properties",
|
|
4579
|
+
".gradle"
|
|
4465
4580
|
];
|
|
4466
4581
|
var CodePlugin = class {
|
|
4467
4582
|
id = "code";
|
|
@@ -4479,34 +4594,36 @@ var CodePlugin = class {
|
|
|
4479
4594
|
getToolbarActions(instance) {
|
|
4480
4595
|
const totalPages = instance.getPageCount?.() ?? 1;
|
|
4481
4596
|
const actions = [];
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
if (
|
|
4503
|
-
|
|
4504
|
-
if (
|
|
4505
|
-
|
|
4506
|
-
|
|
4597
|
+
if (totalPages > 1) {
|
|
4598
|
+
actions.push({
|
|
4599
|
+
id: "thumbnails",
|
|
4600
|
+
icon: "thumbnails",
|
|
4601
|
+
label: "Page Thumbnails",
|
|
4602
|
+
type: "button",
|
|
4603
|
+
group: "navigation",
|
|
4604
|
+
execute: () => instance.toggleThumbnails?.()
|
|
4605
|
+
});
|
|
4606
|
+
actions.push({
|
|
4607
|
+
id: "page-nav",
|
|
4608
|
+
icon: "",
|
|
4609
|
+
label: "Page Navigation",
|
|
4610
|
+
type: "page-nav",
|
|
4611
|
+
group: "navigation",
|
|
4612
|
+
value: instance.getCurrentPage?.() ?? 1,
|
|
4613
|
+
max: totalPages,
|
|
4614
|
+
execute: (action, page) => {
|
|
4615
|
+
const cur = instance.getCurrentPage?.() ?? 1;
|
|
4616
|
+
const max = instance.getPageCount?.() ?? 1;
|
|
4617
|
+
if (action === "prev") {
|
|
4618
|
+
if (cur > 1) instance.goToPage?.(cur - 1);
|
|
4619
|
+
} else if (action === "next") {
|
|
4620
|
+
if (cur < max) instance.goToPage?.(cur + 1);
|
|
4621
|
+
} else if (typeof page === "number") {
|
|
4622
|
+
instance.goToPage?.(page);
|
|
4623
|
+
}
|
|
4507
4624
|
}
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4625
|
+
});
|
|
4626
|
+
}
|
|
4510
4627
|
actions.push(
|
|
4511
4628
|
{
|
|
4512
4629
|
id: "zoom-out",
|
|
@@ -4643,10 +4760,6 @@ var CodePlugin = class {
|
|
|
4643
4760
|
}
|
|
4644
4761
|
const totalPages = Math.max(1, rawPages.length);
|
|
4645
4762
|
let currentPage = 1;
|
|
4646
|
-
const container = document.createElement("div");
|
|
4647
|
-
container.style.width = "100%";
|
|
4648
|
-
container.style.height = "100%";
|
|
4649
|
-
container.style.overflow = "auto";
|
|
4650
4763
|
let fontSize = 13;
|
|
4651
4764
|
let rotation = 0;
|
|
4652
4765
|
let zoomLevel = 1;
|
|
@@ -4655,9 +4768,10 @@ var CodePlugin = class {
|
|
|
4655
4768
|
const code = document.createElement("code");
|
|
4656
4769
|
const sizer = document.createElement("div");
|
|
4657
4770
|
const scrollWrapper = document.createElement("div");
|
|
4771
|
+
const lineGutter = document.createElement("div");
|
|
4772
|
+
ctx.container.style.overflow = "auto";
|
|
4658
4773
|
if (isTxt) {
|
|
4659
|
-
container.style.
|
|
4660
|
-
container.style.backgroundColor = "#f1f5f9";
|
|
4774
|
+
ctx.container.style.backgroundColor = "#f1f5f9";
|
|
4661
4775
|
scrollWrapper.className = "fp-code-scroll-wrapper";
|
|
4662
4776
|
scrollWrapper.style.minWidth = "100%";
|
|
4663
4777
|
scrollWrapper.style.minHeight = "100%";
|
|
@@ -4692,18 +4806,42 @@ var CodePlugin = class {
|
|
|
4692
4806
|
pre.style.transition = "transform 0.15s ease";
|
|
4693
4807
|
pre.style.flexShrink = "0";
|
|
4694
4808
|
} else {
|
|
4695
|
-
container.style.
|
|
4696
|
-
container.style.
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4809
|
+
ctx.container.style.backgroundColor = "#1e1e1e";
|
|
4810
|
+
ctx.container.style.color = "#d4d4d4";
|
|
4811
|
+
scrollWrapper.className = "fp-code-scroll-wrapper";
|
|
4812
|
+
scrollWrapper.style.minWidth = "100%";
|
|
4813
|
+
scrollWrapper.style.minHeight = "100%";
|
|
4814
|
+
scrollWrapper.style.width = "max-content";
|
|
4815
|
+
scrollWrapper.style.height = "max-content";
|
|
4816
|
+
scrollWrapper.style.display = "flex";
|
|
4817
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
4818
|
+
scrollWrapper.style.padding = "16px";
|
|
4819
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
4820
|
+
const lineCount = fullText.split(/\r?\n/).length || 1;
|
|
4821
|
+
const gutterLines = [];
|
|
4822
|
+
for (let i = 1; i <= lineCount; i++) {
|
|
4823
|
+
gutterLines.push(String(i));
|
|
4824
|
+
}
|
|
4825
|
+
lineGutter.className = "fp-code-gutter";
|
|
4826
|
+
lineGutter.style.userSelect = "none";
|
|
4827
|
+
lineGutter.style.textAlign = "right";
|
|
4828
|
+
lineGutter.style.paddingRight = "16px";
|
|
4829
|
+
lineGutter.style.marginRight = "16px";
|
|
4830
|
+
lineGutter.style.borderRight = "1px solid #333333";
|
|
4831
|
+
lineGutter.style.color = "#858585";
|
|
4832
|
+
lineGutter.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
|
|
4833
|
+
lineGutter.style.fontSize = `${fontSize}px`;
|
|
4834
|
+
lineGutter.style.lineHeight = "1.6";
|
|
4835
|
+
lineGutter.style.flexShrink = "0";
|
|
4836
|
+
lineGutter.textContent = gutterLines.join("\n");
|
|
4700
4837
|
pre.style.margin = "0";
|
|
4701
|
-
pre.style.fontFamily = "Consolas, Menlo, Monaco, monospace";
|
|
4838
|
+
pre.style.fontFamily = "Consolas, Menlo, Monaco, 'Courier New', monospace";
|
|
4702
4839
|
pre.style.fontSize = `${fontSize}px`;
|
|
4703
|
-
pre.style.lineHeight = "1.
|
|
4704
|
-
pre.style.whiteSpace = "pre
|
|
4705
|
-
pre.style.wordBreak = "
|
|
4706
|
-
pre.style.
|
|
4840
|
+
pre.style.lineHeight = "1.6";
|
|
4841
|
+
pre.style.whiteSpace = "pre";
|
|
4842
|
+
pre.style.wordBreak = "normal";
|
|
4843
|
+
pre.style.overflowWrap = "normal";
|
|
4844
|
+
pre.style.flex = "1";
|
|
4707
4845
|
}
|
|
4708
4846
|
const ext = (ctx.metadata.extension || "").replace(".", "");
|
|
4709
4847
|
const renderCodePage = (text) => {
|
|
@@ -4723,25 +4861,27 @@ var CodePlugin = class {
|
|
|
4723
4861
|
};
|
|
4724
4862
|
renderCodePage(rawPages[0] || (isTxt ? "" : fullText));
|
|
4725
4863
|
pre.appendChild(code);
|
|
4864
|
+
ctx.container.innerHTML = "";
|
|
4726
4865
|
if (isTxt) {
|
|
4727
4866
|
sizer.appendChild(pre);
|
|
4728
4867
|
scrollWrapper.appendChild(sizer);
|
|
4729
|
-
container.appendChild(scrollWrapper);
|
|
4868
|
+
ctx.container.appendChild(scrollWrapper);
|
|
4730
4869
|
} else {
|
|
4731
|
-
|
|
4870
|
+
scrollWrapper.appendChild(lineGutter);
|
|
4871
|
+
scrollWrapper.appendChild(pre);
|
|
4872
|
+
ctx.container.appendChild(scrollWrapper);
|
|
4732
4873
|
}
|
|
4733
4874
|
const showPage = (pageNum) => {
|
|
4734
4875
|
currentPage = Math.max(1, Math.min(totalPages, pageNum));
|
|
4735
4876
|
renderCodePage(rawPages[currentPage - 1] || (isTxt ? "" : fullText));
|
|
4736
|
-
container.scrollTop = 0;
|
|
4877
|
+
ctx.container.scrollTop = 0;
|
|
4737
4878
|
ctx.emit("page-change", { page: currentPage, total: totalPages });
|
|
4738
4879
|
};
|
|
4739
4880
|
if (totalPages > 1) {
|
|
4740
4881
|
showPage(1);
|
|
4741
4882
|
}
|
|
4742
|
-
ctx.container.appendChild(container);
|
|
4743
4883
|
const calculateTxtFit = () => {
|
|
4744
|
-
const availW = Math.max(280, container.clientWidth - 32);
|
|
4884
|
+
const availW = Math.max(280, ctx.container.clientWidth - 32);
|
|
4745
4885
|
return Math.max(0.4, Math.min(3, availW / 816));
|
|
4746
4886
|
};
|
|
4747
4887
|
const updateTransform = () => {
|
|
@@ -4759,6 +4899,7 @@ var CodePlugin = class {
|
|
|
4759
4899
|
} else {
|
|
4760
4900
|
pre.style.transform = `rotate(${rotation}deg)`;
|
|
4761
4901
|
pre.style.fontSize = `${fontSize}px`;
|
|
4902
|
+
lineGutter.style.fontSize = `${fontSize}px`;
|
|
4762
4903
|
}
|
|
4763
4904
|
};
|
|
4764
4905
|
let resizeObserver = null;
|
|
@@ -4773,11 +4914,11 @@ var CodePlugin = class {
|
|
|
4773
4914
|
updateTransform();
|
|
4774
4915
|
}
|
|
4775
4916
|
}) : null;
|
|
4776
|
-
resizeObserver?.observe(container);
|
|
4917
|
+
resizeObserver?.observe(ctx.container);
|
|
4777
4918
|
}
|
|
4778
4919
|
const cleanup = () => {
|
|
4779
4920
|
resizeObserver?.disconnect();
|
|
4780
|
-
|
|
4921
|
+
scrollWrapper.remove();
|
|
4781
4922
|
ctx.container.innerHTML = "";
|
|
4782
4923
|
};
|
|
4783
4924
|
ctx.signal.addEventListener("abort", cleanup);
|
|
@@ -4822,7 +4963,7 @@ var CodePlugin = class {
|
|
|
4822
4963
|
if (isTxt) {
|
|
4823
4964
|
zoomLevel = Math.min(3.5, zoomLevel + 0.15);
|
|
4824
4965
|
} else {
|
|
4825
|
-
fontSize = Math.min(
|
|
4966
|
+
fontSize = Math.min(48, fontSize + 2);
|
|
4826
4967
|
}
|
|
4827
4968
|
updateTransform();
|
|
4828
4969
|
},
|
|
@@ -4831,7 +4972,7 @@ var CodePlugin = class {
|
|
|
4831
4972
|
if (isTxt) {
|
|
4832
4973
|
zoomLevel = Math.max(0.1, zoomLevel - 0.15);
|
|
4833
4974
|
} else {
|
|
4834
|
-
fontSize = Math.max(
|
|
4975
|
+
fontSize = Math.max(9, fontSize - 2);
|
|
4835
4976
|
}
|
|
4836
4977
|
updateTransform();
|
|
4837
4978
|
},
|
|
@@ -4864,8 +5005,8 @@ var CodePlugin = class {
|
|
|
4864
5005
|
fontSize = 13;
|
|
4865
5006
|
rotation = 0;
|
|
4866
5007
|
zoomLevel = isTxt ? calculateTxtFit() : 1;
|
|
4867
|
-
container.scrollTop = 0;
|
|
4868
|
-
container.scrollLeft = 0;
|
|
5008
|
+
ctx.container.scrollTop = 0;
|
|
5009
|
+
ctx.container.scrollLeft = 0;
|
|
4869
5010
|
updateTransform();
|
|
4870
5011
|
},
|
|
4871
5012
|
rotateCW: () => {
|
|
@@ -5187,7 +5328,7 @@ var MarkdownPlugin = class {
|
|
|
5187
5328
|
{
|
|
5188
5329
|
id: "zoom-out",
|
|
5189
5330
|
icon: "zoom-out",
|
|
5190
|
-
label: "
|
|
5331
|
+
label: "Zoom Out",
|
|
5191
5332
|
type: "button",
|
|
5192
5333
|
group: "zoom",
|
|
5193
5334
|
execute: () => instance.zoomOut?.()
|
|
@@ -5195,19 +5336,11 @@ var MarkdownPlugin = class {
|
|
|
5195
5336
|
{
|
|
5196
5337
|
id: "zoom-in",
|
|
5197
5338
|
icon: "zoom-in",
|
|
5198
|
-
label: "
|
|
5339
|
+
label: "Zoom In",
|
|
5199
5340
|
type: "button",
|
|
5200
5341
|
group: "zoom",
|
|
5201
5342
|
execute: () => instance.zoomIn?.()
|
|
5202
5343
|
},
|
|
5203
|
-
{
|
|
5204
|
-
id: "fit-page",
|
|
5205
|
-
icon: "fit-page",
|
|
5206
|
-
label: "Default Size",
|
|
5207
|
-
type: "button",
|
|
5208
|
-
group: "zoom",
|
|
5209
|
-
execute: () => instance.fitToPage?.()
|
|
5210
|
-
},
|
|
5211
5344
|
{
|
|
5212
5345
|
id: "reset-zoom",
|
|
5213
5346
|
icon: "reset-zoom",
|
|
@@ -5224,6 +5357,14 @@ var MarkdownPlugin = class {
|
|
|
5224
5357
|
group: "zoom",
|
|
5225
5358
|
execute: () => instance.fitToWidth?.()
|
|
5226
5359
|
},
|
|
5360
|
+
{
|
|
5361
|
+
id: "fit-page",
|
|
5362
|
+
icon: "fit-page",
|
|
5363
|
+
label: "Fit to Page",
|
|
5364
|
+
type: "button",
|
|
5365
|
+
group: "zoom",
|
|
5366
|
+
execute: () => instance.fitToPage?.()
|
|
5367
|
+
},
|
|
5227
5368
|
{
|
|
5228
5369
|
id: "copy",
|
|
5229
5370
|
icon: "copy",
|
|
@@ -5247,6 +5388,14 @@ var MarkdownPlugin = class {
|
|
|
5247
5388
|
type: "button",
|
|
5248
5389
|
group: "actions",
|
|
5249
5390
|
execute: () => instance.print?.()
|
|
5391
|
+
},
|
|
5392
|
+
{
|
|
5393
|
+
id: "open-window",
|
|
5394
|
+
icon: "open-window",
|
|
5395
|
+
label: "Open in Separate Full Window",
|
|
5396
|
+
type: "button",
|
|
5397
|
+
group: "actions",
|
|
5398
|
+
execute: () => instance.openInSeparateWindow?.()
|
|
5250
5399
|
}
|
|
5251
5400
|
];
|
|
5252
5401
|
}
|
|
@@ -5259,35 +5408,57 @@ var MarkdownPlugin = class {
|
|
|
5259
5408
|
const cleanHtml = DOMPurify6__default.default.sanitize(rawHtml, {
|
|
5260
5409
|
USE_PROFILES: { html: true }
|
|
5261
5410
|
});
|
|
5262
|
-
const
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5411
|
+
const scrollWrapper = document.createElement("div");
|
|
5412
|
+
scrollWrapper.className = "fp-markdown-scroll-wrapper";
|
|
5413
|
+
scrollWrapper.style.minWidth = "100%";
|
|
5414
|
+
scrollWrapper.style.minHeight = "100%";
|
|
5415
|
+
scrollWrapper.style.width = "max-content";
|
|
5416
|
+
scrollWrapper.style.height = "max-content";
|
|
5417
|
+
scrollWrapper.style.display = "flex";
|
|
5418
|
+
scrollWrapper.style.justifyContent = "center";
|
|
5419
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
5420
|
+
scrollWrapper.style.padding = "24px 16px";
|
|
5421
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
5422
|
+
const sizer = document.createElement("div");
|
|
5423
|
+
sizer.className = "fp-markdown-sizer";
|
|
5424
|
+
sizer.style.position = "relative";
|
|
5425
|
+
sizer.style.flexShrink = "0";
|
|
5426
|
+
sizer.style.display = "flex";
|
|
5427
|
+
sizer.style.justifyContent = "center";
|
|
5428
|
+
sizer.style.alignItems = "flex-start";
|
|
5429
|
+
const docCard = document.createElement("div");
|
|
5430
|
+
docCard.className = "fp-markdown-doc-card";
|
|
5431
|
+
docCard.style.cssText = `
|
|
5432
|
+
width: 860px;
|
|
5433
|
+
min-height: 600px;
|
|
5434
|
+
padding: 40px 48px;
|
|
5269
5435
|
box-sizing: border-box;
|
|
5270
5436
|
line-height: 1.6;
|
|
5271
5437
|
font-size: 15px;
|
|
5272
5438
|
color: var(--fp-text, #24292f);
|
|
5273
5439
|
background: var(--fp-bg, #ffffff);
|
|
5440
|
+
border-radius: 6px;
|
|
5441
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
|
5274
5442
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
|
|
5443
|
+
transform-origin: top center;
|
|
5444
|
+
transition: transform 0.15s ease;
|
|
5445
|
+
flex-shrink: 0;
|
|
5275
5446
|
`;
|
|
5276
|
-
|
|
5447
|
+
docCard.innerHTML = `
|
|
5277
5448
|
<style>
|
|
5278
|
-
.fp-markdown-
|
|
5279
|
-
.fp-markdown-
|
|
5449
|
+
.fp-markdown-doc-card h1, .fp-markdown-doc-card h2, .fp-markdown-doc-card h3,
|
|
5450
|
+
.fp-markdown-doc-card h4, .fp-markdown-doc-card h5, .fp-markdown-doc-card h6 {
|
|
5280
5451
|
margin-top: 24px;
|
|
5281
5452
|
margin-bottom: 16px;
|
|
5282
5453
|
font-weight: 600;
|
|
5283
5454
|
line-height: 1.25;
|
|
5284
5455
|
color: var(--fp-text, #1f2328);
|
|
5285
5456
|
}
|
|
5286
|
-
.fp-markdown-
|
|
5287
|
-
.fp-markdown-
|
|
5288
|
-
.fp-markdown-
|
|
5289
|
-
.fp-markdown-
|
|
5290
|
-
.fp-markdown-
|
|
5457
|
+
.fp-markdown-doc-card h1 { font-size: 2em; padding-bottom: 0.3em; border-bottom: 1px solid var(--fp-border, #d0d7de); }
|
|
5458
|
+
.fp-markdown-doc-card h2 { font-size: 1.5em; padding-bottom: 0.3em; border-bottom: 1px solid var(--fp-border, #d0d7de); }
|
|
5459
|
+
.fp-markdown-doc-card h3 { font-size: 1.25em; }
|
|
5460
|
+
.fp-markdown-doc-card p { margin-top: 0; margin-bottom: 16px; }
|
|
5461
|
+
.fp-markdown-doc-card table {
|
|
5291
5462
|
border-spacing: 0;
|
|
5292
5463
|
border-collapse: collapse;
|
|
5293
5464
|
margin-top: 0;
|
|
@@ -5295,20 +5466,20 @@ var MarkdownPlugin = class {
|
|
|
5295
5466
|
width: 100%;
|
|
5296
5467
|
overflow: auto;
|
|
5297
5468
|
}
|
|
5298
|
-
.fp-markdown-
|
|
5469
|
+
.fp-markdown-doc-card table th, .fp-markdown-doc-card table td {
|
|
5299
5470
|
padding: 6px 13px;
|
|
5300
5471
|
border: 1px solid var(--fp-border, #d0d7de);
|
|
5301
5472
|
}
|
|
5302
|
-
.fp-markdown-
|
|
5473
|
+
.fp-markdown-doc-card table tr:nth-child(2n) {
|
|
5303
5474
|
background-color: var(--fp-toolbar-bg, #f6f8fa);
|
|
5304
5475
|
}
|
|
5305
|
-
.fp-markdown-
|
|
5476
|
+
.fp-markdown-doc-card blockquote {
|
|
5306
5477
|
margin: 0 0 16px 0;
|
|
5307
5478
|
padding: 0 1em;
|
|
5308
5479
|
color: var(--fp-text-muted, #59636e);
|
|
5309
5480
|
border-left: 0.25em solid var(--fp-border, #d0d7de);
|
|
5310
5481
|
}
|
|
5311
|
-
.fp-markdown-
|
|
5482
|
+
.fp-markdown-doc-card pre {
|
|
5312
5483
|
padding: 16px;
|
|
5313
5484
|
overflow: auto;
|
|
5314
5485
|
font-size: 85%;
|
|
@@ -5317,7 +5488,7 @@ var MarkdownPlugin = class {
|
|
|
5317
5488
|
border-radius: 6px;
|
|
5318
5489
|
border: 1px solid var(--fp-border, #d0d7de);
|
|
5319
5490
|
}
|
|
5320
|
-
.fp-markdown-
|
|
5491
|
+
.fp-markdown-doc-card code {
|
|
5321
5492
|
padding: 0.2em 0.4em;
|
|
5322
5493
|
margin: 0;
|
|
5323
5494
|
font-size: 85%;
|
|
@@ -5325,16 +5496,16 @@ var MarkdownPlugin = class {
|
|
|
5325
5496
|
border-radius: 4px;
|
|
5326
5497
|
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
|
|
5327
5498
|
}
|
|
5328
|
-
.fp-markdown-
|
|
5499
|
+
.fp-markdown-doc-card pre code {
|
|
5329
5500
|
padding: 0;
|
|
5330
5501
|
background: transparent;
|
|
5331
5502
|
}
|
|
5332
|
-
.fp-markdown-
|
|
5503
|
+
.fp-markdown-doc-card ul, .fp-markdown-doc-card ol {
|
|
5333
5504
|
padding-left: 2em;
|
|
5334
5505
|
margin-top: 0;
|
|
5335
5506
|
margin-bottom: 16px;
|
|
5336
5507
|
}
|
|
5337
|
-
.fp-markdown-
|
|
5508
|
+
.fp-markdown-doc-card hr {
|
|
5338
5509
|
height: 0.25em;
|
|
5339
5510
|
padding: 0;
|
|
5340
5511
|
margin: 24px 0;
|
|
@@ -5342,50 +5513,95 @@ var MarkdownPlugin = class {
|
|
|
5342
5513
|
border: 0;
|
|
5343
5514
|
}
|
|
5344
5515
|
</style>
|
|
5345
|
-
<div class="fp-markdown-
|
|
5516
|
+
<div class="fp-markdown-body">
|
|
5346
5517
|
${cleanHtml}
|
|
5347
5518
|
</div>
|
|
5348
5519
|
`;
|
|
5349
|
-
|
|
5520
|
+
docCard.querySelectorAll("pre code").forEach((block) => {
|
|
5350
5521
|
hljs__default.default.highlightElement(block);
|
|
5351
5522
|
});
|
|
5523
|
+
sizer.appendChild(docCard);
|
|
5524
|
+
scrollWrapper.appendChild(sizer);
|
|
5352
5525
|
ctx.container.innerHTML = "";
|
|
5353
5526
|
ctx.container.style.overflow = "auto";
|
|
5354
|
-
ctx.container.
|
|
5355
|
-
|
|
5527
|
+
ctx.container.style.backgroundColor = "#f1f5f9";
|
|
5528
|
+
ctx.container.appendChild(scrollWrapper);
|
|
5529
|
+
let scale = 1;
|
|
5530
|
+
let isUserZoomed = false;
|
|
5531
|
+
const calculateFitScale = () => {
|
|
5532
|
+
const availW = Math.max(280, ctx.container.clientWidth - 48);
|
|
5533
|
+
if (availW < 860) {
|
|
5534
|
+
return Math.max(0.35, availW / 860);
|
|
5535
|
+
}
|
|
5536
|
+
return 1;
|
|
5537
|
+
};
|
|
5538
|
+
const applyTransform = () => {
|
|
5539
|
+
const baseW = 860;
|
|
5540
|
+
const baseH = docCard.offsetHeight || 600;
|
|
5541
|
+
const scaledW = Math.round(baseW * scale);
|
|
5542
|
+
const scaledH = Math.round(baseH * scale);
|
|
5543
|
+
sizer.style.width = `${scaledW}px`;
|
|
5544
|
+
sizer.style.height = `${scaledH}px`;
|
|
5545
|
+
docCard.style.width = `${baseW}px`;
|
|
5546
|
+
docCard.style.transform = `scale(${scale})`;
|
|
5547
|
+
docCard.style.transformOrigin = scaledW > ctx.container.clientWidth - 32 ? "top left" : "top center";
|
|
5548
|
+
};
|
|
5549
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
5550
|
+
if (!isUserZoomed) {
|
|
5551
|
+
scale = calculateFitScale();
|
|
5552
|
+
applyTransform();
|
|
5553
|
+
}
|
|
5554
|
+
}) : null;
|
|
5555
|
+
ro?.observe(ctx.container);
|
|
5556
|
+
requestAnimationFrame(() => {
|
|
5557
|
+
if (!isUserZoomed) {
|
|
5558
|
+
scale = calculateFitScale();
|
|
5559
|
+
}
|
|
5560
|
+
applyTransform();
|
|
5561
|
+
});
|
|
5356
5562
|
const cleanup = () => {
|
|
5357
|
-
|
|
5563
|
+
ro?.disconnect();
|
|
5564
|
+
scrollWrapper.remove();
|
|
5358
5565
|
ctx.container.innerHTML = "";
|
|
5359
5566
|
};
|
|
5360
5567
|
ctx.signal.addEventListener("abort", cleanup);
|
|
5361
5568
|
return {
|
|
5362
5569
|
destroy: cleanup,
|
|
5363
5570
|
zoomIn: () => {
|
|
5364
|
-
|
|
5365
|
-
|
|
5571
|
+
isUserZoomed = true;
|
|
5572
|
+
scale = Math.min(3.5, scale + 0.15);
|
|
5573
|
+
applyTransform();
|
|
5366
5574
|
},
|
|
5367
5575
|
zoomOut: () => {
|
|
5368
|
-
|
|
5369
|
-
|
|
5576
|
+
isUserZoomed = true;
|
|
5577
|
+
scale = Math.max(0.25, scale - 0.15);
|
|
5578
|
+
applyTransform();
|
|
5370
5579
|
},
|
|
5371
|
-
getZoom: () =>
|
|
5580
|
+
getZoom: () => scale,
|
|
5372
5581
|
setZoom: (level) => {
|
|
5373
|
-
|
|
5374
|
-
|
|
5582
|
+
isUserZoomed = true;
|
|
5583
|
+
scale = level;
|
|
5584
|
+
applyTransform();
|
|
5375
5585
|
},
|
|
5376
5586
|
fitToPage: () => {
|
|
5377
|
-
|
|
5378
|
-
|
|
5587
|
+
isUserZoomed = false;
|
|
5588
|
+
scale = calculateFitScale();
|
|
5589
|
+
applyTransform();
|
|
5379
5590
|
},
|
|
5380
5591
|
fitToWidth: () => {
|
|
5381
|
-
|
|
5382
|
-
|
|
5592
|
+
isUserZoomed = false;
|
|
5593
|
+
scale = calculateFitScale();
|
|
5594
|
+
applyTransform();
|
|
5383
5595
|
},
|
|
5384
5596
|
resetZoom: () => {
|
|
5385
|
-
|
|
5386
|
-
|
|
5597
|
+
isUserZoomed = false;
|
|
5598
|
+
scale = calculateFitScale();
|
|
5387
5599
|
ctx.container.scrollTop = 0;
|
|
5388
5600
|
ctx.container.scrollLeft = 0;
|
|
5601
|
+
applyTransform();
|
|
5602
|
+
},
|
|
5603
|
+
openInSeparateWindow: () => {
|
|
5604
|
+
ctx?.openInSeparateWindow?.();
|
|
5389
5605
|
},
|
|
5390
5606
|
download: () => {
|
|
5391
5607
|
downloadFile(ctx.buffer, ctx.metadata.name || "document.md", "text/markdown");
|
|
@@ -6701,14 +6917,6 @@ var HtmlPreviewPlugin = class {
|
|
|
6701
6917
|
group: "zoom",
|
|
6702
6918
|
execute: () => instance.zoomIn?.()
|
|
6703
6919
|
},
|
|
6704
|
-
{
|
|
6705
|
-
id: "fit-page",
|
|
6706
|
-
icon: "fit-page",
|
|
6707
|
-
label: "Fit to Page",
|
|
6708
|
-
type: "button",
|
|
6709
|
-
group: "zoom",
|
|
6710
|
-
execute: () => instance.fitToPage?.()
|
|
6711
|
-
},
|
|
6712
6920
|
{
|
|
6713
6921
|
id: "reset-zoom",
|
|
6714
6922
|
icon: "reset-zoom",
|
|
@@ -6725,6 +6933,14 @@ var HtmlPreviewPlugin = class {
|
|
|
6725
6933
|
group: "zoom",
|
|
6726
6934
|
execute: () => instance.fitToWidth?.()
|
|
6727
6935
|
},
|
|
6936
|
+
{
|
|
6937
|
+
id: "fit-page",
|
|
6938
|
+
icon: "fit-page",
|
|
6939
|
+
label: "Fit to Page",
|
|
6940
|
+
type: "button",
|
|
6941
|
+
group: "zoom",
|
|
6942
|
+
execute: () => instance.fitToPage?.()
|
|
6943
|
+
},
|
|
6728
6944
|
{
|
|
6729
6945
|
id: "copy",
|
|
6730
6946
|
icon: "copy",
|
|
@@ -6748,6 +6964,14 @@ var HtmlPreviewPlugin = class {
|
|
|
6748
6964
|
type: "button",
|
|
6749
6965
|
group: "actions",
|
|
6750
6966
|
execute: () => instance.print?.()
|
|
6967
|
+
},
|
|
6968
|
+
{
|
|
6969
|
+
id: "open-window",
|
|
6970
|
+
icon: "open-window",
|
|
6971
|
+
label: "Open in Separate Full Window",
|
|
6972
|
+
type: "button",
|
|
6973
|
+
group: "actions",
|
|
6974
|
+
execute: () => instance.openInSeparateWindow?.()
|
|
6751
6975
|
}
|
|
6752
6976
|
];
|
|
6753
6977
|
}
|
|
@@ -6758,27 +6982,39 @@ var HtmlPreviewPlugin = class {
|
|
|
6758
6982
|
ADD_TAGS: ["style", "link"],
|
|
6759
6983
|
ADD_ATTR: ["target", "rel"]
|
|
6760
6984
|
});
|
|
6985
|
+
const scrollWrapper = document.createElement("div");
|
|
6986
|
+
scrollWrapper.className = "fp-html-scroll-wrapper";
|
|
6987
|
+
scrollWrapper.style.minWidth = "100%";
|
|
6988
|
+
scrollWrapper.style.minHeight = "100%";
|
|
6989
|
+
scrollWrapper.style.width = "max-content";
|
|
6990
|
+
scrollWrapper.style.height = "max-content";
|
|
6991
|
+
scrollWrapper.style.display = "flex";
|
|
6992
|
+
scrollWrapper.style.justifyContent = "flex-start";
|
|
6993
|
+
scrollWrapper.style.alignItems = "flex-start";
|
|
6994
|
+
scrollWrapper.style.boxSizing = "border-box";
|
|
6761
6995
|
const sizer = document.createElement("div");
|
|
6762
6996
|
sizer.className = "fp-html-sizer";
|
|
6763
6997
|
sizer.style.position = "relative";
|
|
6998
|
+
sizer.style.flexShrink = "0";
|
|
6764
6999
|
const iframe = document.createElement("iframe");
|
|
6765
7000
|
iframe.className = "fp-html-iframe";
|
|
6766
7001
|
iframe.style.border = "none";
|
|
6767
7002
|
iframe.style.backgroundColor = "#ffffff";
|
|
6768
7003
|
iframe.style.transformOrigin = "top left";
|
|
6769
|
-
iframe.style.transition = "transform 0.
|
|
7004
|
+
iframe.style.transition = "transform 0.15s ease";
|
|
6770
7005
|
iframe.sandbox.add("allow-same-origin");
|
|
6771
7006
|
sizer.appendChild(iframe);
|
|
7007
|
+
scrollWrapper.appendChild(sizer);
|
|
6772
7008
|
ctx.container.style.overflow = "auto";
|
|
6773
7009
|
ctx.container.style.width = "100%";
|
|
6774
7010
|
ctx.container.style.height = "100%";
|
|
6775
7011
|
ctx.container.innerHTML = "";
|
|
6776
|
-
ctx.container.appendChild(
|
|
7012
|
+
ctx.container.appendChild(scrollWrapper);
|
|
6777
7013
|
iframe.srcdoc = sanitized;
|
|
6778
7014
|
let scale = 1;
|
|
7015
|
+
let baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7016
|
+
let baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6779
7017
|
const applyTransform = () => {
|
|
6780
|
-
const baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
6781
|
-
const baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6782
7018
|
const scaledW = Math.round(baseW * scale);
|
|
6783
7019
|
const scaledH = Math.round(baseH * scale);
|
|
6784
7020
|
sizer.style.width = `${scaledW}px`;
|
|
@@ -6791,22 +7027,33 @@ var HtmlPreviewPlugin = class {
|
|
|
6791
7027
|
iframe.style.transform = `scale(${scale})`;
|
|
6792
7028
|
iframe.style.transformOrigin = "top left";
|
|
6793
7029
|
};
|
|
7030
|
+
const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
7031
|
+
if (Math.abs(scale - 1) < 0.05) {
|
|
7032
|
+
baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7033
|
+
baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
7034
|
+
applyTransform();
|
|
7035
|
+
}
|
|
7036
|
+
}) : null;
|
|
7037
|
+
ro?.observe(ctx.container);
|
|
6794
7038
|
requestAnimationFrame(() => {
|
|
7039
|
+
baseW = Math.max(600, ctx.container.clientWidth || 800);
|
|
7040
|
+
baseH = Math.max(400, ctx.container.clientHeight || 600);
|
|
6795
7041
|
applyTransform();
|
|
6796
7042
|
});
|
|
6797
7043
|
const cleanup = () => {
|
|
6798
|
-
|
|
7044
|
+
ro?.disconnect();
|
|
7045
|
+
scrollWrapper.remove();
|
|
6799
7046
|
ctx.container.innerHTML = "";
|
|
6800
7047
|
};
|
|
6801
7048
|
ctx.signal.addEventListener("abort", cleanup);
|
|
6802
7049
|
return {
|
|
6803
7050
|
destroy: cleanup,
|
|
6804
7051
|
zoomIn: () => {
|
|
6805
|
-
scale
|
|
7052
|
+
scale = Math.min(3.5, scale + 0.15);
|
|
6806
7053
|
applyTransform();
|
|
6807
7054
|
},
|
|
6808
7055
|
zoomOut: () => {
|
|
6809
|
-
scale = Math.max(0.
|
|
7056
|
+
scale = Math.max(0.25, scale - 0.15);
|
|
6810
7057
|
applyTransform();
|
|
6811
7058
|
},
|
|
6812
7059
|
getZoom: () => scale,
|
|
@@ -6828,8 +7075,11 @@ var HtmlPreviewPlugin = class {
|
|
|
6828
7075
|
ctx.container.scrollLeft = 0;
|
|
6829
7076
|
applyTransform();
|
|
6830
7077
|
},
|
|
7078
|
+
openInSeparateWindow: () => {
|
|
7079
|
+
ctx?.openInSeparateWindow?.();
|
|
7080
|
+
},
|
|
6831
7081
|
copy: () => {
|
|
6832
|
-
navigator.clipboard
|
|
7082
|
+
navigator.clipboard?.writeText(rawHtml);
|
|
6833
7083
|
},
|
|
6834
7084
|
download: () => {
|
|
6835
7085
|
const blob = new Blob([ctx.buffer], { type: "text/html" });
|
|
@@ -8945,7 +9195,7 @@ var FilePreview = vue.defineComponent({
|
|
|
8945
9195
|
return () => {
|
|
8946
9196
|
return vue.h("div", {
|
|
8947
9197
|
ref: containerRef,
|
|
8948
|
-
style: { width: "100%", height: "100%", position: "relative" }
|
|
9198
|
+
style: { width: "100%", height: "100%", position: "relative", overflow: "hidden" }
|
|
8949
9199
|
});
|
|
8950
9200
|
};
|
|
8951
9201
|
}
|