Commit 4ce317f5 authored by Alejandro Celaya's avatar Alejandro Celaya Committed by Alejandro Celaya

Use double-space for pretty-printed HTML indentation

parent 19aed53e
......@@ -469,8 +469,8 @@ describe('ExportAnnotations', () => {
context('when copying annotations export to clipboard', () => {
[true, false].forEach(exportFormatsEnabled => {
it('displays copy button if `export_formats` FF is enabled', () => {
fakeStore.isFeatureEnabled.callsFake(
ff => exportFormatsEnabled || ff !== 'export_formats',
fakeStore.isFeatureEnabled.callsFake(ff =>
ff === 'export_formats' ? exportFormatsEnabled : true,
);
const wrapper = createComponent();
......
......@@ -275,7 +275,10 @@ export class AnnotationsExporter {
</html>,
{},
{ pretty: true },
);
// `renderToString` indents lines with tabs when using `pretty: true`.
// Replacing them with double spaces we avoid side effects when pasting
// the result in a web app.
).replace(/\t/g, ' ');
}
private _exportCommon(
......
......@@ -292,13 +292,9 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
now,
});
// The result uses tabs to indent lines.
// We can get rid of that for simplicity and just compare the markup
const removeAllIndentation = str => str.replace(/^[ \t]+/gm, '');
assert.equal(
removeAllIndentation(result),
removeAllIndentation(`<html lang="en">
result,
`<html lang="en">
<head>
<title>
Annotations on &quot;A special document&quot;
......@@ -444,7 +440,7 @@ ${formattedNow},John Doe,,http://example.com,My group,Annotation,,Annotation tex
</article>
</section>
</body>
</html>`),
</html>`,
);
});
});
......
......@@ -45,8 +45,7 @@ export async function copyPlainText(text: string, navigator_ = navigator) {
}
/**
* Copy the string `text` to the clipboard, rendering HTML if any, instead of
* raw markup.
* Copy the string `text` to the clipboard with an HTML media type.
*
* If the browser does not support this, it will fall back to copy the string
* as plain text.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment