@ibiz-template-plugin/ibiz-file-previewer 0.0.20 → 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"
@@ -20058,8 +20068,13 @@ class FilePreviewMDController extends FilePreviewTextController {
20058
20068
  * 获取内容
20059
20069
  */
20060
20070
  async getContent() {
20071
+ const options = this.filePreviewShell.getOptions();
20072
+ const { fileId, fileCat, fileContent } = this.filePreviewShell.getState();
20061
20073
  try {
20062
- let content = await super.getContent();
20074
+ if (fileContent) {
20075
+ return fileContent;
20076
+ }
20077
+ let content = await options.getContent(fileId, "md", fileCat);
20063
20078
  if (this.state.value.fileType === FileType.HTML) {
20064
20079
  const parser = new DOMParser();
20065
20080
  const doc = parser.parseFromString(content, "text/html");
@@ -20074,7 +20089,7 @@ class FilePreviewMDController extends FilePreviewTextController {
20074
20089
  });
20075
20090
  content = turndown.turndown(cleanBodyHTML);
20076
20091
  }
20077
- return content;
20092
+ return content || "";
20078
20093
  } catch (error2) {
20079
20094
  return error2.message || "";
20080
20095
  }
@@ -20086,8 +20101,11 @@ class FilePreviewHtmlController extends FilePreviewTextController {
20086
20101
  */
20087
20102
  async getContent() {
20088
20103
  const options = this.filePreviewShell.getOptions();
20089
- const { fileId, fileCat } = this.filePreviewShell.getState();
20104
+ const { fileId, fileCat, fileContent } = this.filePreviewShell.getState();
20090
20105
  try {
20106
+ if (fileContent) {
20107
+ return fileContent;
20108
+ }
20091
20109
  const content = await options.getContent(fileId, "html", fileCat);
20092
20110
  return content || "";
20093
20111
  } catch (error2) {
@@ -20352,12 +20370,13 @@ class FilePreviewShellController {
20352
20370
  async copyTextContent(_event) {
20353
20371
  if (!this.options.getContent) return;
20354
20372
  await copyTextToClipboard("");
20355
- const { fileId, fileType, fileCat, fileContent } = this.state.value;
20373
+ const { fileId, engineType, fileCat, fileContent } = this.state.value;
20356
20374
  let content = fileContent;
20357
20375
  if (content === "") {
20376
+ const type = engineType === "HTML" ? "html" : "md";
20358
20377
  content = await this.options.getContent(
20359
20378
  fileId,
20360
- fileType,
20379
+ type,
20361
20380
  fileCat
20362
20381
  );
20363
20382
  }