1 CrossReference Plugin for CKEditor 4
2 =================================
4 Adds cross references links with optional auto-numeration for chapters, images, tables and references. Other types of references can be defined in config.
8 Try the plugin demo at <http://indvd00m.com/crossreference/>.
12 Two main conceptions - anchor and link to anchor. There are 4 type of references defined by default: chapter, image, table, reference. Example of anchor of type `image` in raw html:
15 class="cross-reference cross-anchor"
16 cross-reference="image"
18 cross-guid="7d24373b-0756-481d-bf97-5a17ffdf3a28"
19 cross-name="Experimental result"
21 name="image-7d24373b-0756-481d-bf97-5a17ffdf3a28"
23 Fig. 1. Experimental result.
26 Example of link to this anchor in raw html:
29 class="cross-reference cross-link"
30 cross-reference="image"
32 cross-guid="7d24373b-0756-481d-bf97-5a17ffdf3a28"
33 cross-name="Experimental result"
35 href="#image-7d24373b-0756-481d-bf97-5a17ffdf3a28"
36 title="Fig. 1. Experimental result."
41 After every inserting of anchor or links to anchor all references will be updated to be a concerted. Or you can manually update cross-references by selecting option in menu (for example after deleting of anchors).
45 You can switch which types is active by config option `config.crossreference.activeTypes = ['type1', 'type2']`. You can define other types also.
51 activeTypes: ['chapter', 'image', 'table', 'reference'],
56 anchorTextTemplate: '${number}. ${name}.',
57 linkTextTemplate: '${number}',
61 increase: function(number) {
62 var n = parseInt(number);
66 anchorsProvider: 'default',
67 allowCreateAnchors: true,
72 anchorTextTemplate: 'Fig. ${number}. ${name}.',
73 linkTextTemplate: '${number}',
77 increase: function(number) {
78 var n = parseInt(number);
82 anchorsProvider: 'default',
83 allowCreateAnchors: true,
88 anchorTextTemplate: 'Table ${number}. ${name}.',
89 linkTextTemplate: '${number}',
93 increase: function(number) {
94 var n = parseInt(number);
98 anchorsProvider: 'default',
99 allowCreateAnchors: true,
104 anchorTextTemplate: '[${number}] ${name}.',
105 linkTextTemplate: '[${number}]',
109 increase: function(number) {
110 var n = parseInt(number);
114 anchorsProvider: 'default',
115 allowCreateAnchors: true,
121 | Property | Description | Type | Default value |
122 | --- | --- | --- | --- |
123 | `activeTypes` | Which type of anchors would be activated. | Array | `['chapter', 'image', 'table', 'reference']` |
124 | `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 |
125 | `types` | Types definition. | Object | see [Default config](https://github.com/indvd00m/crossreference#default-config) section|
127 ### Example of type definition
132 anchorTextTemplate: 'Fig. ${number}. ${name}.',
133 linkTextTemplate: '${number}',
137 increase: function(number) {
138 var n = parseInt(number);
142 anchorsProvider: 'default',
143 allowCreateAnchors: true,
147 | Property | Description | Type | Required |
148 | --- | --- | --- | --- |
149 | `name` | Type name. | String | Yes |
150 | `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 |
151 | `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 |
152 | `numeration` | Definition of type numeration. See [Example of a numeration definition](https://github.com/indvd00m/crossreference#example-of-a-numeration-definition) section. | Object | No |
153 | `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 |
154 | `allowCreateAnchors` | Can user create anchors of this type in anchors dialog. | Boolean | No |
155 | `groupAnchors` | If `true`, anchors can be filtered by group in link dialog. | Boolean | No |
157 ### Example of a numeration definition
163 increase: function(number) {
164 var n = parseInt(number);
169 | Property | Description | Type |
171 | `enabled` | Enabling/disabling numeration of anchors. | Boolean |
172 | `firstNumber` | First number. For example you may define `firstNumber` as `I` for Roman numerals. | String |
173 | `increase` | Function which must return number (as string) which is next after `number` argument (string). | Function |
175 ### Example of an anchor object
182 guid: '7d24373b-0756-481d-bf97-5a17ffdf3a28',
183 name: 'Experimental result',
185 text: 'Fig. 1. Experimental result.',
186 groupName: 'Group name',
187 groupGuid: '6c848dff-cde3-421f-b926-695c8de37d80'
190 | Property | Description | Type | Required |
191 | --- | --- | --- | --- |
192 | `type` | Type name of this anchor (`config.types.typeName`). | String | Yes |
193 | `guid` | Unique guid of this anchor. | String | Yes |
194 | `name` | Name of this anchor. | String | Yes |
195 | `number` | Number of this anchor (if type contains numeration definition). | String | Depends of type |
196 | `text` | Text of this anchor. Optional property because of text will generated by `type.anchorTextTemplate` template. | String | No |
197 | `groupName` | Name of anchor group. | String | No |
198 | `groupGuid` | Unique guid of anchor group. | String | No |
200 ### Example of type with anchors provider
202 You can define your own anchors provider. By default plugin search anchors in content of editor and use this anchors for links. But if you want refer to anchors outside of editor you can define another type of anchor with `anchorsProvider` function.
207 anchorTextTemplate: '${name}',
208 linkTextTemplate: '${name}',
209 anchorsProvider: function(callback, editorAnchors, type, editor) {
213 guid: '7d24373b-0756-481d-bf97-5a17ffdf3a28',
219 allowCreateAnchors: false,
224 `anchorsProvider` method attributes:
226 | Name | Description | Type |
228 | `callback` | Callback method which must be called with arrays of anchors as argument. | Function |
229 | `editorAnchors` | Anchors of this type (`myType` in this case) which already contains in editor. You can merge this anchors with your own anchors if need. | Array |
230 | `type` | Type definition (Object `myType` in this case). | Object |
231 | `editor` | Instance of ckeditor. | Object |
236 CrossReference Plugin require CKEditor 4.5+ version and dependent from plugins: dialog, notification.
240 1. Download the plugin: https://github.com/indvd00m/crossreference/releases.
242 2. Extract (decompress) the downloaded file into the plugins folder of your
243 CKEditor installation.
244 Example: http://example.com/ckeditor/plugins/crossreference
246 3. Enable the plugin by using the extraPlugins configuration setting.
247 Example: CKEDITOR.config.extraPlugins = 'crossreference';
251 See https://github.com/indvd00m/crossreference/issues.
255 https://icons8.com/web-app/21792/unicast
257 https://icons8.com/web-app/15117/anchor
259 https://icons8.com/web-app/38051/link
261 https://icons8.com/web-app/21100/refresh
265 CrossReference Plugin is distributed under GPL/LGPL/MPL. For license terms, see LICENSE.md.
267 CrossReference Plugin is written by David E. Veliev.