maxGraph/docs/api/classes/EditorPopupMenu.html

111 lines
33 KiB
HTML

<!DOCTYPE html><html class="default"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>EditorPopupMenu | @maxgraph/core</title><meta name="description" content="Documentation for @maxgraph/core"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script async src="../assets/search.js" id="search-script"></script></head><body><script>document.body.classList.add(localStorage.getItem("tsd-theme") || "os")</script><header><div class="tsd-page-toolbar"><div class="container"><div class="table-wrap"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget search no-caption">Search</label><input type="text" id="tsd-search-field"/></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">@maxgraph/core</a></div><div class="table-cell" id="tsd-widgets"><div id="tsd-filter"><a href="#" class="tsd-widget options no-caption" data-toggle="options">Options</a><div class="tsd-filter-group"><div class="tsd-select" id="tsd-filter-visibility"><span class="tsd-select-label">All</span><ul class="tsd-select-list"><li data-value="public">Public</li><li data-value="protected">Public/Protected</li><li data-value="private" class="selected">All</li></ul></div> <input type="checkbox" id="tsd-filter-inherited" checked/><label class="tsd-widget" for="tsd-filter-inherited">Inherited</label></div></div><a href="#" class="tsd-widget menu no-caption" data-toggle="menu">Menu</a></div></div></div></div><div class="tsd-page-title"><div class="container"><ul class="tsd-breadcrumb"><li><a href="../index.html">@maxgraph/core</a></li><li><a href="EditorPopupMenu.html">EditorPopupMenu</a></li></ul><h1>Class EditorPopupMenu</h1></div></div></header><div class="container container-main"><div class="row"><div class="col-8 col-content"><section class="tsd-panel tsd-comment"><div class="tsd-comment tsd-typography"><div class="lead">
<p>Creates popupmenus for mouse events. This object holds an XML node which is a description of the popup menu to be created. In <a href="EditorPopupMenu.html#createMenu">createMenu</a>, the configuration is applied to the context and the resulting menu items are added to the menu dynamically. See <a href="EditorPopupMenu.html#createMenu">createMenu</a> for a description of the configuration format.
This class does not create the DOM nodes required for the popup menu, it only parses an XML description to invoke the respective methods on an {@link mxPopupMenu} each time the menu is displayed.</p>
</div><dl class="tsd-comment-tags"><dt>codec</dt><dd><p>This class uses the {@link DefaultPopupMenuCodec} to read configuration data into an existing instance, however, the actual parsing is done by this class during program execution, so the format is described below.</p>
</dd></dl></div></section><section class="tsd-panel tsd-hierarchy"><h3>Hierarchy</h3><ul class="tsd-hierarchy"><li><span class="target">EditorPopupMenu</span></li></ul></section><section class="tsd-panel-group tsd-index-group"><h2>Index</h2><section class="tsd-panel tsd-index-panel"><div class="tsd-index-content"><section class="tsd-index-section "><h3>Constructors</h3><ul class="tsd-index-list"><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="EditorPopupMenu.html#constructor" class="tsd-kind-icon">constructor</a></li></ul></section><section class="tsd-index-section "><h3>Properties</h3><ul class="tsd-index-list"><li class="tsd-kind-property tsd-parent-kind-class"><a href="EditorPopupMenu.html#config" class="tsd-kind-icon">config</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="EditorPopupMenu.html#imageBasePath" class="tsd-kind-icon">image<wbr/>Base<wbr/>Path</a></li></ul></section><section class="tsd-index-section "><h3>Methods</h3><ul class="tsd-index-list"><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#addAction" class="tsd-kind-icon">add<wbr/>Action</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#addItems" class="tsd-kind-icon">add<wbr/>Items</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#createConditions" class="tsd-kind-icon">create<wbr/>Conditions</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#createMenu" class="tsd-kind-icon">create<wbr/>Menu</a></li></ul></section></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Constructors</h2><section class="tsd-panel tsd-member tsd-kind-constructor tsd-parent-kind-class"><a id="constructor" class="tsd-anchor"></a><h3>constructor</h3><ul class="tsd-signatures tsd-kind-constructor tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">new <wbr/>Editor<wbr/>Popup<wbr/>Menu<span class="tsd-signature-symbol">(</span>config<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Element</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><a href="EditorPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">EditorPopupMenu</a></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L26">editor/EditorPopupMenu.ts:26</a></li></ul></aside><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>config: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Element</span><span class="tsd-signature-symbol"> = null</span></h5></li></ul><h4 class="tsd-returns-title">Returns <a href="EditorPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">EditorPopupMenu</a></h4></li></ul></section></section><section class="tsd-panel-group tsd-member-group "><h2>Properties</h2><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="config" class="tsd-anchor"></a><h3>config</h3><div class="tsd-signature tsd-kind-icon">config<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Element</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L40">editor/EditorPopupMenu.ts:40</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>XML node used as the description of new menu items. This node is used in <a href="EditorPopupMenu.html#createMenu">createMenu</a> to dynamically create the menu items if their respective conditions evaluate to true for the given arguments.</p>
</div></div></section><section class="tsd-panel tsd-member tsd-kind-property tsd-parent-kind-class"><a id="imageBasePath" class="tsd-anchor"></a><h3>image<wbr/>Base<wbr/>Path</h3><div class="tsd-signature tsd-kind-icon">image<wbr/>Base<wbr/>Path<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = null</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L35">editor/EditorPopupMenu.ts:35</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Base path for all icon attributes in the config. Default is null.</p>
</div><dl class="tsd-comment-tags"><dt>default</dt><dd><p>null</p>
</dd></dl></div></section></section><section class="tsd-panel-group tsd-member-group "><h2>Methods</h2><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="addAction" class="tsd-anchor"></a><h3>add<wbr/>Action</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">add<wbr/>Action<span class="tsd-signature-symbol">(</span>menu<span class="tsd-signature-symbol">: </span><a href="MaxPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">MaxPopupMenu</a>, editor<span class="tsd-signature-symbol">: </span><a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a>, lab<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">string</span>, icon<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span>, funct<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Function</span>, action<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span>, cell<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a>, parent<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">PopupMenuItem</span>, iconCls<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span>, enabled<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">PopupMenuItem</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L240">editor/EditorPopupMenu.ts:240</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Helper method to bind an action to a new menu item.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>menu: <a href="MaxPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">MaxPopupMenu</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>{@link PopupMenu} that is used for adding items and separators.</p>
</div></div></li><li><h5>editor: <a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Enclosing <Editor> instance.</p>
</div></div></li><li><h5>lab: <span class="tsd-signature-type">string</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>String that represents the label of the menu item.</p>
</div></div></li><li><h5>icon: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional URL that represents the icon of the menu item.</p>
</div></div></li><li><h5>funct: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">Function</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional function to execute before the optional action. The
function takes an <Editor>, the <Cell> under the mouse and the
mouse event that triggered the call.</p>
</div></div></li><li><h5>action: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional name of the action to execute in the given editor.</p>
</div></div></li><li><h5>cell: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional <Cell> to use as an argument for the action.</p>
</div></div></li><li><h5>parent: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">PopupMenuItem</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>DOM node that represents the parent menu item.</p>
</div></div></li><li><h5>iconCls: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">string</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional CSS class for the menu icon.</p>
</div></div></li><li><h5>enabled: <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol"> = true</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional boolean that specifies if the menu item is enabled.
Default is true.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">PopupMenuItem</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="addItems" class="tsd-anchor"></a><h3>add<wbr/>Items</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">add<wbr/>Items<span class="tsd-signature-symbol">(</span>editor<span class="tsd-signature-symbol">: </span><a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a>, menu<span class="tsd-signature-symbol">: </span><a href="MaxPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">MaxPopupMenu</a>, cell<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a>, evt<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MouseEvent</span>, conditions<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">any</span>, item<span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">Element</span>, parent<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">PopupMenuItem</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L157">editor/EditorPopupMenu.ts:157</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Recursively adds the given items and all of its children into the given menu.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>editor: <a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Enclosing <Editor> instance.</p>
</div></div></li><li><h5>menu: <a href="MaxPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">MaxPopupMenu</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>{@link PopupMenu} that is used for adding items and separators.</p>
</div></div></li><li><h5>cell: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional <Cell> which is under the mousepointer.</p>
</div></div></li><li><h5>evt: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MouseEvent</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional mouse event which triggered the menu.</p>
</div></div></li><li><h5>conditions: <span class="tsd-signature-type">any</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Array of names boolean conditions.</p>
</div></div></li><li><h5>item: <span class="tsd-signature-type">Element</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>XML node that represents the current menu item.</p>
</div></div></li><li><h5>parent: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">PopupMenuItem</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>DOM node that represents the parent menu item.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="createConditions" class="tsd-anchor"></a><h3>create<wbr/>Conditions</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">create<wbr/>Conditions<span class="tsd-signature-symbol">(</span>editor<span class="tsd-signature-symbol">: </span><a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a>, cell<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a>, evt<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MouseEvent</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L270">editor/EditorPopupMenu.ts:270</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>Evaluates the default conditions for the given context.</p>
</div></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>editor: <a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a></h5></li><li><h5>cell: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a><span class="tsd-signature-symbol"> = null</span></h5></li><li><h5>evt: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MouseEvent</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section><section class="tsd-panel tsd-member tsd-kind-method tsd-parent-kind-class"><a id="createMenu" class="tsd-anchor"></a><h3>create<wbr/>Menu</h3><ul class="tsd-signatures tsd-kind-method tsd-parent-kind-class"><li class="tsd-signature tsd-kind-icon">create<wbr/>Menu<span class="tsd-signature-symbol">(</span>editor<span class="tsd-signature-symbol">: </span><a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a>, menu<span class="tsd-signature-symbol">: </span><a href="MaxPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">MaxPopupMenu</a>, cell<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a>, evt<span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MouseEvent</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">void</span></li></ul><ul class="tsd-descriptions"><li class="tsd-description"><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/maxgraph/maxgraph/blob/598b60e2f/packages/core/src/editor/EditorPopupMenu.ts#L138">editor/EditorPopupMenu.ts:138</a></li></ul></aside><div class="tsd-comment tsd-typography"><div class="lead">
<p>This function is called from <a href="Editor.html">Editor</a> to add items to the
given menu based on <a href="EditorPopupMenu.html#config">config</a>. The config is a sequence of
the following nodes and attributes.</p>
</div><dl class="tsd-comment-tags"><dt>childnodes:</dt><dd><p>add - Adds a new menu item. See below for attributes.
separator - Adds a separator. No attributes.
condition - Adds a custom condition. Name attribute.</p>
<p>The add-node may have a child node that defines a function to be invoked
before the action is executed (or instead of an action to be executed).</p>
</dd><dt>attributes:</dt><dd><p>as - Resource key for the label (needs entry in property file).
action - Name of the action to execute in enclosing editor.
icon - Optional icon (relative/absolute URL).
iconCls - Optional CSS class for the icon.
if - Optional name of condition that must be true (see below).
enabled-if - Optional name of condition that specifies if the menu item
should be enabled.
name - Name of custom condition. Only for condition nodes.</p>
</dd><dt>conditions:</dt><dd><p>nocell - No cell under the mouse.
ncells - More than one cell selected.
notRoot - Drilling position is other than home.
cell - Cell under the mouse.
notEmpty - Exactly one cell with children under mouse.
expandable - Exactly one expandable cell under mouse.
collapsable - Exactly one collapsable cell under mouse.
validRoot - Exactly one cell which is a possible root under mouse.
swimlane - Exactly one cell which is a swimlane under mouse.</p>
</dd><dt>example:</dt><dd><p>To add a new item for a given action to the popupmenu:</p>
<pre><code><span class="hl-1">&lt;</span><span class="hl-0">EditorPopupMenu</span><span class="hl-1"> </span><span class="hl-0">as</span><span class="hl-1">=</span><span class="hl-6">&quot;popupHandler&quot;</span><span class="hl-1">&gt;</span><br/><span class="hl-1"> &lt;</span><span class="hl-0">add</span><span class="hl-1"> </span><span class="hl-0">as</span><span class="hl-1">=</span><span class="hl-6">&quot;delete&quot;</span><span class="hl-1"> </span><span class="hl-0">action</span><span class="hl-1">=</span><span class="hl-6">&quot;delete&quot;</span><span class="hl-1"> </span><span class="hl-0">icon</span><span class="hl-1">=</span><span class="hl-6">&quot;images/delete.gif&quot;</span><span class="hl-1"> </span><span class="hl-5">if</span><span class="hl-1">=</span><span class="hl-6">&quot;cell&quot;</span><span class="hl-1">/&gt;</span><br/><span class="hl-1">&lt;/</span><span class="hl-0">EditorPopupMenu</span><span class="hl-1">&gt;</span>
</code></pre>
<p>To add a new item for a custom function:</p>
<pre><code><span class="hl-1">&lt;</span><span class="hl-0">EditorPopupMenu</span><span class="hl-1"> </span><span class="hl-0">as</span><span class="hl-1">=</span><span class="hl-6">&quot;popupHandler&quot;</span><span class="hl-1">&gt;</span><br/><span class="hl-1"> &lt;</span><span class="hl-0">add</span><span class="hl-1"> </span><span class="hl-0">as</span><span class="hl-1">=</span><span class="hl-6">&quot;action1&quot;</span><span class="hl-1">&gt;&lt;![</span><span class="hl-10">CDATA</span><span class="hl-1">[</span><br/><span class="hl-1"> </span><span class="hl-10">function</span><span class="hl-1"> (</span><span class="hl-0">editor</span><span class="hl-1">, </span><span class="hl-0">cell</span><span class="hl-1">, </span><span class="hl-0">evt</span><span class="hl-1">)</span><br/><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-10">editor</span><span class="hl-1">.</span><span class="hl-10">execute</span><span class="hl-1">(</span><span class="hl-6">&#39;action1&#39;</span><span class="hl-1">, </span><span class="hl-10">cell</span><span class="hl-1">, </span><span class="hl-6">&#39;myArg&#39;</span><span class="hl-1">);</span><br/><span class="hl-1"> }</span><br/><span class="hl-1"> ]]&gt;&lt;/</span><span class="hl-10">add</span><span class="hl-1">&gt;</span><br/><span class="hl-1">&lt;/</span><span class="hl-0">EditorPopupMenu</span><span class="hl-1">&gt;</span>
</code></pre>
<p>The above example invokes action1 with an additional third argument via
the editor instance. The third argument is passed to the function that
defines action1. If the add-node has no action-attribute, then only the
function defined in the text content is executed, otherwise first the
function and then the action defined in the action-attribute is
executed. The function in the text content has 3 arguments, namely the
<a href="Editor.html">Editor</a> instance, the {@link mxCell} instance under the mouse, and the
native mouse event.</p>
<p>Custom Conditions:</p>
<p>To add a new condition for popupmenu items:</p>
<pre><code><span class="hl-1">&lt;</span><span class="hl-0">condition</span><span class="hl-1"> </span><span class="hl-0">name</span><span class="hl-1">=</span><span class="hl-6">&quot;condition1&quot;</span><span class="hl-1">&gt;&lt;![</span><span class="hl-10">CDATA</span><span class="hl-1">[</span><br/><span class="hl-1"> </span><span class="hl-10">function</span><span class="hl-1"> (</span><span class="hl-0">editor</span><span class="hl-1">, </span><span class="hl-0">cell</span><span class="hl-1">, </span><span class="hl-0">evt</span><span class="hl-1">)</span><br/><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-10">return</span><span class="hl-1"> </span><span class="hl-0">cell</span><span class="hl-1"> != </span><span class="hl-0">null</span><span class="hl-1">;</span><br/><span class="hl-1"> }</span><br/><span class="hl-1">]]&gt;&lt;/</span><span class="hl-10">condition</span><span class="hl-1">&gt;</span>
</code></pre>
<p>The new condition can then be used in any item as follows:</p>
<pre><code><span class="hl-1">&lt;</span><span class="hl-0">add</span><span class="hl-1"> </span><span class="hl-0">as</span><span class="hl-1">=</span><span class="hl-6">&quot;action1&quot;</span><span class="hl-1"> </span><span class="hl-0">action</span><span class="hl-1">=</span><span class="hl-6">&quot;action1&quot;</span><span class="hl-1"> </span><span class="hl-0">icon</span><span class="hl-1">=</span><span class="hl-6">&quot;action1.gif&quot;</span><span class="hl-1"> </span><span class="hl-5">if</span><span class="hl-1">=</span><span class="hl-6">&quot;condition1&quot;</span><span class="hl-1">/&gt;</span>
</code></pre>
<p>The order in which the items and conditions appear is not significant as
all conditions are evaluated before any items are created.</p>
</dd></dl></div><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameters"><li><h5>editor: <a href="Editor.html" class="tsd-signature-type" data-tsd-kind="Class">Editor</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Enclosing <a href="Editor.html">Editor</a> instance.</p>
</div></div></li><li><h5>menu: <a href="MaxPopupMenu.html" class="tsd-signature-type" data-tsd-kind="Class">MaxPopupMenu</a></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>{@link mxPopupMenu} that is used for adding items and separators.</p>
</div></div></li><li><h5>cell: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><a href="Cell.html" class="tsd-signature-type" data-tsd-kind="Class">Cell</a><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional {@link mxCell} which is under the mousepointer.</p>
</div></div></li><li><h5>evt: <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">MouseEvent</span><span class="tsd-signature-symbol"> = null</span></h5><div class="tsd-comment tsd-typography"><div class="lead">
<p>Optional mouse event which triggered the menu.</p>
</div></div></li></ul><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4></li></ul></section></section></div><div class="col-4 col-menu menu-sticky-wrap menu-highlight"><nav class="tsd-navigation primary"><ul><li class=""><a href="../index.html">Exports</a></li><li class=" tsd-kind-namespace"><a href="../modules/DomHelpers.html">Dom<wbr/>Helpers</a></li><li class=" tsd-kind-namespace"><a href="../modules/cloneUtils.html">clone<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/constants.html">constants</a></li><li class=" tsd-kind-namespace"><a href="../modules/domUtils.html">dom<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/eventUtils.html">event<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/gestureUtils.html">gesture<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/mathUtils.html">math<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/stringUtils.html">string<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/styleUtils.html">style<wbr/>Utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/utils.html">utils</a></li><li class=" tsd-kind-namespace"><a href="../modules/xmlUtils.html">xml<wbr/>Utils</a></li></ul></nav><nav class="tsd-navigation secondary menu-sticky"><ul><li class="current tsd-kind-class"><a href="EditorPopupMenu.html" class="tsd-kind-icon">Editor<wbr/>Popup<wbr/>Menu</a><ul><li class="tsd-kind-constructor tsd-parent-kind-class"><a href="EditorPopupMenu.html#constructor" class="tsd-kind-icon">constructor</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="EditorPopupMenu.html#config" class="tsd-kind-icon">config</a></li><li class="tsd-kind-property tsd-parent-kind-class"><a href="EditorPopupMenu.html#imageBasePath" class="tsd-kind-icon">image<wbr/>Base<wbr/>Path</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#addAction" class="tsd-kind-icon">add<wbr/>Action</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#addItems" class="tsd-kind-icon">add<wbr/>Items</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#createConditions" class="tsd-kind-icon">create<wbr/>Conditions</a></li><li class="tsd-kind-method tsd-parent-kind-class"><a href="EditorPopupMenu.html#createMenu" class="tsd-kind-icon">create<wbr/>Menu</a></li></ul></li></ul></nav></div></div></div><footer class="with-border-bottom"><div class="container"><h2>Legend</h2><div class="tsd-legend-group"><ul class="tsd-legend"><li class="tsd-kind-constructor tsd-parent-kind-class"><span class="tsd-kind-icon">Constructor</span></li><li class="tsd-kind-property tsd-parent-kind-class"><span class="tsd-kind-icon">Property</span></li><li class="tsd-kind-method tsd-parent-kind-class"><span class="tsd-kind-icon">Method</span></li><li class="tsd-kind-accessor tsd-parent-kind-class"><span class="tsd-kind-icon">Accessor</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited method</span></li><li class="tsd-kind-accessor tsd-parent-kind-class tsd-is-inherited"><span class="tsd-kind-icon">Inherited accessor</span></li></ul><ul class="tsd-legend"><li class="tsd-kind-property tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static property</span></li><li class="tsd-kind-method tsd-parent-kind-class tsd-is-static"><span class="tsd-kind-icon">Static method</span></li></ul></div><h2>Settings</h2><p>Theme <select id="theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></p></div></footer><div class="container tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div><script src="../assets/main.js"></script></body></html>