Skip to content

Commit d8a3d93

Browse files
authored
Rename History extension to UndoRedo (#6172)
* rename history extension to undo-redo * added changesets * fix spacing in vue demo
1 parent 89bd9c7 commit d8a3d93

File tree

39 files changed

+119
-125
lines changed

39 files changed

+119
-125
lines changed

.changeset/chilled-trees-agree.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
'@tiptap/extension-underline': major
3333
'@tiptap/extension-document': major
3434
'@tiptap/extension-heading': major
35-
'@tiptap/extension-history': major
35+
'@tiptap/extension-undo-redo': major
3636
'@tiptap/extension-mention': major
3737
'@tiptap/extension-youtube': major
3838
'@tiptap/extension-italic': major

.changeset/chilly-lemons-remember.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ import { GapCursor } from '@tiptap/extensions'
5959

6060
This extension adds undo and redo functionality to the editor.
6161

62-
Migrate from `@tiptap/extension-history` to `@tiptap/extensions`:
62+
Migrate from `@tiptap/extension-undo-redo` to `@tiptap/extensions`:
6363

6464
```diff
65-
- import History from '@tiptap/extension-history'
65+
- import History from '@tiptap/extension-undo-redo'
6666
+ import { History } from '@tiptap/extensions'
6767
```
6868

6969
Usage:
7070

7171
```ts
72-
import { History, HistoryOptions } from '@tiptap/extensions'
72+
import { UndoRedo, UndoRedoOptions } from '@tiptap/extensions'
7373
```
7474

7575
## Placeholder

.changeset/cuddly-impalas-heal.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'@tiptap/extension-hard-break': patch
2323
'@tiptap/extension-heading': patch
2424
'@tiptap/extension-highlight': patch
25-
'@tiptap/extension-history': patch
25+
'@tiptap/extension-undo-redo': patch
2626
'@tiptap/extension-horizontal-rule': patch
2727
'@tiptap/extension-image': patch
2828
'@tiptap/extension-italic': patch

.changeset/pre.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@tiptap/extension-hard-break": "2.11.4",
2525
"@tiptap/extension-heading": "2.11.4",
2626
"@tiptap/extension-highlight": "2.11.4",
27-
"@tiptap/extension-history": "2.11.4",
27+
"@tiptap/extension-undo-redo": "2.11.4",
2828
"@tiptap/extension-horizontal-rule": "2.11.4",
2929
"@tiptap/extension-image": "2.11.4",
3030
"@tiptap/extension-italic": "2.11.4",

.changeset/thirty-rockets-act.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiptap/extension-undo-redo': major
3+
---
4+
5+
Rename history extension to undo-redo to clarify it's functionality and separate itself from other history-related extensions.

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"extension/hard-break",
2828
"extension/heading",
2929
"extension/highlight",
30-
"extension/history",
30+
"extension/undo-redo",
3131
"extension/horizontal-rule",
3232
"extension/image",
3333
"extension/italic",
+26-37
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
This is a [codemod](https://codemod.com) created with [```codemod init```](https://docs.codemod.com/deploying-codemods/cli#codemod-init).
1+
This is a [codemod](https://codemod.com) created with [`codemod init`](https://docs.codemod.com/deploying-codemods/cli#codemod-init).
32

43
## Using this codemod
54

@@ -12,54 +11,44 @@ npx codemod tiptap-2-migrate-imports
1211
### Before
1312

1413
```ts
15-
import Table from '@tiptap/extension-table';
16-
import TableRow from '@tiptap/extension-table-row';
17-
import TableCell from '@tiptap/extension-table-cell';
18-
import TableHeader from '@tiptap/extension-table-header';
14+
import Table from "@tiptap/extension-table";
15+
import TableRow from "@tiptap/extension-table-row";
16+
import TableCell from "@tiptap/extension-table-cell";
17+
import TableHeader from "@tiptap/extension-table-header";
1918
```
2019

2120
### After
2221

2322
```ts
24-
import {
25-
Table,
26-
TableRow,
27-
TableCell,
28-
TableHeader,
29-
} from '@tiptap/extension-table';
23+
import { Table, TableRow, TableCell, TableHeader } from "@tiptap/extension-table";
3024
```
3125

3226
,
3327

3428
### Before
3529

3630
```ts
37-
import { Table } from '@tiptap/extension-table';
38-
import { TableRow } from '@tiptap/extension-table-row';
39-
import { TableCell } from '@tiptap/extension-table-cell';
40-
import { TableHeader } from '@tiptap/extension-table-header';
31+
import { Table } from "@tiptap/extension-table";
32+
import { TableRow } from "@tiptap/extension-table-row";
33+
import { TableCell } from "@tiptap/extension-table-cell";
34+
import { TableHeader } from "@tiptap/extension-table-header";
4135
```
4236

4337
### After
4438

4539
```ts
46-
import {
47-
Table,
48-
TableRow,
49-
TableCell,
50-
TableHeader,
51-
} from '@tiptap/extension-table';
40+
import { Table, TableRow, TableCell, TableHeader } from "@tiptap/extension-table";
5241
```
5342

5443
,
5544

5645
### Before
5746

5847
```ts
59-
import Table1 from '@tiptap/extension-table';
60-
import TableR from '@tiptap/extension-table-row';
61-
import TableCel from '@tiptap/extension-table-cell';
62-
import TableHead from '@tiptap/extension-table-header';
48+
import Table1 from "@tiptap/extension-table";
49+
import TableR from "@tiptap/extension-table-row";
50+
import TableCel from "@tiptap/extension-table-cell";
51+
import TableHead from "@tiptap/extension-table-header";
6352
```
6453

6554
### After
@@ -70,51 +59,51 @@ import {
7059
TableRow as TableR,
7160
TableCell as TableCel,
7261
TableHeader as TableHead,
73-
} from '@tiptap/extension-table';
62+
} from "@tiptap/extension-table";
7463
```
7564

7665
,
7766

7867
### Before
7968

8069
```ts
81-
import BulletList from '@tiptap/extension-bullet-list';
82-
import OrderedList from '@tiptap/extension-ordered-list';
83-
import ListItem from '@tiptap/extension-list-item';
70+
import BulletList from "@tiptap/extension-bullet-list";
71+
import OrderedList from "@tiptap/extension-ordered-list";
72+
import ListItem from "@tiptap/extension-list-item";
8473
```
8574

8675
### After
8776

8877
```ts
89-
import { BulletList, OrderedList, ListItem } from '@tiptap/extension-list';
78+
import { BulletList, OrderedList, ListItem } from "@tiptap/extension-list";
9079
```
9180

9281
,
9382

9483
### Before
9584

9685
```ts
97-
import TextStyle from '@tiptap/extension-text-style';
98-
import { Color } from '@tiptap/extension-color';
86+
import TextStyle from "@tiptap/extension-text-style";
87+
import { Color } from "@tiptap/extension-color";
9988
```
10089

10190
### After
10291

10392
```ts
104-
import { TextStyle, Color } from '@tiptap/extension-text-style';
93+
import { TextStyle, Color } from "@tiptap/extension-text-style";
10594
```
10695

10796
,
10897

10998
### Before
11099

111100
```ts
112-
import { PlaceHolder } from '@tiptap/extension-placeholder';
113-
import History from '@tiptap/extension-history';
101+
import { PlaceHolder } from "@tiptap/extension-placeholder";
102+
import UndoRedo from "@tiptap/extension-undo-redo";
114103
```
115104

116105
### After
117106

118107
```ts
119-
import { PlaceHolder, History } from '@tiptap/extensions';
108+
import { PlaceHolder, UndoRedo } from "@tiptap/extensions";
120109
```
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import History from "@tiptap/extension-history";
1+
import UndoRedo from "@tiptap/extension-undo-redo";
22
import { Placeholder } from "@tiptap/extension-placeholder";
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import { History, Placeholder } from "@tiptap/extensions";
1+
import { UndoRedo, Placeholder } from "@tiptap/extensions";

codemods/tiptap-2-migrate-imports/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default function transform(file: any, api: any) {
2727
"@tiptap/extension-dropcursor": "Dropcursor",
2828
"@tiptap/extension-gapcursor": "Gapcursor",
2929
"@tiptap/extension-focus": "Focus",
30-
"@tiptap/extension-history": "History",
30+
"@tiptap/extension-undo-redo": "UndoRedo",
3131
"@tiptap/extension-placeholder": "Placeholder",
3232
};
3333

@@ -53,7 +53,7 @@ export default function transform(file: any, api: any) {
5353
"@tiptap/extension-dropcursor": "@tiptap/extensions",
5454
"@tiptap/extension-gapcursor": "@tiptap/extensions",
5555
"@tiptap/extension-focus": "@tiptap/extensions",
56-
"@tiptap/extension-history": "@tiptap/extensions",
56+
"@tiptap/extension-undo-redo": "@tiptap/extensions",
5757
"@tiptap/extension-placeholder": "@tiptap/extensions",
5858
};
5959

demos/src/Demos/CollaborationSplitPane/React/Editor.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const Editor = ({ ydoc, provider, room }) => {
9595
},
9696
extensions: [
9797
StarterKit.configure({
98-
history: false,
98+
undoRedo: false,
9999
}),
100100
Highlight,
101101
TaskList,

demos/src/Demos/SingleRoomCollab/React/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default () => {
6767
const editor = useEditor({
6868
extensions: [
6969
StarterKit.configure({
70-
history: false,
70+
undoRedo: false,
7171
}),
7272
CharacterCount.configure({
7373
limit: 10000,

demos/src/Examples/CollaborativeEditing/React/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default () => {
7878
const editor = useEditor({
7979
extensions: [
8080
StarterKit.configure({
81-
history: false,
81+
undoRedo: false,
8282
}),
8383
Highlight,
8484
TaskList,

demos/src/Experiments/All/Vue/index.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ import Text from '@tiptap/extension-text'
122122
import TextAlign from '@tiptap/extension-text-align'
123123
import { Color, TextStyle } from '@tiptap/extension-text-style'
124124
import Underline from '@tiptap/extension-underline'
125-
import { Dropcursor, Gapcursor, History, Placeholder } from '@tiptap/extensions'
125+
import { Dropcursor, Gapcursor, Placeholder, UndoRedo } from '@tiptap/extensions'
126126
import { Editor, EditorContent } from '@tiptap/vue-3'
127127
import { all, createLowlight } from 'lowlight'
128128
@@ -154,7 +154,7 @@ export default {
154154
Gapcursor,
155155
HardBreak,
156156
Heading,
157-
History,
157+
UndoRedo,
158158
HorizontalRule,
159159
Italic,
160160
ListItem,

demos/src/Extensions/History/React/index.jsx demos/src/Extensions/UndoRedo/React/index.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import './styles.scss'
33
import Document from '@tiptap/extension-document'
44
import Paragraph from '@tiptap/extension-paragraph'
55
import Text from '@tiptap/extension-text'
6-
import { History } from '@tiptap/extensions'
6+
import { UndoRedo } from '@tiptap/extensions'
77
import { EditorContent, useEditor, useEditorState } from '@tiptap/react'
88
import React from 'react'
99

1010
export default () => {
1111
const editor = useEditor({
12-
extensions: [Document, Paragraph, Text, History],
12+
extensions: [Document, Paragraph, Text, UndoRedo],
1313
content: `
1414
<p>
15-
With the History extension the Editor will keep track of your changes. And if you think you made a mistake, you can redo your changes. Try it out, change the content and hit the undo button!
15+
With the UndoRedo extension the Editor will keep track of your changes. And if you think you made a mistake, you can redo your changes. Try it out, change the content and hit the undo button!
1616
</p>
1717
<p>
1818
And yes, you can also use a keyboard shortcut to undo changes (Control/Cmd Z) or redo changes (Control/Cmd Shift Z).
@@ -38,10 +38,10 @@ export default () => {
3838
<>
3939
<div className="control-group">
4040
<div className="button-group">
41-
<button onClick={() => editor.chain().focus().undo().run()} disabled={!canUndo}>
41+
<button onClick={() => editor.chain().focus().undo().run()} disabled={!canUndo} type="button">
4242
Undo
4343
</button>
44-
<button onClick={() => editor.chain().focus().redo().run()} disabled={!canRedo}>
44+
<button onClick={() => editor.chain().focus().redo().run()} disabled={!canRedo} type="button">
4545
Redo
4646
</button>
4747
</div>

demos/src/Extensions/History/React/index.spec.js demos/src/Extensions/UndoRedo/React/index.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
context('/src/Extensions/History/React/', () => {
1+
context('/src/Extensions/UndoRedo/React/', () => {
22
beforeEach(() => {
3-
cy.visit('/src/Extensions/History/React/')
3+
cy.visit('/src/Extensions/UndoRedo/React/')
44
cy.get('.tiptap').then(([{ editor }]) => {
55
editor.commands.setContent('<p>Mistake</p>')
66
})

demos/src/Extensions/History/Vue/index.spec.js demos/src/Extensions/UndoRedo/Vue/index.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
context('/src/Extensions/History/Vue/', () => {
1+
context('/src/Extensions/UndoRedo/Vue/', () => {
22
beforeEach(() => {
3-
cy.visit('/src/Extensions/History/Vue/')
3+
cy.visit('/src/Extensions/UndoRedo/Vue/')
44
cy.get('.tiptap').then(([{ editor }]) => {
55
editor.commands.setContent('<p>Mistake</p>')
66
})

demos/src/Extensions/History/Vue/index.vue demos/src/Extensions/UndoRedo/Vue/index.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import Document from '@tiptap/extension-document'
1515
import Paragraph from '@tiptap/extension-paragraph'
1616
import Text from '@tiptap/extension-text'
17-
import { History } from '@tiptap/extensions'
17+
import { UndoRedo } from '@tiptap/extensions'
1818
import { Editor, EditorContent } from '@tiptap/vue-3'
1919
2020
export default {
@@ -30,10 +30,10 @@ export default {
3030
3131
mounted() {
3232
this.editor = new Editor({
33-
extensions: [Document, Paragraph, Text, History],
33+
extensions: [Document, Paragraph, Text, UndoRedo],
3434
content: `
3535
<p>
36-
With the History extension the Editor will keep track of your changes. And if you think you made a mistake, you can redo your changes. Try it out, change the content and hit the undo button!
36+
With the UndoRedo extension the Editor will keep track of your changes. And if you think you made a mistake, you can redo your changes. Try it out, change the content and hit the undo button!
3737
</p>
3838
<p>
3939
And yes, you can also use a keyboard shortcut to undo changes (Control/Cmd Z) or redo changes (Control/Cmd Shift Z).

packages/extension-collaboration/src/collaboration.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ export const Collaboration = Extension.create<CollaborationOptions, Collaboratio
9696
},
9797

9898
onCreate() {
99-
if (this.editor.extensionManager.extensions.find(extension => extension.name === 'history')) {
99+
if (this.editor.extensionManager.extensions.find(extension => extension.name === 'undoRedo')) {
100100
console.warn(
101-
'[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".',
101+
'[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".',
102102
)
103103
}
104104
},

packages/extension-history/src/index.ts

-6
This file was deleted.

packages/extension-history/README.md packages/extension-undo-redo/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# @tiptap/extension-history
1+
# @tiptap/extension-undo-redo
22

3-
[![Version](https://img.shields.io/npm/v/@tiptap/extension-history.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-history)
4-
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-history.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
5-
[![License](https://img.shields.io/npm/l/@tiptap/extension-history.svg)](https://www.npmjs.com/package/@tiptap/extension-history)
3+
[![Version](https://img.shields.io/npm/v/@tiptap/extension-undo-redo.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-undo-redo)
4+
[![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-undo-redo.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
5+
[![License](https://img.shields.io/npm/l/@tiptap/extension-undo-redo.svg)](https://www.npmjs.com/package/@tiptap/extension-undo-redo)
66
[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
77

88
## Introduction

packages/extension-history/package.json packages/extension-undo-redo/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@tiptap/extension-history",
2+
"name": "@tiptap/extension-undo-redo",
33
"description": "history extension for tiptap",
44
"version": "3.0.0-next.6",
55
"homepage": "https://tiptap.dev",
@@ -39,7 +39,7 @@
3939
"repository": {
4040
"type": "git",
4141
"url": "https://github.com/ueberdosis/tiptap",
42-
"directory": "packages/extension-history"
42+
"directory": "packages/extension-undo-redo"
4343
},
4444
"scripts": {
4545
"build": "tsup",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { UndoRedo } from '@tiptap/extensions'
2+
3+
export type { UndoRedoOptions } from '@tiptap/extensions'
4+
export { UndoRedo } from '@tiptap/extensions'
5+
6+
export default UndoRedo

0 commit comments

Comments
 (0)