# HG changeset patch
# User indvdum (gotoindvdum[at]gmail[dot]com)
# Date 1482330019 -10800
# Node ID c925ae65670939597c4a450e451866cb5118f1b4
# Parent 40e26009689ce2dfc2bf1ae33723d4bcae897162
Update crossreference plugin
diff -r 40e26009689c -r c925ae656709 ckeditor/plugins/crossreference/README.md
--- a/ckeditor/plugins/crossreference/README.md Sat Dec 17 03:31:51 2016 +0300
+++ b/ckeditor/plugins/crossreference/README.md Wed Dec 21 17:20:19 2016 +0300
@@ -5,7 +5,26 @@
## Online demo
-Try the plugin demo at .
+Try the plugin demo at .
+
+## CKEditor plugin page
+
+http://ckeditor.com/addon/crossreference
+
+## Requirements
+
+CrossReference Plugin require CKEditor 4.5+ version and dependent from plugins: dialog, notification.
+
+## Installation
+
+ 1. Download the plugin: https://github.com/indvd00m/crossreference/releases.
+
+ 2. Extract (decompress) the downloaded file into the plugins folder of your
+ CKEditor installation.
+ Example: http://example.com/ckeditor/plugins/crossreference
+
+ 3. Enable the plugin by using the extraPlugins configuration setting.
+ Example: CKEDITOR.config.extraPlugins = 'crossreference';
## Description
@@ -122,7 +141,7 @@
| --- | --- | --- | --- |
| `activeTypes` | Which type of anchors would be activated. | Array | `['chapter', 'image', 'table', 'reference']` |
| `overrideTypes` | If you define your own types, enabling this option lead to mixing of your types with types from default config which not yet defined in your config. | Boolean | false |
-| `types` | Types definition. | Object | see [Default config](https://github.com/indvd00m/crossreference#default-config) section|
+| `types` | Types definition. | Object | see [Example of type definition](https://github.com/indvd00m/crossreference#example-of-type-definition) section|
### Example of type definition
@@ -150,7 +169,7 @@
| `anchorTextTemplate` | Template for anchor text. This text will be put in `a` tag. You can use variables in format `${variableName}`. Variables is a properties of an anchor object (see [Example of an anchor object](https://github.com/indvd00m/crossreference#example-of-an-anchor-object) section). | String | No |
| `linkTextTemplate` | Template for link text. This text will be put in `a` tag. You can use variables in format `${variableName}`. Variables is a properties of an anchor object (see [Example of an anchor object](https://github.com/indvd00m/crossreference#example-of-an-anchor-object) section). | String | No |
| `numeration` | Definition of type numeration. See [Example of a numeration definition](https://github.com/indvd00m/crossreference#example-of-a-numeration-definition) section. | Object | No |
-| `anchorsProvider` | See [Example of type with anchors provider](https://github.com/indvd00m/crossreference#example-of-type-with-anchors-provider) section. | String 'default' or function | No |
+| `anchorsProvider` | See [Example of type with anchors provider](https://github.com/indvd00m/crossreference#example-of-type-with-anchors-provider) section. | String `'default'` or function | No |
| `allowCreateAnchors` | Can user create anchors of this type in anchors dialog. | Boolean | No |
| `groupAnchors` | If `true`, anchors can be filtered by group in link dialog. | Boolean | No |
@@ -231,21 +250,6 @@
| `editor` | Instance of ckeditor. | Object |
-## Requirements
-
-CrossReference Plugin require CKEditor 4.5+ version and dependent from plugins: dialog, notification.
-
-## Installation
-
- 1. Download the plugin: https://github.com/indvd00m/crossreference/releases.
-
- 2. Extract (decompress) the downloaded file into the plugins folder of your
- CKEditor installation.
- Example: http://example.com/ckeditor/plugins/crossreference
-
- 3. Enable the plugin by using the extraPlugins configuration setting.
- Example: CKEDITOR.config.extraPlugins = 'crossreference';
-
## Roadmap
See https://github.com/indvd00m/crossreference/issues.
diff -r 40e26009689c -r c925ae656709 ckeditor/plugins/crossreference/dialogs/crossreference-anchor.js
--- a/ckeditor/plugins/crossreference/dialogs/crossreference-anchor.js Sat Dec 17 03:31:51 2016 +0300
+++ b/ckeditor/plugins/crossreference/dialogs/crossreference-anchor.js Wed Dec 21 17:20:19 2016 +0300
@@ -88,7 +88,7 @@
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-anchor')) {
this.element = editor.document.createElement('a');
var guid = generateUUID();
this.element.setAttribute('cross-guid', guid);
@@ -97,7 +97,9 @@
this.insertMode = false;
}
- if (!this.insertMode)
+ if (this.insertMode)
+ this.setValueOf('tab-main', 'name', selection.getSelectedText().trim());
+ else
this.setupContent(this.element);
},
diff -r 40e26009689c -r c925ae656709 ckeditor/plugins/crossreference/dialogs/crossreference-link.js
--- a/ckeditor/plugins/crossreference/dialogs/crossreference-link.js Sat Dec 17 03:31:51 2016 +0300
+++ b/ckeditor/plugins/crossreference/dialogs/crossreference-link.js Wed Dec 21 17:20:19 2016 +0300
@@ -14,8 +14,6 @@
if (typeName)
type = config.types[typeName];
- dialog.setValueOf('tab-main', 'filter', '');
-
var anchorSelect = dialog.getContentElement('tab-main', 'anchor');
anchorSelect.clear();
anchorSelect.add('', '');
@@ -59,7 +57,9 @@
option.html(text);
});
- if (!dialog.insertMode)
+ if (dialog.insertMode)
+ filterAnchors(dialog);
+ else
anchorSelect.setup(dialog.element);
dialog.setState(CKEDITOR.DIALOG_STATE_IDLE);
@@ -208,7 +208,7 @@
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;
@@ -216,9 +216,10 @@
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);
},
diff -r 40e26009689c -r c925ae656709 ckeditor/plugins/crossreference/plugin.js
--- a/ckeditor/plugins/crossreference/plugin.js Sat Dec 17 03:31:51 2016 +0300
+++ b/ckeditor/plugins/crossreference/plugin.js Wed Dec 21 17:20:19 2016 +0300
@@ -189,6 +189,15 @@
}
}
});
+
+ // keystrokes
+
+ editor.setKeystroke(CKEDITOR.CTRL + CKEDITOR.SHIFT + 65, anchorDialogCmdName);
+ editor.setKeystroke(CKEDITOR.CTRL + CKEDITOR.SHIFT + 76, linkDialogCmdName);
+ editor.setKeystroke(CKEDITOR.CTRL + CKEDITOR.ALT + 85, updateCmdName);
+
+ // double click
+
editor.on('doubleclick', function(evt) {
if (evt.data.element && !evt.data.element.isReadOnly() && evt.data.element.getName() === 'a'
&& evt.data.element.hasAttribute('cross-reference')) {