本文整理汇总了TypeScript中tinymce/core/html/Node.attr函数的典型用法代码示例。如果您正苦于以下问题:TypeScript attr函数的具体用法?TypeScript attr怎么用?TypeScript attr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了attr函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
Tools.each('keywords,description,author,copyright,robots'.split(','), function (name) {
const nodes = headerFragment.getAll('meta');
let i, meta;
const value = data[name];
for (i = 0; i < nodes.length; i++) {
meta = nodes[i];
if (meta.attr('name') === name) {
if (value) {
meta.attr('content', value);
} else {
meta.remove();
}
return;
}
}
if (value) {
elm = new Node('meta', 1);
elm.attr('name', name);
elm.attr('content', value);
elm.shortEnded = true;
addHeadNode(elm);
}
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:28,代码来源:Parser.ts
示例2: function
const createPreviewIframeNode = function (editor, node) {
let previewWrapper;
let previewNode;
let shimNode;
const name = node.name;
previewWrapper = new Node('span', 1);
previewWrapper.attr({
'contentEditable': 'false',
'style': node.attr('style'),
'data-mce-object': name,
'class': 'mce-preview-object mce-object-' + name
});
retainAttributesAndInnerHtml(editor, node, previewWrapper);
previewNode = new Node(name, 1);
previewNode.attr({
src: node.attr('src'),
allowfullscreen: node.attr('allowfullscreen'),
width: node.attr('width') || '300',
height: node.attr('height') || (name === 'audio' ? '30' : '150'),
frameborder: '0'
});
shimNode = new Node('span', 1);
shimNode.attr('class', 'mce-shim');
previewWrapper.append(previewNode);
previewWrapper.append(shimNode);
return previewWrapper;
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:33,代码来源:Nodes.ts
示例3: function
suite.test('clone', function () {
let root, node, clone;
node = new Node('#text', 3);
node.value = 'value';
clone = node.clone();
LegacyUnit.equal(clone.name, '#text');
LegacyUnit.equal(clone.type, 3);
LegacyUnit.equal(clone.value, 'value');
LegacyUnit.equal(clone.parent, undefined);
LegacyUnit.equal(clone.next, undefined);
LegacyUnit.equal(clone.prev, undefined);
root = new Node('#frag', 11);
node = new Node('#text', 3);
node.value = 'value';
root.append(node);
LegacyUnit.equal(clone.name, '#text');
LegacyUnit.equal(clone.type, 3);
LegacyUnit.equal(clone.value, 'value');
LegacyUnit.equal(clone.parent, undefined);
LegacyUnit.equal(clone.next, undefined);
LegacyUnit.equal(clone.prev, undefined);
node = new Node('b', 1);
node.attr('id', 'id');
node.attr('class', 'class');
node.attr('title', 'title');
clone = node.clone();
LegacyUnit.equal(clone.name, 'b');
LegacyUnit.equal(clone.type, 1);
LegacyUnit.deepEqual(clone.attributes, [{ name: 'class', value: 'class' }, { name: 'title', value: 'title' }]);
LegacyUnit.deepEqual(clone.attributes.map, { class: 'class', title: 'title' });
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:34,代码来源:NodeTest.ts
示例4: convertParagraphToLi
function convertParagraphToLi(paragraphNode, listName, start?) {
const level = paragraphNode._listLevel || lastLevel;
// Handle list nesting
if (level !== lastLevel) {
if (level < lastLevel) {
// Move to parent list
if (currentListNode) {
currentListNode = currentListNode.parent.parent;
}
} else {
// Create new list
prevListNode = currentListNode;
currentListNode = null;
}
}
if (!currentListNode || currentListNode.name !== listName) {
prevListNode = prevListNode || currentListNode;
currentListNode = new Node(listName, 1);
if (start > 1) {
currentListNode.attr('start', '' + start);
}
paragraphNode.wrap(currentListNode);
} else {
currentListNode.append(paragraphNode);
}
paragraphNode.name = 'li';
// Append list to previous list if it exists
if (level > lastLevel && prevListNode) {
prevListNode.lastChild.append(currentListNode);
}
lastLevel = level;
// Remove start of list item "1. " or "· " etc
removeIgnoredNodes(paragraphNode);
trimListStart(paragraphNode, /^\u00a0+/);
trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
trimListStart(paragraphNode, /^\u00a0+/);
}
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:45,代码来源:WordFilter.ts
示例5: function
editor.serializer.addAttributeFilter('data-mce-object', function (nodes, name) {
let i = nodes.length;
let node;
let realElm;
let ai;
let attribs;
let innerHtml;
let innerNode;
let realElmName;
let className;
while (i--) {
node = nodes[i];
if (!node.parent) {
continue;
}
realElmName = node.attr(name);
realElm = new Node(realElmName, 1);
// Add width/height to everything but audio
if (realElmName !== 'audio' && realElmName !== 'script') {
className = node.attr('class');
if (className && className.indexOf('mce-preview-object') !== -1) {
realElm.attr({
width: node.firstChild.attr('width'),
height: node.firstChild.attr('height')
});
} else {
realElm.attr({
width: node.attr('width'),
height: node.attr('height')
});
}
}
realElm.attr({
style: node.attr('style')
});
// Unprefix all placeholder attributes
attribs = node.attributes;
ai = attribs.length;
while (ai--) {
const attrName = attribs[ai].name;
if (attrName.indexOf('data-mce-p-') === 0) {
realElm.attr(attrName.substr(11), attribs[ai].value);
}
}
if (realElmName === 'script') {
realElm.attr('type', 'text/javascript');
}
// Inject innerhtml
innerHtml = node.attr('data-mce-html');
if (innerHtml) {
innerNode = new Node('#text', 3);
innerNode.raw = true;
innerNode.value = Sanitize.sanitize(editor, unescape(innerHtml));
realElm.append(innerNode);
}
node.replace(realElm);
}
});
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:67,代码来源:FilterContent.ts
注:本文中的tinymce/core/html/Node.attr函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论