onchain-lexical-ui 0.0.2 → 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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "onchain-lexical-ui",
3
3
  "license": "MIT",
4
- "version": "0.0.2",
4
+ "version": "0.0.4",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
7
7
  "@ant-design/icons": "^6.0.0",
@@ -10,7 +10,7 @@
10
10
  "@lexical/utils": "^0.30.0",
11
11
  "katex": "^0.16.22",
12
12
  "lexical": "0.30.0",
13
- "onchain-lexical-context": "^0.0.2",
13
+ "onchain-lexical-context": "^0.0.4",
14
14
  "react-draggable": "^4.5.0"
15
15
  },
16
16
  "browser": {
@@ -1,3 +1,19 @@
1
+ .arrow {
2
+ position: relative;
3
+ &::before {
4
+ content: '';
5
+ display: block;
6
+ width: 8px;
7
+ height: 8px;
8
+ position: absolute;
9
+ top: -2px;
10
+ left: 4px;
11
+ background-color: #fff;
12
+ z-index: -1;
13
+ transform: rotate(45deg);
14
+ }
15
+ }
16
+
1
17
  .dropdown {
2
18
  z-index: 100;
3
19
  display: block;
@@ -7,13 +23,13 @@
7
23
  0 2px 4px 0 rgba(0, 0, 0, 0.1),
8
24
  inset 0 0 0 1px rgba(255, 255, 255, 0.5);
9
25
  // border-radius: 8px;
10
- min-height: 40px;
26
+ // min-height: 40px;
11
27
  background-color: #fff;
12
28
  z-index: 1000;
13
29
  :global {
14
30
  .item {
15
- margin: 0 8px 0 8px;
16
- padding: 8px;
31
+ margin: 0 6px 0 6px;
32
+ padding: 6px;
17
33
  color: #050505;
18
34
  cursor: pointer;
19
35
  line-height: 16px;
@@ -25,15 +41,16 @@
25
41
  justify-content: space-between;
26
42
  background-color: #fff;
27
43
  // border-radius: 8px;
44
+ font-size: 14px;
28
45
  border: 0;
29
46
  max-width: 250px;
30
47
  min-width: 100px;
31
48
  &:first-child {
32
- margin-top: 8px;
49
+ margin-top: 6px;
33
50
  }
34
51
 
35
52
  &:last-child {
36
- margin-bottom: 8px;
53
+ margin-bottom: 6px;
37
54
  }
38
55
 
39
56
  &:hover {
@@ -74,8 +91,8 @@
74
91
 
75
92
  .icon {
76
93
  display: flex;
77
- width: 20px;
78
- height: 20px;
94
+ width: 18px;
95
+ height: 18px;
79
96
  user-select: none;
80
97
  margin-right: 12px;
81
98
  line-height: 16px;
package/src/DropDown.tsx CHANGED
@@ -73,12 +73,16 @@ export function DropDownItem({
73
73
  function DropDownItems({
74
74
  children,
75
75
  dropDownRef,
76
+ arrow = false,
76
77
  zIndex = 100,
78
+ arrowX,
77
79
  onClose,
78
80
  }: {
79
81
  children: React.ReactNode;
80
82
  dropDownRef: React.Ref<HTMLDivElement>;
81
83
  zIndex?: number;
84
+ arrow?: boolean;
85
+ arrowX?: number;
82
86
  onClose: () => void;
83
87
  }) {
84
88
  const [items, setItems] = useState<React.RefObject<HTMLButtonElement>[]>();
@@ -143,9 +147,9 @@ function DropDownItems({
143
147
  return (
144
148
  <DropDownContext.Provider value={contextValue}>
145
149
  <div
146
- className={`${Styles.dropdown}`}
150
+ className={`${Styles.dropdown} ${arrow ? Styles.arrow : ''}`}
147
151
  ref={dropDownRef}
148
- style={{zIndex}}
152
+ style={{left: arrowX, zIndex}}
149
153
  onKeyDown={handleKeyDown}>
150
154
  {children}
151
155
  </div>
@@ -156,12 +160,15 @@ function DropDownItems({
156
160
  export default function DropDown({
157
161
  disabled = false,
158
162
  showIcon = true,
163
+ arrow = false,
164
+ arrowX,
159
165
  buttonLabel,
160
166
  buttonAriaLabel,
161
167
  buttonClassName,
162
168
  buttonIconClassName,
163
169
  children,
164
170
  stopCloseOnClickSelf,
171
+ onOpen,
165
172
  }: {
166
173
  disabled?: boolean;
167
174
  buttonAriaLabel?: string;
@@ -171,6 +178,9 @@ export default function DropDown({
171
178
  showIcon?: boolean;
172
179
  children: ReactNode;
173
180
  stopCloseOnClickSelf?: boolean;
181
+ arrow?: boolean;
182
+ arrowX?: number;
183
+ onOpen?: (value: boolean) => void;
174
184
  }): JSX.Element {
175
185
  const dropDownRef = useRef<HTMLDivElement>(null);
176
186
  const buttonRef = useRef<HTMLButtonElement>(null);
@@ -259,6 +269,26 @@ export default function DropDown({
259
269
  };
260
270
  }, [buttonRef, dropDownRef, showDropDown]);
261
271
 
272
+ useEffect(() => {
273
+ const wheel = (e: WheelEvent) => {
274
+ if (e.target instanceof HTMLElement) {
275
+ if (!e.target.closest(`.${Styles.dropdown}`)) {
276
+ setShowDropDown(false);
277
+ }
278
+ }
279
+ };
280
+ window.addEventListener('wheel', wheel);
281
+ return () => {
282
+ window.removeEventListener('wheel', wheel);
283
+ };
284
+ }, []);
285
+
286
+ useEffect(() => {
287
+ if (onOpen) {
288
+ onOpen(showDropDown);
289
+ }
290
+ }, [showDropDown]);
291
+
262
292
  return (
263
293
  <>
264
294
  <button
@@ -280,6 +310,8 @@ export default function DropDown({
280
310
  <DropDownItems
281
311
  dropDownRef={dropDownRef}
282
312
  zIndex={zIndex}
313
+ arrow={arrow}
314
+ arrowX={arrowX}
283
315
  onClose={handleClose}>
284
316
  {children}
285
317
  </DropDownItems>,
@@ -1,3 +1,5 @@
1
+ @import './const.less';
2
+
1
3
  .editor-shell {
2
4
  width: 100%;
3
5
  // border-radius: 2px;
@@ -61,361 +63,360 @@ div.editor-shell {
61
63
  line-height: 1.7;
62
64
  }
63
65
  :global {
66
+ i.add-comment {
67
+ background-size: cover !important;
68
+ background-image: url(/richText/chat-left-text.svg);
69
+ }
70
+
64
71
  i.palette {
65
- background-image: url(../images/icons/palette.svg);
72
+ background-image: url(/richText/palette.svg);
66
73
  }
67
74
 
68
75
  i.bucket {
69
- background-image: url(../images/icons/paint-bucket.svg);
76
+ background-image: url(/richText/paint-bucket.svg);
70
77
  }
71
78
 
72
79
  i.bold {
73
- background-image: url(../images/icons/type-bold.svg);
80
+ background-image: url(/richText/type-bold.svg);
74
81
  }
75
82
 
76
83
  i.italic {
77
- background-image: url(../images/icons/type-italic.svg);
84
+ background-image: url(/richText/type-italic.svg);
78
85
  }
79
86
 
80
87
  i.clear {
81
- background-image: url(../images/icons/trash.svg);
88
+ background-image: url(/richText/trash.svg);
82
89
  }
83
90
 
84
91
  i.code {
85
- background-image: url(../images/icons/code.svg);
92
+ background-image: url(/richText/code.svg);
86
93
  }
87
94
 
88
95
  i.underline {
89
- background-image: url(../images/icons/type-underline.svg);
96
+ background-image: url(/richText/type-underline.svg);
90
97
  }
91
98
 
92
99
  i.uppercase {
93
- background-image: url(../images/icons/type-uppercase.svg);
100
+ background-image: url(/richText/type-uppercase.svg);
94
101
  }
95
102
 
96
103
  i.lowercase {
97
- background-image: url(../images/icons/type-lowercase.svg);
104
+ background-image: url(/richText/type-lowercase.svg);
98
105
  }
99
106
 
100
107
  i.capitalize {
101
- background-image: url(../images/icons/type-capitalize.svg);
108
+ background-image: url(/richText/type-capitalize.svg);
102
109
  }
103
110
 
104
111
  i.strikethrough {
105
- background-image: url(../images/icons/type-strikethrough.svg);
112
+ background-image: url(/richText/type-strikethrough.svg);
106
113
  }
107
114
 
108
115
  i.subscript {
109
- background-image: url(../images/icons/type-subscript.svg);
116
+ background-image: url(/richText/type-subscript.svg);
110
117
  }
111
118
 
112
119
  i.superscript {
113
- background-image: url(../images/icons/type-superscript.svg);
120
+ background-image: url(/richText/type-superscript.svg);
114
121
  }
115
122
 
116
123
  i.highlight {
117
- background-image: url(../images/icons/highlighter.svg);
124
+ background-image: url(/richText/highlighter.svg);
118
125
  }
119
126
 
120
127
  i.link {
121
- background-image: url(../images/icons/link.svg);
128
+ background-image: url(/richText/link.svg);
122
129
  }
123
130
 
124
131
  i.horizontal-rule {
125
- background-image: url(../images/icons/horizontal-rule.svg);
132
+ background-image: url(/richText/horizontal-rule.svg);
126
133
  }
127
134
 
128
135
  .icon.plus {
129
- background-image: url(../images/icons/plus.svg);
136
+ background-image: url(/richText/plus.svg);
130
137
  }
131
138
 
132
139
  .icon.caret-right {
133
- background-image: url(../images/icons/caret-right-fill.svg);
140
+ background-image: url(/richText/caret-right-fill.svg);
134
141
  }
135
142
 
136
143
  .icon.dropdown-more {
137
- background-image: url(../images/icons/dropdown-more.svg);
144
+ background-image: url(/richText/dropdown-more.svg);
138
145
  }
139
146
 
140
147
  .icon.font-color {
141
- background-image: url(../images/icons/font-color.svg);
142
- }
143
-
144
- .icon.font-family {
145
- background-image: url(../images/icons/font-family.svg);
148
+ background-image: url(/richText/font-color.svg);
149
+ mask-repeat: no-repeat;
150
+ -webkit-mask-repeat: no-repeat;
151
+ mask-size: contain;
152
+ -webkit-mask-size: contain;
146
153
  }
147
154
 
148
155
  .icon.bg-color {
149
- background-image: url(../images/icons/bg-color.svg);
156
+ background-image: url(/richText/bg-color.svg);
150
157
  }
151
158
 
152
- .icon.table {
153
- background-color: #6c757d;
154
- mask-image: url(../images/icons/table.svg);
155
- -webkit-mask-image: url(../images/icons/table.svg);
156
- mask-repeat: no-repeat;
157
- -webkit-mask-repeat: no-repeat;
158
- mask-size: contain;
159
- -webkit-mask-size: contain;
159
+ .icon.font-family {
160
+ background-image: url(/richText/font-family.svg);
160
161
  }
161
162
 
162
163
  i.image {
163
- background-image: url(../images/icons/file-image.svg);
164
+ background-image: url(/richText/file-image.svg);
164
165
  }
165
166
 
166
167
  i.table {
167
- background-image: url(../images/icons/table.svg);
168
+ background-image: url(/richText/table.svg);
168
169
  }
169
170
 
170
171
  i.close {
171
- background-image: url(../images/icons/close.svg);
172
+ background-image: url(/richText/close.svg);
172
173
  }
173
174
 
174
175
  i.figma {
175
- background-image: url(../images/icons/figma.svg);
176
+ background-image: url(/richText/figma.svg);
176
177
  }
177
178
 
178
179
  i.poll {
179
- background-image: url(../images/icons/card-checklist.svg);
180
+ background-image: url(/richText/card-checklist.svg);
180
181
  }
181
182
 
182
183
  i.columns {
183
- background-image: url(../images/icons/3-columns.svg);
184
+ background-image: url(/richText/3-columns.svg);
184
185
  }
185
186
 
186
187
  i.x {
187
- background-image: url(../images/icons/x.svg);
188
+ background-image: url(/richText/x.svg);
188
189
  }
189
190
 
190
191
  i.youtube {
191
- background-image: url(../images/icons/youtube.svg);
192
+ background-image: url(/richText/youtube.svg);
192
193
  }
193
194
 
194
195
  .icon.left-align,
195
196
  i.left-align {
196
- background-image: url(../images/icons/text-left.svg);
197
+ background-image: url(/richText/text-left.svg);
197
198
  }
198
199
 
199
200
  .icon.center-align,
200
201
  i.center-align {
201
- background-image: url(../images/icons/text-center.svg);
202
+ background-image: url(/richText/text-center.svg);
202
203
  }
203
204
 
204
205
  .icon.right-align,
205
206
  i.right-align {
206
- background-image: url(../images/icons/text-right.svg);
207
+ background-image: url(/richText/text-right.svg);
207
208
  }
208
209
 
209
210
  .icon.justify-align,
210
211
  i.justify-align {
211
- background-image: url(../images/icons/justify.svg);
212
+ background-image: url(/richText/justify.svg);
212
213
  }
213
214
 
214
215
  .icon.vertical-top,
215
216
  i.left-align {
216
- background-image: url(../images/icons/vertical-top.svg);
217
+ background-image: url(/richText/vertical-top.svg);
217
218
  }
218
219
 
219
220
  .icon.vertical-middle,
220
221
  i.center-align {
221
- background-image: url(../images/icons/vertical-middle.svg);
222
+ background-image: url(/richText/vertical-middle.svg);
222
223
  }
223
224
 
224
225
  .icon.vertical-bottom,
225
226
  i.right-align {
226
- background-image: url(../images/icons/vertical-bottom.svg);
227
+ background-image: url(/richText/vertical-bottom.svg);
227
228
  }
228
229
 
229
230
  i.indent {
230
- background-image: url(../images/icons/indent.svg);
231
+ background-image: url(/richText/indent.svg);
231
232
  }
232
233
 
233
234
  i.markdown {
234
- background-image: url(../images/icons/markdown.svg);
235
+ background-image: url(/richText/markdown.svg);
235
236
  }
236
237
 
237
238
  i.outdent {
238
- background-image: url(../images/icons/outdent.svg);
239
+ background-image: url(/richText/outdent.svg);
239
240
  }
240
241
 
241
242
  i.undo {
242
- background-image: url(../images/icons/arrow-counterclockwise.svg);
243
+ background-image: url(/richText/arrow-counterclockwise.svg);
243
244
  }
244
245
 
245
246
  i.redo {
246
- background-image: url(../images/icons/arrow-clockwise.svg);
247
+ background-image: url(/richText/arrow-clockwise.svg);
247
248
  }
248
249
 
249
250
  i.sticky {
250
- background-image: url(../images/icons/sticky.svg);
251
+ background-image: url(/richText/sticky.svg);
251
252
  }
252
253
 
253
254
  i.mic {
254
- background-image: url(../images/icons/mic.svg);
255
+ background-image: url(/richText/mic.svg);
255
256
  }
256
257
 
257
258
  i.import {
258
- background-image: url(../images/icons/upload.svg);
259
+ background-image: url(/richText/upload.svg);
259
260
  }
260
261
 
261
262
  i.export {
262
- background-image: url(../images/icons/download.svg);
263
+ background-image: url(/richText/download.svg);
263
264
  }
264
265
 
265
266
  i.share {
266
- background-image: url(../images/icons/send.svg);
267
+ background-image: url(/richText/send.svg);
267
268
  }
268
269
 
269
270
  i.diagram-2 {
270
- background-image: url(../images/icons/diagram-2.svg);
271
+ background-image: url(/richText/diagram-2.svg);
271
272
  }
272
273
 
273
274
  i.user {
274
- background-image: url(../images/icons/user.svg);
275
+ background-image: url(/richText/user.svg);
275
276
  }
276
277
 
277
278
  i.equation {
278
- background-image: url(../images/icons/plus-slash-minus.svg);
279
+ background-image: url(/richText/plus-slash-minus.svg);
279
280
  }
280
281
 
281
282
  i.gif {
282
- background-image: url(../images/icons/filetype-gif.svg);
283
+ background-image: url(/richText/filetype-gif.svg);
283
284
  }
284
285
 
285
286
  i.copy {
286
- background-image: url(../images/icons/copy.svg);
287
+ background-image: url(/richText/copy.svg);
287
288
  }
288
289
 
289
290
  i.success {
290
- background-image: url(../images/icons/success.svg);
291
+ background-image: url(/richText/success.svg);
291
292
  }
292
293
 
293
294
  i.prettier {
294
- background-image: url(../images/icons/prettier.svg);
295
+ background-image: url(/richText/prettier.svg);
295
296
  }
296
297
 
297
298
  i.prettier-error {
298
- background-image: url(../images/icons/prettier-error.svg);
299
+ background-image: url(/richText/prettier-error.svg);
299
300
  }
300
301
 
301
302
  i.page-break,
302
303
  .icon.page-break {
303
- background-image: url(../images/icons/scissors.svg);
304
+ background-image: url(/richText/scissors.svg);
304
305
  }
305
306
 
306
307
  .actions i.indent {
307
- background-image: url(../images/icons/indent.svg);
308
+ background-image: url(/richText/indent.svg);
308
309
  }
309
310
 
310
311
  .actions i.outdent {
311
- background-image: url(../images/icons/outdent.svg);
312
+ background-image: url(/richText/outdent.svg);
312
313
  }
313
314
 
314
315
  .actions i.lock {
315
- background-image: url(../images/icons/lock-fill.svg);
316
+ background-image: url(/richText/lock-fill.svg);
316
317
  }
317
318
 
318
319
  .actions i.image {
319
- background-image: url(../images/icons/file-image.svg);
320
+ background-image: url(/richText/file-image.svg);
320
321
  }
321
322
 
322
323
  .actions i.table {
323
- background-image: url(../images/icons/table.svg);
324
+ background-image: url(/richText/table.svg);
324
325
  }
325
326
 
326
327
  .actions i.unlock {
327
- background-image: url(../images/icons/lock.svg);
328
+ background-image: url(/richText/lock.svg);
328
329
  }
329
330
 
330
331
  .actions i.left-align {
331
- background-image: url(../images/icons/text-left.svg);
332
+ background-image: url(/richText/text-left.svg);
332
333
  }
333
334
 
334
335
  .actions i.center-align {
335
- background-image: url(../images/icons/text-center.svg);
336
+ background-image: url(/richText/text-center.svg);
336
337
  }
337
338
 
338
339
  .actions i.right-align {
339
- background-image: url(../images/icons/text-right.svg);
340
+ background-image: url(/richText/text-right.svg);
340
341
  }
341
342
 
342
343
  .actions i.justify-align {
343
- background-image: url(../images/icons/justify.svg);
344
+ background-image: url(/richText/justify.svg);
344
345
  }
345
346
 
346
347
  .actions i.disconnect {
347
- background-image: url(../images/icons/plug.svg);
348
+ background-image: url(/richText/plug.svg);
348
349
  }
349
350
 
350
351
  .actions i.connect {
351
- background-image: url(../images/icons/plug-fill.svg);
352
+ background-image: url(/richText/plug-fill.svg);
352
353
  }
353
354
  .link-editor div.link-edit {
354
- background-image: url(../images/icons/pencil-fill.svg);
355
+ background-image: url(/richText/pencil-fill.svg);
355
356
  }
356
357
 
357
358
  .link-editor div.link-trash {
358
- background-image: url(../images/icons/trash.svg);
359
+ background-image: url(/richText/trash.svg);
359
360
  }
360
361
 
361
362
  .link-editor div.link-cancel {
362
- background-image: url(../images/icons/close.svg);
363
+ background-image: url(/richText/close.svg);
363
364
  }
364
365
 
365
366
  .link-editor div.link-confirm {
366
- background-image: url(../images/icons/success-alt.svg);
367
+ background-image: url(/richText/success-alt.svg);
367
368
  }
368
369
  i.chevron-down {
369
- background-image: url(../images/icons/chevron-down.svg);
370
+ background-image: url(/richText/chevron-down.svg);
370
371
  }
371
372
  .icon.paragraph {
372
- background-image: url(../images/icons/text-paragraph.svg);
373
+ background-image: url(/richText/text-paragraph.svg);
373
374
  }
374
375
 
375
376
  .icon.h1 {
376
- background-image: url(../images/icons/type-h1.svg);
377
+ background-image: url(/richText/type-h1.svg);
377
378
  }
378
379
 
379
380
  .icon.h2 {
380
- background-image: url(../images/icons/type-h2.svg);
381
+ background-image: url(/richText/type-h2.svg);
381
382
  }
382
383
 
383
384
  .icon.h3 {
384
- background-image: url(../images/icons/type-h3.svg);
385
+ background-image: url(/richText/type-h3.svg);
385
386
  }
386
387
 
387
388
  .icon.h4 {
388
- background-image: url(../images/icons/type-h4.svg);
389
+ background-image: url(/richText/type-h4.svg);
389
390
  }
390
391
 
391
392
  .icon.h5 {
392
- background-image: url(../images/icons/type-h5.svg);
393
+ background-image: url(/richText/type-h5.svg);
393
394
  }
394
395
 
395
396
  .icon.h6 {
396
- background-image: url(../images/icons/type-h6.svg);
397
+ background-image: url(/richText/type-h6.svg);
397
398
  }
398
399
 
399
400
  .icon.bullet-list,
400
401
  .icon.bullet {
401
- background-image: url(../images/icons/list-ul.svg);
402
+ background-image: url(/richText/list-ul.svg);
402
403
  }
403
404
 
404
405
  .icon.check-list,
405
406
  .icon.check {
406
- background-image: url(../images/icons/square-check.svg);
407
+ background-image: url(/richText/square-check.svg);
407
408
  }
408
409
 
409
410
  .icon.numbered-list,
410
411
  .icon.number {
411
- background-image: url(../images/icons/list-ol.svg);
412
+ background-image: url(/richText/list-ol.svg);
412
413
  }
413
414
 
414
415
  .icon.quote {
415
- background-image: url(../images/icons/chat-square-quote.svg);
416
+ background-image: url(/richText/chat-square-quote.svg);
416
417
  }
417
418
 
418
419
  .icon.code {
419
- background-image: url(../images/icons/code.svg);
420
+ background-image: url(/richText/code.svg);
420
421
  }
421
422
  }
@@ -9,7 +9,7 @@ import type {IconFontProps} from '@ant-design/icons/lib/components/IconFont';
9
9
 
10
10
  import {createFromIconfontCN} from '@ant-design/icons';
11
11
  import {useSettings} from 'onchain-lexical-context/settings';
12
- import React from 'react';
12
+ import React, {useMemo} from 'react';
13
13
 
14
14
  import Styles from './index.module.less';
15
15
 
@@ -26,11 +26,36 @@ export const Icon: React.FC<IconFontProps<string>> = ({
26
26
  }) => {
27
27
  const {extra} = useSettings();
28
28
  const AliIconFont = AliIconFontFn(extra.iconScriptUrl);
29
- return (
30
- <AliIconFont
31
- {...props}
32
- className={`${Styles.icon} ${className}`}
33
- type={type}
34
- />
35
- );
29
+ const staticIcon = useMemo(() => {
30
+ return (
31
+ <AliIconFont
32
+ {...props}
33
+ className={`${Styles.icon} ${className}`}
34
+ type={type}
35
+ />
36
+ );
37
+ }, []);
38
+
39
+ return staticIcon;
40
+ };
41
+
42
+ export const StaticIcon: React.FC<IconFontProps<string>> = ({
43
+ type,
44
+ className,
45
+ ...props
46
+ }) => {
47
+ const {extra} = useSettings();
48
+ const AliIconFont = AliIconFontFn(extra.iconScriptUrl);
49
+
50
+ const staticIcon = useMemo(() => {
51
+ return (
52
+ <AliIconFont
53
+ {...props}
54
+ className={`${Styles.icon} ${className}`}
55
+ type={type}
56
+ />
57
+ );
58
+ }, []);
59
+
60
+ return staticIcon;
36
61
  };