ckeditor/plugins/crossreference/dialogs/crossreference-link.js
changeset 5 c925ae656709
parent 0 44d330dccc59
     1.1 --- a/ckeditor/plugins/crossreference/dialogs/crossreference-link.js	Sat Dec 17 03:31:51 2016 +0300
     1.2 +++ b/ckeditor/plugins/crossreference/dialogs/crossreference-link.js	Wed Dec 21 17:20:19 2016 +0300
     1.3 @@ -14,8 +14,6 @@
     1.4  		if (typeName)
     1.5  			type = config.types[typeName];
     1.6  		
     1.7 -		dialog.setValueOf('tab-main', 'filter', '');
     1.8 -		
     1.9  		var anchorSelect = dialog.getContentElement('tab-main', 'anchor');
    1.10  		anchorSelect.clear();
    1.11  		anchorSelect.add('', '');
    1.12 @@ -59,7 +57,9 @@
    1.13  				option.html(text);
    1.14  			});
    1.15  			
    1.16 -			if (!dialog.insertMode)
    1.17 +			if (dialog.insertMode)
    1.18 +				filterAnchors(dialog);
    1.19 +			else
    1.20  				anchorSelect.setup(dialog.element);
    1.21  			
    1.22  			dialog.setState(CKEDITOR.DIALOG_STATE_IDLE);
    1.23 @@ -208,7 +208,7 @@
    1.24  			this.element = selection.getStartElement();
    1.25  			if (this.element)
    1.26  				this.element = this.element.getAscendant('a', true);
    1.27 -			if (!this.element || this.element.getName() != 'a') {
    1.28 +			if (!this.element || this.element.getName() != 'a' || !this.element.hasAttribute('cross-link')) {
    1.29  				this.element = editor.document.createElement('a');
    1.30  				this.element.setAttribute('cross-link', '');
    1.31  				this.insertMode = true;
    1.32 @@ -216,9 +216,10 @@
    1.33  				this.insertMode = false;
    1.34  			}
    1.35  			
    1.36 -			if (this.insertMode)
    1.37 +			if (this.insertMode) {
    1.38 +				this.setValueOf('tab-main', 'filter', selection.getSelectedText().trim());
    1.39  				updateAnchors(this);
    1.40 -			else
    1.41 +			} else
    1.42  				this.setupContent(this.element);
    1.43  		},
    1.44