markdown: Improve drafts rendering of custom Markdown features.

Improves rendering of drafts to make it look more closer
to normal messages. This is done by passing the draft content
through rendered_markdown so that dynamic elements in the content
get updated before showing drafts modal.
This commit is contained in:
m-e-l-u-h-a-n
2021-04-15 14:41:46 +05:30
committed by Tim Abbott
parent 8c3ff92964
commit 16687d4c74

View File

@@ -22,6 +22,7 @@ import * as markdown from "./markdown";
import * as narrow from "./narrow";
import * as overlays from "./overlays";
import * as people from "./people";
import * as rendered_markdown from "./rendered_markdown";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
import * as timerender from "./timerender";
@@ -406,9 +407,17 @@ export function launch() {
drafts,
draft_lifetime: DRAFT_LIFETIME,
});
$("#drafts_table").append(rendered);
const drafts_table = $("#drafts_table");
drafts_table.append(rendered);
if ($("#drafts_table .draft-row").length > 0) {
$("#drafts_table .no-drafts").hide();
// Update possible dynamic elements.
const rendered_drafts = drafts_table.find(
".message_content.rendered_markdown.restore-draft",
);
rendered_drafts.each(function () {
rendered_markdown.update_elements($(this));
});
}
}