Skip to content

Commit

Permalink
Use selected text as link filter (in insert mode)
Browse files Browse the repository at this point in the history
Use selected text as 'filter' field value in link dialog at insert action (close #8)
  • Loading branch information
indvd00m committed Dec 21, 2016
1 parent 0b5ad68 commit a6c685d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions dialogs/crossreference-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ CKEDITOR.dialog.add('crossreference-link-dialog', function(editor) {
if (typeName)
type = config.types[typeName];

dialog.setValueOf('tab-main', 'filter', '');

var anchorSelect = dialog.getContentElement('tab-main', 'anchor');
anchorSelect.clear();
anchorSelect.add('', '');
Expand Down Expand Up @@ -59,7 +57,9 @@ CKEDITOR.dialog.add('crossreference-link-dialog', function(editor) {
option.html(text);
});

if (!dialog.insertMode)
if (dialog.insertMode)
filterAnchors(dialog);
else
anchorSelect.setup(dialog.element);

dialog.setState(CKEDITOR.DIALOG_STATE_IDLE);
Expand Down Expand Up @@ -208,17 +208,18 @@ CKEDITOR.dialog.add('crossreference-link-dialog', function(editor) {
this.element = selection.getStartElement();
if (this.element)
this.element = this.element.getAscendant('a', true);
if (!this.element || this.element.getName() != 'a') {
if (!this.element || this.element.getName() != 'a' || !this.element.hasAttribute('cross-link')) {
this.element = editor.document.createElement('a');
this.element.setAttribute('cross-link', '');
this.insertMode = true;
} else {
this.insertMode = false;
}

if (this.insertMode)
if (this.insertMode) {
this.setValueOf('tab-main', 'filter', selection.getSelectedText().trim());
updateAnchors(this);
else
} else
this.setupContent(this.element);
},

Expand Down

0 comments on commit a6c685d

Please sign in to comment.