@jvs-milkdown/crepe 1.2.0 → 1.2.1

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 (75) hide show
  1. package/lib/cjs/builder.js +55 -2
  2. package/lib/cjs/builder.js.map +1 -1
  3. package/lib/cjs/feature/block-edit/index.js +73 -5
  4. package/lib/cjs/feature/block-edit/index.js.map +1 -1
  5. package/lib/cjs/feature/code-mirror/index.js +65 -3
  6. package/lib/cjs/feature/code-mirror/index.js.map +1 -1
  7. package/lib/cjs/feature/cursor/index.js +55 -2
  8. package/lib/cjs/feature/cursor/index.js.map +1 -1
  9. package/lib/cjs/feature/image-block/index.js +76 -8
  10. package/lib/cjs/feature/image-block/index.js.map +1 -1
  11. package/lib/cjs/feature/latex/index.js +55 -2
  12. package/lib/cjs/feature/latex/index.js.map +1 -1
  13. package/lib/cjs/feature/link-tooltip/index.js +55 -2
  14. package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
  15. package/lib/cjs/feature/list-item/index.js +55 -2
  16. package/lib/cjs/feature/list-item/index.js.map +1 -1
  17. package/lib/cjs/feature/placeholder/index.js +55 -2
  18. package/lib/cjs/feature/placeholder/index.js.map +1 -1
  19. package/lib/cjs/feature/table/index.js +55 -2
  20. package/lib/cjs/feature/table/index.js.map +1 -1
  21. package/lib/cjs/feature/toolbar/index.js +73 -5
  22. package/lib/cjs/feature/toolbar/index.js.map +1 -1
  23. package/lib/cjs/index.js +451 -30
  24. package/lib/cjs/index.js.map +1 -1
  25. package/lib/esm/builder.js +55 -2
  26. package/lib/esm/builder.js.map +1 -1
  27. package/lib/esm/feature/block-edit/index.js +73 -5
  28. package/lib/esm/feature/block-edit/index.js.map +1 -1
  29. package/lib/esm/feature/code-mirror/index.js +65 -3
  30. package/lib/esm/feature/code-mirror/index.js.map +1 -1
  31. package/lib/esm/feature/cursor/index.js +55 -2
  32. package/lib/esm/feature/cursor/index.js.map +1 -1
  33. package/lib/esm/feature/image-block/index.js +76 -8
  34. package/lib/esm/feature/image-block/index.js.map +1 -1
  35. package/lib/esm/feature/latex/index.js +55 -2
  36. package/lib/esm/feature/latex/index.js.map +1 -1
  37. package/lib/esm/feature/link-tooltip/index.js +55 -2
  38. package/lib/esm/feature/link-tooltip/index.js.map +1 -1
  39. package/lib/esm/feature/list-item/index.js +55 -2
  40. package/lib/esm/feature/list-item/index.js.map +1 -1
  41. package/lib/esm/feature/placeholder/index.js +55 -2
  42. package/lib/esm/feature/placeholder/index.js.map +1 -1
  43. package/lib/esm/feature/table/index.js +55 -2
  44. package/lib/esm/feature/table/index.js.map +1 -1
  45. package/lib/esm/feature/toolbar/index.js +73 -5
  46. package/lib/esm/feature/toolbar/index.js.map +1 -1
  47. package/lib/esm/index.js +452 -31
  48. package/lib/esm/index.js.map +1 -1
  49. package/lib/theme/common/code-mirror.css +13 -0
  50. package/lib/theme/common/image-block.css +321 -22
  51. package/lib/theme/common/reset.css +3 -0
  52. package/lib/theme/common/toolbar.css +27 -2
  53. package/lib/tsconfig.tsbuildinfo +1 -1
  54. package/package.json +4 -4
  55. package/src/core/locale.ts +55 -0
  56. package/src/feature/block-edit/menu/config.ts +19 -3
  57. package/src/feature/code-mirror/index.ts +3 -0
  58. package/src/feature/fixed-toolbar/component.tsx +31 -2
  59. package/src/feature/fixed-toolbar/config.ts +18 -3
  60. package/src/feature/fixed-toolbar/document-header.tsx +8 -4
  61. package/src/feature/fixed-toolbar/index.ts +18 -1
  62. package/src/feature/fixed-toolbar/menu-bar.tsx +83 -2
  63. package/src/feature/fixed-toolbar/shortcut-help-modal.tsx +244 -0
  64. package/src/feature/fixed-toolbar/view-menu-state.ts +9 -0
  65. package/src/feature/image-block/index.ts +11 -1
  66. package/src/icons/border.ts +5 -0
  67. package/src/icons/close.ts +3 -0
  68. package/src/icons/crop.ts +6 -0
  69. package/src/icons/index.ts +5 -0
  70. package/src/icons/keyboard.ts +3 -0
  71. package/src/icons/word-wrap.ts +6 -0
  72. package/src/theme/common/code-mirror.css +13 -0
  73. package/src/theme/common/image-block.css +364 -23
  74. package/src/theme/common/reset.css +3 -0
  75. package/src/theme/common/toolbar.css +30 -2
