@jvs-milkdown/crepe 1.2.28 → 1.2.30

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 (42) hide show
  1. package/lib/cjs/builder.js +2 -1
  2. package/lib/cjs/builder.js.map +1 -1
  3. package/lib/cjs/feature/code-mirror/index.js.map +1 -1
  4. package/lib/cjs/feature/toolbar/index.js +84 -62
  5. package/lib/cjs/feature/toolbar/index.js.map +1 -1
  6. package/lib/cjs/index.js +1121 -988
  7. package/lib/cjs/index.js.map +1 -1
  8. package/lib/esm/builder.js +2 -1
  9. package/lib/esm/builder.js.map +1 -1
  10. package/lib/esm/feature/code-mirror/index.js.map +1 -1
  11. package/lib/esm/feature/toolbar/index.js +84 -62
  12. package/lib/esm/feature/toolbar/index.js.map +1 -1
  13. package/lib/esm/index.js +1143 -1010
  14. package/lib/esm/index.js.map +1 -1
  15. package/lib/theme/common/image-block.css +5 -1
  16. package/lib/theme/common/reset.css +1 -1
  17. package/lib/theme/common/table.css +5 -0
  18. package/lib/theme/common/toolbar.css +23 -0
  19. package/lib/tsconfig.tsbuildinfo +1 -1
  20. package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
  21. package/lib/types/feature/fixed-toolbar/component.d.ts +2 -2
  22. package/lib/types/feature/fixed-toolbar/component.d.ts.map +1 -1
  23. package/lib/types/feature/fixed-toolbar/index.d.ts +2 -0
  24. package/lib/types/feature/fixed-toolbar/index.d.ts.map +1 -1
  25. package/lib/types/feature/fixed-toolbar/outline-panel.d.ts.map +1 -1
  26. package/lib/types/feature/fixed-toolbar/view-menu-state.d.ts +3 -0
  27. package/lib/types/feature/fixed-toolbar/view-menu-state.d.ts.map +1 -1
  28. package/lib/types/feature/toolbar/component.d.ts +2 -2
  29. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  30. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  31. package/package.json +4 -4
  32. package/src/feature/code-mirror/index.ts +51 -46
  33. package/src/feature/fixed-toolbar/component.tsx +203 -110
  34. package/src/feature/fixed-toolbar/index.ts +30 -8
  35. package/src/feature/fixed-toolbar/outline-panel.tsx +1 -2
  36. package/src/feature/fixed-toolbar/view-menu-state.ts +2 -0
  37. package/src/feature/toolbar/component.tsx +57 -44
  38. package/src/feature/toolbar/index.ts +9 -13
  39. package/src/theme/common/image-block.css +6 -1
  40. package/src/theme/common/reset.css +1 -1
  41. package/src/theme/common/table.css +5 -0
  42. package/src/theme/common/toolbar.css +30 -0
@@ -1,5 +1,5 @@
1
1
  import type { Ctx } from '@jvs-milkdown/kit/ctx'
2
- import type { PluginView, Selection } from '@jvs-milkdown/kit/prose/state'
2
+ import type { EditorState, PluginView } from '@jvs-milkdown/kit/prose/state'
3
3
  import type { EditorView } from '@jvs-milkdown/kit/prose/view'
4
4
 
5
5
  import { Plugin, PluginKey, TextSelection } from '@jvs-milkdown/kit/prose/state'
@@ -23,6 +23,8 @@ import type { ToolbarItem } from '../toolbar/config'
23
23
 
24
24
  import { crepeFeatureConfig } from '../../core/slice'
25
25
  import { CrepeFeature } from '../index'
26
+ import { colorPlugins } from '../toolbar/color'
27
+ import { fontPlugins } from '../toolbar/font'
26
28
  import { highlightMark } from '../toolbar/highlight-mark'
27
29
  import { underline } from '../toolbar/underline'
28
30
  import { FixedToolbarComponent } from './component'
