Wiki Table Editor API

Contents

API : Classes

Class SimileWikiToolbox

Static methods

  • editTable(wikiTable, onDone, onCancel, row, column) shows a dialog box for editing the given wiki table. If row and column are provided, focus on that cell at the beginning. onDone is a function that will be called when the user finishes editing and clicks OK (or Save or whatever); onCancel is called when the user cancels.
  • editTableInText(text, cursor, onDone, onCancel) shows a dialog box for editing the wiki table surrounding the given cursor position. When the dialog box shows up, focus on the cell that corresponds to where the cursor is in the original text. onDone is called with the resulting text when the user commits the edit; onCancel is called with no argument when the user cancels.
  • createTable(text, cursor, onDone, onCancel) shows a dialog box for editing a new table. When the user commits, the new table gets turned into wikitext, and inserted back into the original text where the cursor was; then onDone is called with the resulting wikitext. If the user cancels, onCancel is called.

Class SimileWikiToolbox.WikiTable

Static methods

  • createTable() returns an empty table in the form of a SimileWikiToolbox.WikiTable object.
  • findTable(text, cursor) returns an object with two fields: tableStart and tableEnd, which are character indices into the text argument specifying where to find the beginning and ending of the table surrounding cursor.
  • parseTable(text, cursor) parses the wikitext table encoded in the given text returns an object with three fields:
    • table, an object of type new SimileWikiToolbox.WikiTable(text)
    • row and column, numbers identifying the cell that corresponds to where cursor was.

Constructor

  • new SimileWikiToolbox.WikiTable(text), where text is optional, returns a SimileWikiToolbox.WikiTable object.

Methods

  • getRowCount() returns the number of rows.
  • getColumnCount() returns the number of rows.
  • insertRow(index) inserts a row at the given index and returns the new row in the form of a SimileWikiToolbox.WikiTableRow object.
  • removeRow(index) removes the row at the given index.
  • moveRow(fromIndex, toIndex) moves a row.
  • getRow(rowIndex) returns the rowIndex'th row in the form of a SimileWikiToolbox.WikiTableRow object.
  • insertColumn(index) inserts a column at the given index.
  • removeColumn(index) removes the column at the given index.
  • moveColumn(fromIndex, toIndex) moves a column.
  • forEachCellInColumn(columnIndex, f) calls f on each cell in the given column. f is a function that takes a SimileWikiToolbox.WikiTableCell argument.
  • mergeCells(startRow, endRow, startColumn, endColumn) merges several cells together.
  • getSettings() returns the settings of the whole table in the form of a SimileWikiToolbox.WikiTableSettings object.
  • toWikiText returns the wikitext serialization of this table.

Class SimileWikiToolbox.WikiTableRow

Methods

  • isHeaderRow() returns true or false.
  • getCellCount() returns the number of cells.
  • getCell(cellIndex) returns the cellIndex'th cell in the form of a SimileWikiToolbox.WikiTableCell object.
  • getSettings() returns the settings of the row in the form of a SimileWikiToolbox.WikiTableRowSettings object.
  • toWikiText returns the wikitext serialization of this row.


Class SimileWikiToolbox.WikiTableCell

  • getContent() returns the text inside the cell.
  • setContent(text) sets the text inside the cell.
  • getRowSpan() returns the number of rows this cell spans.
  • getColumnSpan() returns the number of columns this cell spans.
  • getSettings() returns the settings of the cell in the form of a SimileWikiToolbox.WikiTableCellSettings object.
  • toWikiText returns the wikitext serialization of this cell.


Class SimileWikiToolbox.WikiTableSettings

  • toWikiText returns the wikitext serialization of these settings.

Other methods depend on what settings are possible on a wikitext table.

Class SimileWikiToolbox.WikiTableRowSettings

  • toWikiText returns the wikitext serialization of these settings.

Other methods depend on what settings are possible on a wikitext table row.

Class SimileWikiToolbox.WikiTableCellSettings

  • toWikiText returns the wikitext serialization of these settings.

Other methods depend on what settings are possible on a wikitext table cell.

Go back to Main Wiki Table Editor Page.