本文整理汇总了TypeScript中@ephox/snooker.TableRender类的典型用法代码示例。如果您正苦于以下问题:TypeScript TableRender类的具体用法?TypeScript TableRender怎么用?TypeScript TableRender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TableRender类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const insert = function (editor, columns, rows) {
let tableElm;
const renderedHtml = TableRender.render(rows, columns, 0, 0);
Attr.set(renderedHtml, 'id', '__mce');
const html = Html.getOuter(renderedHtml);
editor.insertContent(html);
tableElm = editor.dom.get('__mce');
editor.dom.setAttrib(tableElm, 'id', null);
editor.$('tr', tableElm).each(function (index, row) {
editor.fire('newrow', {
node: row
});
editor.$('th,td', row).each(function (index, cell) {
editor.fire('newcell', {
node: cell
});
});
});
editor.dom.setAttribs(tableElm, editor.settings.table_default_attributes || {});
editor.dom.setStyles(tableElm, editor.settings.table_default_styles || {});
selectFirstCellInTable(editor, Element.fromDom(tableElm));
return tableElm;
};
示例2: getDefaultStyles
const insert = (editor: Editor, columns: number, rows: number): HTMLElement => {
const defaultStyles = getDefaultStyles(editor);
const options: TableRender.RenderOptions = {
styles: defaultStyles,
attributes: getDefaultAttributes(editor),
percentages: isPercentage(defaultStyles.width) && !isPixelsForced(editor)
};
const table = TableRender.render(rows, columns, 0, 0, options);
Attr.set(table, 'data-mce-id', '__mce');
const html = Html.getOuter(table);
editor.insertContent(html);
return SelectorFind.descendant(Util.getBody(editor), 'table[data-mce-id="__mce"]').map((table) => {
if (isPixelsForced(editor)) {
Css.set(table, 'width', Css.get(table, 'width'));
}
Attr.remove(table, 'data-mce-id');
fireEvents(editor, table);
selectFirstCellInTable(editor, table);
return table.dom();
}).getOr(null);
};