Skip to content

Commit 965408d

Browse files
Tiptap RTE: Block selection (#19811)
* Removed `cursor: not-allowed` style * Sets the `umb-rte-block` `user-select` to `all` * Adds an "invisible" selection background to `umb-ref-rte-block` * Sets the `umb-ufm-render` text-content to be visible * Adds `aria-hidden` attribute * Bumped version of test helper * Fixed the failing tests due to UI changes * Adds `pointer-events: none` to selection-background --------- Co-authored-by: Nhu Dinh <[email protected]>
1 parent 4a37f06 commit 965408d

File tree

7 files changed

+40
-13
lines changed

7 files changed

+40
-13
lines changed

src/Umbraco.Web.UI.Client/src/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,14 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert
354354
:host {
355355
position: relative;
356356
display: block;
357-
user-select: none;
357+
user-select: all;
358358
user-drag: auto;
359359
white-space: nowrap;
360360
}
361+
361362
:host(.ProseMirror-selectednode) {
362363
umb-ref-rte-block {
363-
cursor: not-allowed;
364+
--uui-color-default-contrast: initial;
364365
outline: 3px solid var(--uui-color-focus);
365366
}
366367
}

src/Umbraco.Web.UI.Client/src/packages/block/block-rte/components/ref-rte-block/ref-rte-block.element.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class UmbRefRteBlockElement extends UmbLitElement {
4949
const blockValue = { ...this.content, $settings: this.settings };
5050
return html`
5151
<uui-ref-node standalone href=${(this.config?.showContentEdit ? this._workspaceEditPath : undefined) ?? ''}>
52+
<div class="selection-background" aria-hidden="true">&emsp;</div>
5253
<umb-icon slot="icon" .name=${this.icon}></umb-icon>
5354
<umb-ufm-render slot="name" inline .markdown=${this.label} .value=${blockValue}></umb-ufm-render>
5455
</uui-ref-node>
@@ -60,13 +61,34 @@ export class UmbRefRteBlockElement extends UmbLitElement {
6061
:host {
6162
display: block;
6263
}
64+
6365
uui-ref-node {
6466
min-height: var(--uui-size-16);
6567
}
68+
6669
:host([unpublished]) umb-icon,
6770
:host([unpublished]) umb-ufm-render {
6871
opacity: 0.6;
6972
}
73+
74+
/* HACK: Stretches a space character (&emsp;) to be full-width to make the RTE block appear text-selectable. [LK,NL] */
75+
.selection-background {
76+
position: absolute;
77+
pointer-events: none;
78+
font-size: 100vw;
79+
inset: 0;
80+
overflow: hidden;
81+
z-index: 0;
82+
}
83+
84+
umb-icon,
85+
umb-ufm-render {
86+
z-index: 1;
87+
88+
&::selection {
89+
color: var(--uui-color-default-contrast);
90+
}
91+
}
7092
`,
7193
];
7294
}

src/Umbraco.Web.UI.Client/src/packages/ufm/components/ufm-render/ufm-render.element.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ export class UmbUfmRenderElement extends UmbLitElement {
5050
static override styles = [
5151
UmbTextStyles,
5252
css`
53+
:host {
54+
position: relative;
55+
}
56+
5357
* {
5458
max-width: 100%;
5559
word-wrap: break-word;

tests/Umbraco.Tests.AcceptanceTest/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Umbraco.Tests.AcceptanceTest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"@umbraco/json-models-builders": "^2.0.37",
24-
"@umbraco/playwright-testhelpers": "^16.0.29",
24+
"@umbraco/playwright-testhelpers": "^16.0.32",
2525
"camelize": "^1.0.0",
2626
"dotenv": "^16.3.1",
2727
"node-fetch": "^2.6.7"

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/BlockGrid/ComplexBlockGridTest.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ test('can update property value nested in a block grid area with an RTE with a b
108108
await umbracoUi.content.isFailedStateButtonVisible();
109109
await umbracoUi.content.doesErrorNotificationHaveText(NotificationConstantHelper.error.documentCouldNotBePublished, true, true);
110110
// Updates the textstring block with the correct value
111-
await umbracoUi.content.clickBlockElementWithName(blockListElementTypeName);
111+
await umbracoUi.content.clickBlockElementInRTEWithName(blockListElementTypeName);
112112
await umbracoUi.content.clickEditBlockListEntryWithName(textStringElementTypeName);
113113
await umbracoUi.content.enterPropertyValue(textStringElementDataTypeName, correctPropertyValue);
114114
await umbracoUi.content.clickUpdateButtonForModalWithElementTypeNameAndGroupName(textStringElementTypeName, textStringElementGroupName);
@@ -124,7 +124,7 @@ test('can update property value nested in a block grid area with an RTE with a b
124124
await umbracoUi.reloadPage();
125125
// Waits to make sure the page has loaded
126126
await umbracoUi.waitForTimeout(2000);
127-
await umbracoUi.content.clickBlockElementWithName(blockListElementTypeName);
127+
await umbracoUi.content.clickBlockElementInRTEWithName(blockListElementTypeName);
128128
// Needs to wait to make sure it has loaded
129129
await umbracoUi.waitForTimeout(2000);
130130
await umbracoUi.content.clickEditBlockListEntryWithName(textStringElementTypeName);

tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/Content/RichTextEditor/VariantTipTapBlocks.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test('invariant document type with invariant tiptap RTE with invariant block wit
6161
await umbracoUi.content.isSuccessStateVisibleForSaveAndPublishButton();
6262
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
6363
await umbracoUi.reloadPage();
64-
await umbracoUi.content.clickBlockElementWithName(blockName);
64+
await umbracoUi.content.clickBlockElementInRTEWithName(blockName);
6565
await umbracoUi.content.doesPropertyContainValue(textStringName, textStringText);
6666
});
6767

@@ -128,7 +128,7 @@ test('variant document type with variant tiptap RTE with variant block with an v
128128
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
129129
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
130130
await umbracoUi.reloadPage();
131-
await umbracoUi.content.clickBlockElementWithName(blockName);
131+
await umbracoUi.content.clickBlockElementInRTEWithName(blockName);
132132
await umbracoUi.content.doesPropertyContainValue(textStringName, textStringText);
133133
});
134134

@@ -154,7 +154,7 @@ test('variant document type with invariant tiptap RTE with variant block with an
154154
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
155155
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
156156
await umbracoUi.reloadPage();
157-
await umbracoUi.content.clickBlockElementWithName(blockName);
157+
await umbracoUi.content.clickBlockElementInRTEWithName(blockName);
158158
await umbracoUi.content.doesPropertyContainValue(textStringName, textStringText);
159159
});
160160

@@ -180,6 +180,6 @@ test('variant document type with invariant tiptap RTE with variant block with an
180180
await umbracoUi.content.doesSuccessNotificationHaveText(NotificationConstantHelper.success.published);
181181
expect(await umbracoApi.document.isDocumentPublished(contentId)).toBeTruthy();
182182
await umbracoUi.reloadPage();
183-
await umbracoUi.content.clickBlockElementWithName(blockName);
183+
await umbracoUi.content.clickBlockElementInRTEWithName(blockName);
184184
await umbracoUi.content.doesPropertyContainValue(textStringName, textStringText);
185185
});

0 commit comments

Comments
 (0)