protected override bool DoInsertData(DataAction action, MarkupPointer begin, MarkupPointer end) { // get the table and its cells IHTMLTable sourceTable = GetSourceTable(DataMeister); IHTMLElementCollection cells = (sourceTable as IHTMLElement2).getElementsByTagName("td"); // single-cell tables just get the innerHTML of the cell pasted at the selection if (cells.length == 1) { IHTMLElement cell = cells.item(0, 0) as IHTMLElement; EditorContext.InsertHtml(begin, end, cell.innerHTML, UrlHelper.GetBaseUrl(DataMeister.HTMLData.SourceURL)); } else { // if we are inside a table TableSelection tableSelection = new TableSelection(EditorContext.MarkupServices.CreateMarkupRange(begin, end)); if (tableSelection.Table != null) { // paste the source cells into the table PasteCellsIntoTable(sourceTable, tableSelection); } else { // get table html (make sure width matches # of rows selected) TableHelper.SynchronizeTableWidthForEditing(sourceTable); string html = (sourceTable as IHTMLElement).outerHTML; // insert the html (nests within an undo unit) EditorContext.InsertHtml(begin, end, html, UrlHelper.GetBaseUrl(DataMeister.HTMLData.SourceURL)); } } return(true); }
public void ContinueSizing(int clientX) { // calculate offset int offset = clientX - _lastClientX; // no-op for zero offset if (offset == 0) { return; } if (!_cellWidthsFixed) { // do fixups once during each size operation // This actually causes the cells to change size in many cases, which is incredibly annoying. // TableHelper.SynchronizeCellWidthsForEditing(_table); _cellWidthsFixed = true; } // check for abort condition if (AbortOnMinimumColumnWidth(offset)) { return; } // perform the sizing (middle of the table mode) if (_rightColumn != null) { _leftColumn.Width = Math.Max(_leftColumn.Width + offset, MINIMUM_COLUMN_WIDTH); _rightColumn.Width = Math.Max(_rightColumn.Width - offset, MINIMUM_COLUMN_WIDTH); } // perform the sizing (end of the table mode) else { // change left column _leftColumn.Width = Math.Max(_leftColumn.Width + offset, MINIMUM_COLUMN_WIDTH); // set the table width to prevent table wierdness TableHelper.SynchronizeTableWidthForEditing(_table); } // update last client x _lastClientX = clientX; // make sure we continue showing the sizing cursor ShowSizingCursor(); }