@jvs-milkdown/crepe 1.2.8 → 1.2.9

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@jvs-milkdown/crepe",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "keywords": [
5
5
  "crepe",
6
6
  "editor",
@@ -97,9 +97,9 @@
97
97
  "@codemirror/theme-one-dark": "^6.1.2",
98
98
  "@codemirror/view": "^6.26.0",
99
99
  "@floating-ui/dom": "^1.7.6",
100
- "@jvs-milkdown/kit": "^1.2.8",
101
- "@jvs-milkdown/prose": "^1.2.8",
102
- "@jvs-milkdown/utils": "^1.2.8",
100
+ "@jvs-milkdown/kit": "^1.2.9",
101
+ "@jvs-milkdown/prose": "^1.2.9",
102
+ "@jvs-milkdown/utils": "^1.2.9",
103
103
  "@types/lodash-es": "^4.17.12",
104
104
  "clsx": "^2.0.0",
105
105
  "codemirror": "^6.0.1",
@@ -12,6 +12,8 @@ import {
12
12
 
13
13
  import type { FixedToolbarConfig } from './index'
14
14
 
15
+ import { editorViewCtx } from '@jvs-milkdown/kit/core'
16
+
15
17
  import { builtInCoverImages, randomCover } from './cover-defaults'
16
18
  import { viewMenuStateCtx, editorWidthMap } from './view-menu-state'
17
19
 
@@ -283,6 +285,23 @@ export const DocumentHeader = defineComponent({
283
285
  title.value = (e.target as HTMLTextAreaElement).value
284
286
  adjustTitleHeight()
285
287
  }}
288
+ onKeydown={(e: KeyboardEvent) => {
289
+ if (e.key !== 'Enter') return
290
+ e.preventDefault()
291
+ if (e.ctrlKey || e.metaKey) {
292
+ const target = e.target as HTMLTextAreaElement
293
+ const start = target.selectionStart
294
+ const end = target.selectionEnd
295
+ title.value = title.value.slice(0, start) + '\n' + title.value.slice(end)
296
+ requestAnimationFrame(() => {
297
+ target.selectionStart = target.selectionEnd = start + 1
298
+ adjustTitleHeight()
299
+ })
300
+ } else {
301
+ const view = props.ctx.get(editorViewCtx)
302
+ view?.focus()
303
+ }
304
+ }}
286
305
  rows={1}
287
306
  style={{
288
307
  width: '100%',