@@ -152,6 +152,8 @@
152
152
  outline: none;
153
153
  margin: 4px 0;
154
154
  display: block;
155
+ position: relative;
156
+ z-index: 120;
155
157
 
156
158
  & > .image-wrapper {
157
159
  position: relative;
@@ -168,15 +170,6 @@
168
170
  margin: 0 0 0 auto;
169
171
  }
170
172
 
171
- & > .image-wrapper .operation {
172
- position: absolute;
173
- display: flex;
174
- }
175
-
176
- & > .image-wrapper .operation > .operation-item {
177
- cursor: pointer;
178
- }
179
-
180
173
  & > .image-wrapper img {
181
174
  max-width: 100%;
182
175
  min-height: 100px;
@@ -269,32 +262,64 @@
269
262
  display: flex;
270
263
  justify-content: center;
271
264
  align-items: center;
265
+
266
+ &.cropping {
267
+ outline: none !important;
268
+ }
272
269
  }
273
270
 
274
- .image-wrapper .operation {
275
- gap: 12px;
276
- right: 12px;
277
- top: 12px;
271
+ .image-toolbar {
272
+ position: absolute;
273
+ bottom: calc(100% + 8px);
274
+ left: 50%;
275
+ transform: translateX(-50%);
276
+ display: flex;
277
+ align-items: center;
278
+ justify-content: center;
279
+ gap: 4px;
280
+ padding: 4px 8px;
281
+ background: var(--crepe-color-surface);
282
+ border-radius: 8px;
283
+ box-shadow: var(--crepe-shadow-1);
278
284
  opacity: 0;
279
- transition: all 0.2s;
285
+ pointer-events: none;
286
+ transition: opacity 0.2s;
287
+ width: fit-content;
288
+ z-index: 10;
289
+ white-space: nowrap;
290
+
291
+ &::after {
292
+ content: '';
293
+ position: absolute;
294
+ left: 0;
295
+ right: 0;
296
+ bottom: -8px;
297
+ height: 8px;
298
+ }
280
299
  }
281
300
 
282
- &:hover > .image-wrapper .operation {
301
+ &:hover > .image-toolbar {
283
302
  opacity: 1;
303
+ pointer-events: auto;
284
304
  }
285
305
 
286
- .image-wrapper .operation > .operation-item {
287
- color: var(--crepe-color-on-inverse);
288
- padding: 4px;
289
- background: var(--crepe-color-inverse);
290
- opacity: 0.6;
291
- border-radius: 50%;
306
+ .image-toolbar-item {
307
+ display: flex;
308
+ align-items: center;
309
+ justify-content: center;
310
+ cursor: pointer;
292
311
  width: 32px;
293
312
  height: 32px;
313
+ border-radius: 6px;
314
+ color: var(--crepe-color-on-surface-variant);
294
315
 
295
316
  svg {
296
- width: 24px;
297
- height: 24px;
317
+ width: 20px;
318
+ height: 20px;
319
+ }
320
+
321
+ &:hover {
322
+ background: var(--crepe-color-hover);
298
323
  }
299
324
  }
300
325
 
@@ -431,5 +456,321 @@
431
456
  var(--crepe-color-secondary);
432
457
  }
433
458
  }
459
+
460
+ .setting-panel {
461
+ position: absolute;
462
+ top: 44px;
463
+ right: 0;
464
+ z-index: 10;
465
+ background: var(--crepe-color-surface);
466
+ border-radius: 8px;
467
+ box-shadow: var(--crepe-shadow-1);
468
+ padding: 12px;
469
+ min-width: 200px;
470
+ }
471
+
472
+ .setting-panel-title {
473
+ font-size: 12px;
474
+ font-weight: 600;
475
+ color: var(--crepe-color-on-surface-variant);
476
+ margin-bottom: 8px;
477
+ text-transform: uppercase;
478
+ font-family: var(--crepe-font-default);
479
+ }
480
+
481
+ .crop-options {
482
+ display: flex;
483
+ gap: 4px;
484
+ flex-wrap: wrap;
485
+ }
486
+
487
+ .crop-option {
488
+ padding: 4px 12px;
489
+ border-radius: 4px;
490
+ font-size: 12px;
491
+ font-weight: 600;
492
+ cursor: pointer;
493
+ background: var(--crepe-color-surface-low);
494
+ color: var(--crepe-color-on-surface-variant);
495
+ font-family: var(--crepe-font-default);
496
+
497
+ &:hover {
498
+ background: var(--crepe-color-hover);
499
+ }
500
+
501
+ &.active {
502
+ background: var(--crepe-color-selected);
503
+ color: var(--crepe-color-primary);
504
+ }
505
+ }
506
+
507
+ .setting-row {
508
+ display: flex;
509
+ align-items: center;
510
+ gap: 8px;
511
+ margin-bottom: 8px;
512
+ }
513
+
514
+ .setting-label {
515
+ font-size: 12px;
516
+ font-weight: 600;
517
+ color: var(--crepe-color-on-surface-variant);
518
+ min-width: 32px;
519
+ font-family: var(--crepe-font-default);
520
+ }
521
+
522
+ .setting-value {
523
+ font-size: 12px;
524
+ color: var(--crepe-color-on-surface-variant);
525
+ min-width: 30px;
526
+ font-family: var(--crepe-font-default);
527
+ }
528
+
529
+ .border-style-options {
530
+ display: flex;
531
+ gap: 4px;
532
+ }
533
+
534
+ .border-style-option {
535
+ padding: 4px 10px;
536
+ border-radius: 4px;
537
+ font-size: 12px;
538
+ font-weight: 600;
539
+ cursor: pointer;
540
+ background: var(--crepe-color-surface-low);
541
+ color: var(--crepe-color-on-surface-variant);
542
+ font-family: var(--crepe-font-default);
543
+
544
+ &:hover {
545
+ background: var(--crepe-color-hover);
546
+ }
547
+
548
+ &.active {
549
+ background: var(--crepe-color-selected);
550
+ color: var(--crepe-color-primary);
551
+ }
552
+ }
553
+
554
+ input[type='range'] {
555
+ flex: 1;
556
+ height: 4px;
557
+ accent-color: var(--crepe-color-primary);
558
+ }
559
+
560
+ input[type='color'] {
561
+ width: 28px;
562
+ height: 28px;
563
+ padding: 0;
564
+ border: 1px solid var(--crepe-color-outline);
565
+ border-radius: 4px;
566
+ cursor: pointer;
567
+ background: transparent;
568
+ }
569
+
570
+ .crop-actions {
571
+ display: flex;
572
+ gap: 4px;
573
+ margin-top: 8px;
574
+ flex-wrap: wrap;
575
+ }
576
+
577
+ .crop-action-btn {
578
+ padding: 4px 12px;
579
+ border-radius: 4px;
580
+ font-size: 12px;
581
+ font-weight: 600;
582
+ cursor: pointer;
583
+ border: 1px solid var(--crepe-color-outline);
584
+ background: var(--crepe-color-surface-low);
585
+ color: var(--crepe-color-on-surface-variant);
586
+ font-family: var(--crepe-font-default);
587
+
588
+ &:hover {
589
+ background: var(--crepe-color-hover);
590
+ }
591
+
592
+ &.primary {
593
+ background: var(--crepe-color-primary);
594
+ color: #fff;
595
+ border-color: var(--crepe-color-primary);
596
+ }
597
+ }
598
+
599
+ .crop-overlay {
600
+ position: absolute;
601
+ inset: 0;
602
+ z-index: 5;
603
+ overflow: hidden;
604
+ display: flex;
605
+ flex-direction: column;
606
+ justify-content: flex-end;
607
+ }
608
+
609
+ .crop-box {
610
+ position: absolute;
611
+ border: 2px solid transparent;
612
+ box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
613
+ cursor: move;
614
+ z-index: 2;
615
+ }
616
+
617
+ .crop-grid {
618
+ position: absolute;
619
+ inset: 0;
620
+ pointer-events: none;
621
+ }
622
+
623
+ .crop-grid-line {
624
+ position: absolute;
625
+ background: rgba(255, 255, 255, 0.4);
626
+
627
+ &.horizontal {
628
+ left: 0;
629
+ right: 0;
630
+ height: 1px;
631
+ }
632
+
633
+ &.horizontal.first {
634
+ top: 33.33%;
635
+ }
636
+
637
+ &.horizontal.second {
638
+ top: 66.66%;
639
+ }
640
+
641
+ &.vertical {
642
+ top: 0;
643
+ bottom: 0;
644
+ width: 1px;
645
+ }
646
+
647
+ &.vertical.first {
648
+ left: 33.33%;
649
+ }
650
+
651
+ &.vertical.second {
652
+ left: 66.66%;
653
+ }
654
+ }
655
+
656
+ .crop-handle {
657
+ position: absolute;
658
+ background: transparent;
659
+ z-index: 3;
660
+
661
+ &.nw {
662
+ top: 0;
663
+ left: 0;
664
+ width: 20px;
665
+ height: 20px;
666
+ border-top: 2px solid #000;
667
+ border-left: 2px solid #000;
668
+ cursor: nwse-resize;
669
+ }
670
+
671
+ &.ne {
672
+ top: 0;
673
+ right: 0;
674
+ width: 20px;
675
+ height: 20px;
676
+ border-top: 2px solid #000;
677
+ border-right: 2px solid #000;
678
+ cursor: nesw-resize;
679
+ }
680
+
681
+ &.sw {
682
+ bottom: 0;
683
+ left: 0;
684
+ width: 20px;
685
+ height: 20px;
686
+ border-bottom: 2px solid #000;
687
+ border-left: 2px solid #000;
688
+ cursor: nesw-resize;
689
+ }
690
+
691
+ &.se {
692
+ bottom: 0;
693
+ right: 0;
694
+ width: 20px;
695
+ height: 20px;
696
+ border-bottom: 2px solid #000;
697
+ border-right: 2px solid #000;
698
+ cursor: nwse-resize;
699
+ }
700
+
701
+ &.n {
702
+ top: 0;
703
+ left: 50%;
704
+ transform: translateX(-50%);
705
+ width: 20px;
706
+ height: 0;
707
+ border-top: 2px solid #000;
708
+ cursor: ns-resize;
709
+ }
710
+
711
+ &.s {
712
+ bottom: 0;
713
+ left: 50%;
714
+ transform: translateX(-50%);
715
+ width: 20px;
716
+ height: 0;
717
+ border-bottom: 2px solid #000;
718
+ cursor: ns-resize;
719
+ }
720
+
721
+ &.w {
722
+ left: 0;
723
+ top: 50%;
724
+ transform: translateY(-50%);
725
+ width: 0;
726
+ height: 20px;
727
+ border-left: 2px solid #000;
728
+ cursor: ew-resize;
729
+ }
730
+
731
+ &.e {
732
+ right: 0;
733
+ top: 50%;
734
+ transform: translateY(-50%);
735
+ width: 0;
736
+ height: 20px;
737
+ border-right: 2px solid #000;
738
+ cursor: ew-resize;
739
+ }
740
+ }
741
+
742
+ .crop-toolbar {
743
+ position: absolute;
744
+ bottom: 12px;
745
+ left: 50%;
746
+ transform: translateX(-50%);
747
+ display: flex;
748
+ gap: 8px;
749
+ z-index: 10;
750
+ background: var(--crepe-color-surface);
751
+ border-radius: 8px;
752
+ padding: 4px;
753
+ box-shadow: var(--crepe-shadow-1);
754
+ }
755
+
756
+ .crop-toolbar-btn {
757
+ width: 36px;
758
+ height: 36px;
759
+ display: flex;
760
+ align-items: center;
761
+ justify-content: center;
762
+ cursor: pointer;
763
+ border-radius: 6px;
764
+ color: var(--crepe-color-on-surface-variant);
765
+
766
+ svg {
767
+ width: 20px;
768
+ height: 20px;
769
+ }
770
+
771
+ &:hover {
772
+ background: var(--crepe-color-hover);
773
+ }
774
+ }
434
775
  }
