Creates a Document instance.
The styles processor instance.
ReadonlyisTrue if composition is in progress inside the document.
This property is updated by the module:engine/view/observer/compositionobserver~CompositionObserver. If the module:engine/view/observer/compositionobserver~CompositionObserver is disabled this property will not change.
ReadonlyisTrue if document is focused.
This property is updated by the module:engine/view/observer/focusobserver~FocusObserver. If the module:engine/view/observer/focusobserver~FocusObserver is disabled this property will not change.
Defines whether document is in read-only mode.
When document is read-ony then all roots are read-only as well and caret placed inside this root is hidden.
Readonlyistrue while the user is making a selection in the document (e.g. holding the mouse button and moving the cursor).
When they stop selecting, the property goes back to false.
This property is updated by the module:engine/view/observer/selectionobserver~SelectionObserver.
ReadonlyrootsRoots of the view tree. Collection of the module:engine/view/element~ViewElement view elements.
View roots are created as a result of binding between module:engine/view/document~ViewDocument#roots and module:engine/model/document~ModelDocument#roots and this is handled by module:engine/controller/editingcontroller~EditingController, so to create view root we need to create model root using module:engine/model/document~ModelDocument#createRoot.
ReadonlyselectionSelection done on this document.
ReadonlystylesThe styles processor instance used by this document when normalizing styles.
Internal
Performs post-fixer loops. Executes post-fixer callbacks as long as none of them has done any changes to the model.
Destroys this instance. Makes sure that all observers are destroyed and listeners removed.
Gets a module:engine/view/document~ViewDocument#roots view root element with the specified name. If the name is not specific "main" root is returned.
Optionalname: string
Name of the root.
The view root element with the specified name or null when there is no root of given name.
Returns an array with all roots added to the document.
Allows registering post-fixer callbacks. A post-fixers mechanism allows to update the view tree just before it is rendered to the DOM.
Post-fixers are executed right after all changes from the outermost change block were applied but
before the module:engine/view/view~EditingView#event:render render event is fired. If a post-fixer callback made
a change, it should return true. When this happens, all post-fixers are fired again to check if something else should
not be fixed in the new document tree state.
View post-fixers are useful when you want to apply some fixes whenever the view structure changes. Keep in mind that changes executed in a view post-fixer should not break model-view mapping.
The types of changes which should be safe:
Try to avoid changes which touch view structure:
As a parameter, a post-fixer callback receives a module:engine/view/downcastwriter~ViewDowncastWriter downcast writer.
Typically, a post-fixer will look like this:
editor.editing.view.document.registerPostFixer( writer => {
if ( checkSomeCondition() ) {
writer.doSomething();
// Let other post-fixers know that something changed.
return true;
}
return false;
} );
Note that nothing happens right after you register a post-fixer (e.g. execute such a code in the console).
That is because adding a post-fixer does not execute it.
The post-fixer will be executed as soon as any change in the document needs to cause its rendering.
If you want to re-render the editor's view after registering the post-fixer then you should do it manually by calling
module:engine/view/view~EditingView#forceRender view.forceRender().
If you need to register a callback which is executed when DOM elements are already updated, use module:engine/view/view~EditingView#event:render render event.
Document class creates an abstract layer over the content editable area, contains a tree of view elements and module:engine/view/documentselection~ViewDocumentSelection view selection associated with this document.