Skip to content

Commit fac4482

Browse files
authored
Merge pull request #292 from ckeditor/revert-renames-of-exports
Other: Rename exports to improve name of the editor component in Vue. MINOR BREAKING CHANGE: Rename main package exports to `CkeditorPlugin` and `Ckeditor`.
2 parents 93049a2 + dc58bc9 commit fac4482

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

Diff for: demo/demo.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
*/
55

66
import { createApp } from 'vue';
7-
import { CKEditorPlugin } from '../src/plugin.js';
7+
import { CkeditorPlugin } from '../src/plugin.js';
88
import App from './App.vue';
99

1010
import 'ckeditor5/ckeditor5.css';
1111

1212
createApp( App )
13-
.use( CKEditorPlugin )
13+
.use( CkeditorPlugin )
1414
.mount( '#app' );

Diff for: src/plugin.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
/* eslint-env browser */
77
import * as Vue from 'vue';
8-
import CKEditor from './ckeditor.vue';
8+
import Ckeditor from './ckeditor.vue';
99

1010
/* istanbul ignore if -- @preserve */
1111
if ( !Vue.version || !Vue.version.startsWith( '3.' ) ) {
@@ -16,24 +16,31 @@ if ( !Vue.version || !Vue.version.startsWith( '3.' ) ) {
1616
);
1717
}
1818

19-
const CKEditorPlugin = {
19+
const CkeditorPlugin = {
2020
/**
2121
* Installs the plugin, registering the `<ckeditor>` component.
2222
*
2323
* @param app The application instance.
2424
*/
2525
install( app: Vue.App ): void {
26-
app.component( 'Ckeditor', CKEditor );
26+
app.component( 'Ckeditor', Ckeditor );
2727
}
2828
};
2929

30+
/**
31+
* The component is exported as `Ckeditor` and not `CKEditor`, because of how Vue handles components with
32+
* capitalized names. The component with more than one consecutive capital letter will also be be available
33+
* in kebab-case, where each capital letter is separated by `-`. This way, the `CKEditor` component will
34+
* be available as `c-k-editor`, which doesn't look good.
35+
*/
3036
export {
31-
CKEditorPlugin,
32-
CKEditor
37+
CkeditorPlugin,
38+
Ckeditor
3339
};
3440

3541
declare module 'vue' {
3642
interface GlobalComponents {
37-
Ckeditor: typeof CKEditor;
43+
Ckeditor: typeof Ckeditor;
44+
ckeditor: typeof Ckeditor;
3845
}
3946
}

Diff for: tests/ckeditor.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { nextTick } from 'vue';
77
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
88
import { mount } from '@vue/test-utils';
9-
import { CKEditor } from '../src/plugin.ts';
9+
import { Ckeditor } from '../src/plugin.ts';
1010
import {
1111
MockEditor,
1212
ModelDocument,
@@ -26,7 +26,7 @@ describe( 'CKEditor component', () => {
2626
} );
2727

2828
it( 'should have a name', () => {
29-
expect( CKEditor.name ).to.equal( 'CKEditor' );
29+
expect( Ckeditor.name ).to.equal( 'CKEditor' );
3030
} );
3131

3232
it( 'should print a warning if the "window.CKEDITOR_VERSION" variable is not available', async () => {
@@ -251,7 +251,7 @@ describe( 'CKEditor component', () => {
251251

252252
const component = mount( {
253253
components: {
254-
ckeditor: CKEditor
254+
Ckeditor
255255
},
256256
data: () => ( {
257257
editor: MockEditor,
@@ -524,7 +524,7 @@ describe( 'CKEditor component', () => {
524524
} );
525525

526526
function mountComponent( props: Record<string, any> = {} ) {
527-
return mount( CKEditor, {
527+
return mount( Ckeditor, {
528528
props: {
529529
editor: MockEditor,
530530
...props

Diff for: tests/plugin/integration.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { describe, it, expect, vi } from 'vitest';
77
import { mount } from '@vue/test-utils';
88
import { ClassicEditor, Essentials, Paragraph } from 'ckeditor5';
9-
import { CKEditorPlugin } from '../../src/plugin.js';
9+
import { CkeditorPlugin } from '../../src/plugin.js';
1010

1111
describe( 'CKEditor plugin', () => {
1212
it( 'should work with an actual editor build', async () => {
@@ -40,7 +40,7 @@ describe( 'CKEditor plugin', () => {
4040
{
4141
attachTo: domElement,
4242
global: {
43-
plugins: [ CKEditorPlugin ]
43+
plugins: [ CkeditorPlugin ]
4444
},
4545
data: () => ( {
4646
editor: TestEditor,

Diff for: tests/plugin/localcomponent.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { nextTick } from 'vue';
77
import { describe, it, expect } from 'vitest';
88
import { mount } from '@vue/test-utils';
9-
import { CKEditor } from '../../src/plugin.js';
9+
import { Ckeditor } from '../../src/plugin.js';
1010
import { MockEditor } from '../_utils/mockeditor';
1111

1212
class FooEditor extends MockEditor {}
@@ -15,7 +15,7 @@ describe( 'CKEditor plugin', () => {
1515
it( 'should work when the component is used locally', async () => {
1616
window.CKEDITOR_VERSION = '42.0.0';
1717

18-
const firstComponent = mount( CKEditor, {
18+
const firstComponent = mount( Ckeditor, {
1919
props: {
2020
editor: FooEditor
2121
}

0 commit comments

Comments
 (0)