Created
August 31, 2021 09:41
-
-
Save formatkaka/a8cb28ff27897c10d7ddbc3b92cae7d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// modules are defined as an array | |
// [ module function, map of requires ] | |
// | |
// map of requires is short require name -> numeric require | |
// | |
// anything defined in a previous bundle is accessed via the | |
// orig method which is the require for previous bundles | |
parcelRequire = (function (modules, cache, entry, globalName) { | |
// Save the require from previous bundle to this closure if any | |
var previousRequire = typeof parcelRequire === 'function' && parcelRequire; | |
var nodeRequire = typeof require === 'function' && require; | |
function newRequire(name, jumped) { | |
if (!cache[name]) { | |
if (!modules[name]) { | |
// if we cannot find the module within our internal map or | |
// cache jump to the current global require ie. the last bundle | |
// that was added to the page. | |
var currentRequire = typeof parcelRequire === 'function' && parcelRequire; | |
if (!jumped && currentRequire) { | |
return currentRequire(name, true); | |
} | |
// If there are other bundles on this page the require from the | |
// previous one is saved to 'previousRequire'. Repeat this as | |
// many times as there are bundles until the module is found or | |
// we exhaust the require chain. | |
if (previousRequire) { | |
return previousRequire(name, true); | |
} | |
// Try the node require function if it exists. | |
if (nodeRequire && typeof name === 'string') { | |
return nodeRequire(name); | |
} | |
var err = new Error('Cannot find module \'' + name + '\''); | |
err.code = 'MODULE_NOT_FOUND'; | |
throw err; | |
} | |
localRequire.resolve = resolve; | |
localRequire.cache = {}; | |
var module = cache[name] = new newRequire.Module(name); | |
modules[name][0].call(module.exports, localRequire, module, module.exports, this); | |
} | |
return cache[name].exports; | |
function localRequire(x){ | |
return newRequire(localRequire.resolve(x)); | |
} | |
function resolve(x){ | |
return modules[name][1][x] || x; | |
} | |
} | |
function Module(moduleName) { | |
this.id = moduleName; | |
this.bundle = newRequire; | |
this.exports = {}; | |
} | |
newRequire.isParcelRequire = true; | |
newRequire.Module = Module; | |
newRequire.modules = modules; | |
newRequire.cache = cache; | |
newRequire.parent = previousRequire; | |
newRequire.register = function (id, exports) { | |
modules[id] = [function (require, module) { | |
module.exports = exports; | |
}, {}]; | |
}; | |
var error; | |
for (var i = 0; i < entry.length; i++) { | |
try { | |
newRequire(entry[i]); | |
} catch (e) { | |
// Save first error but execute all entries | |
if (!error) { | |
error = e; | |
} | |
} | |
} | |
if (entry.length) { | |
// Expose entry point to Node, AMD or browser globals | |
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js | |
var mainExports = newRequire(entry[entry.length - 1]); | |
// CommonJS | |
if (typeof exports === "object" && typeof module !== "undefined") { | |
module.exports = mainExports; | |
// RequireJS | |
} else if (typeof define === "function" && define.amd) { | |
define(function () { | |
return mainExports; | |
}); | |
// <script> | |
} else if (globalName) { | |
this[globalName] = mainExports; | |
} | |
} | |
// Override the current require with this new one | |
parcelRequire = newRequire; | |
if (error) { | |
// throw error from earlier, _after updating parcelRequire_ | |
throw error; | |
} | |
return newRequire; | |
})({"FOZT":[function(require,module,exports) { | |
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | |
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | |
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | |
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | |
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | |
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | |
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | |
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | |
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | |
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | |
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | |
/** | |
* Retrieve background images from a master format node | |
* | |
* @param node | |
* @returns {{mobileImage: null, desktopImage: null}} | |
*/ | |
function getBackgroundImages(node) { | |
var images = node.getAttribute('data-background-images'); | |
var response = { | |
desktopImage: null, | |
mobileImage: null, | |
backgroundSize: node.style.backgroundSize, | |
backgroundPosition: node.style.backgroundPosition, | |
backgroundAttachment: node.style.backgroundAttachment, | |
backgroundRepeat: node.style.backgroundRepeat !== 'no-repeat' | |
}; | |
if (images) { | |
var imagesStructure = JSON.parse(images.replace(/\\"/g, '"')); | |
if (imagesStructure.desktop_image) { | |
response.desktopImage = imagesStructure.desktop_image; | |
} | |
if (imagesStructure.mobile_image) { | |
response.mobileImage = imagesStructure.mobile_image; | |
} | |
} | |
return response; | |
} | |
var alignmentToFlex = { | |
top: 'flex-start', | |
middle: 'center', | |
bottom: 'flex-end' | |
}; | |
/** | |
* Retrieve vertical alignment from a master format node | |
* | |
* @param node | |
* @returns {{verticalAlignment: null}} | |
*/ | |
function getVerticalAlignment(node) { | |
var verticalAlignment = null; | |
if (node.style.justifyContent) { | |
verticalAlignment = flexToVerticalAlignment(node.style.justifyContent); | |
} | |
return { | |
verticalAlignment: verticalAlignment | |
}; | |
} | |
/** | |
* Convert vertical alignment values to flex values | |
* | |
* @param alignment | |
* @returns {*} | |
*/ | |
function verticalAlignmentToFlex(alignment) { | |
return alignmentToFlex[alignment]; | |
} | |
/** | |
* Convert flex to vertical alignment values | |
* | |
* @param flex | |
* @returns {*} | |
*/ | |
function flexToVerticalAlignment(flex) { | |
var flexToAlignment = Object.assign.apply(Object, [{}].concat(_toConsumableArray(Object.entries(alignmentToFlex).map(function (_ref) { | |
var _ref2 = _slicedToArray(_ref, 2), | |
a = _ref2[0], | |
b = _ref2[1]; | |
return _defineProperty({}, b, a); | |
})))); | |
return flexToAlignment[flex]; | |
} | |
/** | |
* Retrieve advanced props from content type node | |
* | |
* @param node | |
* @returns {{border: (string|string[]|string), marginRight: (*|string), borderColor: *, paddingBottom: (*|number|string), borderRadius: *, borderWidth: *, paddingRight: (*|number|string), marginBottom: (*|string), paddingTop: (*|string), paddingLeft: (*|string), marginTop: (*|string), marginLeft: (*|string|{get}|number)}} | |
*/ | |
function getAdvanced(node) { | |
return _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getPadding(node)), getMargin(node)), getBorder(node)), getTextAlign(node)), getCssClasses(node)), getIsHidden(node)); | |
} | |
/** | |
* Retrieve the padding from a content type node | |
* | |
* @param node | |
* @returns {{paddingBottom: *, paddingRight: *, paddingTop: *, paddingLeft: *}} | |
*/ | |
function getPadding(node) { | |
return { | |
paddingTop: node.style.paddingTop, | |
paddingRight: node.style.paddingRight, | |
paddingBottom: node.style.paddingBottom, | |
paddingLeft: node.style.paddingLeft | |
}; | |
} | |
/** | |
* Retrieve the margin from a content type node | |
* | |
* @param node | |
* @returns {{marginRight: *, marginBottom: *, marginTop: *, marginLeft: *}} | |
*/ | |
function getMargin(node) { | |
return { | |
marginTop: node.style.marginTop, | |
marginRight: node.style.marginRight, | |
marginBottom: node.style.marginBottom, | |
marginLeft: node.style.marginLeft | |
}; | |
} | |
/** | |
* Retrieve the border from a content type node | |
* | |
* @param node | |
* @returns {{border: (string|string), borderColor: *, borderRadius: *, borderWidth: *}} | |
*/ | |
function getBorder(node) { | |
return { | |
border: node.style.borderStyle, | |
borderColor: node.style.borderColor, | |
borderWidth: node.style.borderWidth, | |
borderRadius: node.style.borderRadius | |
}; | |
} | |
/** | |
* Retrieve the text align from a content type node | |
* | |
* @param node | |
* @returns {{textAlign: *}} | |
*/ | |
function getTextAlign(node) { | |
return { | |
textAlign: node.style.textAlign | |
}; | |
} | |
/** | |
* Retrieve the CSS classes from a content type node | |
* @param node | |
* @returns {{cssClasses: any}} | |
*/ | |
function getCssClasses(node) { | |
return { | |
cssClasses: node.getAttribute('class') ? node.getAttribute('class').split(' ') : [] | |
}; | |
} | |
/** | |
* Retrieve if CSS display property is set to none from a content type node | |
* | |
* @param node | |
* @returns {{isHidden: boolean}} | |
*/ | |
function getIsHidden(node) { | |
return { | |
isHidden: node.style.display === 'none' | |
}; | |
} | |
module.exports = { | |
getBackgroundImages: getBackgroundImages, | |
getVerticalAlignment: getVerticalAlignment, | |
verticalAlignmentToFlex: verticalAlignmentToFlex, | |
flexToVerticalAlignment: flexToVerticalAlignment, | |
getAdvanced: getAdvanced, | |
getPadding: getPadding, | |
getMargin: getMargin, | |
getBorder: getBorder, | |
getTextAlign: getTextAlign, | |
getCssClasses: getCssClasses, | |
getIsHidden: getIsHidden | |
}; | |
},{}],"zUeM":[function(require,module,exports) { | |
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | |
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
var _require = require('../utils'), | |
getAdvanced = _require.getAdvanced, | |
getBackgroundImages = _require.getBackgroundImages, | |
getVerticalAlignment = _require.getVerticalAlignment; | |
module.exports = function (node) { | |
return _objectSpread(_objectSpread(_objectSpread({ | |
minHeight: node.style.minHeight ? node.style.minHeight : null, | |
display: node.style.display, | |
width: node.style.width, | |
backgroundColor: node.style.backgroundColor | |
}, getAdvanced(node)), getBackgroundImages(node)), getVerticalAlignment(node)); | |
}; | |
},{"../utils":"FOZT"}],"Xg27":[function(require,module,exports) { | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { | |
value: true | |
}); | |
exports.default = void 0; | |
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } | |
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | |
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | |
var _require = require('../utils'), | |
getAdvanced = _require.getAdvanced, | |
getBackgroundImages = _require.getBackgroundImages, | |
getVerticalAlignment = _require.getVerticalAlignment, | |
getIsHidden = _require.getIsHidden; | |
var _default = function _default(node, props) { | |
// Determine which node holds the data for the appearance | |
var dataNode = props.appearance === 'contained' ? node.childNodes[0] : node; | |
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({ | |
minHeight: dataNode.style.minHeight ? dataNode.style.minHeight : null | |
}, getVerticalAlignment(dataNode)), {}, { | |
backgroundColor: dataNode.style.backgroundColor ? dataNode.style.backgroundColor : null | |
}, getBackgroundImages(dataNode)), {}, { | |
enableParallax: dataNode.getAttribute('data-enable-parallax') === '1', | |
parallaxSpeed: parseFloat(dataNode.getAttribute('data-parallax-speed')) | |
}, getAdvanced(dataNode)), getIsHidden(node)); | |
}; | |
exports.default = _default; | |
},{"../utils":"FOZT"}],"Focm":[function(require,module,exports) { | |
var columnConfigAggregator = require('./configs/column.configAggregator'); | |
var rowConfigAggregator = require('./configs/row.configAggregator'); | |
var createContentTypeObject = function createContentTypeObject(type, node) { | |
return { | |
contentType: type, | |
appearance: node ? node.getAttribute('data-appearance') : null, | |
children: [] | |
}; | |
}; | |
var walk = function walk(rootEl, contentTypeStructureObj) { | |
var tree = document.createTreeWalker(rootEl, window.NodeFilter.SHOW_ELEMENT | window.NodeFilter.SHOW_TEXT); | |
var currentNode = tree.nextNode(); | |
while (currentNode) { | |
if (currentNode.nodeType !== window.Node.ELEMENT_NODE) { | |
currentNode = tree.nextNode(); | |
continue; | |
} | |
var contentType = currentNode.getAttribute('data-content-type'); | |
if (!contentType) { | |
currentNode = tree.nextNode(); | |
continue; | |
} | |
var props = createContentTypeObject(contentType, currentNode); | |
var contentTypeConfig = getContentTypeConfig(contentType); | |
if (contentTypeConfig && typeof contentTypeConfig.configAggregator === 'function') { | |
try { | |
Object.assign(props, contentTypeConfig.configAggregator(currentNode, props)); | |
} catch (e) { | |
console.error("Failed to aggregate config for content type ".concat(contentType, "."), e); | |
} | |
} else { | |
console.warn("Page Builder ".concat(contentType, " content type is not supported, this content will not be rendered.")); | |
} | |
contentTypeStructureObj.children.push(props); | |
walk(currentNode, props); | |
currentNode = tree.nextSibling(); | |
} | |
return contentTypeStructureObj; | |
}; | |
var pbStyleAttribute = 'data-pb-style'; | |
var bodyId = 'html-body'; | |
/** | |
* Convert styles block to inline styles. | |
* @param {HTMLDocument} document | |
*/ | |
var convertToInlineStyles = function convertToInlineStyles(document) { | |
var styleBlocks = document.getElementsByTagName('style'); | |
var styles = {}; | |
if (styleBlocks.length > 0) { | |
Array.from(styleBlocks).forEach(function (styleBlock) { | |
var cssRules = styleBlock.sheet.cssRules; | |
Array.from(cssRules).forEach(function (rule) { | |
if (rule instanceof window.CSSStyleRule) { | |
var selectors = rule.selectorText.split(',').map(function (selector) { | |
return selector.trim(); | |
}); | |
selectors.forEach(function (selector) { | |
if (!styles[selector]) { | |
styles[selector] = []; | |
} | |
styles[selector].push(rule.style); | |
}); | |
} | |
}); | |
}); | |
} | |
Object.keys(styles).map(function (selector) { | |
var element = document.querySelector(selector); | |
if (!element) { | |
return; | |
} | |
styles[selector].map(function (style) { | |
element.setAttribute('style', element.style.cssText + style.cssText); | |
}); | |
element.removeAttribute(pbStyleAttribute); | |
}); | |
}; | |
/** | |
* Parse the master format storage HTML | |
* | |
* @param {String} htmlStr | |
* @returns {Object} | |
*/ | |
var parseStorageHtml = function parseStorageHtml(htmlStr) { | |
var container = new DOMParser().parseFromString(htmlStr, 'text/html'); | |
var stageContentType = createContentTypeObject('root-container'); | |
container.body.id = bodyId; | |
convertToInlineStyles(container); | |
return walk(container.body, stageContentType); | |
}; //////////////////////////////////////////// | |
////////// | |
function getContentTypeConfig(contentType) { | |
if (contentTypesConfig[contentType]) { | |
return contentTypesConfig[contentType]; | |
} | |
} | |
var contentTypesConfig = { | |
column: { | |
configAggregator: columnConfigAggregator, | |
component: 'Column' | |
}, | |
row: { | |
configAggregator: rowConfigAggregator, | |
component: 'Row' | |
} | |
}; | |
},{"./configs/column.configAggregator":"zUeM","./configs/row.configAggregator":"Xg27"}]},{},["Focm"], null) | |
//# sourceMappingURL=/index.js.map |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment