feat: unified attachment pipeline with clipboard image and file picker
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
d63af25fc1
commit
761a80004a
7 files changed
+597
-57
No files matched your search
@@ -15,6 +15,9 @@ export const LIMITS = {
|
||||
messageChars: 20000,
|
||||
};
|
||||
|
||||
/** A character that can be part of a path (letters of any alphabet too: "ęą"). */
|
||||
const PATH_CHAR = /[\p{L}\p{N}_/\\-]/u;
|
||||
|
||||
/** The extensions that make a file an image (the design's §13.8 list). */
|
||||
const IMAGE_EXTENSIONS = new Set(["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp"]);
|
||||
|
||||
@@ -142,7 +145,7 @@ export function removeMention(text, path) {
|
||||
* @param {{name?:string, kind?:string}} file
|
||||
* @returns {string}
|
||||
*/
|
||||
function kindOf(file) {
|
||||
export function kindOf(file) {
|
||||
if (typeof file.kind === "string" && file.kind !== "") return file.kind.toLowerCase();
|
||||
|
||||
const name = typeof file.name === "string" ? file.name.toLowerCase() : "";
|
||||
@@ -164,8 +167,8 @@ function kindOf(file) {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function standalone(before, after, afterNext) {
|
||||
if (before !== "" && /[\w/\\-]/.test(before)) return false;
|
||||
if (after !== "" && /[\w/\\-]/.test(after)) return false;
|
||||
if (after === "." && /[\w/\\-]/.test(afterNext)) return false;
|
||||
if (before !== "" && PATH_CHAR.test(before)) return false;
|
||||
if (after !== "" && PATH_CHAR.test(after)) return false;
|
||||
if (after === "." && PATH_CHAR.test(afterNext)) return false;
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user