Skip to content

Commit 5f1ecba

Browse files
authored
Tiptap RTE: Codesweep for 16.2 (#19879)
* RTE mock data updates * TODO comment typo correction * Corrected typo in class name This could technically be a breaking-change, but since the class name conflicted with the exported `UmbTiptapToolbarFontFamilyExtensionApi`, then no one could use it anyway. ¯\_(ツ)_/¯ * Tiptap extension code tidy-up Also, makes use of `this.name` instead of hardcoded strings.
1 parent ba8e1ae commit 5f1ecba

File tree

9 files changed

+32
-25
lines changed

9 files changed

+32
-25
lines changed

src/Umbraco.Web.UI.Client/examples/custom-validation-workspace-context/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
This example demonstrates how you can append extra validation messages to the Validation Context based on the value of a Property of a property Editor that this Customization is not interested in overriding/replacing.
44

5-
See this having an effect on the All RTEs page, where too long words are invalid.
5+
See this having an effect on the "Rich Text Editor" page, where too long words are invalid.

src/Umbraco.Web.UI.Client/src/external/tiptap/extensions/tiptap-anchor.extension.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,12 @@ export const Anchor = Node.create({
3333

3434
addOptions() {
3535
return {
36-
HTMLAttributes: {
37-
id: 'id',
38-
},
36+
HTMLAttributes: { id: '' },
3937
};
4038
},
4139

4240
parseHTML() {
43-
return [
44-
{
45-
tag: 'a[id]',
46-
getAttrs: (element) => (element.innerHTML === '' ? {} : false),
47-
},
48-
];
41+
return [{ tag: 'a[id]', getAttrs: (element) => (element.innerHTML === '' ? {} : false) }];
4942
},
5043

5144
renderHTML({ HTMLAttributes }) {

src/Umbraco.Web.UI.Client/src/external/tiptap/extensions/tiptap-figcaption.extension.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ export const Figcaption = Node.create<FigcaptionOptions>({
2727
draggable: false,
2828

2929
parseHTML() {
30-
return [
31-
{
32-
tag: 'figcaption',
33-
},
34-
];
30+
return [{ tag: this.name }];
3531
},
3632

3733
renderHTML({ HTMLAttributes }) {

src/Umbraco.Web.UI.Client/src/external/tiptap/extensions/tiptap-figure.extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const Figure = Node.create<FigureOptions>({
3535
parseHTML() {
3636
return [
3737
{
38-
tag: 'figure',
38+
tag: this.name,
3939
getAttrs: (dom) => {
4040
const figcaption = dom.querySelector('figcaption');
4141
return {

src/Umbraco.Web.UI.Client/src/mocks/data/document-type/document-type.data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1746,7 +1746,7 @@ export const data: Array<UmbMockDocumentTypeModel> = [
17461746
defaultTemplate: { id: 'all-rtes-document-type-id' },
17471747
id: 'all-rtes-document-type-id',
17481748
alias: 'allRtesDocumentType',
1749-
name: 'All RTEs document type',
1749+
name: 'Rich Text Editor document type',
17501750
description: null,
17511751
icon: 'icon-document',
17521752
allowedAsRoot: true,

src/Umbraco.Web.UI.Client/src/mocks/data/document/document.data.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ export const data: Array<UmbMockDocumentModel> = [
7777
<p>
7878
Some value for the RTE with an <a href="https://google.com">external link</a> and an <a type="document" href="/{localLink:c05da24d-7740-447b-9cdc-bd8ce2172e38}">internal link</a> foo foo
7979
</p>
80-
<div class="umb-macro-holder TestMacro umb-macro-mce_1 mceNonEditable"><!-- <?UMBRACO_MACRO macroAlias="TestMacro" /> --><ins>Macro alias: <strong>TestMacro</strong></ins></div>
80+
<div class="umb-macro-holder TestMacro umb-macro-mce_1"><!-- <?UMBRACO_MACRO macroAlias="TestMacro" /> --><ins>Macro alias: <strong>TestMacro</strong></ins></div>
8181
<p>The following tests the embed plugin:</p>
82-
<div class="mceNonEditable umb-embed-holder" data-embed-height="240" data-embed-width="360" data-embed-constrain="false"><iframe width="360" height="240" src="https://www.youtube.com/embed/QRIWz9SotY4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" title="Sleep Token - The Summoning"></iframe></div>
82+
<div class="umb-embed-holder" data-embed-height="240" data-embed-width="360" data-embed-constrain="false"><iframe width="360" height="240" src="https://www.youtube.com/embed/QRIWz9SotY4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" title="Sleep Token - The Summoning"></iframe></div>
8383
<p>End of test content</p>
8484
`,
8585
},
@@ -939,15 +939,15 @@ export const data: Array<UmbMockDocumentModel> = [
939939
publishDate: '2023-02-06T15:32:24.957009',
940940
culture: 'en-US',
941941
segment: null,
942-
name: 'All RTEs',
942+
name: 'Rich Text Editor',
943943
createDate: '2023-02-06T15:32:05.350038',
944944
updateDate: '2023-02-06T15:32:24.957009',
945945
},
946946
],
947947
values: [
948948
{
949949
alias: 'tiptap',
950-
editorAlias: 'Umb.PropertyEditorUi.Tiptap',
950+
editorAlias: 'Umbraco.RichText',
951951
culture: null,
952952
segment: null,
953953
value: {
@@ -957,7 +957,25 @@ export const data: Array<UmbMockDocumentModel> = [
957957
settingsData: [],
958958
expose: [],
959959
},
960-
markup: `<p><a id="anchor"></a> Here is a link for <a target="_blank" data-router-slot="disabled" href="https://gist.github.com/leekelleher/9490718" type="external">all HTML tags</a>.</p><p><span id="foo">Some</span> value for the RTE with an <a target="" data-router-slot="disabled" href="https://google.com" type="external">external link</a> and an <a target="" data-router-slot="disabled" href="/{localLink:c05da24d-7740-447b-9cdc-bd8ce2172e38}" type="document">internal link</a>.</p><div data-foo-bar="123"><span>This is a plain old span tag.</span> <span style="color: red;">Hello </span><span style="color: blue;">world</span><span style="color: red;">.</span></div><table style="min-width: 50px"><colgroup><col style="min-width: 25px"><col style="min-width: 25px"></colgroup><tbody><tr><th colspan="1" rowspan="1"><p> Version</p></th><th colspan="1" rowspan="1"><p>Date</p></th></tr><tr><td colspan="1" rowspan="1"><p>15.3</p></td><td colspan="1" rowspan="1"><p>2025-03-20</p></td></tr><tr><td colspan="1" rowspan="1"><p>16.0</p></td><td colspan="1" rowspan="1"><p>2025-06-12</p></td></tr><tr><td colspan="1" rowspan="1"><p>17.0</p></td><td colspan="1" rowspan="1"><p>2025-11-27</p></td></tr></tbody></table><p><img src="/umbraco/backoffice/assets/installer-illustration.svg" alt="Installer illustration" width="384" height="228" loading="lazy"></p><p>End of test content</p>`,
960+
markup: `
961+
<p><a id="anchor"></a> Here is a link for <a target="_blank" data-router-slot="disabled" href="https://gist.github.com/leekelleher/9490718" type="external">all HTML tags</a>.</p>
962+
963+
<p>Some value for the RTE with an <a href="https://google.com">external link</a> and an <a type="document" href="/{localLink:c05da24d-7740-447b-9cdc-bd8ce2172e38}">internal link</a> foo foo</p>
964+
965+
<p>The following tests the embed plugin:</p>
966+
<p><div class="umb-embed-holder" data-embed-height="240" data-embed-width="360" data-embed-constrain="false" data-embed-url="https://www.youtube.com/watch?v=QRIWz9SotY4"><iframe width="360" height="240" src="https://www.youtube.com/embed/QRIWz9SotY4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" title="Deep dive into Rich Text Editor"></iframe></div></p>
967+
968+
<p><span id="foo">Some</span> value for the RTE with an <a target="" data-router-slot="disabled" href="https://google.com" type="external">external link</a> and an <a target="" data-router-slot="disabled" href="/{localLink:c05da24d-7740-447b-9cdc-bd8ce2172e38}" type="document">internal link</a>.</p>
969+
970+
<div data-foo-bar="123"><span>This is a plain old span tag.</span> <span style="color: red;">Hello </span><span style="color: blue;">world</span><span style="color: red;">.</span></div>
971+
972+
<table style="min-width: 50px"><colgroup><col style="min-width: 25px"><col style="min-width: 25px"></colgroup><tbody><tr><th colspan="1" rowspan="1"><p> Version</p></th><th colspan="1" rowspan="1"><p>Date</p></th></tr><tr><td colspan="1" rowspan="1"><p>15.3</p></td><td colspan="1" rowspan="1"><p>2025-03-20</p></td></tr><tr><td colspan="1" rowspan="1"><p>16.0</p></td><td colspan="1" rowspan="1"><p>2025-06-12</p></td></tr><tr><td colspan="1" rowspan="1"><p>17.0</p></td><td colspan="1" rowspan="1"><p>2025-11-27</p></td></tr></tbody></table>
973+
974+
<p><img src="/umbraco/backoffice/assets/installer-illustration.svg" alt="Installer illustration" width="384" height="228" loading="lazy"></p>
975+
976+
<div class="umb-macro-holder"><!-- <?UMBRACO_MACRO macroAlias="TestMacro" /> --><ins>Macro alias: <strong>TestMacro</strong></ins></div>
977+
978+
<p>End of test content</p>`,
961979
},
962980
},
963981
],

src/Umbraco.Web.UI.Client/src/mocks/handlers/rte-embed.handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const handlers = [
1111
const height = heightParam ? parseInt(heightParam) : 240;
1212

1313
const response: OEmbedResponseModel = {
14-
markup: `<iframe width="${width}" height="${height}" src="https://www.youtube.com/embed/wJNbtYdr-Hg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen title="Sleep Token - The Summoning"></iframe>`,
14+
markup: `<iframe width="${width}" height="${height}" src="https://www.youtube.com/embed/QRIWz9SotY4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen title="Deep dive into Rich Text Editor"></iframe>`,
1515
};
1616

1717
return res(ctx.status(200), ctx.json(response));

src/Umbraco.Web.UI.Client/src/packages/block/block-rte/context/block-rte-entries.context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class UmbBlockRteEntriesContext extends UmbBlockEntriesContext<
147147
await Promise.all(
148148
layoutEntries.map(async (layoutEntry) => {
149149
this._insertBlockFromPropertyValue(layoutEntry, value, originData);
150-
// TODO: Missing some way to insert a Block HTML Element into the RTE at the current cursor point. (hopefully the responsibilit can be avoided here, but there is some connection missing at this point) [NL]
150+
// TODO: Missing some way to insert a Block HTML Element into the RTE at the current cursor point. (hopefully the responsibility can be avoided here, but there is some connection missing at this point) [NL]
151151
}),
152152
);
153153

src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/toolbar/font-size.tiptap-toolbar-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { UmbTiptapToolbarElementApiBase } from '../base.js';
22
import type { MetaTiptapToolbarMenuItem } from '../types.js';
33
import type { Editor } from '@umbraco-cms/backoffice/external/tiptap';
44

5-
export default class UmbTiptapToolbarFontFamilyExtensionApi extends UmbTiptapToolbarElementApiBase {
5+
export default class UmbTiptapToolbarFontSizeExtensionApi extends UmbTiptapToolbarElementApiBase {
66
override isActive(editor?: Editor, item?: MetaTiptapToolbarMenuItem) {
77
const styles = editor?.getAttributes('span')?.style;
88
return styles?.includes(`font-size: ${item?.data};`) === true;

0 commit comments

Comments
 (0)