@jvs-milkdown/crepe 1.2.32 → 1.2.34

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.
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAGhE,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,GAAG,EAMT,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAA;AAalD,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,qBAAqB,oXAgRhC,CAAA"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAGhE,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,GAAG,EAMT,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,GAAG,CAAA;AAalD,KAAK,iBAAiB,GAAG;IACvB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,yBAAyB,CAAA;IAClC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IACrB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,qBAAqB,oXAsQhC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAyBhE,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,UAAU,EAQhB,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AAmG7C,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAeD,eAAO,MAAM,OAAO,0WA+iFlB,CAAA"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/feature/toolbar/component.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAyBhE,OAAO,EAEL,KAAK,GAAG,EACR,KAAK,UAAU,EAQhB,MAAM,KAAK,CAAA;AAEZ,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,GAAG,CAAA;AAmG7C,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;IAClB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;IAC9B,MAAM,CAAC,EAAE,oBAAoB,CAAA;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAeD,eAAO,MAAM,OAAO,0WA6iFlB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jvs-milkdown/crepe",
3
- "version": "1.2.32",
3
+ "version": "1.2.34",
4
4
  "keywords": [
5
5
  "crepe",
6
6
  "editor",
@@ -107,9 +107,9 @@
107
107
  "@codemirror/theme-one-dark": "^6.1.2",
108
108
  "@codemirror/view": "^6.26.0",
109
109
  "@floating-ui/dom": "^1.7.6",
110
- "@jvs-milkdown/kit": "^1.2.32",
111
- "@jvs-milkdown/prose": "^1.2.32",
112
- "@jvs-milkdown/utils": "^1.2.32",
110
+ "@jvs-milkdown/kit": "^1.2.34",
111
+ "@jvs-milkdown/prose": "^1.2.34",
112
+ "@jvs-milkdown/utils": "^1.2.34",
113
113
  "@types/lodash-es": "^4.17.12",
114
114
  "clsx": "^2.0.0",
115
115
  "codemirror": "^6.0.1",
@@ -95,51 +95,41 @@ export const FixedToolbarComponent = defineComponent<FixedToolbarProps>({
95
95
  justifyContent: 'center',
96
96
  }}
97
97
  >
98
- <div
98
+ <button
99
+ type="button"
100
+ class="fixed-toolbar-expand-btn"
101
+ title="展开工具栏"
102
+ onClick={(e: MouseEvent) => {
103
+ e.preventDefault()
104
+ e.stopPropagation()
105
+ viewState.fixedToolbarVisible = true
106
+ }}
99
107
  style={{
100
- position: 'relative',
101
- width: '100%',
102
- maxWidth: isFull.value ? '100%' : maxWidth.value,
103
- margin: isFull.value ? '0' : '0 auto',
104
- height: '100%',
108
+ position: 'absolute',
109
+ top: '0',
110
+ right: '40px',
111
+ display: 'flex',
112
+ alignItems: 'center',
113
+ justifyContent: 'center',
114
+ width: '28px',
115
+ height: '24px',
116
+ border:
117
+ '1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 85%))',
118
+ borderTop: 'none',
119
+ background: 'var(--crepe-color-surface, #ffffff)',
120
+ cursor: 'pointer',
121
+ borderRadius: '0 0 6px 6px',
122
+ boxShadow: '0 4px 8px rgba(0, 0, 0, 0.06)',
123
+ color: 'var(--crepe-color-on-surface, #363b4c)',
124
+ pointerEvents: 'auto',
125
+ zIndex: 200,
105
126
  }}
106
127
  >
107
- <button
108
- type="button"
109
- class="fixed-toolbar-expand-btn"
110
- title="展开工具栏"
111
- onClick={(e: MouseEvent) => {
112
- e.preventDefault()
113
- e.stopPropagation()
114
- viewState.fixedToolbarVisible = true
115
- }}
116
- style={{
117
- position: 'absolute',
118
- top: '0',
119
- right: '6px',
120
- display: 'flex',
121
- alignItems: 'center',
122
- justifyContent: 'center',
123
- width: '28px',
124
- height: '24px',
125
- border:
126
- '1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 85%))',
127
- borderTop: 'none',
128
- background: 'var(--crepe-color-surface, #ffffff)',
129
- cursor: 'pointer',
130
- borderRadius: '0 0 6px 6px',
131
- boxShadow: '0 4px 8px rgba(0, 0, 0, 0.06)',
132
- color: 'var(--crepe-color-on-surface, #363b4c)',
133
- pointerEvents: 'auto',
134
- zIndex: 200,
135
- }}
136
- >
137
- <span
138
- style={{ display: 'inline-flex', alignItems: 'center' }}
139
- innerHTML={chevronDownIcon}
140
- />
141
- </button>
142
- </div>
128
+ <span
129
+ style={{ display: 'inline-flex', alignItems: 'center' }}
130
+ innerHTML={chevronDownIcon}
131
+ />
132
+ </button>
143
133
  </div>
144
134
  )
