diff --git a/docs/src/docPages/api/commands.md b/docs/src/docPages/api/commands.md index 66c210c85..fcbb5fab8 100644 --- a/docs/src/docPages/api/commands.md +++ b/docs/src/docPages/api/commands.md @@ -154,11 +154,12 @@ export default () => ({ commands }) => { Have a look at all of the core commands listed below. They should give you a good first impression of what’s possible. ### Content -| Command | Description | Links | -| ---------------- | -------------------------------------------------------- | ------------------------------------ | -| .clearContent() | Clear the whole document. | [More](/api/commands/clear-content) | -| .insertContent() | Insert a node or string of HTML at the current position. | [More](/api/commands/insert-content) | -| .setContent() | Replace the whole document with new content. | [More](/api/commands/set-content) | +| Command | Description | Links | +| ------------------ | -------------------------------------------------------- | --------------------------------------- | +| .clearContent() | Clear the whole document. | [More](/api/commands/clear-content) | +| .insertContent() | Insert a node or string of HTML at the current position. | [More](/api/commands/insert-content) | +| .insertContentAt() | Insert a node or string of HTML at a specific position. | [More](/api/commands/insert-content-at) | +| .setContent() | Replace the whole document with new content. | [More](/api/commands/set-content) | ### Nodes & Marks | Command | Description | Links | @@ -172,8 +173,6 @@ Have a look at all of the core commands listed below. They should give you a goo | .lift() | Removes an existing wrap. | [More](/api/commands/lift) | | .liftEmptyBlock() | Lift block if empty. | [More](/api/commands/lift-empty-block) | | .newlineInCode() | Add a newline character in code. | [More](/api/commands/newline-in-code) | -| .replace() | Replaces text with a node. | [More](/api/commands/replace) | -| .replaceRange() | Replaces text with a node within a range. | [More](/api/commands/replace-range) | | .resetAttributes() | Resets some node or mark attributes to the default value. | [More](/api/commands/reset-attributes) | | .setMark() | Add a mark with new attributes. | [More](/api/commands/set-mark) | | .setNode() | Replace a given range with a node. | [More](/api/commands/set-node) | diff --git a/docs/src/docPages/api/commands/replace-range.md b/docs/src/docPages/api/commands/insert-content-at.md similarity index 52% rename from docs/src/docPages/api/commands/replace-range.md rename to docs/src/docPages/api/commands/insert-content-at.md index 85c068ecf..2335641af 100644 --- a/docs/src/docPages/api/commands/replace-range.md +++ b/docs/src/docPages/api/commands/insert-content-at.md @@ -1,3 +1,3 @@ -# replaceRange +# insertContentAt diff --git a/docs/src/docPages/api/commands/replace.md b/docs/src/docPages/api/commands/replace.md deleted file mode 100644 index 3c6da44cf..000000000 --- a/docs/src/docPages/api/commands/replace.md +++ /dev/null @@ -1,3 +0,0 @@ -# replace - - diff --git a/docs/src/links.yaml b/docs/src/links.yaml index bc5e2b5b3..a1afe6c02 100644 --- a/docs/src/links.yaml +++ b/docs/src/links.yaml @@ -157,6 +157,9 @@ type: draft - title: insertContent link: /api/commands/insert-content + - title: insertContentAt + link: /api/commands/insert-content-at + type: draft - title: joinBackward link: /api/commands/join-backward type: draft @@ -178,12 +181,6 @@ - title: newlineInCode link: /api/commands/newline-in-code type: draft - - title: replaceRange - link: /api/commands/replace-range - type: draft - - title: replace - link: /api/commands/replace - type: draft - title: resetAttributes link: /api/commands/reset-attributes type: draft diff --git a/packages/core/src/commands/insertContentAt.ts b/packages/core/src/commands/insertContentAt.ts index dde7eb6da..10af8e38d 100644 --- a/packages/core/src/commands/insertContentAt.ts +++ b/packages/core/src/commands/insertContentAt.ts @@ -11,7 +11,7 @@ declare module '@tiptap/core' { interface Commands { insertContentAt: { /** - * Insert a node or string of HTML at the current position. + * Insert a node or string of HTML at a specific position. */ insertContentAt: (range: Range, value: Content) => Command, } diff --git a/packages/core/src/commands/replace.ts b/packages/core/src/commands/replace.ts index 52aff4b10..f3a12d546 100644 --- a/packages/core/src/commands/replace.ts +++ b/packages/core/src/commands/replace.ts @@ -13,6 +13,8 @@ declare module '@tiptap/core' { } export const replace: RawCommands['replace'] = (typeOrName, attributes = {}) => ({ state, commands }) => { + console.warn('[tiptap warn]: replace() is deprecated. please use insertContent() instead.') + const { from, to } = state.selection const range = { from, to } diff --git a/packages/core/src/commands/replaceRange.ts b/packages/core/src/commands/replaceRange.ts index dbb9be77e..66867d26f 100644 --- a/packages/core/src/commands/replaceRange.ts +++ b/packages/core/src/commands/replaceRange.ts @@ -14,6 +14,8 @@ declare module '@tiptap/core' { } export const replaceRange: RawCommands['replaceRange'] = (range, typeOrName, attributes = {}) => ({ tr, state, dispatch }) => { + console.warn('[tiptap warn]: replaceRange() is deprecated. please use insertContent() instead.') + const type = getNodeType(typeOrName, state.schema) const { from, to } = range // const $from = tr.doc.resolve(from)