rename drafty form response content type to text/x-drafy-fr

This commit is contained in:
or-else
2025-08-10 10:30:47 +03:00
parent a84a5a677a
commit 56790262f3
14 changed files with 85 additions and 83 deletions
+9 -6
View File
@@ -1452,9 +1452,9 @@ class DB {
const MAX_FORM_ELEMENTS = 8;
const MAX_PREVIEW_ATTACHMENTS = 3;
const MAX_PREVIEW_DATA_SIZE = 64;
const JSON_MIME_TYPE = 'application/json+drafty';
const JSON_MIME_TYPE_LEGACY = 'application/json';
const DRAFTY_MIME_TYPE = 'text/x-drafty';
const DRAFTY_FR_MIME_TYPE = 'text/x-drafty-fr';
const DRAFTY_FR_MIME_TYPE_LEGACY = 'application/json';
const ALLOWED_ENT_FIELDS = ['act', 'height', 'duration', 'incoming', 'mime', 'name', 'premime', 'preref', 'preview', 'ref', 'size', 'state', 'url', 'val', 'width'];
const segmenter = new Intl.Segmenter();
const INLINE_STYLES = [{
@@ -2290,7 +2290,7 @@ Drafty.attachJSON = function (content, data) {
content.ent.push({
tp: 'EX',
data: {
mime: JSON_MIME_TYPE,
mime: DRAFTY_FR_MIME_TYPE,
val: data
}
});
@@ -2537,7 +2537,7 @@ Drafty.sanitizeEntities = function (content) {
};
Drafty.getDownloadUrl = function (entData) {
let url = null;
if (entData.mime != JSON_MIME_TYPE && entData.mime != JSON_MIME_TYPE_LEGACY && entData.val) {
if (!Drafty.isFormResponseType(entData.mime) && entData.val) {
url = base64toObjectUrl(entData.val, entData.mime, Drafty.logger);
} else if (typeof entData.ref == 'string') {
url = entData.ref;
@@ -2568,6 +2568,9 @@ Drafty.attrValue = function (style, data) {
Drafty.getContentType = function () {
return DRAFTY_MIME_TYPE;
};
Drafty.isFormResponseType = function (mimeType) {
return mimeType === DRAFTY_FR_MIME_TYPE || mimeType === DRAFTY_FR_MIME_TYPE_LEGACY;
};
function chunkify(line, start, end, spans) {
const chunks = [];
if (spans.length == 0) {
@@ -3021,7 +3024,7 @@ function attachmentsToEnd(tree, limit) {
if (attachments.length == limit) {
continue;
}
if (c.data['mime'] == JSON_MIME_TYPE || c.data['mime'] == JSON_MIME_TYPE_LEGACY) {
if (Drafty.isFormResponseType(c.data['mime'])) {
continue;
}
delete c.att;
@@ -5397,7 +5400,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ PACKAGE_VERSION: () => (/* binding */ PACKAGE_VERSION)
/* harmony export */ });
const PACKAGE_VERSION = "0.24.3";
const PACKAGE_VERSION = "0.24.4";
/***/ })