From 9dfdf4c556acbc70041b072b62aa16f2deef0255 Mon Sep 17 00:00:00 2001 From: Ni55aN Date: Fri, 10 Jul 2026 17:05:41 +0000 Subject: [PATCH] feat(docs): document comments history preset Document Presets.comments in the undo/redo guide (EN/UK) and add a short cross-link from the comments guide. Fix addInline node.id typo. Co-authored-by: Cursor --- content/en/docs/04.guides/14.undo-redo.md | 28 +++++++++++++++++++++++ content/en/docs/04.guides/15.comments.md | 7 +++++- content/uk/docs/04.guides/14.undo-redo.md | 28 +++++++++++++++++++++++ content/uk/docs/04.guides/15.comments.md | 7 +++++- 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/content/en/docs/04.guides/14.undo-redo.md b/content/en/docs/04.guides/14.undo-redo.md index 4e1a937b..91a01b92 100644 --- a/content/en/docs/04.guides/14.undo-redo.md +++ b/content/en/docs/04.guides/14.undo-redo.md @@ -11,6 +11,7 @@ This guide is based on the [Basic](/docs/guides/basic) guide. It is recommended ::references :ref-example{title="History" link="/examples/history"} +:ref-guide{title="Comments" link="/docs/guides/comments"} :ref-github{title="Plugin" link="https://github.com/retejs/history-plugin"} :: @@ -44,6 +45,33 @@ history.addPreset(Presets.classic.setup()) It is responsible for tracking the history of adding, removing, or translating nodes, as well as tracking the adding and removing of connections. +## Comments preset {#comments-preset} + +To include comments in the undo/redo stack, install `rete-comment-plugin` version **2.2.0** or higher and register the comments preset together with the classic one. Pass the `CommentPlugin` instance into the preset and widen the history action type with `CommentHistoryActions`. + +```ts +import { CommentPlugin } from "rete-comment-plugin"; +import { + HistoryPlugin, + HistoryActions, + CommentHistoryActions, + Presets +} from "rete-history-plugin"; + +const comment = new CommentPlugin(); +const history = new HistoryPlugin | CommentHistoryActions>(); + +area.use(comment); +area.use(history); + +history.addPreset(Presets.classic.setup()) +history.addPreset(Presets.comments.setup({ comment })) +``` + +This preset tracks creating, removing, editing, and dragging comments, as well as changes to frame membership (for example, when a node is dragged into or out of a frame). + +See the [Comments](/docs/guides/comments) guide for comment setup details. If you enable both **History** and **Comments** features in [Rete Kit](/docs/development/rete-kit) (version **1.21.0** or higher), this wiring is generated automatically. + ## Usage {#usage} The plugin doesn't track user actions by default, such as keyboard shortcuts. To enable user interaction, you can implement usage of `undo`/`redo` methods on your own diff --git a/content/en/docs/04.guides/15.comments.md b/content/en/docs/04.guides/15.comments.md index e4e64bde..c8503251 100644 --- a/content/en/docs/04.guides/15.comments.md +++ b/content/en/docs/04.guides/15.comments.md @@ -11,6 +11,7 @@ This guide is based on the [Basic](/docs/guides/basic) guide. It is recommended ::references :ref-example{title="Comments" link="/examples/comments"} +:ref-guide{title="Undo/Redo" link="/docs/guides/undo-redo"} :ref-github{title="Plugin" link="https://github.com/retejs/comment-plugin"} :: @@ -49,7 +50,7 @@ area.use(comment); Adding an inline comment ```ts -comment.addInline("Inline comment text", [360, -20], node.dd); +comment.addInline("Inline comment text", [360, -20], node.id); ``` where `[360, -20]` is the position of the comment, which can be placed freely in relation to the `node` it is attached to. @@ -87,4 +88,8 @@ const comment = new CommentPlugin({ where the `edit` property must accept an asynchronous function that returns the text for the comment. +## Undo/Redo {#undo-redo} + +Comment changes can be included in the undo/redo stack via `rete-history-plugin` and its comments preset. Setup details are in the [Undo/Redo](/docs/guides/undo-redo#comments-preset) guide. + Check out the complete result on the [Comments](/examples/comments) example page. diff --git a/content/uk/docs/04.guides/14.undo-redo.md b/content/uk/docs/04.guides/14.undo-redo.md index 9051348c..c78de984 100644 --- a/content/uk/docs/04.guides/14.undo-redo.md +++ b/content/uk/docs/04.guides/14.undo-redo.md @@ -11,6 +11,7 @@ keywords: скасувати,повторити,історія,rete-history-plug ::references :ref-example{title="Історія змін" link="/uk/examples/history"} +:ref-guide{title="Коментарі" link="/uk/docs/guides/comments"} :ref-github{title="Плагін" link="https://github.com/retejs/history-plugin"} :: @@ -44,6 +45,33 @@ history.addPreset(Presets.classic.setup()) Він відповідає за трекінг історії додавання, видалення або переміщення вузлів, а також за трекунг додавання та видалення з'єднань. +## Пресет коментарів {#comments-preset} + +Щоб додати коментарі до стеку скасування/повторення, встановіть `rete-comment-plugin` версії **2.2.0** або новішої та підключіть пресет коментарів разом із класичним. Передайте екземпляр `CommentPlugin` у пресет і розширіть тип дій історії за допомогою `CommentHistoryActions`. + +```ts +import { CommentPlugin } from "rete-comment-plugin"; +import { + HistoryPlugin, + HistoryActions, + CommentHistoryActions, + Presets +} from "rete-history-plugin"; + +const comment = new CommentPlugin(); +const history = new HistoryPlugin | CommentHistoryActions>(); + +area.use(comment); +area.use(history); + +history.addPreset(Presets.classic.setup()) +history.addPreset(Presets.comments.setup({ comment })) +``` + +Цей пресет відстежує створення, видалення, редагування та перетягування коментарів, а також зміни членства у фреймі (наприклад, коли вузол перетягують у фрейм або з нього). + +Деталі налаштування коментарів — у гайді [Коментарі](/uk/docs/guides/comments). Якщо увімкнути обидві функції **History** і **Comments** у [Rete Kit](/uk/docs/development/rete-kit) (версія **1.21.0** або новіша), це підключення генерується автоматично. + ## Використання {#usage} Плагін за замовчуванням не відстежує дії користувача, наприклад комбінації клавіш. Щоб увімкнути взаємодію з користувачем, ви можете реалізувати використання методів `undo`/`redo` самостійно diff --git a/content/uk/docs/04.guides/15.comments.md b/content/uk/docs/04.guides/15.comments.md index a1ea9cd5..701819bb 100644 --- a/content/uk/docs/04.guides/15.comments.md +++ b/content/uk/docs/04.guides/15.comments.md @@ -11,6 +11,7 @@ keywords: коментарі,rete-comment-plugin ::references :ref-example{title="Коментарі" link="/uk/examples/comments"} +:ref-guide{title="Undo/Redo" link="/uk/docs/guides/undo-redo"} :ref-github{title="Плагін" link="https://github.com/retejs/comment-plugin"} :: @@ -49,7 +50,7 @@ area.use(comment); Додавання інлайн коментаря ```ts -comment.addInline("Текст інлайн коментаря", [360, -20], node.dd); +comment.addInline("Текст інлайн коментаря", [360, -20], node.id); ``` де `[360, -20]` - це позиція коментаря, який може бути вільно розміщений по відношенню до `node`, до якого він приєднаний. @@ -87,4 +88,8 @@ const comment = new CommentPlugin({ де поле `edit` має приймати асинхронну функцію, яка повертає текст для коментаря. +## Скасування/повторення {#undo-redo} + +Зміни коментарів можна додати до стеку скасування/повторення через `rete-history-plugin` і його пресет коментарів. Деталі налаштування — у гайді [Undo/Redo](/uk/docs/guides/undo-redo#comments-preset). + Перегляньте повний результат на сторінці прикладу [Коментарі](/uk/examples/comments).