1
0
Fork 0
management/front/dkha-web-sz-main/node_modules/renderkid/lib/renderKid/styleApplier/block.js

96 lines
2.0 KiB
JavaScript
Raw Normal View History

2024-01-16 21:26:16 +08:00
"use strict";
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
// Generated by CoffeeScript 2.5.1
var _common, blockStyleApplier, merge, self;
2023-12-18 13:12:25 +08:00
2024-01-16 21:26:16 +08:00
_common = require('./_common');
merge = require('lodash/merge');
2023-12-18 13:12:25 +08:00
module.exports = blockStyleApplier = self = {
2024-01-16 21:26:16 +08:00
applyTo: function applyTo(el, style) {
2023-12-18 13:12:25 +08:00
var config, ret;
ret = _common.getStyleTagsFor(style);
ret.blockConfig = config = {};
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
this._margins(style, config);
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
this._bullet(style, config);
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
this._dims(style, config);
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
return ret;
},
2024-01-16 21:26:16 +08:00
_margins: function _margins(style, config) {
2023-12-18 13:12:25 +08:00
if (style.marginLeft != null) {
2024-01-16 21:26:16 +08:00
merge(config, {
2023-12-18 13:12:25 +08:00
linePrependor: {
options: {
amount: parseInt(style.marginLeft)
}
}
});
}
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
if (style.marginRight != null) {
2024-01-16 21:26:16 +08:00
merge(config, {
2023-12-18 13:12:25 +08:00
lineAppendor: {
options: {
amount: parseInt(style.marginRight)
}
}
});
}
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
if (style.marginTop != null) {
2024-01-16 21:26:16 +08:00
merge(config, {
2023-12-18 13:12:25 +08:00
blockPrependor: {
options: {
amount: parseInt(style.marginTop)
}
}
});
}
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
if (style.marginBottom != null) {
2024-01-16 21:26:16 +08:00
merge(config, {
2023-12-18 13:12:25 +08:00
blockAppendor: {
options: {
amount: parseInt(style.marginBottom)
}
}
});
}
},
2024-01-16 21:26:16 +08:00
_bullet: function _bullet(style, config) {
var after, before, bullet, conf;
if (style.bullet != null && style.bullet.enabled) {
2023-12-18 13:12:25 +08:00
bullet = style.bullet;
conf = {};
conf.alignment = style.bullet.alignment;
2024-01-16 21:26:16 +08:00
var _common$getStyleTagsF = _common.getStyleTagsFor({
2023-12-18 13:12:25 +08:00
color: bullet.color,
background: bullet.background
2024-01-16 21:26:16 +08:00
});
before = _common$getStyleTagsF.before;
after = _common$getStyleTagsF.after;
2023-12-18 13:12:25 +08:00
conf.char = before + bullet.char + after;
2024-01-16 21:26:16 +08:00
merge(config, {
2023-12-18 13:12:25 +08:00
linePrependor: {
options: {
bullet: conf
}
}
});
}
},
2024-01-16 21:26:16 +08:00
_dims: function _dims(style, config) {
2023-12-18 13:12:25 +08:00
var w;
2024-01-16 21:26:16 +08:00
2023-12-18 13:12:25 +08:00
if (style.width != null) {
w = parseInt(style.width);
config.width = w;
}
}
2024-01-16 21:26:16 +08:00
};