@progress/kendo-angular-editor
Version:
Kendo UI Editor for Angular
97 lines (96 loc) • 2.35 kB
JavaScript
/**-----------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the project root for more information
*-------------------------------------------------------------------------------------------*/
/**
* @hidden
*/
export const hasAttrs = (attrs, exclude) => {
for (const attr in attrs) {
if (attr && attrs[attr] !== null && attr !== exclude) {
return true;
}
}
return false;
};
/**
* @hidden
*/
export const getAttrs = (attrs, exclude) => {
const result = {};
for (const attr in attrs) {
if (attr && attrs[attr] !== null && attr !== exclude && attr !== 'constructor' && attr !== '__proto__' && attr !== 'prototype') {
result[attr] = attrs[attr];
}
}
return result;
};
/**
* @hidden
*/
export const getAttributes = (dom) => {
const result = {};
const attributes = dom.attributes;
for (let i = 0; i < attributes.length; i++) {
const attr = attributes[i];
result[attr.name] = attr.value;
}
return result;
};
/**
* @hidden
*/
export const serializeDOMAttrs = (el) => Array.from(el.attributes)
.reduce((acc, curr) => Object.assign({}, acc, { [curr.name]: curr.value }), {});
/**
* @hidden
*/
export const commonAttributes = () => {
return {
...createDefaultAttributes(['class', 'id', 'style'])
};
};
/**
* @hidden
*/
export const createDefaultAttributes = (attrs = []) => {
return {
...attrs.reduce((acc, curr) => ({ ...acc, [curr]: { default: null } }), {})
};
};
/**
* @hidden
*/
export const hole = 0;
/**
* @hidden
*/
export const isSchemaNode = (schemaNodeName) => (node) => node.type.name === schemaNodeName;
/**
* @hidden
*/
export const isTable = isSchemaNode('table');
/**
* @hidden
*/
export const isTableBody = isSchemaNode('table_body');
/**
* @hidden
*/
export const isTableHead = isSchemaNode('table_head');
/**
* @hidden
*/
export const isTableFoot = isSchemaNode('table_foot');
/**
* @hidden
*/
export const isTableRow = isSchemaNode('table_row');
/**
* @hidden
*/
export const isTableCell = isSchemaNode('table_cell');
/**
* @hidden
*/
export const isTableHeaderCell = isSchemaNode('table_header');