@@ -73,6 +75,8 @@ export interface FixedToolbarConfig {
73
75
  showCover?: boolean
74
76
  coverUrl?: string
75
77
  editorWidth?: EditorWidth
78
+ showFloatingToolbar?: boolean // Keep old option deprecated just in case
79
+ fixedToolbarVisible?: boolean
76
80
  }
77
81
 
78
82
  export type FixedToolbarFeatureConfig = Partial<FixedToolbarConfig>
@@ -92,7 +96,7 @@ class FixedToolbarView implements PluginView {
92
96
  #outlineContent?: HTMLElement
93
97
  #outlineApp?: App
94
98
  #watcher?: WatchStopHandle
95
- #selection: ShallowRef<Selection>
99
+ #state: ShallowRef<EditorState>
96
100
  #show = ref(true)
97
101
  #canUndo = ref(false)
98
102
  #canRedo = ref(false)
@@ -121,6 +125,10 @@ class FixedToolbarView implements PluginView {
121
125
  if (config?.coverUrl !== undefined) viewState.coverUrl = config.coverUrl
122
126
  if (config?.editorWidth !== undefined)
123
127
  viewState.editorWidth = config.editorWidth
128
+ if (config?.showFloatingToolbar !== undefined)
129
+ viewState.fixedToolbarVisible = config.showFloatingToolbar
130
+ if (config?.fixedToolbarVisible !== undefined)
131
+ viewState.fixedToolbarVisible = config.fixedToolbarVisible
124
132
 
125
133
  // Load initial view menu state from localStorage if useLocalStorage is enabled
126
134
  if (config?.useLocalStorage) {
@@ -144,6 +152,10 @@ class FixedToolbarView implements PluginView {
144
152
  viewState.coverUrl = parsed.coverUrl
145
153
  if (parsed.editorWidth !== undefined)
146
154
  viewState.editorWidth = parsed.editorWidth
155
+ if (parsed.showFloatingToolbar !== undefined)
156
+ viewState.fixedToolbarVisible = parsed.showFloatingToolbar
157
+ if (parsed.fixedToolbarVisible !== undefined)
158
+ viewState.fixedToolbarVisible = parsed.fixedToolbarVisible
147
159
  }
148
160
  } catch (e) {
149
161
  console.error('Error loading view state from localStorage:', e)
@@ -169,6 +181,7 @@ class FixedToolbarView implements PluginView {
169
181
  showCover: newState.showCover,
170
182
  coverUrl: newState.coverUrl,
171
183
  editorWidth: newState.editorWidth,
184
+ fixedToolbarVisible: newState.fixedToolbarVisible,
172
185
  }
173
186
  localStorage.setItem('jvs-milkdown-data', JSON.stringify(merged))
174
187
  } catch (e) {
@@ -181,13 +194,13 @@ class FixedToolbarView implements PluginView {
181
194
 
182
195
  const content = document.createElement('div')
183
196
  content.className = 'milkdown-fixed-toolbar'
184
- this.#selection = shallowRef(view.state.selection)
197
+ this.#state = shallowRef(view.state)
185
198
 
186
199
  const app = createApp(FixedToolbarComponent, {
187
200
  ctx,
188
201
  hide: () => {}, // No-op for fixed toolbar
189
202
  config,
190
- selection: this.#selection,
203
+ state: this.#state,
191
204
  show: this.#show,
192
205
  canUndo: this.#canUndo,
193
206
  canRedo: this.#canRedo,
@@ -363,12 +376,19 @@ class FixedToolbarView implements PluginView {
363
376
  viewState.documentBackground,
364
377
  viewState.showCover,
365
378
  viewState.editorWidth,
379
+ viewState.fixedToolbarVisible,
366
380
  ],
367
381
  () => {
382
+ if (viewState.fixedToolbarVisible === false) {
383
+ this.#content.classList.add('collapsed')
384
+ } else {
385
+ this.#content.classList.remove('collapsed')
386
+ }
387
+ root.style.backgroundColor = ''
368
388
  if (viewState.documentBackground) {
369
- root.style.backgroundColor = viewState.documentBackground
389
+ this.#view.dom.style.backgroundColor = viewState.documentBackground
370
390
  } else {
371
- root.style.backgroundColor = ''
391
+ this.#view.dom.style.backgroundColor = ''
372
392
  }
373
393
 
374
394
  // Reset root and toolbar styles to default/full-width
@@ -395,7 +415,7 @@ class FixedToolbarView implements PluginView {
395
415
 
396
416
  const maxWidth = (editorWidthMap as any)[viewState.editorWidth]
397
417
  const isFull = maxWidth === 'none'
398
- const px = isFull ? '80px' : '0'
418
+ const px = isFull ? '80px' : '10px'
399
419
  this.#view.dom.style.maxWidth = maxWidth
400
420
  this.#view.dom.style.width = isFull ? '100%' : maxWidth
401
421
  this.#view.dom.style.margin = isFull ? '0' : '0 auto'
@@ -422,7 +442,7 @@ class FixedToolbarView implements PluginView {
422
442
  }
423
443
 
424
444
  update = (view: EditorView) => {
425
- this.#selection.value = view.state.selection
445
+ this.#state.value = view.state
426
446
  try {
427
447
  this.#canUndo.value = undo(view.state)
428
448
  this.#canRedo.value = redo(view.state)
@@ -489,5 +509,7 @@ export const fixedToolbar: DefineFeature<FixedToolbarFeatureConfig> = (
489
509
  .use(fixedToolbarConfig)
490
510
  .use(underline as any)
491
511
  .use(highlightMark as any)
512
+ .use(colorPlugins as any)
513
+ .use(fontPlugins as any)
492
514
  .use(fixedToolbarPlugin)
493
515
  }
@@ -452,8 +452,7 @@ export const OutlinePanel = defineComponent({
452
452
  width: `${state.outlineWidth}px`,
453
453
  minWidth: '200px',
454
454
  maxWidth: '400px',
455
- backgroundColor:
456
- state.documentBackground || 'var(--crepe-color-background)',
455
+ backgroundColor: 'transparent',
457
456
  borderRight: isLeft
458
457
  ? '1px solid var(--crepe-color-outline-variant, color-mix(in srgb, var(--crepe-color-outline), transparent 80%))'
459
458
  : 'none',
@@ -13,6 +13,7 @@ export interface ViewMenuState {
13
13
  showCover: boolean
14
14
  coverUrl: string
15
15
  editorWidth: EditorWidth
16
+ fixedToolbarVisible: boolean
16
17
  }
17
18
 
18
19
  export const editorWidthMap: Record<EditorWidth, string> = {
@@ -31,6 +32,7 @@ export const createViewMenuState = () =>
31
32
  showCover: false,
32
33
  coverUrl: '',
33
34
  editorWidth: 'default',
35
+ fixedToolbarVisible: true,
34
36
  })
35
37
 
36
38
  import { $ctx } from '@jvs-milkdown/kit/utils'
@@ -1,5 +1,6 @@
1
1
  import type { Ctx } from '@jvs-milkdown/kit/ctx'
2
2
  import type { Mark } from '@jvs-milkdown/kit/prose/model'
3
+ import type { EditorState } from '@jvs-milkdown/kit/prose/state'
3
4
 
4
5
  import { Icon } from '@jvs-milkdown/kit/component'
5
6
  import {
@@ -14,11 +15,7 @@ import {
14
15
  selectTextNearPosCommand,
15
16
  } from '@jvs-milkdown/kit/preset/commonmark'
16
17
  import { createTable, mergeCellsCommand } from '@jvs-milkdown/kit/preset/gfm'
17
- import {
18
- type Selection,
19
- TextSelection,
20
- NodeSelection,
21
- } from '@jvs-milkdown/kit/prose/state'
18
+ import { TextSelection, NodeSelection } from '@jvs-milkdown/kit/prose/state'
22
19
  import {
23
20
  mergeCells,
24
21
  splitCell,
@@ -144,7 +141,7 @@ type ToolbarProps = {
144
141
  ctx: Ctx
145
142
  hide: () => void
146
143
  show: Ref<boolean>
147
- selection: ShallowRef<Selection>
144
+ state: ShallowRef<EditorState>
148
145
  config?: ToolbarFeatureConfig
149
146
  isFixed?: boolean
150
147
  }
@@ -167,7 +164,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
167
164
  ctx: { type: Object as any, required: true },
168
165
  hide: { type: Function as any, required: true },
169
166
  show: { type: Object as any, required: true },
170
- selection: { type: Object as any, required: true },
167
+ state: { type: Object as any, required: true },
171
168
  config: { type: Object as any, required: false },
172
169
  isFixed: { type: Boolean, required: false },
173
170
  },
@@ -903,7 +900,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
903
900
  }
904
901
 
905
902
  function checkActive(checker: ToolbarItem['active']) {
906
- keepAlive(props.selection.value)
903
+ keepAlive(props.state, props.state?.value)
907
904
  const status = ctx?.get(editorCtx)?.status
908
905
  if (status !== EditorStatus.Created) return false
909
906
  return checker(ctx)
@@ -912,7 +909,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
912
909
  const blockGroups = computed(() => getBlockGroups('', undefined, ctx))
913
910
 
914
911
  const activeBlockItem = computed(() => {
915
- keepAlive(props.selection.value)
912
+ keepAlive(props.state, props.state?.value)
916
913
  const status = ctx?.get(editorCtx)?.status
917
914
  if (status !== EditorStatus.Created) return null
918
915
 
@@ -957,7 +954,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
957
954
  })
958
955
 
959
956
  const currentAlignIndent = computed(() => {
960
- keepAlive(props.selection.value)
957
+ keepAlive(props.state, props.state?.value)
961
958
  const status = ctx?.get(editorCtx)?.status
962
959
  if (status !== EditorStatus.Created) return { align: 'left', indent: 0 }
963
960
  const view = ctx.get(editorViewCtx)
@@ -1052,14 +1049,14 @@ export const Toolbar = defineComponent<ToolbarProps>({
1052
1049
  }
1053
1050
 
1054
1051
  const canMerge = computed(() => {
1055
- keepAlive(props.selection.value)
1052
+ keepAlive(props.state, props.state?.value)
1056
1053
  const view = ctx?.get(editorViewCtx)
1057
1054
  if (!view) return false
1058
1055
  return mergeCells(view.state)
1059
1056
  })
1060
1057
 
1061
1058
  const canSplit = computed(() => {
1062
- keepAlive(props.selection.value)
1059
+ keepAlive(props.state, props.state?.value)
1063
1060
  const view = ctx?.get(editorViewCtx)
1064
1061
  if (!view) return false
1065
1062
  return splitCell(view.state)
@@ -1136,7 +1133,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
1136
1133
  }
1137
1134
 
1138
1135
  const currentColorState = computed(() => {
1139
- keepAlive(props.selection.value)
1136
+ keepAlive(props.state, props.state?.value)
1140
1137
  const status = ctx?.get(editorCtx)?.status
1141
1138
  if (status !== EditorStatus.Created)
1142
1139
  return { textColor: null, bgColor: null }
@@ -1145,8 +1142,8 @@ export const Toolbar = defineComponent<ToolbarProps>({
1145
1142
  const { state } = view
1146
1143
  const schema = ctx.get(schemaCtx)
1147
1144
 
1148
- const tcHasMark = schema.marks[textColorSchema.id]
1149
- const bcHasMark = schema.marks[bgColorSchema.id]
1145
+ const tcHasMark = schema.marks['textColor']
1146
+ const bcHasMark = schema.marks['bgColor']
1150
1147
 
1151
1148
  if (!tcHasMark || !bcHasMark) return { textColor: null, bgColor: null }
1152
1149
 
@@ -1204,8 +1201,8 @@ export const Toolbar = defineComponent<ToolbarProps>({
1204
1201
  const { from, to, empty } = state.selection
1205
1202
  const schema = ctx.get(schemaCtx)
1206
1203
 
1207
- const tcHasMark = schema.marks[textColorSchema.id]
1208
- const bcHasMark = schema.marks[bgColorSchema.id]
1204
+ const tcHasMark = schema.marks['textColor']
1205
+ const bcHasMark = schema.marks['bgColor']
1209
1206
 
1210
1207
  if (!tcHasMark || !bcHasMark) return
1211
1208
 
@@ -1227,7 +1224,7 @@ export const Toolbar = defineComponent<ToolbarProps>({
1227
1224
  }
1228
1225
 
1229
1226
  const currentFontState = computed(() => {
1230
- keepAlive(props.selection.value)
1227
+ keepAlive(props.state, props.state?.value)
1231
1228
  const status = ctx?.get(editorCtx)?.status
1232
1229
  if (status !== EditorStatus.Created)
1233
1230
  return { fontFamily: null, fontSize: null }
@@ -1236,24 +1233,32 @@ export const Toolbar = defineComponent<ToolbarProps>({
1236
1233
  const { state } = view
1237
1234
  const schema = ctx.get(schemaCtx)
1238
1235
 
1239
- const ffHasMark = schema.marks[fontFamilySchema.id]
1240
- const fsHasMark = schema.marks[fontSizeSchema.id]
1236
+ const ffHasMark = schema.marks['fontFamily']
1237
+ const fsHasMark = schema.marks['fontSize']
1241
1238
 
1242
- if (!ffHasMark || !fsHasMark) return { fontFamily: null, fontSize: null }
1239
+ if (!ffHasMark || !fsHasMark) {
1240
+ return { fontFamily: null, fontSize: null }
1241
+ }
1243
1242
 
1244
1243
  const ffType = fontFamilySchema.type(ctx)
1245
1244
  const fsType = fontSizeSchema.type(ctx)
1246
1245
  const { $cursor, ranges } = state.selection as any
1247
1246
 
1247
+ let result: { fontFamily: string | null; fontSize: string | null } = {
1248
+ fontFamily: null,
1249
+ fontSize: null,
1250
+ }
1248
1251
  if ($cursor) {
1249
- let fontFamily = null
1250
- let fontSize = null
1252
+ let fontFamily: string | null = null
1253
+ let fontSize: string | null = null
1251
1254
  const marks = state.storedMarks || $cursor.marks()
1252
1255
  for (const mark of marks) {
1253
- if (mark.type === ffType) fontFamily = mark.attrs.fontFamily
1254
- if (mark.type === fsType) fontSize = mark.attrs.fontSize
1256
+ if (mark.type === ffType)
1257
+ fontFamily = (mark.attrs.fontFamily as string | null) || null
1258
+ if (mark.type === fsType)
1259
+ fontSize = (mark.attrs.fontSize as string | null) || null
1255
1260
  }
1256
- return { fontFamily, fontSize }
1261
+ result = { fontFamily, fontSize }
1257
1262
  } else {
1258
1263
  const fontFamilies = new Set<string | null>()
1259
1264
  const fontSizes = new Set<string | null>()
@@ -1264,19 +1269,24 @@ export const Toolbar = defineComponent<ToolbarProps>({
1264
1269
  if (node.isText) {
1265
1270
  const ffMark = ffType.isInSet(node.marks)
1266
1271
  const fsMark = fsType.isInSet(node.marks)
1267
- fontFamilies.add(ffMark ? ffMark.attrs.fontFamily : null)
1268
- fontSizes.add(fsMark ? fsMark.attrs.fontSize : null)
1272
+ fontFamilies.add(
1273
+ ffMark ? (ffMark.attrs.fontFamily as string | null) : null
1274
+ )
1275
+ fontSizes.add(
1276
+ fsMark ? (fsMark.attrs.fontSize as string | null) : null
1277
+ )
1269
1278
  }
1270
1279
  })
1271
1280
  }
1272
1281
 
1273
1282
  const fontFamily =
1274
- fontFamilies.size === 1 ? Array.from(fontFamilies)[0] : 'mixed'
1283
+ fontFamilies.size === 1 ? Array.from(fontFamilies)[0]! : 'mixed'
1275
1284
  const fontSize =
1276
- fontSizes.size === 1 ? Array.from(fontSizes)[0] : 'mixed'
1285
+ fontSizes.size === 1 ? Array.from(fontSizes)[0]! : 'mixed'
1277
1286
 
1278
- return { fontFamily, fontSize }
1287
+ result = { fontFamily, fontSize }
1279
1288
  }
1289
+ return result
1280
1290
  })
1281
1291
 
1282
1292
  const setFontFamily = (fontFamily: string | null) => {
@@ -1521,15 +1531,18 @@ export const Toolbar = defineComponent<ToolbarProps>({
1521
1531
  color: '#363B4C',
1522
1532
  }}
1523
1533
  >
1524
- {currentFontState.value.fontFamily &&
1525
- currentFontState.value.fontFamily !== 'mixed'
1526
- ? currentFontState.value.fontFamily
1527
- .split(',')[0]
1528
- .replace(/['"]/g, '') ||
1529
- (ctx ? i18n(ctx, 'customMenu.fontDefault' as any) : '默认')
1530
- : ctx
1531
- ? i18n(ctx, 'customMenu.fontDefault' as any)
1532
- : '默认'}
1534
+ {(() => {
1535
+ const fontState = currentFontState.value
1536
+ const fontFamily = fontState?.fontFamily
1537
+ return fontFamily && fontFamily !== 'mixed'
1538
+ ? fontFamily.split(',')[0]!.replace(/['"]/g, '') ||
1539
+ (ctx
1540
+ ? i18n(ctx, 'customMenu.fontDefault' as any)
1541
+ : '默认')
1542
+ : ctx
1543
+ ? i18n(ctx, 'customMenu.fontDefault' as any)
1544
+ : '默认'
1545
+ })()}
1533
1546
  </span>
1534
1547
  <span
1535
1548
  style={{
@@ -1558,10 +1571,10 @@ export const Toolbar = defineComponent<ToolbarProps>({
1558
1571
  }}
1559
1572
  >
1560
1573
  <span style={{ fontSize: '13px', color: '#363B4C' }}>
1561
- {currentFontState.value.fontSize &&
1562
- currentFontState.value.fontSize !== 'mixed'
1563
- ? currentFontState.value.fontSize
1564
- : '16px'}
1574
+ {(() => {
1575
+ const fs = currentFontState.value.fontSize
1576
+ return fs && fs !== 'mixed' ? fs : '16px'
1577
+ })()}
1565
1578
  </span>
1566
1579
  <span
1567
1580
  style={{
@@ -1,9 +1,5 @@
1
1
  import type { Ctx } from '@jvs-milkdown/kit/ctx'
2
- import type {
3
- EditorState,
4
- PluginView,
5
- Selection,
6
- } from '@jvs-milkdown/kit/prose/state'
2
+ import type { EditorState, PluginView } from '@jvs-milkdown/kit/prose/state'
7
3
  import type { EditorView } from '@jvs-milkdown/kit/prose/view'
8
4
 
9
5
  import { editorViewOptionsCtx } from '@jvs-milkdown/kit/core'
@@ -21,14 +17,14 @@ import type { ToolbarItem } from './config'
21
17
 
22
18
  import { crepeFeatureConfig } from '../../core/slice'
23
19
  import { CrepeFeature } from '../../feature'
24
- import { colorPlugins } from './color'
25
- import { Toolbar } from './component'
26
- import { highlightMark } from './highlight-mark'
27
- import { underline } from './underline'
28
20
  import {
29
21
  getIsAnyPopupOpen,
30
22
  addPopupChangeListener,
31
23
  } from '../../utils/fixed-toolbar-popup-state'
24
+ import { colorPlugins } from './color'
25
+ import { Toolbar } from './component'
26
+ import { highlightMark } from './highlight-mark'
27
+ import { underline } from './underline'
32
28
 
33
29
  interface ToolbarConfig {
34
30
  boldIcon: string
@@ -56,7 +52,7 @@ class ToolbarView implements PluginView {
56
52
  #tooltipProvider: TooltipProvider
57
53
  #content: HTMLElement
58
54
  #app: App
59
- #selection: ShallowRef<Selection>
55
+ #state: ShallowRef<EditorState>
60
56
  #show = ref(false)
61
57
  #mousePressed = false
62
58
  #removePopupListener: (() => void) | undefined
@@ -65,12 +61,12 @@ class ToolbarView implements PluginView {
65
61
  constructor(ctx: Ctx, view: EditorView, config?: ToolbarFeatureConfig) {
66
62
  const content = document.createElement('div')
67
63
  content.className = 'milkdown-toolbar'
68
- this.#selection = shallowRef(view.state.selection)
64
+ this.#state = shallowRef(view.state)
69
65
  const app = createApp(Toolbar, {
70
66
  ctx,
71
67
  hide: this.hide,
72
68
  config,
73
- selection: this.#selection,
69
+ state: this.#state,
74
70
  show: this.#show,
75
71
  })
76
72
  app.mount(content)
@@ -161,7 +157,7 @@ class ToolbarView implements PluginView {
161
157
 
162
158
  update = (view: EditorView, prevState?: EditorState) => {
163
159
  this.#tooltipProvider.update(view, prevState)
164
- this.#selection.value = view.state.selection
160
+ this.#state.value = view.state
165
161
  }
166
162
 
167
163
  destroy = () => {
@@ -155,7 +155,7 @@
155
155
  position: relative;
156
156
 
157
157
  &:hover {
158
- z-index: 120;
158
+ z-index: 210;
159
159
  }
160
160
 
161
161
  & > .image-wrapper {
@@ -325,6 +325,11 @@
325
325
  &:hover {
326
326
  background: var(--crepe-color-hover);
327
327
  }
328
+
329
+ &.active {
330
+ background: var(--crepe-color-selected);
331
+ color: var(--crepe-color-primary);
332
+ }
328
333
  }
329
334
 
330
335
  .image-wrapper .image-resize-handle {
@@ -36,7 +36,7 @@
36
36
 
37
37
  font-family: var(--crepe-font-default);
38
38
  color: var(--crepe-color-on-background);
39
- background: var(--crepe-color-background);
39
+ background: transparent;
40
40
 
41
41
  .milkdown-icon {
42
42
  display: inline-flex;
@@ -4,6 +4,11 @@
4
4
  .milkdown-table-block {
5
5
  display: block;
6
6
  margin: 12px 0 4px 0;
7
+ position: relative;
8
+
9
+ &:hover {
10
+ z-index: 210;
11
+ }
7
12
 
8
13
  table {
9
14
  width: auto;
@@ -100,6 +100,36 @@
100
100
  min-width: 0;
101
101
  max-width: 100%;
102
102
  box-sizing: border-box;
103
+ transition: all 0.2s ease-in-out;
104
+
105
+ &.collapsed {
106
+ background: transparent !important;
107
+ border-bottom: none !important;
108
+ height: 0 !important;
109
+ min-height: 0 !important;
110
+ padding: 0 !important;
111
+ overflow: visible !important;
112
+ pointer-events: none;
113
+ }
114
+
115
+ .fixed-toolbar-expand-btn {
116
+ svg {
117
+ width: 20px !important;
118
+ height: 20px !important;
119
+ path {
120
+ fill: var(--crepe-color-on-surface, #363b4c);
121
+ }
122
+ }
123
+ }
124
+
125
+ .toolbar-item.collapse-btn {
126
+ --toolbar-icon-color: #363b4c;
127
+ svg {
128
+ path {
129
+ fill: currentColor !important;
130
+ }
131
+ }
132
+ }
103
133
 
104
134
  .toolbar-shortcut-btn {
105
135
  display: flex;