diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index 3debcd87..96266faa 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -2918,10 +2918,10 @@ export default class ChatBubbles { const html = RichTextProcessor.wrapRichText(webpage.url); const a: HTMLAnchorElement = htmlToDocumentFragment(html).firstElementChild as any; a.classList.add('webpage-name'); - // const b = document.createElement('b'); - setInnerHTML(a, RichTextProcessor.wrapEmojiText(webpage.site_name)); - // a.textContent = ''; - // a.append(b); + const strong = document.createElement('strong'); + setInnerHTML(strong, RichTextProcessor.wrapEmojiText(webpage.site_name)); + a.textContent = ''; + a.append(strong); quoteTextDiv.append(a); t = a; } @@ -2929,9 +2929,9 @@ export default class ChatBubbles { if(webpage.rTitle) { let titleDiv = document.createElement('div'); titleDiv.classList.add('title'); - // const b = document.createElement('b'); - // titleDiv.append(b); - setInnerHTML(titleDiv, webpage.rTitle); + const strong = document.createElement('strong'); + setInnerHTML(strong, webpage.rTitle); + titleDiv.append(strong); quoteTextDiv.append(titleDiv); t = titleDiv; } diff --git a/src/helpers/dom/getRichElementValue.ts b/src/helpers/dom/getRichElementValue.ts index 4bd7659f..26e8b621 100644 --- a/src/helpers/dom/getRichElementValue.ts +++ b/src/helpers/dom/getRichElementValue.ts @@ -26,7 +26,7 @@ export const markdownTags: {[type in MarkdownType]: MarkdownTag} = { entityName: 'messageEntityUnderline' }, italic: { - match: '[style*="italic"], i', + match: '[style*="italic"], i, em', entityName: 'messageEntityItalic' }, monospace: { @@ -34,7 +34,7 @@ export const markdownTags: {[type in MarkdownType]: MarkdownTag} = { entityName: 'messageEntityPre' }, strikethrough: { - match: '[style*="line-through"], strike', + match: '[style*="line-through"], strike, del', entityName: 'messageEntityStrike' }, link: { diff --git a/src/helpers/dom/getRichValue.ts b/src/helpers/dom/getRichValue.ts index 4c3fe905..07b13f11 100644 --- a/src/helpers/dom/getRichValue.ts +++ b/src/helpers/dom/getRichValue.ts @@ -37,6 +37,7 @@ export default function getRichValue(field: HTMLElement, withEntities = true) { } */ RichTextProcessor.combineSameEntities(entities); + RichTextProcessor.sortEntities(entities); } //console.log('getRichValue:', value, entities); diff --git a/src/lib/richtextprocessor.ts b/src/lib/richtextprocessor.ts index 8f63143f..e5dff343 100644 --- a/src/lib/richtextprocessor.ts +++ b/src/lib/richtextprocessor.ts @@ -403,7 +403,8 @@ namespace RichTextProcessor { }); currentEntities.push(...filtered); - currentEntities.sort((a, b) => a.offset - b.offset); + sortEntities(currentEntities); + // currentEntities.sort((a, b) => a.offset - b.offset); // currentEntities.sort((a, b) => (a.offset - b.offset) || (a._ === 'messageEntityCaret' && -1)); if(!IS_EMOJI_SUPPORTED) { // fix splitted emoji. messageEntityTextUrl can split the emoji if starts before its end (e.g. on fe0f) @@ -439,6 +440,15 @@ namespace RichTextProcessor { //return entities; } + export function sortEntities(entities: MessageEntity[]) { + entities.sort((a, b) => { + return (a.offset - b.offset) || (b.length - a.length); + }); + } + + /** + * * Expecting correctly sorted nested entities (RichTextProcessor.sortEntities) + */ export function wrapRichText(text: string, options: Partial<{ entities: MessageEntity[], contextSite: string, diff --git a/src/scss/partials/_chatBubble.scss b/src/scss/partials/_chatBubble.scss index 7aa789d2..3ba84dbd 100644 --- a/src/scss/partials/_chatBubble.scss +++ b/src/scss/partials/_chatBubble.scss @@ -951,8 +951,6 @@ $bubble-beside-button-width: 38px; } .title { - font-weight: 500 !important; - &:not(:first-child) { margin-top: 1px; } @@ -960,7 +958,6 @@ $bubble-beside-button-width: 38px; .webpage-name { font-size: var(--messages-secondary-text-size); - font-weight: 500 !important; text-decoration: none; @include hover() {