435
776
  }
@@ -206,6 +206,7 @@
206
206
  ul:has(mark) p:has(mark),
207
207
  ol:has(mark) p:has(mark) {
208
208
  padding: 4px 0;
209
+ margin: 0px;
209
210
  border: none;
210
211
  border-radius: 0;
211
212
  background-color: transparent;
@@ -228,6 +229,7 @@
228
229
  code {
229
230
  padding: 0;
230
231
  background: transparent;
232
+ color: var(--crepe-color-inline-code);
231
233
  }
232
234
  }
233
235
 
@@ -292,6 +294,7 @@
292
294
  ul,
293
295
  ol {
294
296
  padding: 0;
297
+ list-style: none;
295
298
  }
296
299
  }
297
300
  }
@@ -19,13 +19,14 @@
19
19
 
20
20
  .divider {
21
21
  width: 1px;
22
+ align-self: center;
22
23
  background: color-mix(
23
24
  in srgb,
24
25
  var(--crepe-color-outline),
25
26
  transparent 80%
26
27
  );
27
28
  height: 24px;
28
- margin: 10px;
29
+ margin: 0 4px;
29
30
  }
30
31
 
31
32
  .toolbar-item {
@@ -36,6 +37,10 @@
36
37
  cursor: pointer;
37
38
  border-radius: 4px;
38
39
 
40
+ &:has(.milkdown-icon) {
41
+ padding: 2px 6px;
42
+ }
43
+
39
44
  &:hover {
40
45
  background: var(--crepe-color-hover);
41
46
  }
@@ -85,15 +90,34 @@
85
90
  top: 0;
86
91
  flex-shrink: 0;
87
92
 
93
+ .toolbar-shortcut-btn {
94
+ display: flex;
95
+ align-items: center;
96
+ justify-content: center;
97
+ flex-shrink: 0;
98
+ width: 28px;
99
+ height: 28px;
100
+ border: none;
101
+ background: transparent;
102
+ cursor: pointer;
103
+ border-radius: 4px;
104
+ color: var(--crepe-color-on-surface-variant, #666);
105
+ margin-left: 6px;
106
+ &:hover {
107
+ background: var(--crepe-color-hover);
108
+ }
109
+ }
110
+
88
111
  .divider {
89
112
  width: 1px;
113
+ align-self: center;
90
114
  background: color-mix(
91
115
  in srgb,
92
116
  var(--crepe-color-outline),
93
117
  transparent 80%
94
118
  );
95
119
  height: 20px;
96
- margin: 10px;
120
+ margin: 0 4px;
97
121
  }
98
122
 
99
123
  .toolbar-item {
@@ -104,6 +128,10 @@
104
128
  cursor: pointer;
105
129
  border-radius: 4px;
106
130
 
131
+ &:has(.milkdown-icon) {
132
+ padding: 2px 6px;
133
+ }
134
+
107
135
  &:hover {
108
136
  background: var(--crepe-color-hover);
109
137
  }