Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Docs and other improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinmar committed Mar 3, 2020
1 parent 16301a1 commit fb8e77a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/controller/datacontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class DataController {
* Creates a data controller instance.
*
* @param {module:engine/model/model~Model} model Data model.
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
*/
constructor( model, stylesProcessor ) {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/controller/editingcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default class EditingController {
* Creates an editing controller instance.
*
* @param {module:engine/model/model~Model} model Editing model.
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
*/
constructor( model, stylesProcessor ) {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/view/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class Document {
/**
* Creates a Document instance.
*
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
*/
constructor( stylesProcessor ) {
/**
Expand Down
6 changes: 3 additions & 3 deletions src/view/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export default class Element extends Node {
*
* Attributes can be passed in various formats:
*
* new Element( 'div', { class: 'editor', contentEditable: 'true' } ); // object
* new Element( 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
* new Element( 'div', mapOfAttributes ); // map
* new Element( viewDocument, 'div', { class: 'editor', contentEditable: 'true' } ); // object
* new Element( viewDocument, 'div', [ [ 'class', 'editor' ], [ 'contentEditable', 'true' ] ] ); // map-like iterator
* new Element( viewDocument, 'div', mapOfAttributes ); // map
*
* @protected
* @param {module:engine/view/document~Document} document The document instance to which this element belongs.
Expand Down
13 changes: 7 additions & 6 deletions src/view/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ import { clone } from 'lodash-es';
import '@ckeditor/ckeditor5-utils/src/version';

/**
* Abstract tree view node class.
* Abstract view node class.
*
* This is an abstract class. Its constructor should not be used directly.
* Use the {@link module:engine/view/element~Element} class to create view elements
* or {@link module:engine/view/text~Text} class to create view text nodes.
* Use the {@link module:engine/view/downcastwriter~DowncastWriter} or {@link module:engine/view/upcastwriter~UpcastWriter}
* to create new instances of view nodes.
*
* @abstract
*/
export default class Node {
/**
* Creates a tree view node.
*
* @param {module:engine/view/document~Document} document A document where the node belongs to.
* @protected
* @param {module:engine/view/document~Document} document The document instance to which this node belongs.
*/
constructor( document ) {
/**
* A document where the node belongs to.
* The document instance to which this node belongs.
*
* @readonly
* @member {module:engine/view/document~Document}
Expand Down Expand Up @@ -119,7 +120,7 @@ export default class Node {
}

/**
* Returns true if a node is in a tree rooted in an element of the root type.
* Returns true if the node is in a tree rooted in the document (is a descendant of one of its roots).
*
* @returns {Boolean}
*/
Expand Down
13 changes: 6 additions & 7 deletions src/view/placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,19 @@ export function hidePlaceholder( writer, element ) {
* {@link module:engine/view/placeholder~enablePlaceholder `enablePlaceholder()`} in that case or make
* sure the correct element is passed to the helper.
*
* @param {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment} elementOrDocumentFragment
* @param {module:engine/view/element~Element} element
* @returns {Boolean}
*/
export function needsPlaceholder( elementOrDocumentFragment ) {
// TODO: How to check whether the element was removed from the document?
if ( elementOrDocumentFragment.root.is( 'documentFragment' ) ) {
export function needsPlaceholder( element ) {
if ( !element.isAttached() ) {
return false;
}

// The element is empty only as long as it contains nothing but uiElements.
const isEmptyish = !Array.from( elementOrDocumentFragment.getChildren() )
const isEmptyish = !Array.from( element.getChildren() )
.some( element => !element.is( 'uiElement' ) );

const doc = elementOrDocumentFragment.document;
const doc = element.document;

// If the element is empty and the document is blurred.
if ( !doc.isFocused && isEmptyish ) {
Expand All @@ -164,7 +163,7 @@ export function needsPlaceholder( elementOrDocumentFragment ) {
const selectionAnchor = viewSelection.anchor;

// If document is focused and the element is empty but the selection is not anchored inside it.
if ( isEmptyish && selectionAnchor && selectionAnchor.parent !== elementOrDocumentFragment ) {
if ( isEmptyish && selectionAnchor && selectionAnchor.parent !== element ) {
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/view/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Node from './node';
/**
* Tree view text node.
*
* The constructor of this class shouldn't be used directly. To create new Text instances
* The constructor of this class should not be used directly. To create a new text node instance
* use the {@link module:engine/view/downcastwriter~DowncastWriter#createText `DowncastWriter#createText()`}
* method when working on data downcasted from the model or the
* {@link module:engine/view/upcastwriter~UpcastWriter#createText `UpcastWriter#createText()`}
Expand All @@ -25,7 +25,7 @@ export default class Text extends Node {
* Creates a tree view text node.
*
* @protected
* @param {module:engine/view/document~Document} document A document where the text belongs to.
* @param {module:engine/view/document~Document} document The document instance to which this text node belongs.
* @param {String} data The text's data.
*/
constructor( document, data ) {
Expand Down
4 changes: 3 additions & 1 deletion src/view/upcastwriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ import Selection from './selection';
*/
export default class UpcastWriter {
/**
* @param {module:engine/view/document~Document} document
* @param {module:engine/view/document~Document} document The view document instance in which this upcast writer operates.
*/
constructor( document ) {
/**
* The view document instance in which this upcast writer operates.
*
* @readonly
* @type {module:engine/view/document~Document}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import env from '@ckeditor/ckeditor5-utils/src/env';
*/
export default class View {
/**
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance..
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor The styles processor instance.
*/
constructor( stylesProcessor ) {
/**
Expand Down

0 comments on commit fb8e77a

Please sign in to comment.