diff --git a/desktop/src/features/messages/lib/mentionHighlightExtension.ts b/desktop/src/features/messages/lib/mentionHighlightExtension.ts index d688631101e..82b54135d63 100644 --- a/desktop/src/features/messages/lib/mentionHighlightExtension.ts +++ b/desktop/src/features/messages/lib/mentionHighlightExtension.ts @@ -565,10 +565,7 @@ export function buildHighlightPatterns( n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ); patterns.push( - new RegExp( - `(?:^|(?<=[\\s(]))@(${escapedNames.join("|")})(?=\\W|$)`, - "gi", - ), + new RegExp(`(^|[\\s(])@(${escapedNames.join("|")})(?=\\W|$)`, "gi"), ); } @@ -580,10 +577,7 @@ export function buildHighlightPatterns( n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), ); patterns.push( - new RegExp( - `(?:^|(?<=\\s))#(${escapedChannels.join("|")})(?=\\W|$)`, - "gi", - ), + new RegExp(`(^|\\s)#(${escapedChannels.join("|")})(?=\\W|$)`, "gi"), ); } @@ -671,7 +665,15 @@ export function findHighlightMatches( pattern.lastIndex = 0; let m: RegExpExecArray | null = pattern.exec(text); while (m !== null) { - results.push({ from: m.index, to: m.index + m[0].length, match: m[0] }); + // Group 1 is the boundary prefix (empty at start-of-text). It replaces + // the previous lookbehind, which macOS 12's WebKit cannot parse + // (see block/buzz#3295); skip it so offsets point at the @/# sigil. + const prefixLen = m[1] ? m[1].length : 0; + results.push({ + from: m.index + prefixLen, + to: m.index + m[0].length, + match: m[0].slice(prefixLen), + }); m = pattern.exec(text); } } diff --git a/desktop/src/features/settings/ui/KeyboardShortcutsCard.tsx b/desktop/src/features/settings/ui/KeyboardShortcutsCard.tsx index c9c12b94216..8b0a7de31c7 100644 --- a/desktop/src/features/settings/ui/KeyboardShortcutsCard.tsx +++ b/desktop/src/features/settings/ui/KeyboardShortcutsCard.tsx @@ -10,11 +10,34 @@ import { } from "./SettingsOptionGroup"; import { SettingsSectionHeader } from "./SettingsSectionHeader"; +// Split a key-combo string on "+" separators. A "+" is a separator unless it +// directly follows another "+" (so "⌘++" keeps "+" as a key) or only +// whitespace remains after it (so a trailing "+" stays attached). Mirrors the +// previous /(? p.trim()) .filter(Boolean); diff --git a/desktop/vite.config.ts b/desktop/vite.config.ts index ca51271dfa1..6afe2335a4d 100644 --- a/desktop/vite.config.ts +++ b/desktop/vite.config.ts @@ -52,6 +52,13 @@ export default defineConfig(async ({ mode }) => { }, }, + // Target Safari 15 so the bundle parses on macOS 12's system WebKit (613), + // which lacks Safari 16.4 syntax (e.g. RegExp lookbehind in literals, + // class static blocks). See https://github.com/block/buzz/issues/3295 + build: { + target: ["es2020", "safari15"], + }, + // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build` // // 1. prevent Vite from obscuring rust errors diff --git a/patches/mdast-util-gfm-autolink-literal@2.0.1.patch b/patches/mdast-util-gfm-autolink-literal@2.0.1.patch new file mode 100644 index 00000000000..3f05ef236d7 --- /dev/null +++ b/patches/mdast-util-gfm-autolink-literal@2.0.1.patch @@ -0,0 +1,13 @@ +diff --git a/lib/index.js b/lib/index.js +index c5ca771c24dd914e342f791716a822431ee32b3a..7fcfaf8441a81d42cceb059c7f48925373e794d3 100644 +--- a/lib/index.js ++++ b/lib/index.js +@@ -132,7 +132,7 @@ function transformGfmAutolinkLiterals(tree) { + tree, + [ + [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl], +- [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail] ++ [/([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail] + ], + {ignore: ['link', 'linkReference']} + ) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8476d3dd321..59565029214 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,6 +10,7 @@ overrides: patchedDependencies: isomorphic-git: e9b414a60d4cf1d8aa18f7a779483984e821989967c235662566e94ef0238d3f + mdast-util-gfm-autolink-literal@2.0.1: b6c92ec682456ca4b035718f71ee2b4a77d00da4c08cbc5e235e99eaabd96c45 virtua@0.49.3: 30a7a92b94800ec37be8d36546ea98c04a05dcd0637f9fac27a06f016ba2eff4 importers: @@ -6069,7 +6070,7 @@ snapshots: transitivePeerDependencies: - supports-color - mdast-util-gfm-autolink-literal@2.0.1: + mdast-util-gfm-autolink-literal@2.0.1(patch_hash=b6c92ec682456ca4b035718f71ee2b4a77d00da4c08cbc5e235e99eaabd96c45): dependencies: '@types/mdast': 4.0.4 ccount: 2.0.1 @@ -6117,7 +6118,7 @@ snapshots: mdast-util-gfm@3.1.0: dependencies: mdast-util-from-markdown: 2.0.3 - mdast-util-gfm-autolink-literal: 2.0.1 + mdast-util-gfm-autolink-literal: 2.0.1(patch_hash=b6c92ec682456ca4b035718f71ee2b4a77d00da4c08cbc5e235e99eaabd96c45) mdast-util-gfm-footnote: 2.1.0 mdast-util-gfm-strikethrough: 2.0.0 mdast-util-gfm-table: 2.0.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index be122c50ced..58da346f1e0 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -20,4 +20,5 @@ overrides: linkify-it: "^5.0.2" patchedDependencies: isomorphic-git: patches/isomorphic-git.patch + mdast-util-gfm-autolink-literal@2.0.1: patches/mdast-util-gfm-autolink-literal@2.0.1.patch virtua@0.49.3: patches/virtua@0.49.3.patch