Skip to content

Commit b7700f0

Browse files
authored
Merge pull request #6665 from leekelleher/v15/tiptap-extensions
Tiptap RTE Extensions
2 parents 0af8bb4 + b7dadfb commit b7700f0

File tree

6 files changed

+108
-13
lines changed

6 files changed

+108
-13
lines changed

15/umbraco-cms/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
* [Dropdown](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/dropdown/README.md)
8181
* [Rich Text Editor](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md)
8282
* [Configuration](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/configuration.md)
83-
* [Plugins](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/plugins.md)
83+
* [Extensions](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/extensions.md)
8484
* [Blocks](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/blocks.md)
8585
* [Change Rich Text Editor UI](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/change-rich-text-editor-ui.md)
8686
* [Rich Text Editor TinyMce](fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor-tinymce/README.md)

15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ You can continue to use the [TinyMCE UI for the Rich Text Editor](../rich-text-e
1212
**Current limitations**
1313

1414
The Tiptap UI currently does not support using custom styles for your rich text.
15+
16+
Resizing media images has not been implemented yet.
17+
1518
{% endhint %}
1619

1720
The Rich Text Editor (RTE) Tiptap property editor is highly configurable and based on [Tiptap](https://tiptap.dev/). Depending on the configuration setup, it provides editors a lot of flexibility when working with content.
@@ -24,9 +27,9 @@ Customize everything from toolbar options to editor size to where pasted images
2427

2528
Use Blocks to define specific parts that can be added as part of the markup of the Rich Text Editor.
2629

27-
## [Plugins](plugins.md)
30+
## [Extensions](extensions.md)
2831

29-
Extend the functionality of the Rich Text Editor with plugins.
32+
Extend the functionality of the Rich Text Editor with extensions.
3033

3134
## Data Type Definition Example
3235

15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/change-rich-text-editor-ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The first step in this guide is to create a new Rich Text Editor Data Type using
1515
As an alternative, you can create a new Data Type using the Tiptap property editor when updating the Document Type.
1616

1717
{% hint style="info" %}
18-
When swapping the UI used for the Rich Text Editor, you need to reconfigure the toolbar.
18+
When swapping the UI used for the Rich Text Editor, you may need to reconfigure the toolbar.
1919
{% endhint %}
2020

2121
1. Navigate to the **Settings** section of the Umbraco Backoffice.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
description: Information on how to work with Tiptap extensions in the rich text editor.
3+
---
4+
5+
# Extensions
6+
7+
The Rich Text Editor (RTE) in Umbraco is based on the open-source editor [Tiptap](https://tiptap.dev/).
8+
9+
Out of the box, Tiptap has limited capabilities and everything is an extension by design. Basic text formatting features such as bold, italic, and underline are their own extensions. This offers great flexibility, making the rich text editor highly configurable. The implementation in Umbraco offers a wide range of built-in extensions to enhance the Tiptap editor capabilities.
10+
11+
Using the same extension points, this article will show you how to add a custom extension to the rich text editor.
12+
13+
## Native Tiptap extensions
14+
15+
Tiptap has a library of supported native extensions. You can find a list of these extensions on the [Tiptap website](https://tiptap.dev/docs/editor/extensions/overview). While many of these are open source, there are also [pro extensions](https://tiptap.dev/docs/guides/pro-extensions) available for commercial subscriptions.
16+
17+
### Tiptap extension types
18+
19+
There are two types of extension: `tiptapExtension` and `tiptapToolbarExtension`.
20+
21+
The `tiptapExtension` extension is used to register a native [Tiptap Extension](https://tiptap.dev/docs/editor/extensions/). These will enhance the capabilities of the rich text editor itself. For example, to enable text formatting, drag-and-drop functionality and spell-checking.
22+
23+
The `tiptapToolbarExtension` extension adds a toolbar action that interacts with the Tiptap editor (and native Tiptap extensions).
24+
25+
26+
## Adding a native extension
27+
28+
{% hint style="info" %}
29+
This example assumes that you will be creating an Umbraco package using the Vite/Lit/TypeScript setup.
30+
You can learn how to do this [Vite Package Setup](../../../../../customizing/development-flow/vite-package-setup.md) article.
31+
{% endhint %}
32+
33+
In this example, you will take the native Tiptap open-source extension [Highlight](https://tiptap.dev/docs/editor/extensions/marks/highlight). Then register it with the rich text editor and add a toolbar button to invoke the Task List action.
34+
35+
1. Install the Highlight extension from the npm registry.
36+
37+
```
38+
npm install @tiptap/extension-highlight
39+
```
40+
41+
2. Create the code to register the native Tiptap extensions in the rich text editor.
42+
43+
```js
44+
import { UmbTiptapExtensionApiBase } from '@umbraco-cms/backoffice/tiptap';
45+
import { Highlight } from '@tiptap/extension-highlight';
46+
47+
export default class UmbTiptapHighlightExtensionApi extends UmbTiptapExtensionApiBase {
48+
getTiptapExtensions = () => [Highlight];
49+
}
50+
```
51+
52+
3. Create the toolbar action to invoke the Highlight extension.
53+
54+
```
55+
import { UmbTiptapToolbarElementApiBase } from '@umbraco-cms/backoffice/tiptap';
56+
import type { Editor } from '@umbraco-cms/backoffice/external/tiptap';
57+
58+
export default class UmbTiptapToolbarHighlightExtensionApi extends UmbTiptapToolbarElementApiBase {
59+
override execute(editor?: Editor) {
60+
editor?.chain().focus().toggleHighlight().run();
61+
}
62+
}
63+
```
64+
65+
Once you have the above code in place, they can be referenced in the [package manifest](../../../../../extending/property-editors/package-manifest.md) file.
66+
67+
{% code title="App_Plugins/MyTiptapExtension/umbraco-package.json" lineNumbers="true" %}
68+
```json
69+
{
70+
"name": "My Tiptap Extension",
71+
"version": "1.0.0",
72+
"extensions": [
73+
{
74+
"type": "tiptapExtension",
75+
"alias": "My.Tiptap.Highlight",
76+
"name": "My Highlight Tiptap Extension",
77+
"api": "/App_Plugins/MyTiptapExtension/highlight.tiptap-api.js",
78+
"meta": {
79+
"icon": "icon-thumbnail-list",
80+
"label": "Highlight",
81+
"group": "#tiptap_extGroup_formatting"
82+
}
83+
},
84+
{
85+
"type": "tiptapToolbarExtension",
86+
"kind": "button",
87+
"alias": "My.Tiptap.Toolbar.TaskList",
88+
"name": "My Highlight Tiptap Toolbar Extension",
89+
"api": "/App_Plugins/MyTiptapExtension/highlight.tiptap-toolbar-api.js",
90+
"meta": {
91+
"alias": "highlight",
92+
"icon": "icon-brush",
93+
"label": "Highlight"
94+
}
95+
}
96+
]
97+
}
98+
```
99+
{% endcode %}
100+
101+
Upon restarting Umbraco, the new extension and toolbar action will be available in the Tiptap Data Type configuration settings.
Loading

15/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/plugins.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)