145
135
  }
@@ -164,7 +154,7 @@ export const FixedToolbarComponent = defineComponent<FixedToolbarProps>({
164
154
  width: '100%',
165
155
  maxWidth: isFull.value ? '100%' : maxWidth.value,
166
156
  margin: isFull.value ? '0' : '0 auto',
167
- paddingRight: '40px',
157
+ padding: '0px 10px',
168
158
  gap: '0px',
169
159
  minWidth: '0',
170
160
  overflow: 'hidden',
@@ -272,38 +262,38 @@ export const FixedToolbarComponent = defineComponent<FixedToolbarProps>({
272
262
  {showShortcuts.value && (
273
263
  <ShortcutHelpModal ctx={props.ctx} visible={showShortcuts} />
274
264
  )}
265
+ </div>
275
266
 
276
- <button
277
- type="button"
278
- class="toolbar-item collapse-btn"
279
- title="折叠工具栏"
280
- onClick={(e: MouseEvent) => {
281
- e.preventDefault()
282
- e.stopPropagation()
283
- viewState.fixedToolbarVisible = false
284
- }}
267
+ <button
268
+ type="button"
269
+ class="toolbar-item collapse-btn"
270
+ title="折叠工具栏"
271
+ onClick={(e: MouseEvent) => {
272
+ e.preventDefault()
273
+ e.stopPropagation()
274
+ viewState.fixedToolbarVisible = false
275
+ }}
276
+ style={{
277
+ position: 'absolute',
278
+ top: '6px',
279
+ right: '40px',
280
+ margin: '0',
281
+ display: 'flex',
282
+ alignItems: 'center',
283
+ justifyContent: 'center',
284
+ pointerEvents: 'auto',
285
+ zIndex: 200,
286
+ }}
287
+ >
288
+ <span
285
289
  style={{
286
- position: 'absolute',
287
- top: '6px',
288
- right: '6px',
289
- margin: '0',
290
- display: 'flex',
290
+ display: 'inline-flex',
291
291
  alignItems: 'center',
292
- justifyContent: 'center',
293
- pointerEvents: 'auto',
294
- zIndex: 200,
292
+ transform: 'rotate(180deg)',
295
293
  }}
296
- >
297
- <span
298
- style={{
299
- display: 'inline-flex',
300
- alignItems: 'center',
301
- transform: 'rotate(180deg)',
302
- }}
303
- innerHTML={chevronDownIcon}
304
- />
305
- </button>
306
- </div>
294
+ innerHTML={chevronDownIcon}
295
+ />
296
+ </button>
307
297
  </div>
308
298
  )
309
299
  }
@@ -572,9 +572,8 @@ export const Toolbar = defineComponent<ToolbarProps>({
572
572
  siblingsWidth += s.offsetWidth
573
573
  }
574
574
  }
575
- // Account for gaps (12px per gap, n-1 gaps for n children)
576
- const gapCount = Math.max(0, siblings.length)
577
- containerWidth = parent.clientWidth - siblingsWidth - gapCount * 12
575
+ // Account for a small safety buffer (12px)
576
+ containerWidth = parent.clientWidth - siblingsWidth - 12
578
577
  } else {
579
578
  containerWidth = container.clientWidth
580
579
  }
@@ -635,7 +634,6 @@ export const Toolbar = defineComponent<ToolbarProps>({
635
634
  overflowVisibleCount.value = visibleCount
636
635
  totalSectionCount.value = toolbarChildren.length
637
636
  }
638
-
639
637
  const handleTableEnter = (e: MouseEvent) => {
640
638
  if (hideTableTimer) clearTimeout(hideTableTimer)
641
639
  const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
@@ -1337,7 +1335,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
1337
1335
  'var(--crepe-color-hover)'
1338
1336
  }}
1339
1337
  onMouseleave={(e: MouseEvent) => {
1340
- ;(e.currentTarget as HTMLElement).style.backgroundColor =
1338
+ ; (e.currentTarget as HTMLElement).style.backgroundColor =
1341
1339
  'transparent'
1342
1340
  }}
1343
1341
  >
@@ -1536,9 +1534,9 @@ export const Toolbar = defineComponent<ToolbarProps>({
1536
1534
  const fontFamily = fontState?.fontFamily
1537
1535
  return fontFamily && fontFamily !== 'mixed'
1538
1536
  ? fontFamily.split(',')[0]!.replace(/['"]/g, '') ||
1539
- (ctx
1540
- ? i18n(ctx, 'customMenu.fontDefault' as any)
1541
- : '默认')
1537
+ (ctx
1538
+ ? i18n(ctx, 'customMenu.fontDefault' as any)
1539
+ : '默认')
1542
1540
  : ctx
1543
1541
  ? i18n(ctx, 'customMenu.fontDefault' as any)
1544
1542
  : '默认'
@@ -1649,12 +1647,12 @@ export const Toolbar = defineComponent<ToolbarProps>({
1649
1647
  display: 'inline-flex',
1650
1648
  color:
1651
1649
  currentColorState.value.textColor &&
1652
- currentColorState.value.textColor !== 'mixed'
1650
+ currentColorState.value.textColor !== 'mixed'
1653
1651
  ? currentColorState.value.textColor
1654
1652
  : '#363B4C',
1655
1653
  backgroundColor:
1656
1654
  currentColorState.value.bgColor &&
1657
- currentColorState.value.bgColor !== 'mixed'
1655
+ currentColorState.value.bgColor !== 'mixed'
1658
1656
  ? currentColorState.value.bgColor
1659
1657
  : undefined,
1660
1658
  borderRadius: '4px',
@@ -1744,7 +1742,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
1744
1742
  <Fragment key={(group as any).key}>
1745
1743
  {items}
1746
1744
  {groupIndex < nonHeadingGroups.length - 1 &&
1747
- group.items.length > 0 ? (
1745
+ group.items.length > 0 ? (
1748
1746
  <div
1749
1747
  class="divider"
1750
1748
  style={{
@@ -1982,7 +1980,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
1982
1980
  mergeCellIcon,
1983
1981
  ctx
1984
1982
  ? i18n(ctx, 'customMenu.mergeCells' as any) ||
1985
- '合并单元格'
1983
+ '合并单元格'
1986
1984
  : '合并单元格',
1987
1985
  false,
1988
1986
  onMergeCells
@@ -1992,7 +1990,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
1992
1990
  splitCellIcon,
1993
1991
  ctx
1994
1992
  ? i18n(ctx, 'customMenu.splitCell' as any) ||
1995
- '拆分单元格'
1993
+ '拆分单元格'
1996
1994
  : '拆分单元格',
1997
1995
  false,
1998
1996
  onSplitCell
@@ -2120,9 +2118,9 @@ export const Toolbar = defineComponent<ToolbarProps>({
2120
2118
  boxSizing: 'border-box',
2121
2119
  border:
2122
2120
  currentColorState.value.bgColor === color ||
2123
- (color === 'transparent' &&
2124
- !currentColorState.value.bgColor &&
2125
- currentColorState.value.bgColor !== 'mixed')
2121
+ (color === 'transparent' &&
2122
+ !currentColorState.value.bgColor &&
2123
+ currentColorState.value.bgColor !== 'mixed')
2126
2124
  ? '2px solid var(--crepe-color-primary)'
2127
2125
  : '1px solid var(--crepe-color-outline-variant)',
2128
2126
  backgroundColor:
@@ -2311,13 +2309,13 @@ export const Toolbar = defineComponent<ToolbarProps>({
2311
2309
  }}
2312
2310
  onMouseenter={(e: MouseEvent) => {
2313
2311
  if (supported) {
2314
- ;(
2312
+ ; (
2315
2313
  e.currentTarget as HTMLElement
2316
2314
  ).style.backgroundColor = 'var(--crepe-color-hover)'
2317
2315
  }
2318
2316
  }}
2319
2317
  onMouseleave={(e: MouseEvent) => {
2320
- ;(e.currentTarget as HTMLElement).style.backgroundColor =
2318
+ ; (e.currentTarget as HTMLElement).style.backgroundColor =
2321
2319
  'transparent'
2322
2320
  }}
2323
2321
  >
@@ -2420,11 +2418,11 @@ export const Toolbar = defineComponent<ToolbarProps>({
2420
2418
  setFontSize(size.value)
2421
2419
  }}
2422
2420
  onMouseenter={(e: MouseEvent) => {
2423
- ;(e.currentTarget as HTMLElement).style.backgroundColor =
2421
+ ; (e.currentTarget as HTMLElement).style.backgroundColor =
2424
2422
  'var(--crepe-color-hover)'
2425
2423
  }}
2426
2424
  onMouseleave={(e: MouseEvent) => {
2427
- ;(e.currentTarget as HTMLElement).style.backgroundColor =
2425
+ ; (e.currentTarget as HTMLElement).style.backgroundColor =
2428
2426
  'transparent'
2429
2427
  }}
2430
2428
  >
@@ -2745,9 +2743,9 @@ export const Toolbar = defineComponent<ToolbarProps>({
2745
2743
  isTable
2746
2744
  ? undefined
2747
2745
  : (_e: MouseEvent) => {
2748
- item.onRun(ctx)
2749
- showOverflowMenu.value = false
2750
- },
2746
+ item.onRun(ctx)
2747
+ showOverflowMenu.value = false
2748
+ },
2751
2749
  isTable,
2752
2750
  isTable ? handleTableEnter : undefined,
2753
2751
  isTable ? handleTableLeave : undefined,