From 5bf07bda9bf6d96ebc672546dc0519f2a375dbe4 Mon Sep 17 00:00:00 2001
From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Date: Wed, 11 Dec 2024 15:41:22 +0100
Subject: [PATCH 1/2] chore: formatting
---
.../components/block-rte-entry/block-rte-entry.element.ts | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/Umbraco.Web.UI.Client/src/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.ts b/src/Umbraco.Web.UI.Client/src/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.ts
index 3696f7ba0513..7b684e201496 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/block/block-rte/components/block-rte-entry/block-rte-entry.element.ts
@@ -300,9 +300,9 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert
? html``
+ look="secondary">
+
+ `
: nothing;
}
From ccd365104a3734fee60753b19af95a76886e1033 Mon Sep 17 00:00:00 2001
From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com>
Date: Wed, 11 Dec 2024 15:42:28 +0100
Subject: [PATCH 2/2] fix: trigger only on a-tags inside our own block elements
Tinymce inserts links using the a-tag, which is triggering our navigation because we cannot control tinymce's rendering. We can however control which links we trigger on the for the 'click' event by using `composedPath()` and ensuring that we are inside one of the block entry elements.
---
.../input-tiny-mce/input-tiny-mce.defaults.ts | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/Umbraco.Web.UI.Client/src/packages/tiny-mce/components/input-tiny-mce/input-tiny-mce.defaults.ts b/src/Umbraco.Web.UI.Client/src/packages/tiny-mce/components/input-tiny-mce/input-tiny-mce.defaults.ts
index ac1260b8ce1b..a9c7b6255b73 100644
--- a/src/Umbraco.Web.UI.Client/src/packages/tiny-mce/components/input-tiny-mce/input-tiny-mce.defaults.ts
+++ b/src/Umbraco.Web.UI.Client/src/packages/tiny-mce/components/input-tiny-mce/input-tiny-mce.defaults.ts
@@ -76,34 +76,34 @@ export const defaultFallbackConfig: RawEditorOptions = {
// If we try to open link in a new tab, then we want to skip skip:
//if ((isWindows && e.ctrlKey) || (!isWindows && e.metaKey)) return;
+ const composedPaths = 'composedPath' in e ? e.composedPath() : null;
+
// Find the target by using the composed path to get the element through the shadow boundaries.
// Notice the difference here compared to RouterSlots implementation [NL]
- const $anchor: HTMLAnchorElement = (('composedPath' in e) as any)
- ? (e
- .composedPath()
- .find(($elem) => $elem instanceof HTMLAnchorElement || ($elem as any).tagName === 'A') as HTMLAnchorElement)
- : (e.target as HTMLAnchorElement);
-
- // Abort if the event is not about the anchor tag
- if ($anchor == null || !($anchor instanceof HTMLAnchorElement || ($anchor as any).tagName === 'A')) {
- return;
- }
-
- // Get the HREF value from the anchor tag
- const href = $anchor.href;
+ const $anchor: HTMLAnchorElement =
+ (composedPaths?.find(
+ ($elem) => $elem instanceof HTMLAnchorElement || ($elem as any).tagName === 'A',
+ ) as HTMLAnchorElement) ?? (e.target as HTMLAnchorElement);
- // Only handle the anchor tag if the follow holds true:
- // - The HREF is relative to the origin of the current location.
- // - The target is targeting the current frame.
- // - The anchor doesn't have the attribute [data-router-slot]="disabled"
+ // Abort if the event is not about the anchor tag or the anchor tag has the attribute [data-router-slot]="disabled"
if (
- !href.startsWith(location.origin) ||
- ($anchor.target !== '' && $anchor.target !== '_self') ||
+ $anchor == null ||
+ !($anchor instanceof HTMLAnchorElement || ($anchor as any).tagName === 'A') ||
$anchor.dataset['routerSlot'] === 'disabled'
) {
return;
}
+ // Abort if the anchor tag is not inside a block element
+ const isInsideBlockElement =
+ composedPaths?.some(
+ ($elem) => ($elem as any).tagName === 'UMB-RTE-BLOCK' || ($elem as any).tagName === 'UMB-RTE-BLOCK-INLINE',
+ ) ?? false;
+
+ if (!isInsideBlockElement) {
+ return;
+ }
+
// Remove the origin from the start of the HREF to get the path
const path = $anchor.pathname + $anchor.search + $anchor.hash;