@zero-library/common 2.0.5 → 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.cjs.js +13 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.css +3 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.esm.js +14 -4
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -2
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;
|
|
@@ -112,11 +113,12 @@ interface Props$1 {
|
|
|
112
113
|
}
|
|
113
114
|
declare const _default$2: ({ content, searchValue, customComponents, onChange, onPartialChange }: Props$1) => react_jsx_runtime.JSX.Element;
|
|
114
115
|
|
|
115
|
-
type
|
|
116
|
+
type RenderControlObj<C, P = ObjectType<any>> = {
|
|
116
117
|
visible?: boolean;
|
|
117
118
|
render?: (ctx: C) => React.ReactNode;
|
|
118
119
|
props?: P;
|
|
119
120
|
};
|
|
121
|
+
type RenderControl<C, P = ObjectType<any>> = boolean | RenderControlObj<C, P>;
|
|
120
122
|
interface RenderWrapperProps<C, P> {
|
|
121
123
|
control?: RenderControl<C, P> | null;
|
|
122
124
|
ctx?: C;
|
|
@@ -365,4 +367,4 @@ declare function getSignPath(): string;
|
|
|
365
367
|
declare const LgPrimaryColor: string;
|
|
366
368
|
declare const themeConfig: ThemeConfig;
|
|
367
369
|
|
|
368
|
-
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createValtioContext, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, _default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
|
370
|
+
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, type RenderControlObj, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createValtioContext, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, _default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
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;
|
|
@@ -112,11 +113,12 @@ interface Props$1 {
|
|
|
112
113
|
}
|
|
113
114
|
declare const _default$2: ({ content, searchValue, customComponents, onChange, onPartialChange }: Props$1) => react_jsx_runtime.JSX.Element;
|
|
114
115
|
|
|
115
|
-
type
|
|
116
|
+
type RenderControlObj<C, P = ObjectType<any>> = {
|
|
116
117
|
visible?: boolean;
|
|
117
118
|
render?: (ctx: C) => React.ReactNode;
|
|
118
119
|
props?: P;
|
|
119
120
|
};
|
|
121
|
+
type RenderControl<C, P = ObjectType<any>> = boolean | RenderControlObj<C, P>;
|
|
120
122
|
interface RenderWrapperProps<C, P> {
|
|
121
123
|
control?: RenderControl<C, P> | null;
|
|
122
124
|
ctx?: C;
|
|
@@ -365,4 +367,4 @@ declare function getSignPath(): string;
|
|
|
365
367
|
declare const LgPrimaryColor: string;
|
|
366
368
|
declare const themeConfig: ThemeConfig;
|
|
367
369
|
|
|
368
|
-
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createValtioContext, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, _default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
|
370
|
+
export { _default$c as AudioPlayer, DateFormatType, DateFormatType2, ERROR, FORBIDDEN, FacePastCode, _default$b as FileIcon, _default$a as FilePreview, _default$9 as FilePreviewDrawer, ILLEGAL_PARAMETER, _default$5 as Iframe, _default$4 as LazyComponent, LgPrimaryColor, LoginPastCode, MISSING_PARAMETER, _default$3 as MarkdownEditor, _default$8 as MarkdownPreview, NOT_FOUND, type NsSetIntervalReturnType, OK, OK2, PERMISSION_DENIED, type Params, _default$7 as PdfPreview, type RenderControl, type RenderControlObj, _default$2 as RenderMarkdown, RenderWrapper, TOKEN_KEY, UNAUTHORIZED, _default$1 as UserAvatar, _default$6 as VideoPlayer, absVal, addUrlLastSlash, arrToObj, buildUrlParams, calculate, clearCurrentUser, clearToken, compareNum, copyText, createValtioContext, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, formType, formatDate, formatNumberWithCommas, genNonDuplicateID, generateRandomNumbers, getCurrentUser, getDeviceId, getEndOfTimestamp, getFileName, getSignPath, getStartOfTimestamp, getTimestamp, getToken, getUrlMainSource, getUrlToken, getWebSocketUrl, is, isArray, isBlob, isBoolean, isClient, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isRegExp, isServer, isString, isUnDef, isWindow, jsonType, minus, nsSetInterval, objToOptions, plus, precision, propsMerge, _default as request, setCurrentUser, setToken, shouldRender, textAreaView, themeConfig, times, toFixed, useDebounce, useDeepEffect, useIframeRelayBridge, useRefState, useSyncInput, useThrottle, useWebSocket };
|
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';
|
|
@@ -225,7 +225,7 @@ function alertInlinePlugin(md2) {
|
|
|
225
225
|
if (!m) return false;
|
|
226
226
|
if (silent) return false;
|
|
227
227
|
const raw = m[1].trim();
|
|
228
|
-
const html = `<lazy-component ${raw}
|
|
228
|
+
const html = `<lazy-component ${raw}></lazy-component>`;
|
|
229
229
|
const token = state.push("html_inline", "", 0);
|
|
230
230
|
token.content = html;
|
|
231
231
|
state.pos += m[0].length;
|
|
@@ -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__ */
|
|
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
|
] }),
|