protected override void OnElementAttached() { base.OnElementAttached(); // If this is a "rectangular" table then automatically add the "unselectable" // attribute to it because we know we can support editing of it without // erratic behavior TableHelper.MakeTableWriterEditableIfRectangular(HTMLElement as IHTMLTable); // Is the table editable? _tableIsEditable = TableHelper.TableElementIsEditable(HTMLElement, ElementRange); if (_tableIsEditable) { // hookup column size editor and cell selection tracker _columnSizeEditor = new TableColumnSizeEditor(HTMLElement as IHTMLTable, EditorContext, HTMLPaintSite); _cellSelectionTracker = new TableCellSelectionTracker(this, TableEditingContext); HookEvents(); // make it unselecteable HTMLElement.setAttribute("unselectable", "on", 0); // if the table has no borders then set a runtime style that lets the user see the borders TableHelper.UpdateDesignTimeBorders(HTMLElement as IHTMLTable, HTMLElement as IHTMLElement2); _tableEditingInitialized = true; } }
private static IHTMLTable GetSourceTable(DataObjectMeister dataMeister) { // find our post body div IHTMLElement body = GetPostBodyElement(dataMeister.HTMLData.HTMLDocument); // look for a single table which constitutes the entire selection if (body != null) { IHTMLElementCollection tables = (body as IHTMLElement2).getElementsByTagName("table"); if (tables.length >= 1) { IHTMLElement table = tables.item(0, 0) as IHTMLElement; if (table.innerText == (body as IHTMLElement).innerText) { if (TableHelper.TableElementIsEditable(table)) { return(table as IHTMLTable); } } } } // didn't find a single table return(null); }
public bool ShowTableContextMenuForElement(IHTMLElement element) { IHTMLTable tableElement = TableHelper.GetContainingTableElement(element); if (tableElement != null) { MarkupRange tableMarkupRange = _editorContext.MarkupServices.CreateMarkupRange(tableElement as IHTMLElement); return(TableHelper.TableElementIsEditable(tableElement as IHTMLElement, tableMarkupRange)); } else { return(false); } }
protected override void OnElementAttached() { // call base base.OnElementAttached(); // determine whether the cell is editable _cellIsEditable = TableHelper.TableElementIsEditable(HTMLElement, ElementRange); // if editable then do our thing if (_cellIsEditable) { // add ourselves to the list of cell element behaviors TableEditingContext.AddCellBehavior(this); // if the table has no borders then set a runtime style that lets the user see the borders TableHelper.UpdateDesignTimeBorders( TableHelper.GetContainingTableElement(HTMLElement), HTMLElement as IHTMLElement2); } }