@jvs-milkdown/crepe 1.2.7 → 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/lib/cjs/builder.js.map +1 -1
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/code-mirror/index.js.map +1 -1
- package/lib/cjs/feature/cursor/index.js.map +1 -1
- package/lib/cjs/feature/image-block/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -1
- package/lib/cjs/feature/list-item/index.js.map +1 -1
- package/lib/cjs/feature/placeholder/index.js.map +1 -1
- package/lib/cjs/feature/table/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +47 -30
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/builder.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/code-mirror/index.js.map +1 -1
- package/lib/esm/feature/cursor/index.js.map +1 -1
- package/lib/esm/feature/image-block/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/feature/link-tooltip/index.js.map +1 -1
- package/lib/esm/feature/list-item/index.js.map +1 -1
- package/lib/esm/feature/placeholder/index.js.map +1 -1
- package/lib/esm/feature/table/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +47 -30
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/fixed-toolbar/config.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/feature/fixed-toolbar/config.ts +32 -29
- package/src/feature/fixed-toolbar/document-header.tsx +19 -0
- package/src/feature/index.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAgChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAkDxD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,EAClC,OAAO,CAAC,EAAE,yBAAyB,EACnC,GAAG,CAAC,EAAE,GAAG;;;;;;;;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/feature/fixed-toolbar/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAgChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAkDxD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,YAAY,CAAC,WAAW,CAAC,EAClC,OAAO,CAAC,EAAE,yBAAyB,EACnC,GAAG,CAAC,EAAE,GAAG;;;;;;;;IAodV"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jvs-milkdown/crepe",
|
|
3
|
-
"version": "1.2.
|
|
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.
|
|
101
|
-
"@jvs-milkdown/prose": "^1.2.
|
|
102
|
-
"@jvs-milkdown/utils": "^1.2.
|
|
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",
|
|
@@ -368,6 +368,38 @@ export function buildDefaultFixedToolbar(
|
|
|
368
368
|
})
|
|
369
369
|
|
|
370
370
|
const blockGroup = builder.addGroup('block', 'Block')
|
|
371
|
+
|
|
372
|
+
if (isTableEnabled) {
|
|
373
|
+
blockGroup.addItem('table', {
|
|
374
|
+
label: ctx ? i18n(ctx, 'menu.item.table') : 'Table',
|
|
375
|
+
icon: tableIcon,
|
|
376
|
+
active: () => false,
|
|
377
|
+
onRun: (ctx) => {
|
|
378
|
+
const commands = ctx.get(commandsCtx)
|
|
379
|
+
const view = ctx.get(editorViewCtx)
|
|
380
|
+
const { from } = view.state.selection
|
|
381
|
+
commands.call(addBlockTypeCommand.key, {
|
|
382
|
+
nodeType: createTable(ctx, 3, 3),
|
|
383
|
+
})
|
|
384
|
+
commands.call(selectTextNearPosCommand.key, { pos: from })
|
|
385
|
+
},
|
|
386
|
+
})
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (isImageBlockEnabled) {
|
|
390
|
+
blockGroup.addItem('image', {
|
|
391
|
+
label: ctx ? i18n(ctx, 'menu.item.image') : 'Image',
|
|
392
|
+
icon: imageIcon,
|
|
393
|
+
active: () => false,
|
|
394
|
+
onRun: (ctx) => {
|
|
395
|
+
const commands = ctx.get(commandsCtx)
|
|
396
|
+
commands.call(addBlockTypeCommand.key, {
|
|
397
|
+
nodeType: imageBlockSchema.type(ctx),
|
|
398
|
+
})
|
|
399
|
+
},
|
|
400
|
+
})
|
|
401
|
+
}
|
|
402
|
+
|
|
371
403
|
blockGroup
|
|
372
404
|
.addItem('quote', {
|
|
373
405
|
label: ctx ? i18n(ctx, 'menu.item.quote') : 'Quote',
|
|
@@ -440,19 +472,6 @@ export function buildDefaultFixedToolbar(
|
|
|
440
472
|
},
|
|
441
473
|
})
|
|
442
474
|
|
|
443
|
-
if (isImageBlockEnabled) {
|
|
444
|
-
blockGroup.addItem('image', {
|
|
445
|
-
label: ctx ? i18n(ctx, 'menu.item.image') : 'Image',
|
|
446
|
-
icon: imageIcon,
|
|
447
|
-
active: () => false,
|
|
448
|
-
onRun: (ctx) => {
|
|
449
|
-
const commands = ctx.get(commandsCtx)
|
|
450
|
-
commands.call(addBlockTypeCommand.key, {
|
|
451
|
-
nodeType: imageBlockSchema.type(ctx),
|
|
452
|
-
})
|
|
453
|
-
},
|
|
454
|
-
})
|
|
455
|
-
}
|
|
456
475
|
|
|
457
476
|
if (isAttachmentEnabled) {
|
|
458
477
|
blockGroup.addItem('attachment', {
|
|
@@ -513,22 +532,6 @@ export function buildDefaultFixedToolbar(
|
|
|
513
532
|
},
|
|
514
533
|
})
|
|
515
534
|
|
|
516
|
-
if (isTableEnabled) {
|
|
517
|
-
blockGroup.addItem('table', {
|
|
518
|
-
label: ctx ? i18n(ctx, 'menu.item.table') : 'Table',
|
|
519
|
-
icon: tableIcon,
|
|
520
|
-
active: () => false,
|
|
521
|
-
onRun: (ctx) => {
|
|
522
|
-
const commands = ctx.get(commandsCtx)
|
|
523
|
-
const view = ctx.get(editorViewCtx)
|
|
524
|
-
const { from } = view.state.selection
|
|
525
|
-
commands.call(addBlockTypeCommand.key, {
|
|
526
|
-
nodeType: createTable(ctx, 3, 3),
|
|
527
|
-
})
|
|
528
|
-
commands.call(selectTextNearPosCommand.key, { pos: from })
|
|
529
|
-
},
|
|
530
|
-
})
|
|
531
|
-
}
|
|
532
535
|
|
|
533
536
|
if (isLatexEnabled) {
|
|
534
537
|
blockGroup.addItem('math-block', {
|
|
@@ -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%',
|
package/src/feature/index.ts
CHANGED
|
@@ -75,7 +75,7 @@ export const defaultFeatures: Record<CrepeFeature, boolean> = {
|
|
|
75
75
|
[CrepeFeature.BlockEdit]: true,
|
|
76
76
|
[CrepeFeature.Placeholder]: true,
|
|
77
77
|
[CrepeFeature.Toolbar]: true,
|
|
78
|
-
[CrepeFeature.FixedToolbar]:
|
|
78
|
+
[CrepeFeature.FixedToolbar]: true,
|
|
79
79
|
[CrepeFeature.CodeMirror]: true,
|
|
80
80
|
[CrepeFeature.Table]: true,
|
|
81
81
|
[CrepeFeature.Latex]: true,
|