ソースを参照

Added API docs.

Szymon Kupś 9 年 前
コミット
b92e4121d5

+ 12 - 0
packages/ckeditor5-heading/src/headings.js

@@ -12,11 +12,23 @@ import ListDropdownController from '../ui/dropdown/list/listdropdown.js';
 import ListDropdownView from '../ui/dropdown/list/listdropdownview.js';
 import Collection from '../utils/collection.js';
 
+/**
+ * The headings feature. Handles switching between different block types.
+ *
+ * @memberOf headings
+ * @extends ckeditor5.Feature
+ */
 export default class Headings extends Feature {
+	/**
+	 * @inheritDoc
+	 */
 	static get requires() {
 		return [ HeadingsEngine ];
 	}
 
+	/**
+	 * @inheritDoc
+	 */
 	init() {
 		const editor = this.editor;
 		const command = editor.commands.get( 'headings' );

+ 39 - 2
packages/ckeditor5-heading/src/headingscommand.js

@@ -8,12 +8,37 @@
 import Command from '../command/command.js';
 import RootElement from '../engine/model/rootelement.js';
 
+/**
+ * Headings command. Used by the {@link headings.Headings headings feature}.
+ *
+ * @memberOf headings
+ * @extends ckeditor5.command.Command
+ */
 export default class HeadingsCommand extends Command {
+	/**
+	 * Creates instance of the command.
+	 *
+	 * @param {ckeditor5.editor.Editor} editor Editor instance.
+	 * @param {Array.<headings.HeadingsFormat>} formats Headings formats to be used by command's instance.
+	 */
 	constructor( editor, formats ) {
 		super( editor );
 
+		/**
+		 * Headings formats used by this command.
+		 *
+		 * @readonly
+		 * @member {headings.HeadingsFormat} headings.HeadingsCommand#formats
+		 */
 		this.formats = formats;
 
+		/**
+		 * Currently selected headings format.
+		 *
+		 * @readonly
+		 * @observable
+		 * @member {headings.HeadingsFormat} headings.HeadingsCommand#value
+		 */
 		this.set( 'value', this.defaultFormat );
 
 		// Listen on selection change and set current command's format to format in current selection.
@@ -33,13 +58,16 @@ export default class HeadingsCommand extends Command {
 	/**
 	 * The default format.
 	 *
-	 * @type {Object}
+	 * @type {headings.HeadingsFormat}
 	 */
 	get defaultFormat() {
 		// See https://github.com/ckeditor/ckeditor5/issues/98.
 		return this._getFormatById( 'paragraph' );
 	}
 
+	/**
+	 * @inheritDoc
+	 */
 	_doExecute( formatId = this.defaultFormat.id ) {
 		// TODO: What should happen if format is not found?
 		const doc = this.editor.document;
@@ -101,7 +129,7 @@ export default class HeadingsCommand extends Command {
 	 *
 	 * @private
 	 * @param {String} id
-	 * @returns {Object}
+	 * @returns {headings.HeadingsFormat}
 	 */
 	_getFormatById( id ) {
 		return this.formats.find( item => item.id === id );
@@ -132,3 +160,12 @@ function findTopmostBlock( position, nodeAfter = true ) {
 
 	return parent;
 }
+
+/**
+ * Headings format descriptor.
+ *
+ * @typedef {Object} headings.HeadingsFormat
+ * @property {String} id Format identifier, it will be used as element's name in the model.
+ * @property {String} viewElement Name of the view element that will be used to represent model element in the view.
+ * @property {String} label Display name of the format.
+ */

+ 14 - 0
packages/ckeditor5-heading/src/headingsengine.js

@@ -18,11 +18,25 @@ const formats = [
 	{ id: 'heading3', viewElement: 'h4', label: 'Heading 3' }
 ];
 
+/**
+ * The headings feature. Handles switching between block formats - different headings and paragraph.
+ * This class represents part of the feature that can be used without any UI - for example inside
+ * Node.js environment.
+ *
+ * @memberOf headings
+ * @extends ckeditor5.Feature
+ */
 export default class HeadingsEngine extends Feature {
+	/**
+	 * @inheritDoc
+	 */
 	static get requires() {
 		return [ Paragraph ];
 	}
 
+	/**
+	 * @inheritDoc
+	 */
 	init() {
 		const editor = this.editor;
 		const data = editor.data;