@zero-library/common 2.0.8 → 2.1.0
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 +24 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +29 -14
- package/dist/index.d.ts +29 -14
- package/dist/index.esm.js +23 -19
- package/dist/index.esm.js.map +1 -1
- package/package.json +2 -3
package/dist/index.cjs.js
CHANGED
|
@@ -44,7 +44,6 @@ var TiptapLink = require('@tiptap/extension-link');
|
|
|
44
44
|
var state = require('@tiptap/pm/state');
|
|
45
45
|
var view = require('@tiptap/pm/view');
|
|
46
46
|
var react$1 = require('@floating-ui/react');
|
|
47
|
-
var TurndownService = require('turndown');
|
|
48
47
|
var core = require('@tiptap/core');
|
|
49
48
|
|
|
50
49
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -83,7 +82,6 @@ var TableCell__default = /*#__PURE__*/_interopDefault(TableCell);
|
|
|
83
82
|
var TableHeader__default = /*#__PURE__*/_interopDefault(TableHeader);
|
|
84
83
|
var TableRow__default = /*#__PURE__*/_interopDefault(TableRow);
|
|
85
84
|
var TiptapLink__default = /*#__PURE__*/_interopDefault(TiptapLink);
|
|
86
|
-
var TurndownService__default = /*#__PURE__*/_interopDefault(TurndownService);
|
|
87
85
|
|
|
88
86
|
// src/components/File/styles.module.less
|
|
89
87
|
var styles_module_default = {
|
|
@@ -354,20 +352,6 @@ var MarkdownPreview_default = ({ fileUrl, searchValue }) => {
|
|
|
354
352
|
}, [fileUrl]);
|
|
355
353
|
return error ? /* @__PURE__ */ jsxRuntime.jsx(antd.Result, { status: "error", title: error }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "height-full", children: /* @__PURE__ */ jsxRuntime.jsx(RenderMarkdown_default, { content, searchValue }) });
|
|
356
354
|
};
|
|
357
|
-
function createValtioContext() {
|
|
358
|
-
const Context = React16.createContext(null);
|
|
359
|
-
const ValtioProvider = ({ store, children }) => /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value: store, children });
|
|
360
|
-
const useValtioStore = () => {
|
|
361
|
-
const store = React16.useContext(Context);
|
|
362
|
-
if (!store) throw new Error("useStore must be used within Provider");
|
|
363
|
-
return store;
|
|
364
|
-
};
|
|
365
|
-
return {
|
|
366
|
-
ValtioProvider,
|
|
367
|
-
useValtioStore
|
|
368
|
-
// Context
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
355
|
|
|
372
356
|
// src/hooks/iframe/iframeRelay.ts
|
|
373
357
|
function emit(type, data, to = "top") {
|
|
@@ -473,6 +457,9 @@ var isExternal = (path) => {
|
|
|
473
457
|
var isBlob = (val) => {
|
|
474
458
|
return is(val, "Blob");
|
|
475
459
|
};
|
|
460
|
+
var isLocalhost = (host) => {
|
|
461
|
+
return /^(localhost:)/.test(host || location.host);
|
|
462
|
+
};
|
|
476
463
|
|
|
477
464
|
// src/hooks/iframe/useIframeRelayBridge.ts
|
|
478
465
|
function useIframeRelayBridge(allowedOrigins = ["*"]) {
|
|
@@ -503,6 +490,20 @@ function useIframeRelayBridge(allowedOrigins = ["*"]) {
|
|
|
503
490
|
}
|
|
504
491
|
return { on, off };
|
|
505
492
|
}
|
|
493
|
+
function useCreateValtioContext() {
|
|
494
|
+
const Context = React16.createContext(null);
|
|
495
|
+
const ValtioProvider = ({ store, children }) => /* @__PURE__ */ jsxRuntime.jsx(Context.Provider, { value: store, children });
|
|
496
|
+
const useValtioStore = () => {
|
|
497
|
+
const store = React16.useContext(Context);
|
|
498
|
+
if (!store) throw new Error("useStore must be used within Provider");
|
|
499
|
+
return store;
|
|
500
|
+
};
|
|
501
|
+
return {
|
|
502
|
+
ValtioProvider,
|
|
503
|
+
useValtioStore
|
|
504
|
+
// Context
|
|
505
|
+
};
|
|
506
|
+
}
|
|
506
507
|
function useDebounce(func, wait = 400) {
|
|
507
508
|
const { current } = React16.useRef({ func, timeOut: null });
|
|
508
509
|
React16.useEffect(() => {
|
|
@@ -680,6 +681,9 @@ var generateRandomNumbers = (min, max, count) => {
|
|
|
680
681
|
var getFileName = (filePath) => {
|
|
681
682
|
return filePath.split("?")[0].split("/").pop() || "";
|
|
682
683
|
};
|
|
684
|
+
var getFileSuffixName = (fileName) => {
|
|
685
|
+
return fileName.split(".").pop() || "";
|
|
686
|
+
};
|
|
683
687
|
var textAreaView = (con) => {
|
|
684
688
|
return con ? con.replace(/\r\n/g, "\n").replace(/\n/g, "<br/>") : "";
|
|
685
689
|
};
|
|
@@ -4953,7 +4957,6 @@ var SearchAndReplace = core.Extension.create({
|
|
|
4953
4957
|
}
|
|
4954
4958
|
});
|
|
4955
4959
|
var searchAndReplace_default = SearchAndReplace;
|
|
4956
|
-
var turndown = new TurndownService__default.default();
|
|
4957
4960
|
var MainToolbarContent = ({
|
|
4958
4961
|
onHighlighterClick,
|
|
4959
4962
|
onLinkClick,
|
|
@@ -5083,7 +5086,7 @@ var MarkdownEditor_default = ({ value = "", onChange, onScrollPage, searchValue,
|
|
|
5083
5086
|
});
|
|
5084
5087
|
const getMarkdown = () => {
|
|
5085
5088
|
if (!editor) return "";
|
|
5086
|
-
return
|
|
5089
|
+
return editor.storage.markdown.getMarkdown();
|
|
5087
5090
|
};
|
|
5088
5091
|
const bodyRect = useCursorVisibility({
|
|
5089
5092
|
editor,
|
|
@@ -5293,7 +5296,6 @@ exports.clearCurrentUser = clearCurrentUser;
|
|
|
5293
5296
|
exports.clearToken = clearToken;
|
|
5294
5297
|
exports.compareNum = compareNum;
|
|
5295
5298
|
exports.copyText = copyText;
|
|
5296
|
-
exports.createValtioContext = createValtioContext;
|
|
5297
5299
|
exports.decimalPlaces = decimalPlaces;
|
|
5298
5300
|
exports.deepCopy = deepCopy;
|
|
5299
5301
|
exports.deepEqual = deepEqual;
|
|
@@ -5311,6 +5313,7 @@ exports.getCurrentUser = getCurrentUser;
|
|
|
5311
5313
|
exports.getDeviceId = getDeviceId;
|
|
5312
5314
|
exports.getEndOfTimestamp = getEndOfTimestamp;
|
|
5313
5315
|
exports.getFileName = getFileName;
|
|
5316
|
+
exports.getFileSuffixName = getFileSuffixName;
|
|
5314
5317
|
exports.getSignPath = getSignPath;
|
|
5315
5318
|
exports.getStartOfTimestamp = getStartOfTimestamp;
|
|
5316
5319
|
exports.getTimestamp = getTimestamp;
|
|
@@ -5332,6 +5335,7 @@ exports.isExpire = isExpire;
|
|
|
5332
5335
|
exports.isExternal = isExternal;
|
|
5333
5336
|
exports.isFunction = isFunction;
|
|
5334
5337
|
exports.isInteger = isInteger;
|
|
5338
|
+
exports.isLocalhost = isLocalhost;
|
|
5335
5339
|
exports.isMap = isMap;
|
|
5336
5340
|
exports.isNegative = isNegative;
|
|
5337
5341
|
exports.isNull = isNull;
|
|
@@ -5360,6 +5364,7 @@ exports.textAreaView = textAreaView;
|
|
|
5360
5364
|
exports.themeConfig = themeConfig;
|
|
5361
5365
|
exports.times = times;
|
|
5362
5366
|
exports.toFixed = toFixed;
|
|
5367
|
+
exports.useCreateValtioContext = useCreateValtioContext;
|
|
5363
5368
|
exports.useDebounce = useDebounce;
|
|
5364
5369
|
exports.useDeepEffect = useDeepEffect;
|
|
5365
5370
|
exports.useIframeRelayBridge = useIframeRelayBridge;
|