@chaoswise/business 1.0.5 → 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.
Files changed (82) hide show
  1. package/lib/I18nInput/index.d.ts +31 -0
  2. package/lib/I18nInput/index.js +379 -0
  3. package/lib/I18nInput/index.less +7 -0
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.js +1 -4
  6. package/lib/locales/en_US.json +1 -1
  7. package/lib/locales/index.d.ts +7 -0
  8. package/lib/locales/index.js +28 -13
  9. package/lib/locales/intl.d.ts +11 -0
  10. package/lib/locales/intl.js +39 -24
  11. package/lib/locales/ja_JP.json +1 -0
  12. package/lib/locales/normalizeLocale.d.ts +2 -0
  13. package/lib/locales/normalizeLocale.js +27 -0
  14. package/lib/locales/withLocale.d.ts +28 -0
  15. package/lib/locales/withLocale.js +2 -2
  16. package/lib/locales/zh_CN.json +1 -1
  17. package/lib/locales/zh_HK.json +1 -0
  18. package/lib/locales/zh_TW.json +1 -1
  19. package/package.json +10 -5
  20. package/lib/AggregateSearch/CLSPL/CLQLLexer.js +0 -78
  21. package/lib/AggregateSearch/CLSPL/CLQLParser.js +0 -2724
  22. package/lib/AggregateSearch/CLSPL/CLQLParserListener.js +0 -347
  23. package/lib/AggregateSearch/CLSPL/CLQLParserVisitor.js +0 -251
  24. package/lib/AggregateSearch/CLSPL/SPLStagy.js +0 -197
  25. package/lib/AggregateSearch/CLSPL/index.js +0 -196
  26. package/lib/AggregateSearch/CLSPL/makeTokenizeFn.js +0 -18
  27. package/lib/AggregateSearch/CLSPL/token.js +0 -7
  28. package/lib/AggregateSearch/components/CloseAllIcon/index.js +0 -13
  29. package/lib/AggregateSearch/components/CloseAllIcon/index.less +0 -11
  30. package/lib/AggregateSearch/components/DropDown/assets/combined.svg +0 -22
  31. package/lib/AggregateSearch/components/DropDown/assets/copy.svg +0 -22
  32. package/lib/AggregateSearch/components/DropDown/assets/delete.svg +0 -24
  33. package/lib/AggregateSearch/components/DropDown/assets/home.svg +0 -20
  34. package/lib/AggregateSearch/components/DropDown/assets/key.svg +0 -21
  35. package/lib/AggregateSearch/components/DropDown/assets/star.svg +0 -22
  36. package/lib/AggregateSearch/components/DropDown/assets/time-circle.svg +0 -20
  37. package/lib/AggregateSearch/components/DropDown/assets/value.svg +0 -23
  38. package/lib/AggregateSearch/components/DropDown/config.js +0 -54
  39. package/lib/AggregateSearch/components/DropDown/index.js +0 -584
  40. package/lib/AggregateSearch/components/DropDown/index.less +0 -118
  41. package/lib/AggregateSearch/components/SwitchBtn/assets/tag-icon.svg +0 -17
  42. package/lib/AggregateSearch/components/SwitchBtn/assets/text-icon.svg +0 -18
  43. package/lib/AggregateSearch/components/SwitchBtn/index.js +0 -27
  44. package/lib/AggregateSearch/components/SwitchBtn/index.less +0 -31
  45. package/lib/AggregateSearch/hooks/useDropDown.js +0 -428
  46. package/lib/AggregateSearch/index.js +0 -520
  47. package/lib/AggregateSearch/index.less +0 -225
  48. package/lib/AggregateSearch/utils/index.js +0 -391
  49. package/lib/ContentEditableSearch/components/CloseAllIcon/index.js +0 -13
  50. package/lib/ContentEditableSearch/components/CloseAllIcon/index.less +0 -11
  51. package/lib/ContentEditableSearch/index.js +0 -157
  52. package/lib/ContentEditableSearch/index.less +0 -65
  53. package/lib/ContentEditableSearch/utils/index.js +0 -98
  54. package/lib/PropertyControlViewer/assets/doCommon.less +0 -75
  55. package/lib/PropertyControlViewer/assets/doSelect.less +0 -74
  56. package/lib/PropertyControlViewer/assets/index.less +0 -189
  57. package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/iconfont.js +0 -1
  58. package/lib/PropertyControlViewer/components/DoAppIcon/CustomIcon/index.js +0 -29
  59. package/lib/PropertyControlViewer/components/DoAppIcon/iconData/IconJson.js +0 -0
  60. package/lib/PropertyControlViewer/components/DoAppIcon/index.js +0 -41
  61. package/lib/PropertyControlViewer/components/DoCiUnitBitmap.js +0 -50
  62. package/lib/PropertyControlViewer/components/DoCommon.js +0 -36
  63. package/lib/PropertyControlViewer/components/DoDefaultPlaceholder.js +0 -9
  64. package/lib/PropertyControlViewer/components/DoImage.js +0 -107
  65. package/lib/PropertyControlViewer/components/DoQuote/components/QuoteView.js +0 -63
  66. package/lib/PropertyControlViewer/components/DoQuote/components/TableQuoteView.js +0 -18
  67. package/lib/PropertyControlViewer/components/DoQuote/index.js +0 -16
  68. package/lib/PropertyControlViewer/components/DoSelect.js +0 -80
  69. package/lib/PropertyControlViewer/components/DoTable.js +0 -44
  70. package/lib/PropertyControlViewer/components/DoUser.js +0 -61
  71. package/lib/PropertyControlViewer/components/TagShowMoreList/index.js +0 -132
  72. package/lib/PropertyControlViewer/components/TagShowMoreList/index.less +0 -106
  73. package/lib/PropertyControlViewer/config/constants.js +0 -84
  74. package/lib/PropertyControlViewer/config/utils.js +0 -353
  75. package/lib/PropertyControlViewer/index.js +0 -195
  76. package/lib/PropertyControlViewer/index.less +0 -107
  77. package/lib/Watermark/index.js +0 -187
  78. package/lib/Watermark/index.less +0 -17
  79. package/lib/demo.js +0 -0
  80. package/lib/locale/en_US.js +0 -9
  81. package/lib/locale/index.js +0 -12
  82. package/lib/locale/zh_CN.js +0 -9
