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 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:
11 class="cross-reference cross-anchor"
12 cross-reference="image"
14 cross-guid="7d24373b-0756-481d-bf97-5a17ffdf3a28"
15 cross-name="Experimental result"
17 name="image-7d24373b-0756-481d-bf97-5a17ffdf3a28"
19 Fig. 1. Experimental result.
22 Example of link to this anchor in raw html:
25 class="cross-reference cross-link"
26 cross-reference="image"
28 cross-guid="7d24373b-0756-481d-bf97-5a17ffdf3a28"
29 cross-name="Experimental result"
31 href="#image-7d24373b-0756-481d-bf97-5a17ffdf3a28"
32 title="Fig. 1. Experimental result."
37 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).
41 You can switch which types is active by config option `config.crossreference.activeTypes = ['type1', 'type2']`. You can define other types also.
47 activeTypes: ['chapter', 'image', 'table', 'reference'],
52 anchorTextTemplate: '${number}. ${name}.',
53 linkTextTemplate: '${number}',
57 increase: function(number) {
58 var n = parseInt(number);
62 anchorsProvider: 'default',
63 allowCreateAnchors: true,
68 anchorTextTemplate: 'Fig. ${number}. ${name}.',
69 linkTextTemplate: '${number}',
73 increase: function(number) {
74 var n = parseInt(number);
78 anchorsProvider: 'default',
79 allowCreateAnchors: true,
84 anchorTextTemplate: 'Table ${number}. ${name}.',
85 linkTextTemplate: '${number}',
89 increase: function(number) {
90 var n = parseInt(number);
94 anchorsProvider: 'default',
95 allowCreateAnchors: true,
100 anchorTextTemplate: '[${number}] ${name}.',
101 linkTextTemplate: '[${number}]',
105 increase: function(number) {
106 var n = parseInt(number);
110 anchorsProvider: 'default',
111 allowCreateAnchors: true,
117 | Property | Description | Type | Default value |
118 | --- | --- | --- | --- |
119 | `activeTypes` | Which type of anchors would be activated. | Array | `['chapter', 'image', 'table', 'reference']` |
120 | `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 |
121 | `types` | Types definition. | Object | see [Default config](https://github.com/indvd00m/crossreference#default-config) section|
123 ### Example of type definition
128 anchorTextTemplate: 'Fig. ${number}. ${name}.',
129 linkTextTemplate: '${number}',
133 increase: function(number) {
134 var n = parseInt(number);
138 anchorsProvider: 'default',
139 allowCreateAnchors: true,
143 | Property | Description | Type | Required |
144 | --- | --- | --- | --- |
145 | `name` | Type name. | String | Yes |
146 | `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 |
147 | `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 |
148 | `numeration` | Definition of type numeration. See [Example of a numeration config](https://github.com/indvd00m/crossreference#example-of-a-numeration-config) section. | Object | No |
149 | `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 |
150 | `allowCreateAnchors` | Can user create anchors of this type in anchors dialog. | Boolean | No |
151 | `groupAnchors` | If `true`, anchors can be filtered by group in link dialog. | Boolean | No |
153 ### Example of a numeration definition
159 increase: function(number) {
160 var n = parseInt(number);
165 | Property | Description | Type |
167 | `enabled` | Enabling/disabling numeration of anchors. | Boolean |
168 | `firstNumber` | First number. For example you may define `firstNumber` as `I` for Roman numerals. | String |
169 | `increase` | Function which must return number (as string) which is next after `number` argument (string). | Function |
171 ### Example of an anchor object
178 guid: '7d24373b-0756-481d-bf97-5a17ffdf3a28',
179 name: 'Experimental result',
181 text: 'Fig. 1. Experimental result.',
182 groupName: 'Group name',
183 groupGuid: '6c848dff-cde3-421f-b926-695c8de37d80'
186 | Property | Description | Type | Required |
187 | --- | --- | --- | --- |
188 | `type` | Type name of this anchor (`config.types.typeName`). | String | Yes |
189 | `guid` | Unique guid of this anchor. | String | Yes |
190 | `name` | Name of this anchor. | String | Yes |
191 | `number` | Number of this anchor (if type contains numeration definition). | String | Depends of type |
192 | `text` | Text of this anchor. Optional property because of text will generated by `type.anchorTextTemplate` template. | String | No |
193 | `groupName` | Name of anchor group. | String | No |
194 | `groupGuid` | Unique guid of anchor group. | String | No |
196 ### Example of type with anchors provider
198 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.
203 anchorTextTemplate: '${name}',
204 linkTextTemplate: '${name}',
205 anchorsProvider: function(callback, editorAnchors, type, editor) {
209 guid: '7d24373b-0756-481d-bf97-5a17ffdf3a28',
215 allowCreateAnchors: false,
220 `anchorsProvider` method attributes:
222 | Name | Description | Type |
224 | `callback` | Callback method which must be called with arrays of anchors as argument. | Function |
225 | `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 |
226 | `type` | Type definition (Object `myType` in this case). | Object |
227 | `editor` | Instance of ckeditor. | Object |
232 CrossReference Plugin require CKEditor 4.5+ version and dependent from plugins: dialog, notification.
236 1. Download the plugin.
238 2. Extract (decompress) the downloaded file into the plugins folder of your
239 CKEditor installation.
240 Example: http://example.com/ckeditor/plugins/crossreference
242 3. Enable the plugin by using the extraPlugins configuration setting.
243 Example: CKEDITOR.config.extraPlugins = 'crossreference';
247 See https://github.com/indvd00m/crossreference/issues.
251 https://icons8.com/web-app/15117/anchor
253 https://icons8.com/web-app/38051/link
255 https://icons8.com/web-app/21100/refresh
259 CrossReference Plugin is distributed under GPL/LGPL/MPL. For license terms, see LICENSE.md.
261 CrossReference Plugin is written by David E. Veliev.