mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-05-03 13:09:29 +08:00
61 lines
1.4 KiB
Text
61 lines
1.4 KiB
Text
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
const defaults = Object.freeze({
|
|
inline: false,
|
|
width: null,
|
|
height: null,
|
|
hAlign: "center",
|
|
vAlign: "middle",
|
|
slice: false,
|
|
hFlip: false,
|
|
vFlip: false,
|
|
rotate: 0
|
|
});
|
|
function mergeCustomisations(defaults2, item) {
|
|
const result = {};
|
|
for (const key in defaults2) {
|
|
const attr = key;
|
|
result[attr] = defaults2[attr];
|
|
if (item[attr] === void 0) {
|
|
continue;
|
|
}
|
|
const value = item[attr];
|
|
switch (attr) {
|
|
case "inline":
|
|
case "slice":
|
|
if (typeof value === "boolean") {
|
|
result[attr] = value;
|
|
}
|
|
break;
|
|
case "hFlip":
|
|
case "vFlip":
|
|
if (value === true) {
|
|
result[attr] = !result[attr];
|
|
}
|
|
break;
|
|
case "hAlign":
|
|
case "vAlign":
|
|
if (typeof value === "string" && value !== "") {
|
|
result[attr] = value;
|
|
}
|
|
break;
|
|
case "width":
|
|
case "height":
|
|
if (typeof value === "string" && value !== "" || typeof value === "number" && value || value === null) {
|
|
result[attr] = value;
|
|
}
|
|
break;
|
|
case "rotate":
|
|
if (typeof value === "number") {
|
|
result[attr] += value;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
exports.defaults = defaults;
|
|
exports.mergeCustomisations = mergeCustomisations;
|