mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Use the Markdown textarea for every editor. Remove the retired environment and Snap options from server settings, all platform launchers, build scripts and current documentation. Keep released and archived changelog entries intact. Keep notification HTML escaping independent of editor configuration, preserve attachment metadata and mention behavior, and cover Markdown and emoji round trips in browser tests. Also import the translator used by attachment error handlers. Thanks to xet7 !
40 lines
1.4 KiB
JavaScript
40 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
// Pure helper: build the `meta` object stored on every card attachment
|
|
// (Attachments FilesCollection, ostrio:files). Kept side-effect free so it can
|
|
// be unit tested without a database or the Meteor client environment.
|
|
//
|
|
// Shared by the card Attachments popup and clipboard upload through
|
|
// Utils.getCommonAttachmentMetaFrom(). Existing attachments referenced in
|
|
// comments remain visible in the gallery through meta.cardId, without any
|
|
// meta.source filtering (#3843).
|
|
//
|
|
// For a linked card the attachment is attached to the REAL card (linkedId),
|
|
// so it shows up on the original card and on every linked copy.
|
|
//
|
|
// `getCardById` resolves the real card of a linked card (the client passes
|
|
// ReactiveCache.getCard). A missing/null card yields an empty meta rather
|
|
// than throwing, so a failed lookup cannot crash an upload handler.
|
|
function buildCardAttachmentMeta(card, getCardById) {
|
|
const meta = {};
|
|
if (!card) {
|
|
return meta;
|
|
}
|
|
if (typeof card.isLinkedCard === 'function' && card.isLinkedCard()) {
|
|
const realCard =
|
|
typeof getCardById === 'function' ? getCardById(card.linkedId) : null;
|
|
if (realCard) {
|
|
meta.boardId = realCard.boardId;
|
|
}
|
|
meta.cardId = card.linkedId;
|
|
} else {
|
|
meta.boardId = card.boardId;
|
|
meta.swimlaneId = card.swimlaneId;
|
|
meta.listId = card.listId;
|
|
meta.cardId = card._id;
|
|
}
|
|
return meta;
|
|
}
|
|
|
|
export { buildCardAttachmentMeta };
|