@jvs-milkdown/crepe 1.2.0 → 1.2.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 (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 +457 -31
  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 +458 -32
  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 +324 -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 +91 -3
  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 +368 -23
  74. package/src/theme/common/reset.css +3 -0
  75. package/src/theme/common/toolbar.css +30 -2
@@ -152,10 +152,16 @@
152
152
  outline: none;
153
153
  margin: 4px 0;
154
154
  display: block;
155
+ position: relative;
156
+
157
+ &:hover {
158
+ z-index: 120;
159
+ }
155
160
 
156
161
  & > .image-wrapper {
157
162
  position: relative;
158
163
  width: fit-content;
164
+ max-width: 100%;
159
165
  margin: 0 auto;
160
166
  min-width: 100px;
161
167
  }
@@ -168,15 +174,6 @@
168
174
  margin: 0 0 0 auto;
169
175
  }
170
176
 
171
- & > .image-wrapper .operation {
172
- position: absolute;
173
- display: flex;
174
- }
175
-
176
- & > .image-wrapper .operation > .operation-item {
177
- cursor: pointer;
178
- }
179
-
180
177
  & > .image-wrapper img {
181
178
  max-width: 100%;
182
179
  min-height: 100px;
@@ -269,32 +266,64 @@
269
266
  display: flex;
270
267
  justify-content: center;
271
268
  align-items: center;
269
+
270
+ &.cropping {
271
+ outline: none !important;
272
+ }
272
273
  }
273
274
 
274
- .image-wrapper .operation {
275
- gap: 12px;
276
- right: 12px;
277
- top: 12px;
275
+ .image-toolbar {
276
+ position: absolute;
277
+ bottom: calc(100% + 8px);
278
+ left: 50%;
279
+ transform: translateX(-50%);
280
+ display: flex;
281
+ align-items: center;
282
+ justify-content: center;
283
+ gap: 4px;
284
+ padding: 4px 8px;
285
+ background: var(--crepe-color-surface);
286
+ border-radius: 8px;
287
+ box-shadow: var(--crepe-shadow-1);
278
288
  opacity: 0;
279
- transition: all 0.2s;
289
+ pointer-events: none;
290
+ transition: opacity 0.2s;
291
+ width: fit-content;
292
+ z-index: 10;
293
+ white-space: nowrap;
294
+
295
+ &::after {
296
+ content: '';
297
+ position: absolute;
298
+ left: 0;
299
+ right: 0;
300
+ bottom: -8px;
301
+ height: 8px;
302
+ }
280
303
  }
281
304
 
282
- &:hover > .image-wrapper .operation {
305
+ &:hover > .image-toolbar {
283
306
  opacity: 1;
307
+ pointer-events: auto;
284
308
  }
285
309
 
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%;
310
+ .image-toolbar-item {
311
+ display: flex;
312
+ align-items: center;
313
+ justify-content: center;
314
+ cursor: pointer;
292
315
  width: 32px;
293
316
  height: 32px;
317
+ border-radius: 6px;
318
+ color: var(--crepe-color-on-surface-variant);
294
319
 
295
320
  svg {
296
- width: 24px;
297
- height: 24px;
321
+ width: 20px;
322
+ height: 20px;
323
+ }
324
+
325
+ &:hover {
326
+ background: var(--crepe-color-hover);
298
327
  }
299
328
  }
300
329
 
@@ -431,5 +460,321 @@
431
460
  var(--crepe-color-secondary);
432
461
  }
433
462
  }
