Merge branch 'main' into feature/extension-code-block-lowlight
# Conflicts: # docs/src/docPages/api/nodes/code-block-lowlight.md # docs/src/links.yaml
This commit is contained in:
@@ -3,6 +3,22 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
# [2.0.0-beta.14](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.13...@tiptap/core@2.0.0-beta.14) (2021-04-04)
|
||||
|
||||
**Note:** Version bump only for package @tiptap/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [2.0.0-beta.13](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.12...@tiptap/core@2.0.0-beta.13) (2021-04-02)
|
||||
|
||||
**Note:** Version bump only for package @tiptap/core
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# [2.0.0-beta.12](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/core@2.0.0-beta.11...@tiptap/core@2.0.0-beta.12) (2021-04-01)
|
||||
|
||||
**Note:** Version bump only for package @tiptap/core
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@tiptap/core",
|
||||
"description": "headless rich text editor",
|
||||
"version": "2.0.0-beta.12",
|
||||
"version": "2.0.0-beta.14",
|
||||
"homepage": "https://tiptap.dev",
|
||||
"keywords": [
|
||||
"tiptap",
|
||||
|
||||
@@ -94,6 +94,7 @@ export class NodeView<Component, Editor extends CoreEditor = CoreEditor> impleme
|
||||
}
|
||||
|
||||
const isInput = ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName)
|
||||
|| target.isContentEditable
|
||||
|
||||
// any input event within node views should be ignored by ProseMirror
|
||||
if (isInput) {
|
||||
|
||||
31
packages/core/src/commands/insertNode.ts
Normal file
31
packages/core/src/commands/insertNode.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { NodeType } from 'prosemirror-model'
|
||||
import getNodeType from '../helpers/getNodeType'
|
||||
import { Command, RawCommands, AnyObject } from '../types'
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands {
|
||||
insertNode: {
|
||||
/**
|
||||
* Insert a node at the current position.
|
||||
*/
|
||||
insertNode: (typeOrName: string | NodeType, attributes?: AnyObject) => Command,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const insertNode: RawCommands['insertNode'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {
|
||||
const { selection } = tr
|
||||
const type = getNodeType(typeOrName, state.schema)
|
||||
|
||||
if (!type) {
|
||||
return false
|
||||
}
|
||||
|
||||
const node = type.create(attributes)
|
||||
|
||||
if (dispatch) {
|
||||
tr.insert(selection.anchor, node)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import * as extendMarkRange from '../commands/extendMarkRange'
|
||||
import * as first from '../commands/first'
|
||||
import * as focus from '../commands/focus'
|
||||
import * as insertHTML from '../commands/insertHTML'
|
||||
import * as insertNode from '../commands/insertNode'
|
||||
import * as insertText from '../commands/insertText'
|
||||
import * as joinBackward from '../commands/joinBackward'
|
||||
import * as joinForward from '../commands/joinForward'
|
||||
@@ -58,6 +59,7 @@ export { extendMarkRange }
|
||||
export { first }
|
||||
export { focus }
|
||||
export { insertHTML }
|
||||
export { insertNode }
|
||||
export { insertText }
|
||||
export { joinBackward }
|
||||
export { joinForward }
|
||||
@@ -109,6 +111,7 @@ export const Commands = Extension.create({
|
||||
...first,
|
||||
...focus,
|
||||
...insertHTML,
|
||||
...insertNode,
|
||||
...insertText,
|
||||
...joinBackward,
|
||||
...joinForward,
|
||||
|
||||
Reference in New Issue
Block a user