@cozeloop/components 0.0.3 → 0.0.4

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 (165) hide show
  1. package/package.json +9 -3
  2. package/.eslintcache +0 -1
  3. package/.rush/temp/shrinkwrap-deps.json +0 -770
  4. package/OWNERS +0 -5
  5. package/config/rush-project.json +0 -8
  6. package/eslint.config.js +0 -7
  7. package/rslib.config.js +0 -7
  8. package/script/publish.js +0 -146
  9. package/src/base-search-select/base-search-form-select.tsx +0 -10
  10. package/src/base-search-select/base-search-select.tsx +0 -200
  11. package/src/base-search-select/index.module.less +0 -16
  12. package/src/base-search-select/index.tsx +0 -3
  13. package/src/base-search-select/types.ts +0 -16
  14. package/src/base-search-select/utils.ts +0 -78
  15. package/src/basic-card/index.tsx +0 -23
  16. package/src/card-pane/index.module.less +0 -14
  17. package/src/card-pane/index.tsx +0 -25
  18. package/src/chip-select/index.module.less +0 -17
  19. package/src/chip-select/index.tsx +0 -7
  20. package/src/code-editor/index.tsx +0 -9
  21. package/src/code-usage/code-item.module.less +0 -32
  22. package/src/code-usage/index.tsx +0 -91
  23. package/src/codemirror-editor/code-editor.tsx +0 -139
  24. package/src/codemirror-editor/index.ts +0 -4
  25. package/src/codemirror-editor/json-editor.tsx +0 -183
  26. package/src/codemirror-editor/raw-text-editor.tsx +0 -68
  27. package/src/codemirror-editor/text-editor.tsx +0 -58
  28. package/src/codemirror-editor/themes/coze-dark.ts +0 -116
  29. package/src/codemirror-editor/themes/coze-light.ts +0 -122
  30. package/src/collapse-card/index.module.less +0 -27
  31. package/src/collapse-card/index.tsx +0 -93
  32. package/src/collapsible-card/index.module.less +0 -63
  33. package/src/collapsible-card/index.tsx +0 -57
  34. package/src/column-manage-storage/index.tsx +0 -64
  35. package/src/columns-select/index.tsx +0 -244
  36. package/src/edit-icon-button/index.tsx +0 -36
  37. package/src/footer-actions/index.tsx +0 -33
  38. package/src/hooks/use-infinite-scroll.ts +0 -183
  39. package/src/hooks/use-mouse-down-offset.ts +0 -50
  40. package/src/hooks/use-unsave-leave-warning.ts +0 -49
  41. package/src/id-render/icon-button-container.tsx +0 -37
  42. package/src/id-render/index.tsx +0 -64
  43. package/src/index-controller/record-navigation.tsx +0 -57
  44. package/src/index-controller/use-item-index-controller.ts +0 -197
  45. package/src/index.ts +0 -208
  46. package/src/infinite-scroll-table/index.tsx +0 -99
  47. package/src/info-tooltip/index.tsx +0 -41
  48. package/src/input-components/radio-button.tsx +0 -63
  49. package/src/input-slider/index.module.less +0 -30
  50. package/src/input-slider/index.tsx +0 -161
  51. package/src/input-with-count/index.tsx +0 -31
  52. package/src/jump-button/jump-icon-button.tsx +0 -12
  53. package/src/large-txt-render/index.tsx +0 -46
  54. package/src/layout/content.tsx +0 -28
  55. package/src/layout/header.tsx +0 -15
  56. package/src/layout/index.module.less +0 -28
  57. package/src/layout/index.tsx +0 -9
  58. package/src/layout/tabs.tsx +0 -11
  59. package/src/lazy-load-component/index.tsx +0 -55
  60. package/src/logic-editor/index.ts +0 -3
  61. package/src/logic-editor/logic-editor.module.less +0 -13
  62. package/src/logic-editor/logic-editor.tsx +0 -200
  63. package/src/logic-editor/logic-left-render.tsx +0 -100
  64. package/src/logic-editor/logic-operator-render.tsx +0 -54
  65. package/src/logic-editor/logic-right-render.tsx +0 -51
  66. package/src/logic-editor/logic-types.tsx +0 -238
  67. package/src/logic-editor/utils.ts +0 -22
  68. package/src/logic-expr/assets/select.svg +0 -1
  69. package/src/logic-expr/consts.ts +0 -6
  70. package/src/logic-expr/expr-group-render.tsx +0 -238
  71. package/src/logic-expr/expr-render.tsx +0 -226
  72. package/src/logic-expr/index.module.less +0 -252
  73. package/src/logic-expr/index.ts +0 -13
  74. package/src/logic-expr/logic-expr.tsx +0 -261
  75. package/src/logic-expr/logic-not.tsx +0 -46
  76. package/src/logic-expr/logic-toggle.tsx +0 -96
  77. package/src/logic-expr/types.ts +0 -95
  78. package/src/loop-radio-group/index.tsx +0 -16
  79. package/src/multi-part-editor/components/image-item-renderer.tsx +0 -134
  80. package/src/multi-part-editor/components/index.module.less +0 -21
  81. package/src/multi-part-editor/components/multipart-item-renderer.tsx +0 -74
  82. package/src/multi-part-editor/components/url-input-modal.tsx +0 -317
  83. package/src/multi-part-editor/components/video-item-renderer.tsx +0 -145
  84. package/src/multi-part-editor/index.module.less +0 -8
  85. package/src/multi-part-editor/index.tsx +0 -571
  86. package/src/multi-part-editor/multi-part-render.tsx +0 -87
  87. package/src/multi-part-editor/type.tsx +0 -103
  88. package/src/multi-part-editor/upload-button.tsx +0 -256
  89. package/src/multi-part-editor/utils.ts +0 -64
  90. package/src/open-detail-button/index.tsx +0 -30
  91. package/src/page-content/index.tsx +0 -99
  92. package/src/primary-page/index.tsx +0 -1
  93. package/src/primary-page/primary-header.tsx +0 -64
  94. package/src/primary-title/index.module.less +0 -14
  95. package/src/primary-title/index.tsx +0 -18
  96. package/src/provider/index.tsx +0 -89
  97. package/src/resizable-side-sheet/index.tsx +0 -69
  98. package/src/resize-sidesheet/index.module.less +0 -14
  99. package/src/resize-sidesheet/index.tsx +0 -68
  100. package/src/resize-sidesheet/use-drag.ts +0 -43
  101. package/src/schema-editor/index.tsx +0 -52
  102. package/src/search-form/index.tsx +0 -134
  103. package/src/semi-schema-form/components/tmpls/array-field-item.tsx +0 -97
  104. package/src/semi-schema-form/components/tmpls/array-field.tsx +0 -127
  105. package/src/semi-schema-form/components/tmpls/base-input.tsx +0 -126
  106. package/src/semi-schema-form/components/tmpls/description-field.tsx +0 -23
  107. package/src/semi-schema-form/components/tmpls/error-list.tsx +0 -44
  108. package/src/semi-schema-form/components/tmpls/field-error.tsx +0 -33
  109. package/src/semi-schema-form/components/tmpls/field.tsx +0 -54
  110. package/src/semi-schema-form/components/tmpls/icon-button.tsx +0 -112
  111. package/src/semi-schema-form/components/tmpls/index.ts +0 -39
  112. package/src/semi-schema-form/components/tmpls/object-field.tsx +0 -173
  113. package/src/semi-schema-form/components/tmpls/submit.tsx +0 -31
  114. package/src/semi-schema-form/components/tmpls/title-field.tsx +0 -30
  115. package/src/semi-schema-form/components/widgets/checkbox.tsx +0 -67
  116. package/src/semi-schema-form/components/widgets/checkboxs.tsx +0 -100
  117. package/src/semi-schema-form/components/widgets/index.ts +0 -17
  118. package/src/semi-schema-form/components/widgets/radio.tsx +0 -105
  119. package/src/semi-schema-form/components/widgets/range.tsx +0 -73
  120. package/src/semi-schema-form/components/widgets/select.tsx +0 -108
  121. package/src/semi-schema-form/components/widgets/textarea.tsx +0 -63
  122. package/src/semi-schema-form/index.tsx +0 -14
  123. package/src/sentinel-form/enum.ts +0 -16
  124. package/src/sentinel-form/index.tsx +0 -382
  125. package/src/step-nav/index.module.less +0 -45
  126. package/src/step-nav/index.tsx +0 -53
  127. package/src/table/index.module.less +0 -144
  128. package/src/table/index.tsx +0 -18
  129. package/src/table/sort-icon.tsx +0 -73
  130. package/src/table/table-with-pagination.tsx +0 -150
  131. package/src/table/table-without-pagniation.tsx +0 -66
  132. package/src/table-batch-operate/table-batch-operation.tsx +0 -47
  133. package/src/table-batch-operate/use-batch-operate.ts +0 -111
  134. package/src/table-col-actions/index.module.less +0 -8
  135. package/src/table-col-actions/index.tsx +0 -149
  136. package/src/table-cols-config/index.module.less +0 -34
  137. package/src/table-cols-config/index.tsx +0 -171
  138. package/src/table-cols-config/type.ts +0 -12
  139. package/src/table-cols-config/use-hidden-col-keys.ts +0 -53
  140. package/src/table-cols-config/util.ts +0 -56
  141. package/src/table-empty/index.tsx +0 -23
  142. package/src/table-header/index.module.less +0 -7
  143. package/src/table-header/index.tsx +0 -70
  144. package/src/tabs/index.module.less +0 -48
  145. package/src/tabs/index.tsx +0 -9
  146. package/src/text-area-pro/index.module.less +0 -5
  147. package/src/text-area-pro/index.tsx +0 -49
  148. package/src/text-with-copy/index.tsx +0 -95
  149. package/src/title-with-sub/index.tsx +0 -27
  150. package/src/tooltip-when-disabled/index.tsx +0 -23
  151. package/src/tooltip-with-disabled/index.tsx +0 -17
  152. package/src/types.d.ts +0 -24
  153. package/src/upload/index.ts +0 -39
  154. package/src/user-profile/index.tsx +0 -49
  155. package/src/utils/basic.ts +0 -29
  156. package/src/version-list/index.module.less +0 -16
  157. package/src/version-list/version-descriptions.tsx +0 -80
  158. package/src/version-list/version-item.tsx +0 -30
  159. package/src/version-list/version-list.tsx +0 -59
  160. package/src/version-list/version-switch-panel.tsx +0 -31
  161. package/tailwind.config.ts +0 -6
  162. package/tsconfig.build.json +0 -44
  163. package/tsconfig.json +0 -17
  164. package/tsconfig.misc.json +0 -28
  165. package/vitest.config.mts +0 -7
