Skip to content

Commit

Permalink
Merge branch 'master' into 5498-puppeteer-v22
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
#	package.json
  • Loading branch information
sosnovsky committed May 20, 2024
2 parents 6c5ca7e + d4b2b95 commit 964da7a
Show file tree
Hide file tree
Showing 10 changed files with 243 additions and 43 deletions.
2 changes: 2 additions & 0 deletions extension/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div class="lightboxed">

version 8.5.5 on May 20, 2024: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/478?closed=1" target="_blank">Manifest V3</a>

version 8.5.4 on March 7, 2024: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/476?closed=1" target="_blank">Improved compatibility with firewalls</a>

version 8.5.3 on February 7, 2024: <a href="https://github.com/FlowCrypt/flowcrypt-browser/milestone/468?closed=1" target="_blank">Improvements for encrypted content detection and PGP/MIME messages parsing</a>
Expand Down
59 changes: 38 additions & 21 deletions extension/chrome/elements/compose-modules/compose-input-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
this.squire = new window.Squire(el, { addLinks });
this.initShortcuts();
this.handlePaste();
this.handleDragImages();
this.handlePasteImages();
this.resizeReplyBox();
this.scrollIntoView();
Expand All @@ -136,35 +137,51 @@ export class ComposeInputModule extends ViewModule<ComposeView> {
});
};

private handlePasteImages = () => {
private loadImageFromFile = (file: File, callback: (result: string) => void) => {
const reader = new FileReader();
reader.onload = () => callback(reader.result as string);
reader.readAsDataURL(file);
};

private insertImageIntoSquire = (imageData: string, name: string) => {
try {
this.squire.insertImage(imageData, { name, title: name });
this.view.draftModule.draftSave().catch(Catch.reportErr);
} catch (e) {
Catch.reportErr(e);
}
};

private handleDragImages = () => {
this.squire.addEventListener('drop', (ev: DragEvent) => {
try {
if (!this.isRichText()) {
return;
}
if (!ev.dataTransfer?.files.length) {
return;
}
const file = ev.dataTransfer.files[0];
const reader = new FileReader();
reader.onload = () => {
try {
this.squire.insertImage(reader.result?.toString() ?? '', { name: file.name, title: file.name });
this.view.draftModule.draftSave().catch(Catch.reportErr);
} catch (e) {
Catch.reportErr(e);
}
};
reader.readAsDataURL(file);
} catch (e) {
Catch.reportErr(e);
if (!this.isRichText() || !ev.dataTransfer?.files.length) {
return;
}
const file = ev.dataTransfer.files[0];
this.loadImageFromFile(file, imageData => {
this.insertImageIntoSquire(imageData, file.name);
});
});
this.squire.addEventListener('dragover', (e: DragEvent) => {
e.preventDefault(); // this is needed for 'drop' event to fire
});
};

private handlePasteImages = () => {
this.squire.addEventListener('pasteImage', (ev: Event & { detail: { clipboardData: DataTransfer } }) => {
if (!this.isRichText()) return;
const items = Array.from(ev.detail.clipboardData?.items ?? []);
const imageItem = items.find(item => /image/.test(item.type));

const imageFile = imageItem?.getAsFile();
if (imageItem && imageFile) {
this.loadImageFromFile(imageFile, imageData => {
this.insertImageIntoSquire(imageData, 'Pasted Image');
});
}
});
};

private handleRTL = () => {
const checkRTL = () => {
let container = $(this.squire.getSelection().commonAncestorContainer);
Expand Down
2 changes: 1 addition & 1 deletion extension/chrome/settings/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export class SetupView extends View {
return;
}
if (!armoredPubkey) {
await Ui.modal.warning('Public key not usable - not sumbitting to Attester');
await Ui.modal.warning('Public key not usable - not submitting to Attester');
return;
}
const pub = await KeyUtil.parse(armoredPubkey);
Expand Down
15 changes: 8 additions & 7 deletions extension/js/common/platform/catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import { Url } from '../core/common.js';
import { FLAVOR, InMemoryStoreKeys, SHARED_TENANT_API_HOST, VERSION } from '../core/const.js';
import { GlobalStore } from './store/global-store.js';
import { InMemoryStore } from './store/in-memory-store.js';

export class UnreportableError extends Error {}
Expand Down Expand Up @@ -283,8 +284,8 @@ export class Catch {
private static formatExceptionForReport(thrown: unknown, line?: number, col?: number): ErrorReport {
if (!line || !col) {
const { line: parsedLine, col: parsedCol } = Catch.getErrorLineAndCol(thrown);
line = parsedLine;
col = parsedCol;
line = parsedLine > 0 ? parsedLine : 1;
col = parsedCol > 0 ? parsedCol : 1;
}
if (thrown instanceof Error) {
// reporting stack may differ from the stack of the actual error, both may be interesting
Expand All @@ -299,8 +300,8 @@ export class Catch {
name: exception.name.substring(0, 50),
message: exception.message.substring(0, 200),
url: location.href.split('?')[0],
line: line || 0,
col: col || 0,
line: line || 1,
col: col || 1,
trace: exception.stack || '',
version: VERSION,
environment: Catch.RUNTIME_ENVIRONMENT,
Expand All @@ -311,8 +312,8 @@ export class Catch {

private static async doSendErrorToSharedTenantFes(errorReport: ErrorReport) {
try {
const uncheckedUrlParams = Url.parse(['acctEmail']);
const acctEmail = String(uncheckedUrlParams.acctEmail);
const { acctEmail: parsedEmail } = Url.parse(['acctEmail']);
const acctEmail = parsedEmail ? String(parsedEmail) : (await GlobalStore.acctEmailsGet())?.[0];
if (!acctEmail) {
console.error('Not reporting error because user is not logged in');
return;
Expand Down Expand Up @@ -376,7 +377,7 @@ export class Catch {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return { line: Number(matched![1]), col: Number(matched![2]) };
} catch (lineErr) {
return { line: 0, col: 0 };
return { line: 1, col: 1 };
}
}

Expand Down
192 changes: 186 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 964da7a

Please sign in to comment.