Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ export class UmbBlockRteEntryElement extends UmbLitElement implements UmbPropert
? html`<uui-button
@click=${this.#expose}
label=${this.localize.term('blockEditor_createThisFor', this._contentTypeName)}
look="secondary"
><uui-icon name="icon-add"></uui-icon
></uui-button>`
look="secondary">
<uui-icon name="icon-add"></uui-icon>
</uui-button>`
: nothing;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down