@@ -1,91 +0,0 @@
1
- import React from 'react';
2
- import { IconCozCopy } from '@coze-arch/coze-design/icons';
3
- import { handleCopy } from '../utils/basic';
4
- import { CodeEditor } from '../code-editor';
5
-
6
- import styles from './code-item.module.less';
7
-
8
- export enum SupportedLang {
9
- Golang = 'go',
10
- Js = 'javascript',
11
- Python = 'python',
12
- }
13
-
14
- interface UsageContentProps {
15
- content: string;
16
- copyable?: boolean;
17
- lang?: SupportedLang;
18
- height?: number;
19
- }
20
-
21
- const UsageContent = ({
22
- content,
23
- copyable,
24
- lang = SupportedLang.Js,
25
- height = 300,
26
- }: UsageContentProps) => (
27
- <div className="bg-[var(--semi-color-fill-0)] p-[16px] rounded-[8px] text-[14px] flex">
28
- <div className="flex-1 whitespace-pre-wrap break-all">
29
- <CodeEditor
30
- width={'100%'}
31
- height={height}
32
- language={lang}
33
- value={content}
34
- theme={'code-block-grey'}
35
- options={{
36
- minimap: { enabled: false },
37
- wordWrap: 'on',
38
- scrollBeyondLastLine: false,
39
- unicodeHighlight: { ambiguousCharacters: false },
40
- lineNumbers: 'on',
41
- formatOnPaste: true,
42
- readOnly: true,
43
- }}
44
- beforeMount={monaco => {
45
- monaco.editor.defineTheme('code-block-grey', {
46
- base: 'vs',
47
- inherit: true,
48
- rules: [],
49
- colors: {
50
- 'editor.background': '#F4F4F4', // Set the background color of the editor
51
- },
52
- });
53
- }}
54
- />
55
- </div>
56
- <div className="ml-[8px]">
57
- {copyable ? (
58
- <IconCozCopy
59
- className="ml-[4px] text-[var(--coz-fg-dim)] cursor-pointer hover:coz-fg-primary"
60
- onClick={() => handleCopy(content || '')}
61
- />
62
- ) : null}
63
- </div>
64
- </div>
65
- );
66
-
67
- interface UsageItemProps {
68
- title?: React.ReactNode;
69
- content?: string;
70
- lang?: SupportedLang;
71
- contentHeight?: number;
72
- }
73
-
74
- export const UsageItem = ({
75
- title,
76
- content,
77
- lang,
78
- contentHeight,
79
- }: UsageItemProps) => (
80
- <div className={styles['usage-detail']}>
81
- <div className="text-[#16px] font-[500] mb-4">{title}</div>
82
- {content ? (
83
- <UsageContent
84
- content={content}
85
- copyable={true}
86
- lang={lang}
87
- height={contentHeight}
88
- />
89
- ) : null}
90
- </div>
91
- );
@@ -1,139 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { type ComponentType } from 'react';
3
-
4
- import { createRenderer, option } from '@coze-editor/editor/react';
5
- import preset, { languages, themes } from '@coze-editor/editor/preset-code';
6
- import { shell } from '@coze-editor/editor/language-shell';
7
- import { json } from '@coze-editor/editor/language-json';
8
- import { mixLanguages } from '@coze-editor/editor';
9
- import { EditorView } from '@codemirror/view';
10
-
11
- import { cozeLight } from './themes/coze-light';
12
- import { cozeDark } from './themes/coze-dark';
13
-
14
- // 注册语言
15
- languages.register('json', {
16
- // mixLanguages 用于解决 「插值也使用了括号,导致无法正确高亮」的问题
17
- language: mixLanguages({
18
- outerLanguage: json.language,
19
- }),
20
- languageService: json.languageService,
21
- });
22
-
23
- languages.register('shell', shell);
24
-
25
- // 注册主题
26
- themes.register('coze-light', cozeLight);
27
- themes.register('coze-dark', cozeDark);
28
-
29
- const minHeightOption = (value?: string | number) =>
30
- EditorView.theme({
31
- '.cm-content, .cm-gutter, .cm-right-gutter': {
32
- minHeight:
33
- typeof value === 'number'
34
- ? `${value}px`
35
- : typeof value === 'string'
36
- ? value
37
- : 'unset',
38
- },
39
- '&.cm-editor': {
40
- minHeight:
41
- typeof value === 'number'
42
- ? `${value}px`
43
- : typeof value === 'string'
44
- ? value
45
- : 'unset',
46
- },
47
- });
48
-
49
- const maxHeightOption = (value?: string | number) =>
50
- EditorView.theme({
51
- '&.cm-editor': {
52
- maxHeight:
53
- typeof value === 'number'
54
- ? `${value}px`
55
- : typeof value === 'string'
56
- ? value
57
- : 'unset',
58
- },
59
- });
60
-
61
- const heightOption = (value?: string | number) =>
62
- EditorView.theme({
63
- '&.cm-editor': {
64
- height:
65
- typeof value === 'number'
66
- ? `${value}px`
67
- : typeof value === 'string'
68
- ? value
69
- : 'unset',
70
- },
71
- });
72
-
73
- const paddingOption = (value?: string | number) =>
74
- EditorView.theme({
75
- '&.cm-editor': {
76
- padding:
77
- typeof value === 'number'
78
- ? `${value}px`
79
- : typeof value === 'string'
80
- ? value
81
- : 'unset',
82
- },
83
- });
84
-
85
- const borderRadiusOption = (value?: string | number) =>
86
- EditorView.theme({
87
- '&.cm-editor, .cm-gutters': {
88
- borderRadius:
89
- typeof value === 'number'
90
- ? `${value}px`
91
- : typeof value === 'string'
92
- ? value
93
- : 'unset',
94
- },
95
- });
96
-
97
- const lineHeightOption = (value?: string | number) =>
98
- EditorView.theme({
99
- '.cm-content, .cm-gutter, .cm-right-gutter': {
100
- lineHeight:
101
- typeof value === 'number'
102
- ? `${value}px`
103
- : typeof value === 'string'
104
- ? value
105
- : 'unset',
106
- },
107
- });
108
-
109
- function createStyleOptions() {
110
- return [
111
- option('minHeight', minHeightOption),
112
- option('maxHeight', maxHeightOption),
113
- option('editerHeight', heightOption),
114
- option('borderRadius', borderRadiusOption),
115
- option('padding', paddingOption),
116
- option('lineHeight', lineHeightOption),
117
- ];
118
- }
119
-
120
- const builtinExtensions = [
121
- EditorView.theme({
122
- '&.cm-focused': {
123
- outline: 'none',
124
- },
125
- '& *': {
126
- fontFamily: 'Menlo, Monaco, "Courier New", monospace',
127
- },
128
- }),
129
- EditorView.theme({
130
- '&.cm-content': {
131
- wordBreak: 'break-all',
132
- },
133
- }),
134
- ];
135
-
136
- export const CodeMirrorCodeEditor: ComponentType<any> = createRenderer(
137
- [...preset, ...createStyleOptions()],
138
- builtinExtensions,
139
- );
@@ -1,4 +0,0 @@
1
- export { CodeMirrorCodeEditor } from './code-editor';
2
- export { CodeMirrorTextEditor } from './text-editor';
3
- export { CodeMirrorJsonEditor } from './json-editor';
4
- export { CodeMirrorRawTextEditor } from './raw-text-editor';
@@ -1,183 +0,0 @@
1
- /* eslint-disable security/detect-non-literal-regexp */
2
- import React, {
3
- useCallback,
4
- useEffect,
5
- useRef,
6
- useImperativeHandle,
7
- } from 'react';
8
-
9
- import { EditorProvider } from '@coze-editor/editor/react';
10
- import {
11
- type EditorAPI,
12
- transformerCreator,
13
- } from '@coze-editor/editor/preset-code';
14
- import { json } from '@coze-editor/editor/language-json';
15
- import { EditorView } from '@codemirror/view';
16
-
17
- import { CodeMirrorCodeEditor } from './code-editor';
18
-
19
- interface BaseJsonEditorProps {
20
- value: string;
21
- onChange?: (value: string) => void;
22
- className?: string;
23
- dataTestID?: string;
24
- placeholder?: string | HTMLElement;
25
- isDarkTheme?: boolean;
26
- readonly?: boolean;
27
- minHeight?: string | number;
28
- maxHeight?: string | number;
29
- editerHeight?: string | number;
30
- padding?: string | number;
31
- borderRadius?: string | number;
32
- onFocus?: () => void;
33
- onBlur?: () => void;
34
- }
35
-
36
- interface Match {
37
- match: string;
38
- range: [number, number];
39
- }
40
-
41
- const extensions = [
42
- EditorView.theme({
43
- '.cm-activeLineGutter': {
44
- backgroundColor: 'transparent !important',
45
- },
46
- '.cm-activeLine': {
47
- backgroundColor: 'transparent !important',
48
- },
49
- }),
50
- ];
51
-
52
- function findAllMatches(inputString: string, regex: RegExp): Match[] {
53
- const globalRegex = new RegExp(
54
- regex,
55
- regex.flags.includes('g') ? regex.flags : `${regex.flags}g`,
56
- );
57
- let match;
58
- const matches: Match[] = [];
59
-
60
- while (true) {
61
- match = globalRegex.exec(inputString);
62
- if (!match) {
63
- break;
64
- }
65
-
66
- if (match.index === globalRegex.lastIndex) {
67
- globalRegex.lastIndex++;
68
- }
69
- matches.push({
70
- match: match[0],
71
- range: [match.index, match.index + match[0].length],
72
- });
73
- }
74
-
75
- return matches;
76
- }
77
-
78
- const transformer = transformerCreator(text => {
79
- const originalSource = text.toString();
80
- const matches = findAllMatches(originalSource, /\{\{([^\}]*)\}\}/g);
81
-
82
- if (matches.length > 0) {
83
- matches.forEach(({ range }) => {
84
- text.replaceRange(range[0], range[1], 'null');
85
- });
86
- }
87
-
88
- return text;
89
- });
90
-
91
- export const CodeMirrorJsonEditor = React.forwardRef(
92
- (props: BaseJsonEditorProps, ref) => {
93
- const {
94
- value,
95
- onChange,
96
- placeholder,
97
- className,
98
- isDarkTheme,
99
- readonly,
100
- minHeight = '100px',
101
- maxHeight,
102
- editerHeight,
103
- padding,
104
- borderRadius,
105
- onFocus,
106
- onBlur,
107
- } = props;
108
-
109
- const apiRef = useRef<EditorAPI | null>(null);
110
-
111
- const handleChange = useCallback(
112
- (e: { value: string }) => {
113
- if (typeof onChange === 'function') {
114
- onChange(e.value);
115
- }
116
- },
117
- [onChange],
118
- );
119
-
120
- useEffect(() => {
121
- apiRef.current?.updateASTDecorations();
122
- }, [isDarkTheme]);
123
-
124
- // 值受控;
125
- useEffect(() => {
126
- const editor = apiRef.current;
127
-
128
- if (!editor) {
129
- return;
130
- }
131
-
132
- if (typeof value === 'string' && value !== editor.getValue()) {
133
- editor.setValue(value);
134
- }
135
- }, [value]);
136
-
137
- const formatJson = async () => {
138
- const view = apiRef.current?.$view;
139
- if (!view) {
140
- return;
141
- }
142
- view.dispatch(
143
- await json.languageService.format(view.state, {
144
- tabSize: 2,
145
- }),
146
- );
147
- };
148
-
149
- useImperativeHandle(ref, () => ({
150
- formatJson,
151
- }));
152
-
153
- return (
154
- <EditorProvider>
155
- <div className={className}>
156
- <CodeMirrorCodeEditor
157
- defaultValue={value ?? ''}
158
- onChange={handleChange}
159
- options={{
160
- placeholder,
161
- lineWrapping: true,
162
- theme: isDarkTheme ? 'coze-dark' : 'coze-light',
163
- languageId: 'json',
164
- editable: !readonly,
165
- transformer,
166
- minHeight,
167
- maxHeight,
168
- editerHeight,
169
- borderRadius,
170
- padding,
171
- fontSize: 13,
172
- lineHeight: 20,
173
- }}
174
- didMount={api => (apiRef.current = api)}
175
- extensions={extensions}
176
- onFocus={onFocus}
177
- onBlur={onBlur}
178
- />
179
- </div>
180
- </EditorProvider>
181
- );
182
- },
183
- );
@@ -1,68 +0,0 @@
1
- import { forwardRef, useCallback, useEffect, useRef } from 'react';
2
-
3
- import { EditorProvider } from '@coze-editor/editor/react';
4
- import { type EditorAPI } from '@coze-editor/editor/preset-universal';
5
-
6
- import { CodeMirrorTextEditor } from './text-editor';
7
-
8
- interface CodeMirrorRawTextEditorProps {
9
- value: string;
10
- onChange?: (value?: string) => void;
11
- className?: string;
12
- readonly?: boolean;
13
- dataTestID?: string;
14
- placeholder?: string | HTMLElement;
15
- minHeight?: string | number;
16
- }
17
-
18
- export const CodeMirrorRawTextEditor = forwardRef<
19
- HTMLDivElement,
20
- CodeMirrorRawTextEditorProps
21
- >((props, ref) => {
22
- const { value, onChange, placeholder, className, minHeight, readonly } =
23
- props;
24
-
25
- const apiRef = useRef<EditorAPI | null>(null);
26
-
27
- const handleChange = useCallback(
28
- (e: { value: string }) => {
29
- if (typeof onChange === 'function') {
30
- onChange(e.value);
31
- }
32
- },
33
- [onChange],
34
- );
35
-
36
- // 值受控;
37
- useEffect(() => {
38
- const editor = apiRef.current;
39
-
40
- if (!editor) {
41
- return;
42
- }
43
-
44
- if (typeof value === 'string' && value !== editor.getValue()) {
45
- editor.setValue(value);
46
- }
47
- }, [value]);
48
-
49
- return (
50
- <EditorProvider>
51
- <div ref={ref} className={className}>
52
- <CodeMirrorTextEditor
53
- defaultValue={value ?? ''}
54
- onChange={handleChange}
55
- options={{
56
- placeholder,
57
- lineWrapping: true,
58
- minHeight,
59
- fontSize: 13,
60
- editable: !readonly,
61
- lineHeight: 20,
62
- }}
63
- didMount={api => (apiRef.current = api)}
64
- />
65
- </div>
66
- </EditorProvider>
67
- );
68
- });
@@ -1,58 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { type ComponentType } from 'react';
3
-
4
- import { createRenderer, option } from '@coze-editor/editor/react';
5
- import universal from '@coze-editor/editor/preset-universal';
6
- import { mixLanguages } from '@coze-editor/editor';
7
- import { keymap, EditorView } from '@codemirror/view';
8
- import { defaultKeymap, history, historyKeymap } from '@codemirror/commands';
9
-
10
- const RawEditorTheme = EditorView.theme({
11
- '&.cm-editor': {
12
- outline: 'none',
13
- },
14
- '&.cm-content': {
15
- wordBreak: 'break-all',
16
- },
17
- });
18
-
19
- const minHeightOption = (value?: string | number) =>
20
- EditorView.theme({
21
- '.cm-content, .cm-gutter, .cm-right-gutter': {
22
- minHeight:
23
- typeof value === 'number'
24
- ? `${value}px`
25
- : typeof value === 'string'
26
- ? value
27
- : 'unset',
28
- },
29
- });
30
-
31
- const lineHeightOption = (value?: string | number) =>
32
- EditorView.theme({
33
- '.cm-content, .cm-gutter, .cm-right-gutter': {
34
- lineHeight:
35
- typeof value === 'number'
36
- ? `${value}px`
37
- : typeof value === 'string'
38
- ? value
39
- : 'unset',
40
- },
41
- });
42
-
43
- const extensions = [
44
- mixLanguages({}),
45
- RawEditorTheme,
46
- // ...其他 extensions
47
- history(),
48
- keymap.of([...defaultKeymap, ...historyKeymap]),
49
- ];
50
-
51
- export const CodeMirrorTextEditor: ComponentType<any> = createRenderer(
52
- [
53
- ...universal,
54
- option('minHeight', minHeightOption),
55
- option('lineHeight', lineHeightOption),
56
- ],
57
- extensions,
58
- );
@@ -1,116 +0,0 @@
1
- import { createTheme, tags as t } from '@coze-editor/editor/preset-code';
2
- import { EditorView } from '@codemirror/view';
3
-
4
- const colors = {
5
- background: '#151B27',
6
- // syntax
7
- comment: '#FFFFFF63',
8
- key: '#39E5D7',
9
- string: '#FF94D2',
10
- number: '#FF9933',
11
- boolean: '#78B0FF',
12
- null: '#78B0FF',
13
- separator: '#FFFFFFC9',
14
- };
15
-
16
- export const cozeDark = [
17
- EditorView.theme({
18
- '.cm-completionIcon-property': {
19
- backgroundImage:
20
- 'url("' +
21
- 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMWVtIiBoZWlnaHQ9IjFlbSIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xMi4zNTc2IDguMTAzNTVDMTIuMTYyMyA3LjkwODI5IDExLjg0NTcgNy45MDgyOSAxMS42NTA1IDguMTAzNTVMOC4xMDM1NSAxMS42NTA1QzcuOTA4MjkgMTEuODQ1NyA3LjkwODI5IDEyLjE2MjMgOC4xMDM1NSAxMi4zNTc2TDExLjY1MDUgMTUuOTA0NUMxMS44NDU3IDE2LjA5OTggMTIuMTYyMyAxNi4wOTk4IDEyLjM1NzYgMTUuOTA0NUwxNS45MDQ1IDEyLjM1NzZDMTYuMDk5OCAxMi4xNjIzIDE2LjA5OTggMTEuODQ1NyAxNS45MDQ1IDExLjY1MDVMMTIuMzU3NiA4LjEwMzU1WiIgZmlsbD0iI0ZGRkZGRkM5Ii8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0xMS4wMDI2IDEuNDU1NDVDMTEuNjIxNCAxLjA5ODE4IDEyLjM4MzggMS4wOTgxOCAxMy4wMDI2IDEuNDU1NDVMMjAuNjM4IDUuODYzNzRDMjEuMjU2OCA2LjIyMSAyMS42MzggNi44ODEyNiAyMS42MzggNy41OTU3OVYxNi40MTI0QzIxLjYzOCAxNy4xMjY5IDIxLjI1NjggMTcuNzg3MiAyMC42MzggMTguMTQ0NEwxMy4wMDI2IDIyLjU1MjdDMTIuMzgzOCAyMi45MSAxMS42MjE0IDIyLjkxIDExLjAwMjYgMjIuNTUyN0wzLjM2NzE5IDE4LjE0NDRDMi43NDgzOSAxNy43ODcyIDIuMzY3MTkgMTcuMTI2OSAyLjM2NzE5IDE2LjQxMjRWNy41OTU3OUMyLjM2NzE5IDYuODgxMjYgMi43NDgzOSA2LjIyMTAxIDMuMzY3MTkgNS44NjM3NEwxMS4wMDI2IDEuNDU1NDVaTTEyLjAwMjYgMy4xODc1TDE5LjYzOCA3LjU5NTc5VjE2LjQxMjRMMTIuMDAyNiAyMC44MjA3TDQuMzY3MTkgMTYuNDEyNEw0LjM2NzE5IDcuNTk1NzlMMTIuMDAyNiAzLjE4NzVaIiBmaWxsPSIjRkZGRkZGQzkiLz48L3N2Zz4=' +
22
- '")',
23
- backgroundSize: '11px 11px',
24
- backgroundRepeat: 'no-repeat',
25
- width: '11px',
26
- height: '11px',
27
- },
28
- '.cm-completionIcon-property::after': {
29
- content: '""',
30
- },
31
- }),
32
- createTheme({
33
- variant: 'dark',
34
- settings: {
35
- background: colors.background,
36
- foreground: '#fff',
37
- caret: '#AEAFAD',
38
- selection: '#d9d9d942',
39
- gutterBackground: colors.background,
40
- gutterForeground: '#FFFFFF63',
41
- gutterBorderColor: 'transparent',
42
- gutterBorderWidth: 0,
43
- lineHighlight: '#272e3d36',
44
- bracketColors: ['#FFEF61', '#DD99FF', '#78B0FF'],
45
- tooltip: {
46
- backgroundColor: '#363D4D',
47
- color: '#fff',
48
- border: 'none',
49
- },
50
- completionItemHover: {
51
- backgroundColor: '#FFFFFF0F',
52
- },
53
- completionItemSelected: {
54
- backgroundColor: '#FFFFFF17',
55
- },
56
- completionItemIcon: {
57
- color: '#FFFFFFC9',
58
- },
59
- completionItemLabel: {
60
- color: '#FFFFFFC9',
61
- },
62
- completionItemDetail: {
63
- color: '#FFFFFF63',
64
- },
65
- },
66
- styles: [
67
- // json
68
- {
69
- tag: t.comment,
70
- color: colors.comment,
71
- },
72
- {
73
- tag: [t.propertyName],
74
- color: colors.key,
75
- },
76
- {
77
- tag: [t.string],
78
- color: colors.string,
79
- },
80
- {
81
- tag: [t.number],
82
- color: colors.number,
83
- },
84
- {
85
- tag: [t.bool],
86
- color: colors.boolean,
87
- },
88
- {
89
- tag: [t.null],
90
- color: colors.null,
91
- },
92
- {
93
- tag: [t.separator],
94
- color: colors.separator,
95
- },
96
-
97
- // shell
98
- // curl
99
- {
100
- tag: [t.standard(t.variableName)],
101
- color: '#3BEB84',
102
- },
103
- // -X
104
- {
105
- tag: [t.attributeName],
106
- color: '#FF9933',
107
- },
108
- // cp-disable-next-line
109
- // url in string (includes quotes), e.g. "https://..."
110
- {
111
- tag: [t.special(t.string)],
112
- color: '#78B0FF',
113
- },
114
- ],
115
- }),
116
- ];