Methods
contextMenu(forThis) → {Array.<Object>}
Items to be included on the TinyMCE context menu if an atom of this class is right-clicked. For information on the format of the returned data, see the TinyMCE v6 manual on custom context menus.
In this case, it adds one item, for viewing the meaning of the expression in a pop-up dialog, either as a hierarchy of bullet points and sections, or as a block of putdown code.
Parameters
-
forThis
Atom
the atom that received the right-click action that led to the creation of the context menu
Returns
-
Array.<Object>
data representing the contents of a TinyMCE context menu
Source
edit() → {Promise}
Shows a dialog for editing an expression atom, but it may show one of three different dialogs, depending on whether the user has chosen beginner, intermediate, or advanced mode in their settings.
Beginner mode does this:
Shows a dialog containing just a MathLive editor and a checkbox for given/claim status. The user can then confirm or cancel the edit, as per the convention described in the edit() function for the Atom class.
Intermediate mode does this:
Shows a multi-part dialog for editing expression atoms using Lurch notation or a MathLive editor widget. The user can then confirm or cancel the edit, as per the convention described in the edit() function for the Atom class.
Advanced mode does this:
The dialog is extremely minimalist, no title bar, no footer buttons, no miniature headings over each input/output, and the only input is the Lurch notation. The MathLive widget is a read-only preview. There is no checkbox for given/claim status, but that status is inferred from the Lurch notation.
Returns
-
Promise
same convention as specified in edit() for Atoms
Source
toEmbed() → {string}
When embedding a copy of the Lurch app in a larger page, users will want
to write simple HTML describing a Lurch document, then have a script
create a copy of the Lurch app and put that document into it. We allow
for representing expressions using <lurch>...</lurch>
elements, which
contain Lurch notation. This function can convert any expression atom
into the corresponding lurch
element, as a string.
Returns
-
string
the representation of the atom as a
lurch
element
Source
toLCs() → {Array.<LogicConcept>}
The behavior of this function depends on whether the atom was last edited using beginner mode, intermediate mode, or advanced mode.
If it was created using beginner mode, then we check to ensure that the LaTeX version of the MathLive editor's contents represents a single mathematical expression, optionally marked as an assumption. If so, we return an array containing just that expression (possibly marked as a given). If not, we return an empty array.
If it was created using intermediate mode, then it may represent a statement (i.e., claim expression), an assumption (i.e., given expression), or a declaration (of any of a variety of types, with or without body). As long as one of these holds true, we return a JavaScript array containing the single LogicConcept represented by this atom. If not, we return an empty array.
If it was created using advanced mode, then we parse the Lurch notation that was typed into the advanced mode dialog. This will produce zero or more LogicConcepts, in an array, which we return.
Returns
-
Array.<LogicConcept>
an array containing zero or one LogicConcepts
Source
toLatex() → {string}
All atoms must be able to represent themselves in LaTeX form, so that the document (or a portion of it) can be exporeted for use in a LaTeX editor, such as Overleaf. This function overrides the default implementation with a representation suitable to expression atoms. It wraps the LaTeX representation of the expression in dollar signs.
Returns
-
string
LaTeX representation of an expression atom
Source
update()
The behavior of this function depends on whether the atom was last edited using beginner mode, intermediate mode, or advanced mode.
If it was created using beginner mode, then we place its HTML representation in the body of the atom, and possibly place the word "Assume" into the prefix of the atom, iff the atom is marked as an assumption. The atom suffix is not involved.
If it was created using intermediate mode and is a statement or assumption, then we treat it as in beginner mode. However, if it is a declaration, we use documentForm() to convert it to HTML and use that as the body of the atom. Any former prefix in the atom is removed. The atom suffix is not involved.
If it was created using advanced mode, then we apply a Lurch notation to LaTeX conversion function, followed by a rendering of that LaTeX as HTML, which goes into the body of the atom. Any former prefix in the atom is removed. The atom suffix is not involved.