Assign replacements
This commit is contained in:
parent
e29d9db2e7
commit
c74d6c6fff
3 changed files with 41 additions and 5 deletions
|
@ -36,6 +36,7 @@ import { ExportTypes } from "./exportUtils";
|
|||
import { IExportOptions } from "./exportUtils";
|
||||
import MatrixClientContext from "../../contexts/MatrixClientContext";
|
||||
import getExportCSS from "./exportCSS";
|
||||
import { textForEvent } from "../../TextForEvent";
|
||||
|
||||
export default class HTMLExporter extends Exporter {
|
||||
protected avatars: Map<string, boolean>;
|
||||
|
@ -346,13 +347,16 @@ export default class HTMLExporter extends Exporter {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
eventTile = await this.getEventTileMarkup(this.createModifiedEvent(this.mediaOmitText, mxEv), joined);
|
||||
eventTile = await this.getEventTileMarkup(
|
||||
this.createModifiedEvent(this.mediaOmitText, mxEv),
|
||||
joined,
|
||||
);
|
||||
}
|
||||
} else eventTile = await this.getEventTileMarkup(mxEv, joined);
|
||||
} catch (e) {
|
||||
// TODO: Handle callEvent errors
|
||||
console.error(e);
|
||||
eventTile = await this.getEventTileMarkup(this.createModifiedEvent("Error parsing HTML", mxEv), joined);
|
||||
eventTile = await this.getEventTileMarkup(this.createModifiedEvent(textForEvent(mxEv), mxEv), joined);
|
||||
}
|
||||
|
||||
return eventTile;
|
||||
|
|
|
@ -20,6 +20,7 @@ import ThemeWatcher from "../../settings/watchers/ThemeWatcher";
|
|||
|
||||
const getExportCSS = async (): Promise<string> => {
|
||||
const theme = new ThemeWatcher().getEffectiveTheme();
|
||||
// eslint-disable-next-line camelcase
|
||||
const hash = __webpack_hash__;
|
||||
const bundle = await fetch(`bundles/${hash}/bundle.css`);
|
||||
const bundleCSS = await bundle.text();
|
||||
|
@ -32,13 +33,14 @@ const getExportCSS = async (): Promise<string> => {
|
|||
themeCSS = await res.text();
|
||||
}
|
||||
const fontFaceRegex = /@font-face {.*?}/sg;
|
||||
themeCSS.replace(fontFaceRegex, '');
|
||||
themeCSS.replace(
|
||||
|
||||
themeCSS = themeCSS.replace(fontFaceRegex, '');
|
||||
themeCSS = themeCSS.replace(
|
||||
/font-family: Inter/g,
|
||||
`font-family: -apple-system, BlinkMacSystemFont, avenir next,
|
||||
avenir, segoe ui, helvetica neue, helvetica, Ubuntu, roboto, noto, arial, sans-serif`,
|
||||
);
|
||||
themeCSS.replace(
|
||||
themeCSS = themeCSS.replace(
|
||||
/font-family: Inconsolata/g,
|
||||
"font-family: Menlo, Consolas, Monaco, Liberation Mono, Lucida Console, monospace",
|
||||
);
|
||||
|
|
|
@ -37,6 +37,12 @@ describe('export', function() {
|
|||
return MY_USER_ID;
|
||||
};
|
||||
|
||||
const mockExportOptions: IExportOptions = {
|
||||
numberOfMessages: 5,
|
||||
maxSize: 100 * 1024 * 1024,
|
||||
attachmentsIncluded: false,
|
||||
};
|
||||
|
||||
const invalidExportOptions: IExportOptions[] = [
|
||||
{
|
||||
numberOfMessages: 10**9,
|
||||
|
@ -97,5 +103,29 @@ describe('export', function() {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
it('tests the file extension splitter', function() {
|
||||
const exporter = new PlainTextExporter(room, ExportTypes.BEGINNING, mockExportOptions, null);
|
||||
const fileNameWithExtensions = {
|
||||
"": ["", ""],
|
||||
"name": ["name", ""],
|
||||
"name.txt": ["name", ".txt"],
|
||||
".htpasswd": ["", ".htpasswd"],
|
||||
"name.with.many.dots.myext": ["name.with.many.dots", ".myext"],
|
||||
};
|
||||
for (const fileName in fileNameWithExtensions) {
|
||||
expect(exporter.splitFileName(fileName)).toStrictEqual(fileNameWithExtensions[fileName]);
|
||||
}
|
||||
});
|
||||
|
||||
// it('checks if the reply regex executes correctly', function() {
|
||||
// const eventContents = [
|
||||
// {
|
||||
// "msgtype": "m.text",
|
||||
// "body": "> <@me:here> Testing....\n\nTest",
|
||||
// "expectedText": "",
|
||||
// },
|
||||
// ];
|
||||
// });
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue