1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | import { Plugin } from 'ckeditor5/src/core';
|
11 | import AttributeCommand from '../attributecommand';
|
12 |
|
13 | const SUPERSCRIPT = 'superscript';
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export default class SuperscriptEditing extends Plugin {
|
24 | |
25 |
|
26 |
|
27 | static get pluginName() {
|
28 | return 'SuperscriptEditing';
|
29 | }
|
30 |
|
31 | |
32 |
|
33 |
|
34 | init() {
|
35 | const editor = this.editor;
|
36 |
|
37 | editor.model.schema.extend( '$text', { allowAttributes: SUPERSCRIPT } );
|
38 | editor.model.schema.setAttributeProperties( SUPERSCRIPT, {
|
39 | isFormatting: true,
|
40 | copyOnEnter: true
|
41 | } );
|
42 |
|
43 |
|
44 |
|
45 | editor.conversion.attributeToElement( {
|
46 | model: SUPERSCRIPT,
|
47 | view: 'sup',
|
48 | upcastAlso: [
|
49 | {
|
50 | styles: {
|
51 | 'vertical-align': 'super'
|
52 | }
|
53 | }
|
54 | ]
|
55 | } );
|
56 |
|
57 |
|
58 | editor.commands.add( SUPERSCRIPT, new AttributeCommand( editor, SUPERSCRIPT ) );
|
59 | }
|
60 | }
|