@spacecorexdev/core 0.0.4 → 0.0.5
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/package.json +2 -36
- package/src/api/_base.ts +243 -0
- package/src/api/index.ts +17 -0
- package/src/api/project.ts +1345 -0
- package/src/api/user.ts +1174 -0
- package/src/contract.ts +50 -0
- package/src/hooks/index.ts +2 -0
- package/{dist/hooks/index.js → src/hooks/useLongPress.ts} +53 -49
- package/src/hooks/useOnlineStatus.ts +22 -0
- package/src/index.ts +14 -0
- package/src/types/id.ts +2 -0
- package/src/types/index.ts +5 -0
- package/src/types/project/base.ts +63 -0
- package/src/types/project/contract.ts +79 -0
- package/src/types/project/contractStatus.tsx +15 -0
- package/src/types/project/index.ts +5 -0
- package/src/types/project/member.ts +46 -0
- package/src/types/project/progress.ts +43 -0
- package/src/types/projectRole.ts +17 -0
- package/src/types/theme.ts +1 -0
- package/src/types/user/index.ts +1 -0
- package/src/types/user/role.ts +7 -0
- package/src/ui/CommentTimeline/index.tsx +330 -0
- package/src/ui/FileManager/FileContextMenu.tsx +628 -0
- package/src/ui/FileManager/FileGridView.tsx +529 -0
- package/src/ui/FileManager/FileTableView.tsx +405 -0
- package/src/ui/FileManager/FileToolbar.tsx +119 -0
- package/src/ui/FileManager/FileVersionHistoryModal.tsx +175 -0
- package/src/ui/FileManager/MoveCopyToProjectModal.tsx +119 -0
- package/src/ui/FileManager/ShareToWechatModal.tsx +419 -0
- package/src/ui/FileManager/hooks/useFileManagerActions.ts +2532 -0
- package/src/ui/FileManager/hooks/useFileManagerState.ts +419 -0
- package/src/ui/FileManager/index.tsx +580 -0
- package/src/ui/FileManager/projectFileManagerApi.ts +57 -0
- package/src/ui/FileManager/types.ts +184 -0
- package/src/ui/FileManager/utils/fileDeltaWorker.ts +193 -0
- package/src/ui/FileManager/utils/fileTree.ts +178 -0
- package/src/ui/FileManager/utils/fileUpload.ts +714 -0
- package/src/ui/FileManager/utils/fileUtils.ts +65 -0
- package/src/ui/InvoiceRecordsList/index.tsx +813 -0
- package/src/ui/MyFileSelectorModal.tsx +261 -0
- package/src/ui/ProjectSelector/index.tsx +472 -0
- package/src/ui/ProjectSelector/projectCache.ts +40 -0
- package/src/ui/RoleSelector/index.tsx +473 -0
- package/src/ui/RoleSelector/roleCache.ts +40 -0
- package/src/ui/UIAlert.tsx +399 -0
- package/src/ui/UIAlertExample.tsx +129 -0
- package/src/ui/UIConfirm.tsx +335 -0
- package/src/ui/UIConfirmExample.tsx +165 -0
- package/src/ui/UIDatePicker.tsx +146 -0
- package/src/ui/UIDateRangePicker.tsx +38 -0
- package/src/ui/UIFilePreview/ExcelEditor/index.tsx +617 -0
- package/src/ui/UIFilePreview/ExcelEditor/types.ts +24 -0
- package/src/ui/UIFilePreview/ExportDropdown.css +85 -0
- package/src/ui/UIFilePreview/ExportDropdown.tsx +109 -0
- package/src/ui/UIFilePreview/IndexedDBUtils.ts +564 -0
- package/src/ui/UIFilePreview/MarkdownEditor/exportMarkdownPdf.ts +576 -0
- package/src/ui/UIFilePreview/MarkdownEditor/index.tsx +677 -0
- package/src/ui/UIFilePreview/MarkdownEditor/markdownEditor.css +1005 -0
- package/src/ui/UIFilePreview/MarkdownEditor/types.ts +15 -0
- package/src/ui/UIFilePreview/PPTXEditor/index.tsx +602 -0
- package/src/ui/UIFilePreview/RichDocEditor/exportRDocMarkdown.ts +77 -0
- package/src/ui/UIFilePreview/RichDocEditor/exportRDocPdf.ts +374 -0
- package/src/ui/UIFilePreview/RichDocEditor/index.tsx +730 -0
- package/src/ui/UIFilePreview/RichDocEditor/richdoc-editor.css +59 -0
- package/src/ui/UIFilePreview/UIFilePreview.tsx +611 -0
- package/src/ui/UIFilePreview/WordEditor/index.tsx +3933 -0
- package/src/ui/UIFilePreview/WordEditor/style.ts +1213 -0
- package/src/ui/UIFilePreview/WordEditor/word-editor.css +999 -0
- package/src/ui/UIFilePreview/filePreview.css +193 -0
- package/src/ui/UIFilePreview/filetypes/archive.tsx +66 -0
- package/src/ui/UIFilePreview/filetypes/cad.tsx +287 -0
- package/src/ui/UIFilePreview/filetypes/excel.tsx +355 -0
- package/src/ui/UIFilePreview/filetypes/image.tsx +20 -0
- package/src/ui/UIFilePreview/filetypes/imageLoader.ts +63 -0
- package/src/ui/UIFilePreview/filetypes/pdf.tsx +156 -0
- package/src/ui/UIFilePreview/filetypes/ppt.tsx +535 -0
- package/src/ui/UIFilePreview/filetypes/pptExportPdf.ts +523 -0
- package/src/ui/UIFilePreview/filetypes/video.tsx +482 -0
- package/src/ui/UIFilePreview/filetypes/word.tsx +245 -0
- package/src/ui/UIFilePreview/filetypes/wordExportMarkdown.ts +86 -0
- package/src/ui/UIFilePreview/filetypes/wordExportPdf.tsx +427 -0
- package/src/ui/UIFilePreview/index.ts +35 -0
- package/src/ui/UIFilePreview/pdfPagination.ts +143 -0
- package/src/ui/UIFilePreview/previewUtils.tsx +531 -0
- package/src/ui/UIFileUpload.tsx +382 -0
- package/src/ui/UIImageUpload.tsx +195 -0
- package/src/ui/UILoading.tsx +255 -0
- package/src/ui/UILoadingExample.tsx +139 -0
- package/src/ui/UISelect.tsx +105 -0
- package/src/ui/UIToast.tsx +381 -0
- package/src/ui/UIToastExample.tsx +69 -0
- package/src/ui/UIToastSingle.tsx +279 -0
- package/src/ui/UIViewToggle.tsx +64 -0
- package/src/ui/UserSelector/index.tsx +583 -0
- package/src/ui/index.ts +84 -0
- package/src/ui/upload/image.ts +135 -0
- package/src/ui/upload/index.ts +73 -0
- package/src/ui/upload/submitFile.ts +106 -0
- package/src/ui/upload/submitForm.ts +124 -0
- package/src/ui/upload/upload.err.ts +15 -0
- package/src/ui/upload/upload.ts +250 -0
- package/src/utils/CacheDepartmentInfo.ts +372 -0
- package/src/utils/CacheFileContent.ts +315 -0
- package/src/utils/CachePermissionInfo.ts +235 -0
- package/src/utils/CacheRoleInfo.ts +303 -0
- package/src/utils/CacheUserInfo.ts +818 -0
- package/src/utils/CacheViewToggleInfo.ts +182 -0
- package/src/utils/MessageContentUtils.ts +268 -0
- package/src/utils/clipboard.ts +70 -0
- package/src/utils/companyEmail.ts +19 -0
- package/src/utils/forbidDebugger.ts +59 -0
- package/src/utils/formatters.ts +94 -0
- package/src/utils/htmlUtils.tsx +59 -0
- package/src/utils/index.ts +18 -0
- package/src/utils/keyboard.ts +114 -0
- package/src/utils/mammothApi.ts +16 -0
- package/src/utils/polyfills.ts +928 -0
- package/src/utils/regex.ts +14 -0
- package/src/utils/storage.ts +95 -0
- package/src/utils/workerBootstrap.ts +87 -0
- package/dist/api/index.js +0 -1553
- package/dist/contract.js +0 -5
- package/dist/index.js +0 -4492
- package/dist/types/index.js +0 -49
- package/dist/ui/index.css +0 -1876
- package/dist/ui/index.js +0 -22245
- package/dist/utils/index.js +0 -4296
- /package/{dist → src}/styles/ant-modal.css +0 -0
- /package/{dist → src}/styles/ant-spin.css +0 -0
- /package/{dist → src}/styles/ant-table.css +0 -0
- /package/{dist → src}/styles/index.css +0 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
export function htmlNoData() {
|
|
4
|
+
return (
|
|
5
|
+
<div className="ant-empty ant-empty-normal justify-self-center text-muted py-4">
|
|
6
|
+
<div className="ant-empty-image">
|
|
7
|
+
<svg width="64" height="41" viewBox="0 0 64 41" xmlns="http://www.w3.org/2000/svg">
|
|
8
|
+
<title> 无数据 </title>
|
|
9
|
+
<g transform="translate(0 1)" fill="none" fillRule="evenodd">
|
|
10
|
+
<ellipse fill="rgb(var(--color-muted) / 0.12)" cx="32" cy="33" rx="32" ry="7"></ellipse>
|
|
11
|
+
<g fillRule="nonzero" stroke="rgb(var(--color-border))">
|
|
12
|
+
<path d="M55 12.76L44.854 1.258C44.367.474 43.656 0 42.907 0H21.093c-.749 0-1.46.474-1.947 1.257L9 12.761V22h46v-9.24z"></path>
|
|
13
|
+
<path d="M41.613 15.931c0-1.605.994-2.93 2.227-2.931H55v18.137C55 33.26 53.68 35 52.05 35h-40.1C10.32 35 9 33.259 9 31.137V13h11.16c1.233 0 2.227 1.323 2.227 2.928v.022c0 1.605 1.005 2.901 2.237 2.901h14.752c1.232 0 2.237-1.308 2.237-2.913v-.007z" fill="rgb(var(--color-surface))"></path>
|
|
14
|
+
</g>
|
|
15
|
+
</g>
|
|
16
|
+
</svg>
|
|
17
|
+
</div>
|
|
18
|
+
<div className="ant-empty-description justify-self-center text-sm font-thin text-muted" > 无数据 </div>
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function useEffectResize(onSmallView: () => void, onLargeView: () => void, smallViewWidth:number = 768) {
|
|
24
|
+
const onSmallViewRef = useRef(onSmallView);
|
|
25
|
+
const onLargeViewRef = useRef(onLargeView);
|
|
26
|
+
|
|
27
|
+
onSmallViewRef.current = onSmallView;
|
|
28
|
+
onLargeViewRef.current = onLargeView;
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
// 仅在 small/large 状态真正切换时触发回调,避免移动端滚动导致地址栏收起/展开
|
|
32
|
+
// 触发 resize 时反复覆盖用户手动设置的状态(如视图模式)
|
|
33
|
+
let isSmallView = window.innerWidth <= smallViewWidth;
|
|
34
|
+
|
|
35
|
+
const handleResize = () => {
|
|
36
|
+
const newIsSmallView = window.innerWidth <= smallViewWidth;
|
|
37
|
+
if (newIsSmallView === isSmallView) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
isSmallView = newIsSmallView;
|
|
41
|
+
if (newIsSmallView) {
|
|
42
|
+
onSmallViewRef.current();
|
|
43
|
+
} else {
|
|
44
|
+
onLargeViewRef.current();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// 初次挂载时按当前屏幕尺寸触发一次回调
|
|
49
|
+
if (isSmallView) {
|
|
50
|
+
onSmallViewRef.current();
|
|
51
|
+
} else {
|
|
52
|
+
onLargeViewRef.current();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
window.addEventListener('resize', handleResize);
|
|
56
|
+
|
|
57
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
58
|
+
}, [smallViewWidth]);
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './CacheDepartmentInfo';
|
|
2
|
+
export * from './CacheFileContent';
|
|
3
|
+
export * from './CachePermissionInfo';
|
|
4
|
+
export * from './CacheRoleInfo';
|
|
5
|
+
export * from './CacheUserInfo';
|
|
6
|
+
export * from './CacheViewToggleInfo';
|
|
7
|
+
export * from './MessageContentUtils';
|
|
8
|
+
export * from './clipboard';
|
|
9
|
+
export * from './companyEmail';
|
|
10
|
+
export * from './forbidDebugger';
|
|
11
|
+
export * from './formatters';
|
|
12
|
+
export * from './keyboard';
|
|
13
|
+
export * from './mammothApi';
|
|
14
|
+
export * from './polyfills';
|
|
15
|
+
export * from './regex';
|
|
16
|
+
export * from './storage';
|
|
17
|
+
export * from './workerBootstrap';
|
|
18
|
+
export * from './htmlUtils';
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) 2021 bpui All Rights Reserved.
|
|
5
|
+
* Author: brian.li
|
|
6
|
+
* Date: 2021-09-06 13:55
|
|
7
|
+
* Desc:
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import key from 'keymaster'
|
|
11
|
+
|
|
12
|
+
export const keyboard = {
|
|
13
|
+
/**
|
|
14
|
+
* @descs: 定义一个快捷键.
|
|
15
|
+
*
|
|
16
|
+
* 可以使用如下的修饰键:
|
|
17
|
+
* - `⇧`, `shift`
|
|
18
|
+
* - `option`, `⌥`, `alt`
|
|
19
|
+
* - `ctrl`, `control`, `command`, and `⌘`.
|
|
20
|
+
*
|
|
21
|
+
* 可以使用如下的特殊键:
|
|
22
|
+
* - `backspace`, `tab`, `clear`
|
|
23
|
+
* - `enter`, `return`
|
|
24
|
+
* - `esc`, `escape`, `space`,
|
|
25
|
+
* - `up`, `down`, `left`, `right`, `home`, `end`, `pageup`, `pagedown`, `del`, `delete`
|
|
26
|
+
* - `f1` through `f19`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
*
|
|
30
|
+
* keyboard.on('a', () => {});
|
|
31
|
+
* keyboard.on('ctrl+r', () => {});
|
|
32
|
+
* keyboard.on('ctrl+r, ⌘+r', () => {});
|
|
33
|
+
*/
|
|
34
|
+
on: function(keyname: string, callback: /*bp.keyboard.KeyHandler*/any) {
|
|
35
|
+
key(keyname, callback)
|
|
36
|
+
return this
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 解除按键handler.
|
|
41
|
+
*/
|
|
42
|
+
off: function(keyname: string) {
|
|
43
|
+
key.unbind(keyname)
|
|
44
|
+
return this
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 检查指定的按键是否按下.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* if (keyboard.isPressed('M')) {
|
|
52
|
+
* alert('M key is pressed, can ya believe it!?');
|
|
53
|
+
* }
|
|
54
|
+
* if (keyboard.isPressed(77)) {
|
|
55
|
+
* alert('M key is pressed, can ya believe it!?');
|
|
56
|
+
* }
|
|
57
|
+
*/
|
|
58
|
+
isPressed(keyCode: number | string): boolean {
|
|
59
|
+
return key.isPressed(keyCode)
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 检查shift键是否按下.
|
|
64
|
+
*/
|
|
65
|
+
get shift(): boolean {
|
|
66
|
+
return key.shift
|
|
67
|
+
},
|
|
68
|
+
get '⇧'(): boolean {
|
|
69
|
+
return key['⇧']
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 检查alt键是否按下.
|
|
74
|
+
*/
|
|
75
|
+
get alt(): boolean {
|
|
76
|
+
return key.alt
|
|
77
|
+
},
|
|
78
|
+
get option(): boolean {
|
|
79
|
+
return key.option
|
|
80
|
+
},
|
|
81
|
+
get '⌥'(): boolean {
|
|
82
|
+
return key['⌥']
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 检查control键是否按下.
|
|
87
|
+
*/
|
|
88
|
+
get ctrl(): boolean {
|
|
89
|
+
return key.ctrl
|
|
90
|
+
},
|
|
91
|
+
get control(): boolean {
|
|
92
|
+
return key.control
|
|
93
|
+
},
|
|
94
|
+
get '⌃'(): boolean {
|
|
95
|
+
return key['⌃']
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 检查command键是否按下.
|
|
100
|
+
*/
|
|
101
|
+
get command(): boolean {
|
|
102
|
+
return key.command
|
|
103
|
+
},
|
|
104
|
+
get '⌘'(): boolean {
|
|
105
|
+
return key['⌘']
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 获得按下按键的keyCode列表.
|
|
110
|
+
*/
|
|
111
|
+
get pressedKeyCodes(): number[] {
|
|
112
|
+
return key.getPressedKeyCodes()
|
|
113
|
+
},
|
|
114
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as mammothModule from 'mammoth';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* mammoth 的浏览器可用实例。
|
|
5
|
+
*
|
|
6
|
+
* 背景:npm 包 mammoth@1.12.3 的 Node 入口依赖 `@xmldom/xmldom`,但它声明的 `^0.8.6`
|
|
7
|
+
* 与项目里被提升到根目录的 `0.9.x` 不兼容(0.9 起会强制校验 parseFromString 的 mimeType,
|
|
8
|
+
* 且构造 DOMParser 时传 errorHandler 会直接报错)。Vite 预打包时把 mammoth 解析到了 0.9,
|
|
9
|
+
* 导致 docx 解析全线失败。
|
|
10
|
+
*
|
|
11
|
+
* 因此 vite.config.ts 里把 `mammoth` 别名到了官方预构建的 `mammoth.browser.js`——它自带
|
|
12
|
+
* `@xmldom/xmldom@0.8.6`,是自包含的。该文件是 UMD 包,只有一个 default 导出,所以这里统一
|
|
13
|
+
* 做一次解包,兼容 UMD(取 .default)与 ESM(直接取命名空间)两种形态。
|
|
14
|
+
*/
|
|
15
|
+
export const mammoth: typeof mammothModule =
|
|
16
|
+
(mammothModule as unknown as { default?: typeof mammothModule }).default ?? mammothModule;
|