Ver Fonte

WIP - Fixes.

Maciej Bukowski há 6 anos atrás
pai
commit
57711c747f

+ 0 - 25
packages/ckeditor5-engine/src/dev-utils/enableenginedebug.js

@@ -1,25 +0,0 @@
-// TODO
-// export class DebugPlugin extends Plugin {
-// 	constructor( editor ) {
-// 		super( editor );
-
-// 		const model = this.editor.model;
-// 		const modelDocument = model.document;
-// 		const view = this.editor.editing.view;
-// 		const viewDocument = view.document;
-
-// 		modelDocument[ treeDump ] = [];
-// 		viewDocument[ treeDump ] = [];
-
-// 		dumpTrees( modelDocument, modelDocument.version );
-// 		dumpTrees( viewDocument, modelDocument.version );
-
-// 		// model.on( 'applyOperation', () => {
-// 		// 	dumpTrees( modelDocument, modelDocument.version );
-// 		// }, { priority: 'lowest' } );
-
-// 		model.document.on( 'change', () => {
-// 			dumpTrees( viewDocument, modelDocument.version );
-// 		}, { priority: 'lowest' } );
-// 	}
-// }

+ 13 - 0
packages/ckeditor5-engine/src/dev-utils/utils.js

@@ -55,6 +55,8 @@ const maxTreeDumpLength = 20;
  * @param {*} version
  */
 export function dumpTrees( document, version ) {
+	console.log( document, version );
+
 	let string = '';
 
 	for ( const root of document.roots ) {
@@ -70,6 +72,17 @@ export function dumpTrees( document, version ) {
 	}
 }
 
+export function initDocumentDumping( document ) {
+	document[ treeDump ] = [];
+}
+
+/**
+ * Helper function that dumps document for the given version.
+ *
+ * @private
+ * @param {*} document
+ * @param {*} version
+ */
 export function logDocument( document, version ) {
 	console.log( '--------------------' );
 

+ 1 - 1
packages/ckeditor5-engine/src/model/document.js

@@ -18,7 +18,7 @@ import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import { isInsideSurrogatePair, isInsideCombinedSymbol } from '@ckeditor/ckeditor5-utils/src/unicode';
 import { clone } from 'lodash-es';
 
-// @if CK_DEBUG_ENGINE // const { dumpTrees, logDocument } = require( '../dev-tools/utils' );
+// @if CK_DEBUG_ENGINE // const { logDocument } = require( '../dev-utils/utils' );
 
 const graveyardName = '$graveyard';
 

+ 2 - 2
packages/ckeditor5-engine/src/model/element.js

@@ -13,7 +13,7 @@ import Text from './text';
 import TextProxy from './textproxy';
 import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
 
-// @if CK_DEBUG_ENGINE // const { stringifyMap, convertMapToStringifiedObject } = require( '../dev-utils/utils' );
+// @if CK_DEBUG_ENGINE // const { stringifyMap, convertMapToStringifiedObject, convertMapToTags } = require( '../dev-utils/utils' );
 
 /**
  * Model element. Type of {@link module:engine/model/node~Node node} that has a {@link module:engine/model/element~Element#name name} and
@@ -349,7 +349,7 @@ export default class Element extends Node {
 	// @if CK_DEBUG_ENGINE // 	}
 	// @if CK_DEBUG_ENGINE // }
 
-	// @if CK_DEBUG_ENGINE // printTree() {
+	// @if CK_DEBUG_ENGINE // printTree( level = 0) {
 	// @if CK_DEBUG_ENGINE // 	let string = '';
 
 	// @if CK_DEBUG_ENGINE // 	string += '\t'.repeat( level );

+ 2 - 4
packages/ckeditor5-engine/src/model/model.js

@@ -26,8 +26,8 @@ import getSelectedContent from './utils/getselectedcontent';
 import { injectSelectionPostFixer } from './utils/selection-post-fixer';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
-// @if CK_DEBUG_ENGINE // const { dumpTrees } = require( '../dev-tools/utils' );
-// @if CK_DEBUG_ENGINE // const { OperationReplayer } = require( '../dev-tools/operation-replayer' ).default;
+// @if CK_DEBUG_ENGINE // const { dumpTrees } = require( '../dev-utils/utils' );
+// @if CK_DEBUG_ENGINE // const { OperationReplayer } = require( '../dev-utils/operationreplayer' ).default;
 
 /**
  * Editor's data model. Read about the model in the
@@ -254,8 +254,6 @@ export default class Model {
 
 		// @if CK_DEBUG_ENGINE //this._appliedOperations.push( operation );
 
-		// @if CK_DEBUG_ENGINE //return _modelApplyOperation.call( this, operation );
-
 		operation._execute();
 	}
 

+ 2 - 0
packages/ckeditor5-engine/src/model/operation/detachoperation.js

@@ -12,6 +12,8 @@ import Range from '../range';
 import { _remove } from './utils';
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
+// @if CK_DEBUG_ENGINE // const ModelRange = require( '../range' ).default;
+
 /**
  * Operation to permanently remove node from detached root.
  * Note this operation is only a local operation and won't be send to the other clients.

+ 2 - 0
packages/ckeditor5-engine/src/model/operation/moveoperation.js

@@ -14,6 +14,8 @@ import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 import compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';
 import { _move } from './utils';
 
+// @if CK_DEBUG_ENGINE // const ModelRange = require( '../range' ).default;
+
 /**
  * Operation to move a range of {@link module:engine/model/item~Item model items}
  * to given {@link module:engine/model/position~Position target position}.

+ 1 - 1
packages/ckeditor5-engine/src/model/text.js

@@ -9,7 +9,7 @@
 
 import Node from './node';
 
-// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-tools/utils' );
+// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-utils/utils' );
 
 /**
  * Model text node. Type of {@link module:engine/model/node~Node node} that contains {@link module:engine/model/text~Text#data text data}.

+ 1 - 1
packages/ckeditor5-engine/src/model/textproxy.js

@@ -9,7 +9,7 @@
 
 import CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';
 
-// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-tools/utils' );
+// @if CK_DEBUG_ENGINE // const { convertMapToStringifiedObject } = require( '../dev-utils/utils' );
 
 /**
  * `TextProxy` represents a part of {@link module:engine/model/text~Text text node}.

+ 1 - 1
packages/ckeditor5-engine/src/view/document.js

@@ -12,7 +12,7 @@ import Collection from '@ckeditor/ckeditor5-utils/src/collection';
 import mix from '@ckeditor/ckeditor5-utils/src/mix';
 import ObservableMixin from '@ckeditor/ckeditor5-utils/src/observablemixin';
 
-// @if CK_DEBUG_ENGINE // const { logDocument } = require( '../dev-tools/utils' );
+// @if CK_DEBUG_ENGINE // const { logDocument } = require( '../dev-utils/utils' );
 
 /**
  * Document class creates an abstract layer over the content editable area, contains a tree of view elements and

+ 2 - 2
packages/ckeditor5-engine/src/view/element.js

@@ -15,7 +15,7 @@ import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
 import Matcher from './matcher';
 import { isPlainObject } from 'lodash-es';
 
-// @if CK_DEBUG_ENGINE // const { convertMapToTags } = require( '../dev-tools/utils' );
+// @if CK_DEBUG_ENGINE // const { convertMapToTags } = require( '../dev-utils/utils' );
 
 /**
  * View element.
@@ -775,7 +775,7 @@ export default class Element extends Node {
 	 * @method module:engine/view/element~Element#getFillerOffset
 	 */
 
-	// @if CK_DEBUG_ENGINE // printTree() {
+	// @if CK_DEBUG_ENGINE // printTree( level = 0) {
 	// @if CK_DEBUG_ENGINE // 	let string = '';
 
 	// @if CK_DEBUG_ENGINE //	string += '\t'.repeat( level ) + `<${ this.name }${ convertMapToTags( this.getAttributes() ) }>`;