浏览代码

Improved docs.

Oskar Wróbel 8 年之前
父节点
当前提交
34ba22b37f

+ 23 - 0
packages/ckeditor5-engine/src/conversion/buildmodelconverter.js

@@ -254,6 +254,29 @@ class ModelConverterBuilder {
 		}
 	}
 
+	/**
+	 * Registers what view stamp will be created by converter to mark marker range bounds. Separate elements will be
+	 * created at the beginning and at the end of the range. If range is collapsed then only one element will be created.
+	 *
+	 * Method accepts various ways of providing how the view element will be created. You can pass view element name as
+	 * `string`, view element instance which will be cloned and used, or creator function which returns view element that
+	 * will be used. Keep in mind that when you view element instance or creator function, it has to be/return a
+	 * proper type of view element: {@link module:engine/view/uielement~UIElement UIElement}.
+	 *
+	 *		buildModelConverter().for( dispatcher ).fromMarker( 'comment' ).toStamp( 'span' );
+	 *
+	 *		buildModelConverter().for( dispatcher ).fromMarker( 'comment' ).toStamp( new UIElement( 'span' ) );
+	 *
+	 *		buildModelConverter().for( dispatcher )
+	 *			.fromMarker( 'comment' )
+	 *			.toStamp( ( data ) => new UIElement( 'span', { 'data-name': data.marker.getName() ) );
+	 *
+	 * Creator function provides
+	 * {@link module:engine/conversion/modelconversiondispatcher~ModelConversionDispatcher#event:insert insert event} parameters.
+	 *
+	 * @param {String|module:engine/view/element~UIElement|Function} element UIElement created by converter or
+	 * a function that returns view element.
+	 */
 	toStamp( element ) {
 		for ( let dispatcher of this._dispatchers ) {
 			if ( this._from.type == 'element' || this._from.type == 'attribute' ) {

+ 2 - 0
packages/ckeditor5-engine/src/conversion/model-to-view-converters.js

@@ -91,6 +91,8 @@ export function insertText() {
 /**
  * Function factory, creates a converter that converts marker adding change to the view ui element.
  * The view ui element that will be added to the view depends on passed parameter. See {@link ~insertElement}.
+ * In a case of collapsed range element will not wrap range but separate elements will be placed at the beginning
+ * and at the end of the range.
  *
  * **Note:** unlike {@link ~insertElement}, the converter does not bind view element to model, because this converter
  * uses marker as "model source of data". This means that view ui element does not have corresponding model element.