@zero-library/common 2.0.6 → 2.0.7

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.d.mts CHANGED
@@ -100,8 +100,9 @@ interface Props$2 {
100
100
  extraNav?: ReactNode;
101
101
  showToolbar?: boolean;
102
102
  onQuote?: (text: string) => void;
103
+ onDownloadFile?: (fileContent: string, targetFormat?: string) => Promise<void>;
103
104
  }
104
- declare const _default$3: ({ value, onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar, onQuote }: Props$2) => react_jsx_runtime.JSX.Element;
105
+ declare const _default$3: ({ value, onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar, onQuote, onDownloadFile }: Props$2) => react_jsx_runtime.JSX.Element;
105
106
 
106
107
  interface Props$1 {
107
108
  content?: string;
package/dist/index.d.ts CHANGED
@@ -100,8 +100,9 @@ interface Props$2 {
100
100
  extraNav?: ReactNode;
101
101
  showToolbar?: boolean;
102
102
  onQuote?: (text: string) => void;
103
+ onDownloadFile?: (fileContent: string, targetFormat?: string) => Promise<void>;
103
104
  }
104
- declare const _default$3: ({ value, onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar, onQuote }: Props$2) => react_jsx_runtime.JSX.Element;
105
+ declare const _default$3: ({ value, onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar, onQuote, onDownloadFile }: Props$2) => react_jsx_runtime.JSX.Element;
105
106
 
106
107
  interface Props$1 {
107
108
  content?: string;
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
2
2
  import { FileUnknownOutlined, FileZipOutlined, FileMarkdownOutlined, FileGifOutlined, FileImageOutlined, FileJpgOutlined, NotificationOutlined, VideoCameraOutlined, FilePptOutlined, FileExcelOutlined, FileWordOutlined, FilePdfOutlined, FileTextOutlined } from '@ant-design/icons';
3
3
  import * as React16 from 'react';
4
4
  import { forwardRef, useState, useMemo, useEffect, lazy, Suspense, createContext, useRef, useCallback, useContext } from 'react';
5
- import { Spin, notification, Modal, Result, Splitter, Empty, Image, Flex, Drawer, Avatar, Alert, Form, Input, Button } from 'antd';
5
+ import { Spin, notification, Modal, Result, Splitter, Empty, Image, Flex, Drawer, Tag, Avatar, Alert, Form, Input, Button } from 'antd';
6
6
  import parse from 'html-react-parser';
7
7
  import { jsonrepair } from 'jsonrepair';
8
8
  import markdownit from 'markdown-it';
@@ -663,6 +663,7 @@ var downloadFile = (url, name) => {
663
663
  document.body.appendChild(a);
664
664
  a.click();
665
665
  document.body.removeChild(a);
666
+ window.URL.revokeObjectURL(url);
666
667
  };
667
668
  var addUrlLastSlash = (url = "") => {
668
669
  const u = new URL(url, "https://logosdata.cn");
@@ -980,6 +981,9 @@ axios.interceptors.request.use(
980
981
  );
981
982
  axios.interceptors.response.use(
982
983
  function(response) {
984
+ if (isBlob(response.data)) {
985
+ return response;
986
+ }
983
987
  if (response.data?.code !== OK && response.data?.code !== OK2) {
984
988
  const isPermission = response.data?.code === PERMISSION_DENIED;
985
989
  if (response.config?.showError !== false) {
@@ -4968,7 +4972,7 @@ var MobileToolbarContent = ({ type, onBack }) => /* @__PURE__ */ jsxs(Fragment,
4968
4972
  /* @__PURE__ */ jsx(ToolbarSeparator, {}),
4969
4973
  type === "highlighter" ? /* @__PURE__ */ jsx(HighlightContent, {}) : /* @__PURE__ */ jsx(LinkContent, {})
4970
4974
  ] });
4971
- var MarkdownEditor_default = ({ value = "", onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar = true, onQuote }) => {
4975
+ var MarkdownEditor_default = ({ value = "", onChange, onScrollPage, searchValue, disabled, extraNav, showToolbar = true, onQuote, onDownloadFile }) => {
4972
4976
  const isMobile = useMobile();
4973
4977
  const windowSize = useWindowSize();
4974
4978
  const lastContentRef = useRef("");
@@ -5143,11 +5147,17 @@ var MarkdownEditor_default = ({ value = "", onChange, onScrollPage, searchValue,
5143
5147
  ) : /* @__PURE__ */ jsx(MobileToolbarContent, { type: mobileView === "highlighter" ? "highlighter" : "link", onBack: () => setMobileView("main") })
5144
5148
  }
5145
5149
  ) });
5150
+ const downloadFile2 = () => {
5151
+ onDownloadFile?.(editor.storage.markdown.getMarkdown(), "docx");
5152
+ };
5146
5153
  return /* @__PURE__ */ jsx("div", { className: classNames2("height-full", "editor-parent"), children: /* @__PURE__ */ jsxs(EditorContext.Provider, { value: { editor }, children: [
5147
5154
  showToolbar && /* @__PURE__ */ jsxs(Fragment, { children: [
5148
5155
  /* @__PURE__ */ jsxs(Flex, { justify: "end", align: "center", children: [
5149
5156
  NsToolBar({ isBubble: false }),
5150
- extraNav && /* @__PURE__ */ jsx("div", { className: "m-l-16 m-r-16", children: extraNav })
5157
+ extraNav && /* @__PURE__ */ jsxs(Flex, { align: "center", className: "m-l-16 m-r-16", children: [
5158
+ onDownloadFile && /* @__PURE__ */ jsx(Tag, { bordered: false, color: "default", className: "cursor-pointer", onClick: downloadFile2, children: "\u4E0B\u8F7D" }),
5159
+ extraNav
5160
+ ] })
5151
5161
  ] }),
5152
5162
  !isMobile && /* @__PURE__ */ jsx(BubbleMenu, { editor, children: NsToolBar({ isBubble: true }) })
5153
5163
  ] }),