mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 15:14:13 +08:00
aa24be1a9a
* DEV: Add API to alter uploads Markdown * DEV: Extract data attributes from image / download Markdown For example '[test|attachment|hello=world]' will generate an 'a' element with a data attribute: 'data-hello=world'. This commit also makes MarkdownIt to transform '|attachment' into 'class="attachment"'. This transformation used to be a part of the process which resolves short URLs (i.e. upload://). * DEV: Export imageNameFromFileName
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
acceptance("Composer Attachment", {
|
|
loggedIn: true,
|
|
pretend(server, helper) {
|
|
server.post("/uploads/lookup-urls", () => {
|
|
return helper.response([
|
|
{
|
|
short_url: "upload://asdsad.png",
|
|
url: "/uploads/default/3X/1/asjdiasjdiasida.png",
|
|
short_path: "/uploads/short-url/asdsad.png"
|
|
}
|
|
]);
|
|
});
|
|
}
|
|
});
|
|
|
|
QUnit.test("attachments are cooked properly", async assert => {
|
|
await visit("/t/internationalization-localization/280");
|
|
await click("#topic-footer-buttons .btn.create");
|
|
|
|
await fillIn(".d-editor-input", "[test](upload://abcdefg.png)");
|
|
|
|
assert.equal(
|
|
find(".d-editor-preview:visible")
|
|
.html()
|
|
.trim(),
|
|
'<p><a href="/404">test</a></p>'
|
|
);
|
|
|
|
await fillIn(".d-editor-input", "[test|attachment](upload://asdsad.png)");
|
|
|
|
assert.equal(
|
|
find(".d-editor-preview:visible")
|
|
.html()
|
|
.trim(),
|
|
'<p><a class="attachment" href="/uploads/short-url/asdsad.png">test</a></p>'
|
|
);
|
|
});
|