@@ -1,225 +0,0 @@
1
- // == when hoverd
2
- .hover(@color: @input-hover-border-color) {
3
- border-color: @color;
4
- border-right-width: @border-width-base !important;
5
- }
6
-
7
- // input status
8
- // == when focus or actived
9
- .active(@color: @outline-color) {
10
- border-color:~`colorPalette('@{color}', 5) `;
11
- border-right-width: @border-width-base !important;
12
- outline: 0;
13
- box-shadow: @input-outline-offset @outline-blur-size @outline-width fade(@color, 20%);
14
- }
15
- // tooltip挂载到body上
16
- .uniq-aggregateSearch-tooltip{
17
- white-space: nowrap;
18
- background: #FFF1F0;
19
- border: @border-width-base @border-style-base @red-5;
20
- border-radius: 0 0 2px 2px;
21
- font-size: 12px;
22
- color: @red-5;
23
- padding: 0 10px;
24
- min-width: 100px;
25
- height: 20px;
26
- line-height: 20px;
27
- }
28
- .aggregate-search-wrapper {
29
- background: #FFFFFF;
30
- border-radius: 2px;
31
- font-size: 12px;
32
- display: flex;
33
- align-items: flex-start;
34
- white-space: pre-wrap;
35
- position: relative;
36
- border: @border-width-base @border-style-base @input-border-color;
37
- border-radius: @border-radius-base;
38
- width: 100%;
39
- // 聚焦样式修改
40
- &:focus-within {
41
- .active();
42
- }
43
-
44
- &:hover {
45
- .hover();
46
- }
47
-
48
- // 取消默认聚焦样式
49
- &:focus-visible {
50
- outline: none;
51
- }
52
-
53
- .aggregate-search-input {
54
- position: relative;
55
- padding: 0 10px;
56
- padding-right: 30px;
57
- flex: 1;
58
- height: 100%;
59
- min-height: 26px;
60
- line-height: 26px;
61
- // border-radius: @border-radius-base 0 0 @border-radius-base;
62
- outline: none;
63
-
64
- &:empty:before {
65
- content: attr(data-placeholder);
66
- font-size: 12px;
67
- color: rgba(0, 0, 0, 0.45);
68
- line-height: 20px;
69
- }
70
-
71
- &:empty+.close-all-icon {
72
- display: none;
73
- }
74
-
75
- &:not(.syntax-error):focus:before {
76
- // 需要排除掉syntax-error的样式不然报错内容丢失
77
- content: ""; // 不能为none,否则placeholder不显示
78
- }
79
-
80
- .tag-box {
81
- position: relative;
82
- background: #FFFFFF;
83
- border: @border-width-base @border-style-base #E3E3E3;
84
- border-radius: 2px;
85
- min-height: 20px;
86
- line-height: 18px;
87
- display: inline-block;
88
- margin-right: 2px;
89
- padding-right: 5px;
90
- word-break: break-word;
91
- .tag-box-item-close {
92
- position: absolute;
93
- height: 20px;
94
- line-height: 20px;
95
- display: none;
96
- top: -1px;
97
- right: -12px;
98
- width: 12px;
99
- border: @border-width-base @border-style-base #E3E3E3;
100
- border-left: none;
101
- z-index: 10;
102
- background: #fff;
103
- border-radius: 0 @border-radius-base @border-radius-base 0;
104
-
105
- &::before,
106
- &::after {
107
- content: ''; // content为x时,样式突兀
108
- width: 0.5px;
109
- height: 8px;
110
- background: @text-color-show;
111
- position: absolute;
112
- top: 5.5px;
113
- right: 6px;
114
- left: auto;
115
- }
116
-
117
- &::before {
118
- transform: rotate(45deg);
119
- }
120
-
121
- &::after {
122
- transform: rotate(-45deg);
123
- }
124
- }
125
- &:hover {
126
- border-color: @primary-5;
127
- border-top-right-radius: 0;
128
- border-bottom-right-radius: 0;
129
- .tag-box-item-close {
130
- display: inline-block;
131
- border-color: @primary-5;
132
- &:hover {
133
- cursor: pointer;
134
- &::before,
135
- &::after {
136
- background: @primary-5;
137
- }
138
- }
139
-
140
- }
141
- }
142
- &:not(.syntax-error):not(&:hover):has(.tag-con-keyword_AND_OR:nth-child(1)):has(.tag-box-item-close:nth-child(2)) {
143
- border-color: transparent;
144
- }
145
-
146
- .tag-con {
147
- display: inline-block;
148
- min-height: 18px;
149
- line-height: 18px;
150
-
151
- &:first-child {
152
- padding-left: 5px;
153
- }
154
- }
155
-
156
- .tag-con-key {
157
- background: rgba(0, 0, 0, 0.06);
158
- }
159
-
160
- .tag-con-key-last {
161
- padding-right: 2px;
162
- }
163
-
164
- .tag-con-keyword {
165
- color: #FA8C16;
166
- }
167
-
168
- .tag-con-identifier {
169
- color: #FA8C16;
170
- }
171
-
172
- .tag-con-match {
173
- color: #FA8C16;
174
- padding-left: 2px;
175
- }
176
- }
177
- }
178
-
179
- &.aggregate-search-text-wrapper {
180
- .aggregate-search-input {
181
- line-height: 20px;
182
- padding-top: 3px;
183
- padding-bottom: 3px;
184
- }
185
- }
186
- }
187
-
188
-
189
- .syntax-error {
190
- // 语法错误,高亮样式
191
- border: @border-width-base @border-style-base @red-5 !important;
192
- box-shadow: none !important;
193
-
194
- &:hover {
195
-
196
- // 伪类展示属性值
197
- // &:before {
198
- // content: attr(data-error);
199
- // position: absolute;
200
- // white-space: nowrap;
201
- // top: -28px;
202
- // left: -1px;
203
- // height: 20px;
204
- // line-height: 20px;
205
- // background: #FFF1F0;
206
- // border: @border-width-base @border-style-base @red-5;
207
- // border-radius: 0 0 2px 2px;
208
- // font-size: 12px;
209
- // color: @red-5;
210
- // padding: 0 10px;
211
- // min-width: 100px;
212
- // }
213
- }
214
- &:hover {
215
- .tag-box-item-close {
216
- border-color: @red-5 !important;
217
- &:hover {
218
- &::before,
219
- &::after {
220
- background: @red-5 !important;
221
- }
222
- }
223
- }
224
- }
225
- }
@@ -1,391 +0,0 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
3
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
7
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
8
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
9
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
10
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
- import makeTokenizeFn from "../CLSPL/makeTokenizeFn";
12
- import MyGrammarLexer from "../CLSPL/CLQLLexer.js";
13
- import { TOKEN_TYPES } from "../CLSPL/token";
14
- import SPLCheck from "../CLSPL/index";
15
- import classNames from "classnames";
16
- import { v4 as uid } from 'uuid';
17
- export var parseStringToToken = function parseStringToToken(value) {
18
- var TOKEN_MAPPING = new Map([[MyGrammarLexer.COLON, TOKEN_TYPES.MATCH],
19
- // 冒号
20
- [MyGrammarLexer.LPAREN, TOKEN_TYPES.IDENTIFIER],
21
- // 左括号
22
- [MyGrammarLexer.RPAREN, TOKEN_TYPES.IDENTIFIER],
23
- // 右括号
24
- [MyGrammarLexer.LT, TOKEN_TYPES.MATCH],
25
- // <
26
- [MyGrammarLexer.GT, TOKEN_TYPES.MATCH],
27
- // >
28
- [MyGrammarLexer.LE, TOKEN_TYPES.MATCH],
29
- // <=
30
- [MyGrammarLexer.GE, TOKEN_TYPES.MATCH],
31
- // >=
32
- [MyGrammarLexer.QUESTION, TOKEN_TYPES.IDENTIFIER],
33
- // ?
34
- [MyGrammarLexer.STAR, TOKEN_TYPES.IDENTIFIER],
35
- // *
36
- [MyGrammarLexer.LBRAKET, TOKEN_TYPES.IDENTIFIER],
37
- // [
38
- [MyGrammarLexer.RBRAKET, TOKEN_TYPES.IDENTIFIER],
39
- // ]
40
- [MyGrammarLexer.LCURLY, TOKEN_TYPES.IDENTIFIER],
41
- // {
42
- [MyGrammarLexer.RCURLY, TOKEN_TYPES.IDENTIFIER],
43
- // }
44
- [MyGrammarLexer.WAVE, TOKEN_TYPES.IDENTIFIER],
45
- // ~
46
- [MyGrammarLexer.PLUS, TOKEN_TYPES.IDENTIFIER],
47
- // +
48
- [MyGrammarLexer.MINUS, TOKEN_TYPES.IDENTIFIER],
49
- // -
50
- [MyGrammarLexer.K_AND, TOKEN_TYPES.KEYWORD],
51
- // 关键字 AND
52
- [MyGrammarLexer.K_OR, TOKEN_TYPES.KEYWORD],
53
- // 关键字 OR
54
- [MyGrammarLexer.K_NOT, TOKEN_TYPES.KEYWORD],
55
- // 关键字 NOT
56
- [MyGrammarLexer.K_TO, TOKEN_TYPES.KEYWORD] // 关键字 TO
57
- ]);
58
- var tokenize = makeTokenizeFn(MyGrammarLexer, TOKEN_MAPPING);
59
- return tokenize(value);
60
- };
61
-
62
- // 语法检测
63
- export var checkSyntax = function checkSyntax(value) {
64
- return new Promise(function (resolve) {
65
- new SPLCheck({
66
- spl: value || ""
67
- }).resolving(function (result) {
68
- if ((result === null || result === void 0 ? void 0 : result.type) === "error") {
69
- resolve(result);
70
- } else {
71
- resolve("");
72
- }
73
- });
74
- });
75
- };
76
-
77
- // 以空格分隔内容,但是不包括()内和NOT后的空格和双引号内的空格
78
- var splitBySpace = function splitBySpace(str) {
79
- var res = [];
80
- var temp = "";
81
- var isBracket = false; // 括号内不分割
82
- var isQuote = false; // 引号内不分割
83
- var isSquareBracket = false; // 方括号内不分割
84
- var isOpenBracket = false; // 花括号内不分割
85
-
86
- for (var i = 0; i < str.length; i++) {
87
- var _char = str[i];
88
- // 检测当前字符与前面的字符拼接是否为 "NOT "
89
- var isNot = "".concat(temp).concat(_char).toUpperCase() === "NOT ";
90
- if (['"'].includes(_char)) {
91
- isQuote = !isQuote;
92
- }
93
- if (["["].includes(_char)) {
94
- isSquareBracket = true;
95
- }
96
- if (["]"].includes(_char)) {
97
- isSquareBracket = false;
98
- }
99
- if (["{"].includes(_char)) {
100
- isOpenBracket = true;
101
- }
102
- if (["}"].includes(_char)) {
103
- isOpenBracket = false;
104
- }
105
- if (["("].includes(_char)) {
106
- isBracket = true;
107
- }
108
- if ([")"].includes(_char)) {
109
- isBracket = false;
110
- }
111
- if (_char === " " && !isBracket && !isNot && !isQuote && !isSquareBracket && !isOpenBracket) {
112
- res.push(temp);
113
- // '1 2 3 4' ==> ['1', ' ', '3', ' ', '4']
114
- res.push(" ");
115
- temp = "";
116
- } else {
117
- temp += _char;
118
- }
119
- }
120
- if (temp) {
121
- res.push(temp);
122
- }
123
- return res;
124
- };
125
-
126
- // 按token结果生成html
127
- export var genHtmlAndSyntaxCheckResByString = function genHtmlAndSyntaxCheckResByString(originalStr) {
128
- var tags = splitBySpace(originalStr.endsWith(" ") ? originalStr : originalStr + " ");
129
- var htmlString = tags.map(function (inputString) {
130
- var html = "";
131
- var tagId = "";
132
- if (!inputString.trim()) {
133
- html = inputString;
134
- } else {
135
- tagId = uid();
136
- var tokenList = parseStringToToken(inputString);
137
- var matchIndex = tokenList.findIndex(function (item) {
138
- return item.type === TOKEN_TYPES.MATCH;
139
- });
140
- var hasMatch = matchIndex !== -1;
141
- html = tokenList.map(function (token, index) {
142
- var genClassName = function genClassName(typeClass) {
143
- return classNames(typeClass, {
144
- "tag-con": true,
145
- // [typeClass]: true,
146
- "tag-con-key": hasMatch ? index < matchIndex : false,
147
- "tag-con-key-last": matchIndex ? index === matchIndex - 1 : false,
148
- "tag-con-value": hasMatch ? index > matchIndex : false
149
- });
150
- };
151
- var genDataType = function genDataType(index) {
152
- if (hasMatch) {
153
- if (index < matchIndex) {
154
- return "key";
155
- }
156
- if (index === matchIndex) {
157
- return "match";
158
- }
159
- return "value";
160
- }
161
- return "key";
162
- };
163
- var dataType = genDataType(index);
164
- var getEleProps = function getEleProps(type, text) {
165
- var typeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, TOKEN_TYPES.MATCH, {
166
- tagName: "span",
167
- props: {
168
- "class": genClassName("tag-con-match"),
169
- "data-attr": "match",
170
- "data-type": dataType
171
- }
172
- }), TOKEN_TYPES.KEYWORD, {
173
- tagName: "span",
174
- props: {
175
- "class": genClassName(text.toUpperCase() === "AND" || text.toUpperCase() === "OR" ? "tag-con-keyword tag-con-keyword_AND_OR" : "tag-con-keyword"),
176
- "data-attr": "keyword",
177
- "data-type": dataType
178
- }
179
- }), TOKEN_TYPES.IDENTIFIER, {
180
- tagName: "span",
181
- props: {
182
- "class": genClassName("tag-con-identifier"),
183
- "data-attr": "identifier",
184
- "data-type": dataType
185
- }
186
- }), TOKEN_TYPES.NONE, {
187
- tagName: "span",
188
- props: {
189
- "class": genClassName("tag-con-none"),
190
- "data-attr": "none",
191
- "data-type": dataType
192
- }
193
- });
194
- return typeMap[type];
195
- };
196
- var type = token.type,
197
- text = token.text;
198
- var curProps = getEleProps(type, text);
199
- var elePropsString = Object.entries(curProps.props).map(function (_ref) {
200
- var _ref2 = _slicedToArray(_ref, 2),
201
- key = _ref2[0],
202
- value = _ref2[1];
203
- return "".concat(key, "=\"").concat(value, "\"");
204
- }).join(" ");
205
- return "<".concat(curProps.tagName, " ").concat(elePropsString, ">").concat(text, "</").concat(curProps.tagName, ">");
206
- }).join("");
207
- }
208
- if (!html.trim()) {
209
- return html;
210
- }
211
- return "<span class=\"tag-box\" data-attr=\"tag-box\" id=\"".concat(tagId, "\">").concat(html, "<span class=\"tag-box-item-close\" contenteditable=\"false\"></span></span>");
212
- }).join("");
213
- return htmlString;
214
- };
215
-
216
- // 获取光标所在节点
217
- export var getCurrentNode = function getCurrentNode() {
218
- var selection = window.getSelection();
219
- var range = selection.getRangeAt(0);
220
- var currentNode = range.endContainer;
221
- // 光标记录的大多数情况下是文本节点,需要获取父节点作为当前节点
222
- if (currentNode.nodeType === 3) {
223
- return currentNode.parentNode;
224
- }
225
- return currentNode;
226
- };
227
-
228
- // 获取当前光标所在的tag
229
- export var getCurrentTag = function getCurrentTag() {
230
- var _currentNode$dataset, _currentNode$parentEl;
231
- var currentNode = getCurrentNode();
232
- var curTag;
233
- var type = currentNode === null || currentNode === void 0 || (_currentNode$dataset = currentNode.dataset) === null || _currentNode$dataset === void 0 ? void 0 : _currentNode$dataset["attr"];
234
- var parentType = (_currentNode$parentEl = currentNode.parentElement) === null || _currentNode$parentEl === void 0 || (_currentNode$parentEl = _currentNode$parentEl.dataset) === null || _currentNode$parentEl === void 0 ? void 0 : _currentNode$parentEl["attr"];
235
- if (type === "tag-box") {
236
- curTag = currentNode;
237
- }
238
- if (parentType === "tag-box") {
239
- curTag = currentNode.parentElement;
240
- }
241
- return curTag;
242
- };
243
-
244
- // 删除当前内容
245
- export var deleteCurrentContent = function deleteCurrentContent() {
246
- var _anchorNode$parentEle;
247
- var selection = window.getSelection();
248
- var anchorNode = selection.anchorNode;
249
- if (((_anchorNode$parentEle = anchorNode.parentElement.dataset) === null || _anchorNode$parentEle === void 0 ? void 0 : _anchorNode$parentEle["attr"]) !== "container") {
250
- // FIXED 自动创建span标签导致的问题
251
- anchorNode = anchorNode.parentElement;
252
- container.current.removeChild(anchorNode);
253
- } else {
254
- var con = anchorNode.data;
255
- // tags间保留空格,处理光标不能插入tags间的问题
256
- var offset = con.startsWith("\xA0") ? 1 : 0;
257
- var selRange = selection.getRangeAt(0);
258
- selRange.setStart(anchorNode, offset);
259
- selRange.setEndAfter(anchorNode);
260
- selRange.deleteContents();
261
- }
262
- };
263
-
264
- // 光标位置插入节点
265
- export var insertRang = function insertRang(node) {
266
- var selection = window.getSelection();
267
- var selRange = selection.getRangeAt(0);
268
- selRange.insertNode(node);
269
- };
270
-
271
- // 粘贴去除格式
272
- export function textInit(e) {
273
- // cancel paste
274
- e.preventDefault();
275
- // get text representation of clipboard
276
- var text = (e.originalEvent || e).clipboardData.getData("text/plain");
277
- // insert text manually
278
- document.execCommand("insertText", false, text);
279
- }
280
-
281
- // 获取当前输入的光标位置(纯文本模式)
282
- export var getCursorPosition = function getCursorPosition(node) {
283
- var _endContainer$dataset;
284
- var selection = window.getSelection();
285
- if (selection.type !== 'Caret') {
286
- return null;
287
- }
288
- var range = selection.getRangeAt(0);
289
- var endContainer = range.endContainer;
290
- if (((_endContainer$dataset = endContainer.dataset) === null || _endContainer$dataset === void 0 ? void 0 : _endContainer$dataset['attr']) === 'container') {
291
- return 0;
292
- }
293
-
294
- // 计算纯文本模式下,当前光标所处的位置
295
- var positionIndex = 0;
296
- var isBreak = false;
297
- var _loop = function loop(node) {
298
- var nodes = node.childNodes;
299
- for (var index = 0; index < nodes.length; index++) {
300
- if (isBreak) {
301
- break;
302
- }
303
- var element = nodes[index];
304
- if (element.nodeType === 3) {
305
- if (element === endContainer) {
306
- positionIndex += range.endOffset;
307
- isBreak = true;
308
- break;
309
- } else {
310
- positionIndex += element.data.length;
311
- }
312
- } else {
313
- _loop(element);
314
- }
315
- }
316
- };
317
- _loop(node);
318
- return positionIndex;
319
- };
320
-
321
- // 根据纯文本模式下的光标位置,设置html模式下的光标位置
322
- export var getCursorNodeAndIndex = function getCursorNodeAndIndex(node, positionIndex) {
323
- var targetNode;
324
- var targetIndex;
325
- var sum = 0;
326
- var isBreak = false;
327
- var _loop2 = function loop(node) {
328
- var nodes = node.childNodes;
329
- for (var index = 0; index < nodes.length; index++) {
330
- if (isBreak) {
331
- break;
332
- }
333
- var element = nodes[index];
334
- if (element.nodeType === 3) {
335
- var _element$data;
336
- var elementLength = ((_element$data = element.data) === null || _element$data === void 0 ? void 0 : _element$data.length) || 0;
337
- if (sum <= positionIndex && sum + elementLength >= positionIndex) {
338
- targetNode = element;
339
- targetIndex = positionIndex - sum;
340
- isBreak = true;
341
- break;
342
- } else {
343
- sum += elementLength;
344
- }
345
- } else {
346
- _loop2(element);
347
- }
348
- }
349
- };
350
- _loop2(node);
351
- return {
352
- targetNode: targetNode,
353
- targetIndex: targetIndex
354
- };
355
- };
356
-
357
- // 光标跳转到指定位置
358
- export var setCursorPosition = function setCursorPosition(targetNode, targetIndex) {
359
- if (!targetNode) {
360
- return;
361
- }
362
- var selection = window.getSelection();
363
- var range = new Range();
364
- range.setStart(targetNode, targetIndex);
365
- range.collapse(true);
366
- selection.removeAllRanges();
367
- selection.addRange(range);
368
- };
369
- export function isObjectEqual(obj1, obj2) {
370
- var obj1Keys = Object.keys(obj1);
371
- var obj2Keys = Object.keys(obj2);
372
- if (obj1Keys.length !== obj2Keys.length) {
373
- return false;
374
- }
375
- for (var _i = 0, _obj1Keys = obj1Keys; _i < _obj1Keys.length; _i++) {
376
- var key = _obj1Keys[_i];
377
- if (obj1[key] !== obj2[key]) {
378
- return false;
379
- }
380
- }
381
- return true;
382
- }
383
- // 将节点克隆并将标签里面所有的关闭按钮节点移出
384
- export var cloneDomRemoveCloseBtn = function cloneDomRemoveCloseBtn(node) {
385
- var cloneNode = node.cloneNode(true);
386
- var closeBtns = cloneNode.querySelectorAll(".tag-box-item-close");
387
- closeBtns.forEach(function (item) {
388
- item.remove();
389
- });
390
- return cloneNode;
391
- };
@@ -1,13 +0,0 @@
1
- import _Icon from "@chaoswise/ui/lib/Icon";
2
- import React from "react";
3
- import "./index.less";
4
- var CloseAllIcon = function CloseAllIcon(_ref) {
5
- var onClickCloseAll = _ref.onClickCloseAll;
6
- return /*#__PURE__*/React.createElement(_Icon, {
7
- type: "close-circle",
8
- theme: "filled",
9
- onClick: onClickCloseAll,
10
- className: "content-editable-close-all-icon"
11
- });
12
- };
13
- export default CloseAllIcon;
@@ -1,11 +0,0 @@
1
- .content-editable-close-all-icon{
2
- display: block;
3
- position: absolute;
4
- right: 15px;
5
- top: 7px;
6
- color: rgba(0,0,0,0.25);
7
- cursor: pointer;
8
- &:hover{
9
- color: @text-color-secondary;
10
- }
11
- }