/** * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ /** * @fileOverview A set of utilities to find and create horizontal spaces in edited content. */ 'use strict'; ( function() { CKEDITOR.plugins.add( 'lineutils' ); /** * Determines a position relative to an element in DOM (before). * * @readonly * @property {Number} [=0] * @member CKEDITOR */ CKEDITOR.LINEUTILS_BEFORE = 1; /** * Determines a position relative to an element in DOM (after). * * @readonly * @property {Number} [=2] * @member CKEDITOR */ CKEDITOR.LINEUTILS_AFTER = 2; /** * Determines a position relative to an element in DOM (inside). * * @readonly * @property {Number} [=4] * @member CKEDITOR */ CKEDITOR.LINEUTILS_INSIDE = 4; /** * A utility that traverses the DOM tree and discovers elements * (relations) matching user-defined lookups. * * @private * @class CKEDITOR.plugins.lineutils.finder * @constructor Creates a Finder class instance. * @param {CKEDITOR.editor} editor Editor instance that the Finder belongs to. * @param {Object} def Finder's definition. * @since 4.3 */ function Finder( editor, def ) { CKEDITOR.tools.extend( this, { editor: editor, editable: editor.editable(), doc: editor.document, win: editor.window }, def, true ); this.inline = this.editable.isInline(); if ( !this.inline ) { this.frame = this.win.getFrame(); } this.target = this[ this.inline ? 'editable' : 'doc' ]; } Finder.prototype = { /** * Initializes searching for elements with every mousemove event fired. * To stop searching use {@link #stop}. * * @param {Function} [callback] Function executed on every iteration. */ start: function( callback ) { var that = this, editor = this.editor, doc = this.doc, el, elfp, x, y; var moveBuffer = CKEDITOR.tools.eventsBuffer( 50, function() { if ( editor.readOnly || editor.mode != 'wysiwyg' ) return; that.relations = {}; // Sometimes it happens that elementFromPoint returns null (especially on IE). // Any further traversal makes no sense if there's no start point. Abort. // Note: In IE8 elementFromPoint may return zombie nodes of undefined nodeType, // so rejecting those as well. if ( !( elfp = doc.$.elementFromPoint( x, y ) ) || !elfp.nodeType ) { return; } el = new CKEDITOR.dom.element( elfp ); that.traverseSearch( el ); if ( !isNaN( x + y ) ) { that.pixelSearch( el, x, y ); } callback && callback( that.relations, x, y ); } ); // Searching starting from element from point on mousemove. this.listener = this.editable.attachListener( this.target, 'mousemove', function( evt ) { x = evt.data.$.clientX; y = evt.data.$.clientY; moveBuffer.input(); } ); this.editable.attachListener( this.inline ? this.editable : this.frame, 'mouseout', function() { moveBuffer.reset(); } ); }, /** * Stops observing mouse events attached by {@link #start}. */ stop: function() { if ( this.listener ) { this.listener.removeListener(); } }, /** * Returns a range representing the relation, according to its element * and type. * * @param {Object} location Location containing a unique identifier and type. * @returns {CKEDITOR.dom.range} Range representing the relation. */ getRange: ( function() { var where = {}; where[ CKEDITOR.LINEUTILS_BEFORE ] = CKEDITOR.POSITION_BEFORE_START; where[ CKEDITOR.LINEUTILS_AFTER ] = CKEDITOR.POSITION_AFTER_END; where[ CKEDITOR.LINEUTILS_INSIDE ] = CKEDITOR.POSITION_AFTER_START; return function( location ) { var range = this.editor.createRange(); range.moveToPosition( this.relations[ location.uid ].element, where[ location.type ] ); return range; }; } )(), /** * Stores given relation in a {@link #relations} object. Processes the relation * to normalize and avoid duplicates. * * @param {CKEDITOR.dom.element} el Element of the relation. * @param {Number} type Relation, one of `CKEDITOR.LINEUTILS_AFTER`, `CKEDITOR.LINEUTILS_BEFORE`, `CKEDITOR.LINEUTILS_INSIDE`. */ store: ( function() { function merge( el, type, relations ) { var uid = el.getUniqueId(); if ( uid in relations ) { relations[ uid ].type |= type; } else { relations[ uid ] = { element: el, type: type }; } } return function( el, type ) { var alt; // Normalization to avoid duplicates: // CKEDITOR.LINEUTILS_AFTER bec
name: "B2 Back Room"
letters {
key: "b"
level2: true
path: "Components/Collectables/collectable"
}
paintings {
name: "EYES2"
path: "Components/Paintings/eyes2"
orientation: "east"
}
paintings {
name: "EYES3"
path: "Components/Paintings/eyes3"
orientation: "west"
}