@quansitech/antd-admin 1.1.0 → 1.1.2

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.
Files changed (119) hide show
  1. package/dist/components/Column/Cascader.d.ts +3 -0
  2. package/dist/components/Column/Cascader.js +110 -0
  3. package/dist/components/Column/File.d.ts +18 -0
  4. package/dist/components/Column/File.js +176 -0
  5. package/dist/components/Column/Image.d.ts +10 -0
  6. package/dist/components/Column/Image.js +104 -0
  7. package/dist/components/Column/Readonly/Action/Link.d.ts +11 -0
  8. package/dist/components/Column/Readonly/Action/Link.js +114 -0
  9. package/dist/components/Column/Readonly/Action/index.d.ts +4 -0
  10. package/dist/components/Column/Readonly/Action/index.js +3 -0
  11. package/dist/components/Column/Readonly/Action.d.ts +12 -0
  12. package/dist/components/Column/Readonly/Action.js +96 -0
  13. package/dist/components/Column/Readonly/Cascader.d.ts +9 -0
  14. package/dist/components/Column/Readonly/Cascader.js +52 -0
  15. package/dist/components/Column/Readonly/File.d.ts +8 -0
  16. package/dist/components/Column/Readonly/File.js +54 -0
  17. package/dist/components/Column/Readonly/Image.d.ts +3 -0
  18. package/dist/components/Column/Readonly/Image.js +69 -0
  19. package/dist/components/Column/Readonly/Ueditor.d.ts +3 -0
  20. package/dist/components/Column/Readonly/Ueditor.js +24 -0
  21. package/dist/components/Column/Readonly/index.d.ts +8 -0
  22. package/dist/components/Column/Readonly/index.js +7 -0
  23. package/dist/components/Column/Ueditor.d.ts +27 -0
  24. package/dist/components/Column/Ueditor.js +333 -0
  25. package/dist/components/Column/index.d.ts +7 -0
  26. package/dist/components/Column/index.js +6 -0
  27. package/dist/components/Form/Action/Button.d.ts +15 -0
  28. package/dist/components/Form/Action/Button.js +194 -0
  29. package/dist/components/Form/Action/index.d.ts +4 -0
  30. package/dist/components/Form/Action/index.js +3 -0
  31. package/dist/components/Form/Actions.d.ts +6 -0
  32. package/dist/components/Form/Actions.js +48 -0
  33. package/dist/components/Form.d.ts +20 -0
  34. package/dist/components/Form.js +217 -0
  35. package/dist/components/FormContext.d.ts +7 -0
  36. package/dist/components/FormContext.js +2 -0
  37. package/dist/components/Layout/New.d.ts +7 -0
  38. package/dist/components/Layout/New.js +257 -0
  39. package/dist/components/Layout.d.ts +4 -0
  40. package/dist/components/Layout.js +67 -0
  41. package/dist/components/LayoutContext.d.ts +26 -0
  42. package/dist/components/LayoutContext.js +2 -0
  43. package/dist/components/ModalContext.d.ts +8 -0
  44. package/dist/components/ModalContext.js +6 -0
  45. package/dist/components/Table/Action/Button.d.ts +10 -0
  46. package/dist/components/Table/Action/Button.js +166 -0
  47. package/dist/components/Table/Action/StartEditable.d.ts +10 -0
  48. package/dist/components/Table/Action/StartEditable.js +79 -0
  49. package/dist/components/Table/Action/index.d.ts +5 -0
  50. package/dist/components/Table/Action/index.js +4 -0
  51. package/dist/components/Table/ToolbarActions.d.ts +6 -0
  52. package/dist/components/Table/ToolbarActions.js +52 -0
  53. package/dist/components/Table.d.ts +19 -0
  54. package/dist/components/Table.js +322 -0
  55. package/dist/components/TableContext.d.ts +14 -0
  56. package/dist/components/TableContext.js +2 -0
  57. package/dist/components/Tabs.d.ts +15 -0
  58. package/dist/components/Tabs.js +62 -0
  59. package/dist/env.d.ts +1 -0
  60. package/dist/global.d.ts +6 -0
  61. package/dist/index.d.ts +7 -0
  62. package/dist/index.js +7 -0
  63. package/dist/lib/container.d.ts +9 -0
  64. package/dist/lib/container.js +93 -0
  65. package/dist/lib/customRule.d.ts +3 -0
  66. package/dist/lib/customRule.js +7 -0
  67. package/dist/lib/global.d.ts +9 -0
  68. package/dist/lib/global.js +2 -0
  69. package/dist/lib/helpers.d.ts +14 -0
  70. package/dist/lib/helpers.js +183 -0
  71. package/dist/lib/http.d.ts +5 -0
  72. package/dist/lib/http.js +72 -0
  73. package/dist/lib/schemaHandler.d.ts +5 -0
  74. package/dist/lib/schemaHandler.js +133 -0
  75. package/dist/lib/upload.d.ts +20 -0
  76. package/dist/lib/upload.js +215 -0
  77. package/dist/lib/writeExtra.d.ts +1 -0
  78. package/dist/lib/writeExtra.js +28 -0
  79. package/dist/types.d.ts +25 -0
  80. package/package.json +14 -8
  81. package/components/Column/Cascader.tsx +0 -79
  82. package/components/Column/File.tsx +0 -166
  83. package/components/Column/Image.tsx +0 -77
  84. package/components/Column/Readonly/Action/Link.tsx +0 -78
  85. package/components/Column/Readonly/Action.tsx +0 -80
  86. package/components/Column/Readonly/Cascader.tsx +0 -51
  87. package/components/Column/Readonly/File.tsx +0 -53
  88. package/components/Column/Readonly/Image.tsx +0 -39
  89. package/components/Column/Readonly/Ueditor.tsx +0 -18
  90. package/components/Column/Ueditor.tsx +0 -314
  91. package/components/Form/Action/Button.tsx +0 -129
  92. package/components/Form/Actions.tsx +0 -39
  93. package/components/Form.tsx +0 -177
  94. package/components/FormContext.ts +0 -9
  95. package/components/Layout/New.tsx +0 -252
  96. package/components/Layout.tsx +0 -52
  97. package/components/LayoutContext.ts +0 -26
  98. package/components/ModalContext.ts +0 -16
  99. package/components/Table/Action/Button.tsx +0 -89
  100. package/components/Table/Action/StartEditable.tsx +0 -59
  101. package/components/Table/ToolbarActions.tsx +0 -44
  102. package/components/Table.tsx +0 -280
  103. package/components/TableContext.ts +0 -15
  104. package/components/Tabs.tsx +0 -72
  105. package/lib/container.ts +0 -84
  106. package/lib/customRule.ts +0 -10
  107. package/lib/global.ts +0 -11
  108. package/lib/helpers.tsx +0 -146
  109. package/lib/http.ts +0 -74
  110. package/lib/schemaHandler.ts +0 -122
  111. package/lib/upload.ts +0 -177
  112. package/lib/writeExtra.js +0 -31
  113. /package/{components → dist/components}/Column/Readonly/Action/types.d.ts +0 -0
  114. /package/{components → dist/components}/Column/Readonly/types.d.ts +0 -0
  115. /package/{components → dist/components}/Column/types.d.ts +0 -0
  116. /package/{components → dist/components}/Form/Action/types.d.ts +0 -0
  117. /package/{components → dist/components}/Table/Action/types.d.ts +0 -0
  118. /package/{components → dist/components}/Table.scss +0 -0
  119. /package/{components → dist/components}/types.d.ts +0 -0
