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