Expand all

abstract ve.ce.GeneratedContentNode

Constructor

new ve.ce.GeneratedContentNode()abstract #

ContentEditable generated content node.

Source:
ContentEditable generated content node.

Methods

abortGenerating() #

Abort the currently pending generation, if any, and remove the generating CSS class.

This invokes .abort() on the pending promise if the promise has that method. It also ensures that if the promise does get resolved or rejected later, this is ignored.

Source:
Abort the currently pending generation, if any, and remove the generating CSS class.

afterRender() #

Trigger rerender events after rendering the contents of the node.

Nodes may override this method if the rerender event needs to be deferred (e.g. until images have loaded)

Source:

Fires:

Trigger rerender events after rendering the contents of the node.

doneGenerating(generatedContents, [config], [staged]) #

Called when the node successfully finishes generating new content.

Parameters:

Name Type Attributes Description
generatedContents Object | string | Array

Generated contents

config Object optional

Config object passed to forceUpdate()

staged boolean optional

Update happened in staging mode

Source:
Called when the node successfully finishes generating new content.

failGenerating() #

Called when the GeneratedContentNode has failed to generate new content.

Source:
Called when the GeneratedContentNode has failed to generate new content.

filterRenderedDomElements(domElements) → {Array.<Node>} #

Filter out elements from the rendered content which we don't want to display in the CE.

Parameters:

Name Type Description
domElements Array.<Node>

Clones of the DOM elements from the store, already copied into the document

Source:

Returns:

DOM elements to keep

Type
Array.<Node>
Filter out elements from the rendered content which we don't want to display in the CE.

forceUpdate([config], [staged]) #

Force the contents to be updated. Like update(), but bypasses the store.

Parameters:

Name Type Attributes Description
config Object optional

Optional additional data to pass to generateContents()

staged boolean optional

Update happened in staging mode

Source:
Force the contents to be updated.

generateContents([config]) → {jQuery.Promise}abstract #

Start a deferred process to generate the contents of the node.

If successful, the returned promise must be resolved with the generated DOM elements passed in as the first parameter, i.e. promise.resolve( domElements ); . Any other parameters to .resolve() are ignored.

If the returned promise object is abortable (has an .abort() method), .abort() will be called if a newer update is started before the current update has finished. When a promise is aborted, it should cease its work and shouldn't be resolved or rejected. If an outdated update's promise is resolved or rejected anyway (which may happen if an aborted promise misbehaves, or if the promise wasn't abortable), this is ignored and doneGenerating()/failGenerating() is not called.

Additional data may be passed in the config object to instruct this function to render something different than what's in the model. This data is implementation-specific and is passed through by forceUpdate().

Parameters:

Name Type Attributes Description
config Object optional

Optional additional data

Source:

Returns:

Promise object, may be abortable

Type
jQuery.Promise
Start a deferred process to generate the contents of the node.

getBoundingElement() → {jQuery} #

Get the bounding element

Source:

Returns:

Bounding element

Type
jQuery
Get the bounding element

getFocusableElement() → {jQuery} #

Get the focusable element

Source:

Returns:

Focusable element

Type
jQuery
Get the focusable element

getRenderedDomElements(domElements) → {Array.<HTMLElement>} #

Make an array of DOM elements suitable for rendering.

Subclasses can override this to provide their own cleanup steps. This function takes an array of DOM elements cloned within the source document and returns an array of DOM elements cloned into the target document. If it's important that the DOM elements still be associated with the original document, you should modify domElements before calling the parent implementation, otherwise you should call the parent implementation first and modify its return value.

Parameters:

Name Type Description
domElements Array.<Node>

Clones of the DOM elements from the store

Source:

Returns:

Clones of the DOM elements in the right document, with modifications

Type
Array.<HTMLElement>
Make an array of DOM elements suitable for rendering.

getResizableElement() → {jQuery} #

Get the resizable element

Source:

Returns:

Resizable element

Type
jQuery
Get the resizable element

isGenerating() → {boolean} #

Check whether this GeneratedContentNode is currently generating new content.

Source:

Returns:

Whether we're generating

Type
boolean
Check whether this GeneratedContentNode is currently generating new content.

onGeneratedContentNodeUpdate(staged) #

Handler for the update event

Parameters:

Name Type Description
staged boolean

Update happened in staging mode

Source:
Handler for the update event

preventTabbingInside()private #

Prevent tabbing to focusable elements inside the editable surface, because it conflicts with allowing tabbing out of the surface. (The surface takes the focus back when it moves to an element inside it.)

In the future, this might be implemented using the inert property, currently not supported by any browser: https://html.spec.whatwg.org/multipage/interaction.html#inert-subtrees https://caniuse.com/mdn-api_htmlelement_inert

Source:

Prevent tabbing to focusable elements inside the editable surface, because it conflicts with allowing tabbing out of the surface.

render(generatedContents, [staged]) #

Rerender the contents of this node.

Parameters:

Name Type Attributes Description
generatedContents Object | string | Array

Generated contents, in the default case an HTMLElement array

staged boolean optional

Update happened in staging mode

Source:

Fires:

Rerender the contents of this node.

startGenerating() #

Called when the node starts generating new content.

This function is only called when the node wasn't already generating content. If a second update comes in, this function will only be called if the first update has already finished (i.e. doneGenerating or failGenerating has already been called).

Source:
Called when the node starts generating new content.

update([config], [staged]) #

Update the contents of this node based on the model and config data. If this combination of model and config data has been rendered before, the cached rendering in the store will be used.

Parameters:

Name Type Attributes Description
config Object optional

Optional additional data to pass to generateContents()

staged boolean optional

Update happened in staging mode

Source:
Update the contents of this node based on the model and config data.

validateGeneratedContents($element) → {boolean} #

Check whether the response HTML contains an error.

The default implementation always returns true.

Parameters:

Name Type Description
$element jQuery

The generated element

Source:

Returns:

There is no error

Type
boolean
Check whether the response HTML contains an error.

awaitGeneratedContent(view) → {jQuery.Promise}static #

Wait for all content-generation within a given node to finish

If no GeneratedContentNodes are within the node, a resolved promise will be returned.

Parameters:

Name Type Description
view ve.ce.View

Any view node

Source:

Returns:

Promise, resolved when content is generated

Type
jQuery.Promise

Wait for all content-generation within a given node to finish

If no GeneratedContentNodes are within the node, a resolved promise will be returned.

Events