@ibiz-template-plugin/ibiz-file-previewer 0.0.18 → 0.0.21

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/index.es.js CHANGED
@@ -977,26 +977,36 @@ const FileTypeEngineMap = /* @__PURE__ */ new Map([
977
977
  /* HTML */
978
978
  ]],
979
979
  // ET类型文件
980
+ // ------TXT类型文件服务端暂未支持START------
981
+ // [FileType.TXT, [EngineType.TXT]], // TXT类型文件
982
+ // [FileType.JSON, [EngineType.TXT]], // JSON类型文件
983
+ // [FileType.XML, [EngineType.TXT]], // XML类型文件
980
984
  ["txt", [
981
- "TXT"
982
- /* TXT */
985
+ "MD"
986
+ /* MD */
983
987
  ]],
984
988
  // TXT类型文件
985
989
  ["json", [
986
- "TXT"
987
- /* TXT */
990
+ "MD"
991
+ /* MD */
988
992
  ]],
989
993
  // JSON类型文件
990
994
  ["xml", [
991
- "TXT"
992
- /* TXT */
995
+ "MD"
996
+ /* MD */
993
997
  ]],
994
998
  // XML类型文件
999
+ // ------TXT类型文件服务端暂未支持END------
995
1000
  ["pdf", [
996
1001
  "PDF"
997
1002
  /* PDF */
998
1003
  ]],
999
1004
  // PDF类型文件
1005
+ ["ofd", [
1006
+ "PDF"
1007
+ /* PDF */
1008
+ ]],
1009
+ // OFD类型文件
1000
1010
  ["doc", [
1001
1011
  "PDF",
1002
1012
  "HTML"
@@ -1753,16 +1763,10 @@ const Teleport = ({ to = "body", children }) => {
1753
1763
  const target = document.querySelector(to);
1754
1764
  if (target) {
1755
1765
  containerRef.current = target;
1756
- } else {
1757
- const el = document.createElement("div");
1758
- el.id = to.replace("#", "");
1759
- document.body.appendChild(el);
1760
- containerRef.current = el;
1761
1766
  }
1762
1767
  return () => {
1763
- var _a;
1764
- if (to.startsWith("#") && !document.querySelector(to)) {
1765
- (_a = containerRef.current) == null ? void 0 : _a.remove();
1768
+ if (containerRef.current) {
1769
+ containerRef.current = null;
1766
1770
  }
1767
1771
  };
1768
1772
  }, [to]);
@@ -18472,8 +18476,9 @@ const ThumbnailPanel = (props) => {
18472
18476
  const ImagePage = (props) => {
18473
18477
  const isLoading = useSignal(true);
18474
18478
  const imgRef = A(null);
18479
+ const [imgStyle, setImgStyle] = d$2({});
18475
18480
  const elementHeight = useSignal(0);
18476
- const imgStyle = useComputed(() => {
18481
+ y$1(() => {
18477
18482
  let result = {};
18478
18483
  const { width, height } = props.parentDimensions;
18479
18484
  if (isLoading.value) {
@@ -18500,8 +18505,8 @@ const ImagePage = (props) => {
18500
18505
  });
18501
18506
  }
18502
18507
  }
18503
- return result;
18504
- });
18508
+ setImgStyle(result);
18509
+ }, [props.parentDimensions, props.state.value, isLoading.value]);
18505
18510
  const handleImageLoad = () => {
18506
18511
  isLoading.value = false;
18507
18512
  };
@@ -18533,7 +18538,7 @@ const ImagePage = (props) => {
18533
18538
  {
18534
18539
  ref: imgRef,
18535
18540
  className: "image-page",
18536
- style: imgStyle.value,
18541
+ style: imgStyle,
18537
18542
  "data-page-index": props.index,
18538
18543
  children: [
18539
18544
  /* @__PURE__ */ u(
@@ -20063,8 +20068,13 @@ class FilePreviewMDController extends FilePreviewTextController {
20063
20068
  * 获取内容
20064
20069
  */
20065
20070
  async getContent() {
20071
+ const options = this.filePreviewShell.getOptions();
20072
+ const { fileId, fileCat, fileContent } = this.filePreviewShell.getState();
20066
20073
  try {
20067
- let content = await super.getContent();
20074
+ if (fileContent) {
20075
+ return fileContent;
20076
+ }
20077
+ let content = await options.getContent(fileId, "md", fileCat);
20068
20078
  if (this.state.value.fileType === FileType.HTML) {
20069
20079
  const parser = new DOMParser();
20070
20080
  const doc = parser.parseFromString(content, "text/html");
@@ -20079,7 +20089,7 @@ class FilePreviewMDController extends FilePreviewTextController {
20079
20089
  });
20080
20090
  content = turndown.turndown(cleanBodyHTML);
20081
20091
  }
20082
- return content;
20092
+ return content || "";
20083
20093
  } catch (error2) {
20084
20094
  return error2.message || "";
20085
20095
  }
@@ -20091,8 +20101,11 @@ class FilePreviewHtmlController extends FilePreviewTextController {
20091
20101
  */
20092
20102
  async getContent() {
20093
20103
  const options = this.filePreviewShell.getOptions();
20094
- const { fileId, fileCat } = this.filePreviewShell.getState();
20104
+ const { fileId, fileCat, fileContent } = this.filePreviewShell.getState();
20095
20105
  try {
20106
+ if (fileContent) {
20107
+ return fileContent;
20108
+ }
20096
20109
  const content = await options.getContent(fileId, "html", fileCat);
20097
20110
  return content || "";
20098
20111
  } catch (error2) {
@@ -20290,7 +20303,13 @@ class FilePreviewShellController {
20290
20303
  this.destroyComponent();
20291
20304
  this.container = document.querySelector(this.options.selector);
20292
20305
  if (this.container)
20293
- G$1(_$2(FilePreviewShell, { controller: this }), this.container);
20306
+ G$1(
20307
+ _$2(FilePreviewShell, {
20308
+ key: JSON.stringify(this.state.value),
20309
+ controller: this
20310
+ }),
20311
+ this.container
20312
+ );
20294
20313
  }
20295
20314
  /**
20296
20315
  * 销毁组件实例
@@ -20351,12 +20370,13 @@ class FilePreviewShellController {
20351
20370
  async copyTextContent(_event) {
20352
20371
  if (!this.options.getContent) return;
20353
20372
  await copyTextToClipboard("");
20354
- const { fileId, fileType, fileCat, fileContent } = this.state.value;
20373
+ const { fileId, engineType, fileCat, fileContent } = this.state.value;
20355
20374
  let content = fileContent;
20356
20375
  if (content === "") {
20376
+ const type = engineType === "HTML" ? "html" : "md";
20357
20377
  content = await this.options.getContent(
20358
20378
  fileId,
20359
- fileType,
20379
+ type,
20360
20380
  fileCat
20361
20381
  );
20362
20382
  }