@tiptap/core 2.0.0-beta.203 → 2.0.0-beta.205
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/dist/packages/core/src/commands/deleteCurrentNode.d.ts +12 -0
- package/dist/packages/core/src/commands/index.d.ts +2 -2
- package/dist/packages/core/src/commands/join.d.ts +33 -0
- package/dist/packages/core/src/types.d.ts +1 -0
- package/dist/tiptap-core.cjs +33 -2
- package/dist/tiptap-core.cjs.map +1 -1
- package/dist/{tiptap-core.mjs → tiptap-core.esm.js} +35 -4
- package/dist/tiptap-core.esm.js.map +1 -0
- package/dist/tiptap-core.umd.js +33 -2
- package/dist/tiptap-core.umd.js.map +1 -1
- package/package.json +13 -4
- package/src/commands/deleteCurrentNode.ts +41 -0
- package/src/commands/index.ts +2 -2
- package/src/commands/join.ts +50 -0
- package/src/extensions/keymap.ts +1 -0
- package/src/types.ts +2 -0
- package/dist/packages/core/src/commands/joinBackward.d.ts +0 -12
- package/dist/packages/core/src/commands/joinForward.d.ts +0 -12
- package/dist/tiptap-core.mjs.map +0 -1
- package/src/commands/joinBackward.ts +0 -18
- package/src/commands/joinForward.ts +0 -18
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/core",
|
|
3
3
|
"description": "headless rich text editor",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.205",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -19,19 +19,28 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/packages/core/src/index.d.ts",
|
|
22
|
-
"import": "./dist/tiptap-core.
|
|
22
|
+
"import": "./dist/tiptap-core.esm.js",
|
|
23
23
|
"require": "./dist/tiptap-core.cjs"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"main": "dist/tiptap-core.cjs",
|
|
27
27
|
"umd": "dist/tiptap-core.umd.js",
|
|
28
|
-
"module": "dist/tiptap-core.
|
|
28
|
+
"module": "dist/tiptap-core.esm.js",
|
|
29
29
|
"types": "dist/packages/core/src/index.d.ts",
|
|
30
30
|
"files": [
|
|
31
31
|
"src",
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
|
-
"
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"prosemirror-commands": "^1.3.1",
|
|
36
|
+
"prosemirror-keymap": "^1.2.0",
|
|
37
|
+
"prosemirror-model": "^1.18.1",
|
|
38
|
+
"prosemirror-schema-list": "^1.2.2",
|
|
39
|
+
"prosemirror-state": "^1.4.1",
|
|
40
|
+
"prosemirror-transform": "^1.7.0",
|
|
41
|
+
"prosemirror-view": "^1.28.2"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
35
44
|
"prosemirror-commands": "^1.3.1",
|
|
36
45
|
"prosemirror-keymap": "^1.2.0",
|
|
37
46
|
"prosemirror-model": "^1.18.1",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { RawCommands } from '../types'
|
|
2
|
+
|
|
3
|
+
declare module '@tiptap/core' {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
deleteCurrentNode: {
|
|
6
|
+
/**
|
|
7
|
+
* Delete the node that currently has the selection anchor.
|
|
8
|
+
*/
|
|
9
|
+
deleteCurrentNode: () => ReturnType,
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const deleteCurrentNode: RawCommands['deleteCurrentNode'] = () => ({ tr, dispatch }) => {
|
|
15
|
+
const { selection } = tr
|
|
16
|
+
const currentNode = selection.$anchor.node()
|
|
17
|
+
|
|
18
|
+
// if there is content inside the current node, break out of this command
|
|
19
|
+
if (currentNode.content.size > 0) {
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const $pos = tr.selection.$anchor
|
|
24
|
+
|
|
25
|
+
for (let depth = $pos.depth; depth > 0; depth -= 1) {
|
|
26
|
+
const node = $pos.node(depth)
|
|
27
|
+
|
|
28
|
+
if (node.type === currentNode.type) {
|
|
29
|
+
if (dispatch) {
|
|
30
|
+
const from = $pos.before(depth)
|
|
31
|
+
const to = $pos.after(depth)
|
|
32
|
+
|
|
33
|
+
tr.delete(from, to).scrollIntoView()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return false
|
|
41
|
+
}
|
package/src/commands/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './clearContent'
|
|
|
3
3
|
export * from './clearNodes'
|
|
4
4
|
export * from './command'
|
|
5
5
|
export * from './createParagraphNear'
|
|
6
|
+
export * from './deleteCurrentNode'
|
|
6
7
|
export * from './deleteNode'
|
|
7
8
|
export * from './deleteRange'
|
|
8
9
|
export * from './deleteSelection'
|
|
@@ -14,8 +15,7 @@ export * from './focus'
|
|
|
14
15
|
export * from './forEach'
|
|
15
16
|
export * from './insertContent'
|
|
16
17
|
export * from './insertContentAt'
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './joinForward'
|
|
18
|
+
export * from './join'
|
|
19
19
|
export * from './keyboardShortcut'
|
|
20
20
|
export * from './lift'
|
|
21
21
|
export * from './liftEmptyBlock'
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
joinBackward as originalJoinBackward, joinDown as originalJoinDown, joinForward as originalJoinForward, joinUp as originalJoinUp,
|
|
3
|
+
} from 'prosemirror-commands'
|
|
4
|
+
|
|
5
|
+
import { RawCommands } from '../types'
|
|
6
|
+
|
|
7
|
+
declare module '@tiptap/core' {
|
|
8
|
+
interface Commands<ReturnType> {
|
|
9
|
+
joinUp: {
|
|
10
|
+
/**
|
|
11
|
+
* Join two nodes Up.
|
|
12
|
+
*/
|
|
13
|
+
joinUp: () => ReturnType,
|
|
14
|
+
}
|
|
15
|
+
joinDown: {
|
|
16
|
+
/**
|
|
17
|
+
* Join two nodes Down.
|
|
18
|
+
*/
|
|
19
|
+
joinDown: () => ReturnType,
|
|
20
|
+
}
|
|
21
|
+
joinBackward: {
|
|
22
|
+
/**
|
|
23
|
+
* Join two nodes Backwards.
|
|
24
|
+
*/
|
|
25
|
+
joinBackward: () => ReturnType,
|
|
26
|
+
}
|
|
27
|
+
joinForward: {
|
|
28
|
+
/**
|
|
29
|
+
* Join two nodes Forwards.
|
|
30
|
+
*/
|
|
31
|
+
joinForward: () => ReturnType,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const joinUp: RawCommands['joinUp'] = () => ({ state, dispatch }) => {
|
|
37
|
+
return originalJoinUp(state, dispatch)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const joinDown: RawCommands['joinDown'] = () => ({ state, dispatch }) => {
|
|
41
|
+
return originalJoinDown(state, dispatch)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const joinBackward: RawCommands['joinBackward'] = () => ({ state, dispatch }) => {
|
|
45
|
+
return originalJoinBackward(state, dispatch)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const joinForward: RawCommands['joinForward'] = () => ({ state, dispatch }) => {
|
|
49
|
+
return originalJoinForward(state, dispatch)
|
|
50
|
+
}
|
package/src/extensions/keymap.ts
CHANGED
|
@@ -37,6 +37,7 @@ export const Keymap = Extension.create({
|
|
|
37
37
|
|
|
38
38
|
const handleDelete = () => this.editor.commands.first(({ commands }) => [
|
|
39
39
|
() => commands.deleteSelection(),
|
|
40
|
+
() => commands.deleteCurrentNode(),
|
|
40
41
|
() => commands.joinForward(),
|
|
41
42
|
() => commands.selectNodeForward(),
|
|
42
43
|
])
|
package/src/types.ts
CHANGED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RawCommands } from '../types';
|
|
2
|
-
declare module '@tiptap/core' {
|
|
3
|
-
interface Commands<ReturnType> {
|
|
4
|
-
joinBackward: {
|
|
5
|
-
/**
|
|
6
|
-
* Join two nodes backward.
|
|
7
|
-
*/
|
|
8
|
-
joinBackward: () => ReturnType;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare const joinBackward: RawCommands['joinBackward'];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RawCommands } from '../types';
|
|
2
|
-
declare module '@tiptap/core' {
|
|
3
|
-
interface Commands<ReturnType> {
|
|
4
|
-
joinForward: {
|
|
5
|
-
/**
|
|
6
|
-
* Join two nodes forward.
|
|
7
|
-
*/
|
|
8
|
-
joinForward: () => ReturnType;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export declare const joinForward: RawCommands['joinForward'];
|