@@ -1,78 +0,0 @@
1
- import React, {useContext, useState} from "react";
2
- import {modalShow, replaceParams, replaceUrl, routerNavigateTo} from "../../../../lib/helpers";
3
- import {Button, Popconfirm, Spin} from "antd";
4
- import {TableContext} from "../../../TableContext";
5
- import http from "../../../../lib/http";
6
- import {TableColumnOptionProps} from "./types";
7
-
8
- type Props = TableColumnOptionProps & {
9
- href?: string,
10
- request?: RequestOptions,
11
- modal?: ModalOptions,
12
- modalByField?: string,
13
- danger?: boolean
14
- }
15
-
16
- export default function (props: Props) {
17
-
18
- const [loading, setLoading] = useState(false)
19
- const tableContext = useContext(TableContext)
20
-
21
- const onClick = async (e: any) => {
22
- setLoading(true)
23
- try {
24
- if (props.href) {
25
- routerNavigateTo(replaceUrl(props.href, props.record))
26
- return
27
- }
28
- if (props.request) {
29
- await http({
30
- method: props.request.method,
31
- url: replaceUrl(props.request.url, props.record),
32
- headers: props.request.headers || {},
33
- data: props.request.data ? replaceParams(props.request.data, props.record) : null,
34
- })
35
-
36
- await tableContext.actionRef?.reload()
37
- }
38
- if (props.modal) {
39
- let url
40
- if (props.modal.content.url) {
41
- url = replaceUrl(props.modal.content.url, props.record)
42
- }
43
- await modalShow({
44
- ...props.modal,
45
- contexts: {
46
- tableContext,
47
- },
48
- content: {
49
- ...props.modal.content,
50
- url,
51
- },
52
- })
53
- }
54
- if (props.modalByField) {
55
- const m = props.record[props.modalByField]
56
- await modalShow({
57
- ...m,
58
- contexts: {
59
- tableContext,
60
- },
61
- })
62
- }
63
- } finally {
64
- setLoading(false)
65
- }
66
- }
67
-
68
- return <>
69
- <Spin spinning={loading}>
70
- {props.request?.confirm
71
- ? <Popconfirm title={props.request?.confirm} onConfirm={onClick}>
72
- <Button type={"link"} danger={props.danger} onClick={() => {
73
- }}>{props.title}</Button>
74
- </Popconfirm> : <Button type={"link"} danger={props.danger} onClick={onClick}>{props.title}</Button>
75
- }
76
- </Spin>
77
- </>
78
- }
@@ -1,80 +0,0 @@
1
- import {Component, lazy, useEffect, useState} from "react";
2
- import {ReactComponentLike} from "prop-types";
3
- import container from "../../../lib/container";
4
- import {Badge, Flex} from "antd";
5
- import {ColumnReadonlyProps} from "./types";
6
- import {asyncFilter, handleRules} from "../../../lib/helpers";
7
- import {Rules} from "@rc-component/async-validator/lib/interface";
8
- import {upperFirst} from "lodash";
9
- import {TableColumnActionProps} from "./Action/types";
10
-
11
- type ComponentType = {
12
- component: ReactComponentLike,
13
- props: any,
14
- }
15
-
16
- export default ({actions, record}: ColumnReadonlyProps & {
17
- actions?: {
18
- type: string,
19
- title: string,
20
- showRules?: Rules,
21
- badge?: any,
22
- }[],
23
- }) => {
24
-
25
- const [Components, setComponents] = useState<ComponentType[]>([]);
26
-
27
- useEffect(() => {
28
- if (actions) {
29
- asyncFilter(actions, async (Component) => {
30
- if (!Component.showRules) {
31
- return true
32
- }
33
- return await handleRules(Component.showRules, record)
34
- }).then((Components: TableColumnActionProps[]) => setComponents(Components.map(a => {
35
- let badge = a.badge
36
- const matches = (badge + '').match(/^__(\w+)__$/)
37
- if (matches) {
38
- badge = record[matches[1]]
39
- }
40
-
41
- const c = `Column.Readonly.Action.${upperFirst(a.type)}`
42
- return {
43
- props: {
44
- ...a,
45
- record,
46
- badge,
47
- },
48
- component: lazy(container.get(c)),
49
- }
50
- })))
51
- }
52
- }, []);
53
-
54
-
55
- return <>
56
- {
57
- <Flex wrap={true}>
58
- {
59
- Components.map(Component => (
60
- Component.props.badge ?
61
- <Badge key={Component.props.title}
62
- count={Component.props.badge}
63
- offset={[-12, 6]}
64
- size={'small'}
65
- styles={{
66
- indicator: {
67
- zIndex: 100,
68
- padding: '0 4px',
69
- }
70
- }}>
71
- <Component.component
72
- key={Component.props.title} {...Component.props}></Component.component>
73
- </Badge> :
74
- <Component.component key={Component.props.title} {...Component.props}></Component.component>
75
- ))
76
- }
77
- </Flex>
78
- }
79
- </>
80
- }
@@ -1,51 +0,0 @@
1
- import {ColumnReadonlyProps} from "./types";
2
- import {ReactNode, useEffect, useState} from "react";
3
- import http from "../../../lib/http";
4
-
5
- export default function (props: ColumnReadonlyProps & {
6
- schema: {
7
- fieldProps: {
8
- loadDataUrl: string
9
- }
10
- }
11
- }) {
12
- const [text, setText] = useState<ReactNode>('-');
13
-
14
- useEffect(() => {
15
- setText(props.dom)
16
- const value = props.entity.value
17
-
18
- // 远程获取数据
19
- if (props.schema.fieldProps?.loadDataUrl) {
20
- http({
21
- url: props.schema.fieldProps.loadDataUrl,
22
- method: 'get',
23
- params: {
24
- value,
25
- }
26
- }).then(res => {
27
- if (!value) {
28
- return
29
- }
30
- const findValue = (options: any[], value: any): any => {
31
- for (let i = 0; i < options.length; i++) {
32
- const option = options[i];
33
- if (option.value === value) {
34
- return [option.label]
35
- } else if (option.children) {
36
- return [option.label, ...findValue(option.children, value)]
37
- }
38
- }
39
- }
40
-
41
- setText(findValue(res.data, value).join(' / '))
42
-
43
- })
44
- }
45
-
46
- }, []);
47
-
48
- return <div className={props.entity.className}>
49
- {text}
50
- </div>
51
- }
@@ -1,53 +0,0 @@
1
- import {ColumnReadonlyProps} from "./types";
2
- import {Spin, Upload, UploadFile} from "antd";
3
- import React, {useContext, useEffect, useState} from "react";
4
- import {FormContext} from "../../FormContext";
5
- import {UploadListType} from "antd/es/upload/interface";
6
- import {TableContext} from "../../TableContext";
7
-
8
- export default function (props: ColumnReadonlyProps & {
9
- listType?: UploadListType,
10
- onPreview?: (file: UploadFile) => void,
11
- }) {
12
-
13
- const [loading, setLoading] = useState(true);
14
- const [fileList, setFileList] = useState<UploadFile[]>([]);
15
- const formContext = useContext(FormContext);
16
- const tableContext = useContext(TableContext);
17
-
18
- useEffect(() => {
19
- let extraRenderValue = [];
20
- if (formContext && formContext.extraRenderValues) {
21
- extraRenderValue = formContext.extraRenderValues[props.schema.dataIndex as string] ?? []
22
- } else if (tableContext && tableContext.extraRenderValues) {
23
- extraRenderValue = tableContext.extraRenderValues[props.index]?.[props.schema.dataIndex as string] ?? []
24
- }
25
- setFileList(extraRenderValue.map((item: any) => {
26
- return {
27
- uid: item.id,
28
- status: 'done',
29
- url: item.url,
30
- name: item.name,
31
- hash_id: item.hash_id,
32
- response: {
33
- file_id: item.id,
34
- url: item.url,
35
- }
36
- }
37
- }))
38
-
39
- setLoading(false)
40
- }, []);
41
-
42
-
43
- return <>
44
- <Spin spinning={loading}>
45
- <Upload
46
- disabled={true}
47
- listType={props.listType || 'text'}
48
- fileList={fileList}
49
- onPreview={props.onPreview}
50
- ></Upload>
51
- </Spin>
52
- </>
53
- }
@@ -1,39 +0,0 @@
1
- import {ColumnReadonlyProps} from "./types";
2
- import {Image, UploadFile} from "antd";
3
- import {FileType, getBase64} from "../../../lib/upload";
4
- import React, {useState} from "react";
5
- import File from "./File";
6
-
7
- export default function (props: ColumnReadonlyProps) {
8
-
9
- const [previewImage, setPreviewImage] = useState('');
10
- const [previewOpen, setPreviewOpen] = useState(false);
11
-
12
- const handlePreview = async (file: UploadFile) => {
13
- if (!file.url && !file.preview) {
14
- file.preview = await getBase64(file.originFileObj as FileType);
15
- }
16
-
17
- setPreviewImage(file.url || (file.preview as string));
18
- setPreviewOpen(true);
19
- };
20
-
21
-
22
- return <>
23
- <File {...props}
24
- listType="picture-card"
25
- onPreview={handlePreview}
26
- ></File>
27
- {previewImage && (
28
- <Image
29
- wrapperStyle={{display: 'none'}}
30
- preview={{
31
- visible: previewOpen,
32
- onVisibleChange: (visible) => setPreviewOpen(visible),
33
- afterOpenChange: (visible) => !visible && setPreviewImage(''),
34
- }}
35
- src={previewImage}
36
- />
37
- )}
38
- </>
39
- }
@@ -1,18 +0,0 @@
1
- import {ColumnReadonlyProps} from "./types";
2
- import {useEffect, useState} from "react";
3
-
4
- export default function (props: ColumnReadonlyProps) {
5
-
6
- const [value, setValue] = useState(props.entity.value);
7
-
8
- useEffect(() => {
9
- const div = document.createElement('div');
10
- div.innerHTML = props.entity.value;
11
- setValue(div.innerText);
12
- }, []);
13
-
14
-
15
- return <>
16
- <div className={'article-content'} dangerouslySetInnerHTML={{__html: value}}/>
17
- </>
18
- }
@@ -1,314 +0,0 @@
1
- import {ColumnProps} from "./types";
2
- import {Component} from "react";
3
- import {createScript, filterObjectKeys} from "../../lib/helpers";
4
- import {Spin} from "antd";
5
- import {ModalContext, ModalContextProps} from "../ModalContext";
6
- import {uniqueId} from "lodash";
7
-
8
- declare global {
9
- interface Window {
10
- UE: any,
11
- UE_LOADING_PROMISE: Promise<any>,
12
- }
13
- }
14
-
15
- export default class Ueditor extends Component<ColumnProps & {
16
- fieldProps: {
17
- ueditorPath: string,
18
- }
19
- }, any> {
20
- modalContext = {} as ModalContextProps
21
-
22
- editor: any = null
23
- catching = false
24
- containerRef: HTMLElement | null = null
25
- state = {
26
- loading: true,
27
- containerId: uniqueId('ueditor_'),
28
- width: '',
29
- }
30
-
31
-
32
- componentDidMount() {
33
- this.setState({
34
- width: this.containerRef?.offsetWidth ? `${this.containerRef?.offsetWidth}px` : '100%'
35
- })
36
-
37
- this.props.rules?.push({
38
- validator: async (rule: any, value: any) => {
39
- if (this.catching) {
40
- throw new Error('正在抓取图片')
41
- }
42
- return true
43
- },
44
- })
45
-
46
- if (!window.UE && !window.UE_LOADING_PROMISE) {
47
- window.UE_LOADING_PROMISE =
48
- createScript(this.props.fieldProps.configJsPath || this.props.fieldProps.ueditorPath + '/ueditor.config.js')
49
- .then(() => {
50
- return createScript(this.props.fieldProps.ueditorPath + '/ueditor.all.js')
51
- })
52
- .then(() => {
53
- return createScript(this.props.fieldProps.ueditorPath + '/lang/zh-cn/zh-cn.js')
54
- })
55
- }
56
-
57
- window.UE_LOADING_PROMISE.then(() => {
58
- let that = this
59
- window.UE.plugins['forceCatchRemoteImg'] = function () {
60
- if (this.options.forcecatchremote) {
61
- this.addListener("afterpaste", function (t: any, a: any) {
62
- const load_src = that.props.fieldProps.ueditorPath + '/img/load.gif';
63
- const domUtils = window.UE.dom.domUtils;
64
-
65
- const parser = new DOMParser();
66
- const pasteDom = parser.parseFromString(a.html, "text/html");
67
-
68
- // @ts-ignore
69
- const allImgs = domUtils.getElementsByTagName(this.document, "img");
70
- const imgs = domUtils.getElementsByTagName(pasteDom, "img");
71
-
72
- let notCatch = (src: string) => {
73
- if (src.indexOf(location.host) !== -1) {
74
- return true;
75
- }
76
- if (/(^\.)|(^\/)/.test(src)) {
77
- return true;
78
- }
79
- return src.indexOf('img_catch_success') !== -1;
80
-
81
- }
82
-
83
- let catchGo = false;
84
- for (let i = 0; i < imgs.length; i++) {
85
- if (notCatch(imgs[i].src)) {
86
- continue
87
- }
88
- for (let l = 0; l < allImgs.length; l++) {
89
- if (allImgs[l].src == imgs[i].src) {
90
- catchGo = true;
91
- domUtils.setAttributes(allImgs[l], {
92
- "src": load_src,
93
- "_src": allImgs[l].src
94
- });
95
- }
96
- }
97
- }
98
-
99
- if (catchGo) {
100
- // $('.submit').trigger('startHandlePostData', '正在抓取图片');
101
- that.catching = true
102
- that.props.dataIndex && that.props.form?.validateFields([that.props.dataIndex])
103
- }
104
- });
105
-
106
- this.addListener("catchremotesuccess", function () {
107
- that.catching = false
108
- that.props.dataIndex && that.props.form?.validateFields([that.props.dataIndex])
109
- // $('.submit').trigger('endHandlePostData');
110
- });
111
- }
112
-
113
- }
114
-
115
- // plugins/insert_richtext.js
116
- /**
117
- * 抓取微信富文本
118
- */
119
- window.UE.plugin.register('insert_richtext', function () {
120
- // @ts-ignore
121
- const me = this;
122
-
123
- function filter(div: HTMLElement) {
124
- const domUtils = window.UE.dom.domUtils;
125
- const browser = window.UE.browser;
126
- const utils = window.UE.utils;
127
-
128
- let html;
129
- let ci;
130
- if (div.firstChild) {
131
- //去掉cut中添加的边界值
132
- const nodes = domUtils.getElementsByTagName(div, 'span');
133
- for (let i = 0, ni; ni = nodes[i++];) {
134
- if (ni.id == '_baidu_cut_start' || ni.id == '_baidu_cut_end') {
135
- domUtils.remove(ni);
136
- }
137
- }
138
-
139
- if (browser.webkit) {
140
-
141
- let brs = div.querySelectorAll('div br');
142
- for (let i = 0, bi; bi = brs[i++];) {
143
- const pN = bi.parentNode as HTMLElement;
144
- if (pN) {
145
- if (pN.tagName == 'DIV' && pN.childNodes.length == 1) {
146
- pN.innerHTML = '<p><br/></p>';
147
- domUtils.remove(pN);
148
- }
149
- }
150
- }
151
- const divs = div.querySelectorAll('#baidu_pastebin');
152
- for (let i = 0, di; di = divs[i++];) {
153
- const tmpP = me.document.createElement('p');
154
- di.parentNode?.insertBefore(tmpP, di);
155
- while (di.firstChild) {
156
- tmpP.appendChild(di.firstChild);
157
- }
158
- domUtils.remove(di);
159
- }
160
-
161
- const metas = div.querySelectorAll('meta');
162
- for (let i = 0, ci; ci = metas[i++];) {
163
- domUtils.remove(ci);
164
- }
165
-
166
- brs = div.querySelectorAll('br');
167
- for (let i = 0; ci = brs[i++];) {
168
- if (/^apple-/i.test(ci.className)) {
169
- domUtils.remove(ci);
170
- }
171
- }
172
- }
173
- if (browser.gecko) {
174
- const dirtyNodes = div.querySelectorAll('[_moz_dirty]');
175
- for (let i = 0; ci = dirtyNodes[i++];) {
176
- ci.removeAttribute('_moz_dirty');
177
- }
178
- }
179
- if (!browser.ie) {
180
- const spans = div.querySelectorAll('span.Apple-style-span');
181
- for (let i = 0, ci; ci = spans[i++];) {
182
- domUtils.remove(ci, true);
183
- }
184
- }
185
-
186
- //ie下使用innerHTML会产生多余的\r\n字符,也会产生&nbsp;这里过滤掉
187
- html = div.innerHTML;//.replace(/>(?:(\s|&nbsp;)*?)</g,'><');
188
-
189
- //过滤word粘贴过来的冗余属性
190
- html = window.UE.filterWord(html);
191
- //取消了忽略空白的第二个参数,粘贴过来的有些是有空白的,会被套上相关的标签
192
- var root = window.UE.htmlparser(html);
193
-
194
- //如果给了过滤规则就先进行过滤
195
- if (me.options.filterRules) {
196
- window.UE.filterNode(root, me.options.filterRules);
197
- }
198
- //执行默认的处理
199
- me.filterInputRule(root);
200
- //针对chrome的处理
201
- if (browser.webkit) {
202
- var br = root.lastChild();
203
- if (br && br.type == 'element' && br.tagName == 'br') {
204
- root.removeChild(br)
205
- }
206
- utils.each(me.body.querySelectorAll('div'), function (node: HTMLElement) {
207
- if (domUtils.isEmptyBlock(node)) {
208
- domUtils.remove(node, true)
209
- }
210
- })
211
- }
212
- html = {'html': root.toHtml()};
213
- me.fireEvent('beforepaste', html, root);
214
- //抢了默认的粘贴,那后边的内容就不执行了,比如表格粘贴
215
- if (!html.html) {
216
- return;
217
- }
218
- root = window.UE.htmlparser(html.html, true);
219
- //如果开启了纯文本模式
220
- if (me.queryCommandState('pasteplain') === 1) {
221
- me.execCommand('insertHtml', window.UE.filterNode(root, me.options.filterTxtRules).toHtml(), true);
222
- } else {
223
- //文本模式
224
- window.UE.filterNode(root, me.options.filterTxtRules);
225
- const txtContent = root.toHtml();
226
- //完全模式
227
- const htmlContent = html.html;
228
-
229
- const address = me.selection.getRange().createAddress(true);
230
- // @ts-ignore
231
- me.execCommand('insertHtml', me.getOpt('retainOnlyLabelPasted') === true ? getPureHtml(htmlContent) : htmlContent, true);
232
- }
233
-
234
- me.fireEvent("afterpaste", html);
235
- }
236
- }
237
-
238
-
239
- return {
240
- bindEvents: {
241
- 'afterInsertRichText': function (e: Event, html: HTMLElement) {
242
- me.execCommand('cleardoc');
243
- filter.call(me, html);
244
- me.document.body.innerHTML = `<section>${html}</section>`;
245
-
246
- me.fireEvent('catchremoteimage');
247
-
248
- that.catching = true
249
- that.props.dataIndex && that.props.form?.validateFields([that.props.dataIndex])
250
- // $('.submit').trigger('startHandlePostData', '正在抓取图片');
251
- },
252
- },
253
- commands: {}
254
- }
255
- });
256
-
257
-
258
- const config = {
259
- ...this.props.fieldProps?.config,
260
- forcecatchremote: typeof this.props.fieldProps?.config?.forcecatchremote === 'undefined' ? true : this.props.fieldProps.config.forcecatchremote,
261
- }
262
- if (this.modalContext?.inModal) {
263
- config.zIndex = 2000
264
- config.topOffset = 0
265
- }
266
-
267
- this.editor = window.UE.getEditor(this.state.containerId, config)
268
- this.editor?.ready(() => {
269
- const value = this.props.config.value
270
- if (value) {
271
- const div = document.createElement('div')
272
- div.innerHTML = value
273
- this.editor?.setContent(div.innerText || '')
274
- this.props.form?.setFieldValue(this.props.dataIndex, this.editor?.getContent())
275
- }
276
-
277
- this.editor?.addListener('contentChange', () => {
278
- this.props.form?.setFieldValue(this.props.dataIndex, this.editor?.getContent())
279
- })
280
- this.setState({loading: false})
281
- })
282
- })
283
-
284
- }
285
-
286
- componentWillUnmount() {
287
- this.editor?.destroy()
288
- }
289
-
290
- render() {
291
- return <ModalContext.Consumer>
292
- {
293
- modalContext => {
294
- this.modalContext = modalContext
295
- return <div {...filterObjectKeys(this.props, [
296
- 'id',
297
- 'fieldProps',
298
- 'onChange',
299
- 'value',
300
- 'form',
301
- 'config',
302
- 'rules',
303
- 'ueditorPath',
304
- 'dataIndex',
305
- ])} ref={el => this.containerRef = el}>
306
- <Spin spinning={this.state.loading}>
307
- <div id={this.state.containerId} style={{width: this.state.width}}/>
308
- </Spin>
309
- </div>
310
- }
311
- }
312
- </ModalContext.Consumer>
313
- }
314
- }