mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 09:31:17 -08:00
add changeset
This commit is contained in:
1 parent
0eba80d43e
commit
bdd902cdc9
3 files changed
+11
-5
No files matched your search
@@ -198,6 +198,7 @@ const elementToPlainText = (node: CustomElement, children: string): string => {
|
||||
};
|
||||
|
||||
const SPOILERINPUTREGEX = /\|\|.+?\|\|/g;
|
||||
//very loose link check with the empty text at the end to make sure it doesnt overextend
|
||||
const LINKINPUTREGEX = /<?(https?:\/\/.+?)>?( |$|\))/g;
|
||||
|
||||
/**
|
||||
@@ -319,7 +320,9 @@ export const getLinks = (editor: Editor): string[] | undefined => {
|
||||
let { text } = node;
|
||||
const urlsMatch = text.match(LINKINPUTREGEX);
|
||||
let urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
// clear the extra deadspace
|
||||
urls = urls?.map((url) => (url = url.replace(/(.+?)[ |)]/g, '$1')));
|
||||
// remove previews when so wanted
|
||||
urls = urls?.filter((url) => !(url.startsWith('<') && url.endsWith('>')));
|
||||
finalList = finalList.concat(urls ?? []);
|
||||
return;
|
||||
|
||||
@@ -150,10 +150,13 @@ export function MText({
|
||||
let urls = urlsMatch ? [...new Set(urlsMatch)] : undefined;
|
||||
bundleContent = content['com.beeper.linkpreviews'] as BundleContent[];
|
||||
//small "fix" for if someone sends malformed objects (ie not arrays of objects)
|
||||
try{
|
||||
try {
|
||||
bundleContent = bundleContent?.filter((bundle) => !!urls?.includes(bundle.matched_url));
|
||||
if (renderUrlsPreview && bundleContent) urls = bundleContent.map((bundle) => bundle.matched_url);
|
||||
}catch{ urls = [];};
|
||||
if (renderUrlsPreview && bundleContent)
|
||||
urls = bundleContent.map((bundle) => bundle.matched_url);
|
||||
} catch {
|
||||
urls = [];
|
||||
}
|
||||
|
||||
if ((content['com.beeper.per_message_profile'] as PerMessageProfileBeeperFormat)?.has_fallback) {
|
||||
// unwrap per-message profile fallback if present
|
||||
|
||||
@@ -805,8 +805,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
|
||||
content['m.mentions'] = getMentionContent(Array.from(mentionData.users), mentionData.room);
|
||||
|
||||
content["com.beeper.linkpreviews"] = [];
|
||||
links?.forEach(link => content["com.beeper.linkpreviews"].push({'matched_url': link}));
|
||||
content['com.beeper.linkpreviews'] = [];
|
||||
links?.forEach((link) => content['com.beeper.linkpreviews'].push({ matched_url: link }));
|
||||
|
||||
if (replyDraft || !customHtmlEqualsPlainText(formattedBody, body)) {
|
||||
content.format = 'org.matrix.custom.html';
|
||||
|
||||
Reference in new issue
Block a user