463
+
464
+ .setting-panel {
465
+ position: absolute;
466
+ top: 44px;
467
+ right: 0;
468
+ z-index: 10;
469
+ background: var(--crepe-color-surface);
470
+ border-radius: 8px;
471
+ box-shadow: var(--crepe-shadow-1);
472
+ padding: 12px;
473
+ min-width: 200px;
474
+ }
475
+
476
+ .setting-panel-title {
477
+ font-size: 12px;
478
+ font-weight: 600;
479
+ color: var(--crepe-color-on-surface-variant);
480
+ margin-bottom: 8px;
481
+ text-transform: uppercase;
482
+ font-family: var(--crepe-font-default);
483
+ }
484
+
485
+ .crop-options {
486
+ display: flex;
487
+ gap: 4px;
488
+ flex-wrap: wrap;
489
+ }
490
+
491
+ .crop-option {
492
+ padding: 4px 12px;
493
+ border-radius: 4px;
494
+ font-size: 12px;
495
+ font-weight: 600;
496
+ cursor: pointer;
497
+ background: var(--crepe-color-surface-low);
498
+ color: var(--crepe-color-on-surface-variant);
499
+ font-family: var(--crepe-font-default);
500
+
501
+ &:hover {
502
+ background: var(--crepe-color-hover);
503
+ }
504
+
505
+ &.active {
506
+ background: var(--crepe-color-selected);
507
+ color: var(--crepe-color-primary);
508
+ }
509
+ }
510
+
511
+ .setting-row {
512
+ display: flex;
513
+ align-items: center;
514
+ gap: 8px;
515
+ margin-bottom: 8px;
516
+ }
517
+
518
+ .setting-label {
519
+ font-size: 12px;
520
+ font-weight: 600;
521
+ color: var(--crepe-color-on-surface-variant);
522
+ min-width: 32px;
523
+ font-family: var(--crepe-font-default);
524
+ }
525
+
526
+ .setting-value {
527
+ font-size: 12px;
528
+ color: var(--crepe-color-on-surface-variant);
529
+ min-width: 30px;
530
+ font-family: var(--crepe-font-default);
531
+ }
532
+
533
+ .border-style-options {
534
+ display: flex;
535
+ gap: 4px;
536
+ }
537
+
538
+ .border-style-option {
539
+ padding: 4px 10px;
540
+ border-radius: 4px;
541
+ font-size: 12px;
542
+ font-weight: 600;
543
+ cursor: pointer;
544
+ background: var(--crepe-color-surface-low);
545
+ color: var(--crepe-color-on-surface-variant);
546
+ font-family: var(--crepe-font-default);
547
+
548
+ &:hover {
549
+ background: var(--crepe-color-hover);
550
+ }
551
+
552
+ &.active {
553
+ background: var(--crepe-color-selected);
554
+ color: var(--crepe-color-primary);
555
+ }
556
+ }
557
+
558
+ input[type='range'] {
559
+ flex: 1;
560
+ height: 4px;
561
+ accent-color: var(--crepe-color-primary);
562
+ }
563
+
564
+ input[type='color'] {
565
+ width: 28px;
566
+ height: 28px;
567
+ padding: 0;
568
+ border: 1px solid var(--crepe-color-outline);
569
+ border-radius: 4px;
570
+ cursor: pointer;
571
+ background: transparent;
572
+ }
573
+
574
+ .crop-actions {
575
+ display: flex;
576
+ gap: 4px;
577
+ margin-top: 8px;
578
+ flex-wrap: wrap;
579
+ }
580
+
581
+ .crop-action-btn {
582
+ padding: 4px 12px;
583
+ border-radius: 4px;
584
+ font-size: 12px;
585
+ font-weight: 600;
586
+ cursor: pointer;
587
+ border: 1px solid var(--crepe-color-outline);
588
+ background: var(--crepe-color-surface-low);
589
+ color: var(--crepe-color-on-surface-variant);
590
+ font-family: var(--crepe-font-default);
591
+
592
+ &:hover {
593
+ background: var(--crepe-color-hover);
594
+ }
595
+
596
+ &.primary {
597
+ background: var(--crepe-color-primary);
598
+ color: #fff;
599
+ border-color: var(--crepe-color-primary);
600
+ }
601
+ }
602
+
603
+ .crop-overlay {
604
+ position: absolute;
605
+ inset: 0;
606
+ z-index: 5;
607
+ overflow: hidden;
608
+ display: flex;
609
+ flex-direction: column;
610
+ justify-content: flex-end;
611
+ }
612
+
613
+ .crop-box {
614
+ position: absolute;
615
+ /* border: 2px solid transparent; */
616
+ box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
617
+ cursor: move;
618
+ z-index: 2;
619
+ }
620
+
621
+ .crop-grid {
622
+ position: absolute;
623
+ inset: 0;
624
+ pointer-events: none;
625
+ }
626
+
627
+ .crop-grid-line {
628
+ position: absolute;
629
+ background: rgba(255, 255, 255, 0.4);
630
+
631
+ &.horizontal {
632
+ left: 0;
633
+ right: 0;
634
+ height: 1px;
635
+ }
636
+
637
+ &.horizontal.first {
638
+ top: 33.33%;
639
+ }
640
+
641
+ &.horizontal.second {
642
+ top: 66.66%;
643
+ }
644
+
645
+ &.vertical {
646
+ top: 0;
647
+ bottom: 0;
648
+ width: 1px;
649
+ }
650
+
651
+ &.vertical.first {
652
+ left: 33.33%;
653
+ }
654
+
655
+ &.vertical.second {
656
+ left: 66.66%;
657
+ }
658
+ }
659
+
660
+ .crop-handle {
661
+ position: absolute;
662
+ background: transparent;
663
+ z-index: 3;
664
+
665
+ &.nw {
666
+ top: 0;
667
+ left: 0;
668
+ width: 20px;
669
+ height: 20px;
670
+ border-top: 2px solid #000;
671
+ border-left: 2px solid #000;
672
+ cursor: nwse-resize;
673
+ }
674
+
675
+ &.ne {
676
+ top: 0;
677
+ right: 0;
678
+ width: 20px;
679
+ height: 20px;
680
+ border-top: 2px solid #000;
681
+ border-right: 2px solid #000;
682
+ cursor: nesw-resize;
683
+ }
684
+
685
+ &.sw {
686
+ bottom: 0;
687
+ left: 0;
688
+ width: 20px;
689
+ height: 20px;
690
+ border-bottom: 2px solid #000;
691
+ border-left: 2px solid #000;
692
+ cursor: nesw-resize;
693
+ }
694
+
695
+ &.se {
696
+ bottom: 0;
697
+ right: 0;
698
+ width: 20px;
699
+ height: 20px;
700
+ border-bottom: 2px solid #000;
701
+ border-right: 2px solid #000;
702
+ cursor: nwse-resize;
703
+ }
704
+
705
+ &.n {
706
+ top: 0;
707
+ left: 50%;
708
+ transform: translateX(-50%);
709
+ width: 20px;
710
+ height: 0;
711
+ border-top: 2px solid #000;
712
+ cursor: ns-resize;
713
+ }
714
+
715
+ &.s {
716
+ bottom: 0;
717
+ left: 50%;
718
+ transform: translateX(-50%);
719
+ width: 20px;
720
+ height: 0;
721
+ border-bottom: 2px solid #000;
722
+ cursor: ns-resize;
723
+ }
724
+
725
+ &.w {
726
+ left: 0;
727
+ top: 50%;
728
+ transform: translateY(-50%);
729
+ width: 0;
730
+ height: 20px;
731
+ border-left: 2px solid #000;
732
+ cursor: ew-resize;
733
+ }
734
+
735
+ &.e {
736
+ right: 0;
737
+ top: 50%;
738
+ transform: translateY(-50%);
739
+ width: 0;
740
+ height: 20px;
741
+ border-right: 2px solid #000;
742
+ cursor: ew-resize;
743
+ }
744
+ }
745
+
746
+ .crop-toolbar {
747
+ position: absolute;
748
+ bottom: 12px;
749
+ left: 50%;
750
+ transform: translateX(-50%);
751
+ display: flex;
752
+ gap: 8px;
753
+ z-index: 10;
754
+ background: var(--crepe-color-surface);
755
+ border-radius: 8px;
756
+ padding: 4px;
757
+ box-shadow: var(--crepe-shadow-1);
758
+ }
759
+
760
+ .crop-toolbar-btn {
761
+ width: 36px;
762
+ height: 36px;
763
+ display: flex;
764
+ align-items: center;
765
+ justify-content: center;
766
+ cursor: pointer;
767
+ border-radius: 6px;
768
+ color: var(--crepe-color-on-surface-variant);
769
+
770
+ svg {
771
+ width: 20px;
772
+ height: 20px;
773
+ }
774
+
775
+ &:hover {
776
+ background: var(--crepe-color-hover);
777
+ }
778
+ }
434
779
  }
435
780
  }
@@ -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
  }