VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-form__js__fdeditor__utils.js
/*** module: node_modules/absol-form/js/fdeditor/utils.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.findPrevTextNode = findPrevTextNode;
exports.findNextTextNode = findNextTextNode;
exports.findLastTextNode = findLastTextNode;
exports.findFirstTextNode = findFirstTextNode;
exports.findFDComponentOfNode = findFDComponentOfNode;
exports.getTextNodeBounds = getTextNodeBounds;
exports.inheritComponentClassAttribute = inheritComponentClassAttribute;
exports.decodeHtmlText = decodeHtmlText;
exports.CHAR_EMQ = exports.CHAR_ZWS = void 0;

var _Rectangle = _interopRequireDefault(require("absol/src/Math/Rectangle"));

var _utils = require("absol-acomp/js/utils");

var _generator = require("absol/src/JSMaker/generator");


var CHAR_ZWS = String.fromCharCode(8203);
exports.CHAR_ZWS = CHAR_ZWS;
var CHAR_EMQ = String.fromCharCode(8193);
exports.CHAR_EMQ = CHAR_EMQ;

function findPrevTextNode(node) {
  // console.log('findPrevTextNode', node)
  var parent = node.parentElement;
  if (!parent) return null;
  var idx = Array.prototype.indexOf.call(parent.childNodes, node);
  var found = null;

  for (var i = idx - 1; !found && i >= 0; --i) {
    found = findLastTextNode(parent.childNodes[i]);
  }

  if (!found) found = findPrevTextNode(parent);
  return found;
}
/**
 *
 * @param {Text | AElement}node
 * @returns {*|null}
 */


function findNextTextNode(node) {
  // console.log('findPrevTextNode', node)
  var parent = node.parentElement;
  if (!parent) return null;
  var idx = Array.prototype.indexOf.call(parent.childNodes, node);
  var found = null;
  var n = parent.childNodes.length;

  for (var i = idx + 1; !found && i < n; ++i) {
    found = findLastTextNode(parent.childNodes[i]);
  }

  if (!found) found = findNextTextNode(parent);
  return found;
}
/**
 *
 * @param {Text | AElement|*} node
 * @returns {Text}
 */


function findLastTextNode(node) {
  if (!node) return null;
  if (node.nodeType === Node.TEXT_NODE) return node;
  var n = node.childNodes.length - 1;
  var found = null;

  for (var i = n; !found && i >= 0; --i) {
    found = findLastTextNode(node.childNodes[i]);
  }

  return found;
}
/**
 *
 * @param {Text | AElement|*} node
 * @returns {Text}
 */


function findFirstTextNode(node) {
  if (!node) return null;
  if (node.nodeType === Node.TEXT_NODE) return node;
  var n = node.childNodes.length;
  var found = null;

  for (var i = 0; !found && i < n; ++i) {
    found = findLastTextNode(node.childNodes[i]);
  }

  return found;
}

function findFDComponentOfNode(node) {
  while (node) {
    if (node.fdComponent) return node.fdComponent;
    node = node.parentElement;
  }

  return null;
}
/**
 *TODO: import from absol-acomp
 * @param {Text} text
 * @param {number=} startOffset
 * @param {number=} endOffset
 * @returns {*[]}
 */


function getTextNodeBounds(text, startOffset, endOffset) {
  if (!text || text.nodeType !== Node.TEXT_NODE || !text.parentElement) return null;
  var style = getComputedStyle(text.parentElement);
  var fontSize = parseFloat(style.getPropertyValue('font-size').replace('px', ''));
  var lineHeight = style.getPropertyValue('line-height');
  if (lineHeight === 'normal') lineHeight = 1.2;else lineHeight = parseFloat(lineHeight.replace('px', '')) / fontSize;
  var txt = text.data;
  var y = -Infinity;
  var c;
  var range;
  var parts = [];
  var cPart;
  var j;
  var delta = lineHeight * fontSize / 3;
  var rect;
  var i = 0;
  if ((0, _utils.isNaturalNumber)(startOffset)) i = Math.max(startOffset, i);
  if ((0, _utils.isNaturalNumber)(endOffset)) endOffset = Math.min(txt.length, endOffset);else endOffset = txt.length;

  while (i < endOffset) {
    c = txt[i];
    j = i + 1;
    range = document.createRange();
    range.setStart(text, i);
    range.setEnd(text, j);
    rect = _Rectangle.default.fromClientRect(range.getBoundingClientRect());

    if (Math.abs(rect.y - y) < delta) {
      cPart.end = j;
      cPart.rect = cPart.rect.merge(rect);
    } else {
      cPart = {
        start: i,
        end: j,
        rect: rect
      };
      y = rect.y;
      parts.push(cPart);
    }

    i = j;
  }

  parts.forEach(part => {
    rect = part.rect;
    part.text = txt.substring(part.start, part.end);
  });
  return parts;
}
/**
 *
 * @param target
 * @param source
 * @param {"style"|"attr"|null=}opt
 */


function inheritComponentClassAttribute(target, source, opt) {
  target.prototype.tag = source.prototype.tag;

  if (!opt || opt === 'attr') {
    Object.keys(source.prototype.attributeHandlers).filter(key => !target.prototype.attributeHandlers[key]).forEach(key => {
      target.prototype.attributeHandlers[key] = Object.assign({}, source.prototype.attributeHandlers[key]);
    });
    Object.assign(target.prototype.attributes, source.prototype.attributes);
  }

  if (!opt || opt === "style") {
    if (source.prototype.BOX_ALIGN_CLASSES) {
      target.prototype.BOX_ALIGN_CLASSES = source.prototype.BOX_ALIGN_CLASSES;
    }

    Object.keys(source.prototype.styleHandlers).filter(key => !target.prototype.styleHandlers[key]).forEach(key => {
      target.prototype.styleHandlers[key] = Object.assign({}, source.prototype.styleHandlers[key]);
    });
    Object.assign(target.prototype.style, source.prototype.style);
  }
}

function decodeHtmlText(html) {
  var txt = document.createElement("textarea");
  txt.innerHTML = html;
  return txt.value;
} //
// export function hyperLayoutConverter(data) {
//     if (data.class) return copyJSVariable(data);
//     if (!data.tag.endsWith('Layout')) return copyJSVariable(data);
//     var res = {
//         tag:'HyperLayout'
//     }
//     switch (data.tag) {
//         case 'HyperLayout':
//
//             break;
//         case 'LinearLayout': break;
//         case 'RelativeLayout':break;
//         case 'ChainLayout':break;
//     }
//
//     return res;
//
// }

VaKeR 2022