From 0030f083b09811dd0acb24cd298f9ee17ab04794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Wed, 5 May 2021 19:42:47 +0200 Subject: [PATCH] docs: update content --- docs/src/docPages/api/commands.md | 13 ++++++------- .../{replace-range.md => insert-content-at.md} | 2 +- docs/src/docPages/api/commands/replace.md | 3 --- docs/src/links.yaml | 9 +++------ packages/core/src/commands/insertContentAt.ts | 2 +- packages/core/src/commands/replace.ts | 2 ++ packages/core/src/commands/replaceRange.ts | 2 ++ 7 files changed, 15 insertions(+), 18 deletions(-) rename docs/src/docPages/api/commands/{replace-range.md => insert-content-at.md} (52%) delete mode 100644 docs/src/docPages/api/commands/replace.md diff --git a/docs/src/docPages/api/commands.md b/docs/src/docPages/api/commands.md index 66c210c8..fcbb5fab 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 85c068ec..2335641a 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 3c6da44c..00000000 --- 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 bc5e2b5b..a1afe6c0 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 dde7eb6d..10af8e38 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 52aff4b1..f3a12d54 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 dbb9be77..66867d26 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)