Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename exports back to CkeditorPlugin and Ckeditor. #292

Merged
merged 3 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

import { createApp } from 'vue';
import { CKEditorPlugin } from '../src/plugin.js';
import { CkeditorPlugin } from '../src/plugin.js';
import App from './App.vue';

import 'ckeditor5/ckeditor5.css';

createApp( App )
.use( CKEditorPlugin )
.use( CkeditorPlugin )
.mount( '#app' );
18 changes: 12 additions & 6 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

/* eslint-env browser */
import * as Vue from 'vue';
import CKEditor from './ckeditor.vue';
import Ckeditor from './ckeditor.vue';

/* istanbul ignore if -- @preserve */
if ( !Vue.version || !Vue.version.startsWith( '3.' ) ) {
Expand All @@ -16,24 +16,30 @@ if ( !Vue.version || !Vue.version.startsWith( '3.' ) ) {
);
}

const CKEditorPlugin = {
const CkeditorPlugin = {
/**
* Installs the plugin, registering the `<ckeditor>` component.
*
* @param app The application instance.
*/
install( app: Vue.App ): void {
app.component( 'Ckeditor', CKEditor );
app.component( 'Ckeditor', Ckeditor );
}
};

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

declare module 'vue' {
interface GlobalComponents {
Ckeditor: typeof CKEditor;
Ckeditor: typeof Ckeditor;
filipsobol marked this conversation as resolved.
Show resolved Hide resolved
}
}
8 changes: 4 additions & 4 deletions tests/ckeditor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { nextTick } from 'vue';
import { describe, beforeEach, afterEach, it, expect, vi } from 'vitest';
import { mount } from '@vue/test-utils';
import { CKEditor } from '../src/plugin.ts';
import { Ckeditor } from '../src/plugin.ts';
import {
MockEditor,
ModelDocument,
Expand All @@ -26,7 +26,7 @@ describe( 'CKEditor component', () => {
} );

it( 'should have a name', () => {
expect( CKEditor.name ).to.equal( 'CKEditor' );
expect( Ckeditor.name ).to.equal( 'CKEditor' );
} );

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

const component = mount( {
components: {
ckeditor: CKEditor
Ckeditor
},
data: () => ( {
editor: MockEditor,
Expand Down Expand Up @@ -524,7 +524,7 @@ describe( 'CKEditor component', () => {
} );

function mountComponent( props: Record<string, any> = {} ) {
return mount( CKEditor, {
return mount( Ckeditor, {
props: {
editor: MockEditor,
...props
Expand Down
4 changes: 2 additions & 2 deletions tests/plugin/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { describe, it, expect, vi } from 'vitest';
import { mount } from '@vue/test-utils';
import { ClassicEditor, Essentials, Paragraph } from 'ckeditor5';
import { CKEditorPlugin } from '../../src/plugin.js';
import { CkeditorPlugin } from '../../src/plugin.js';

describe( 'CKEditor plugin', () => {
it( 'should work with an actual editor build', async () => {
Expand Down Expand Up @@ -40,7 +40,7 @@ describe( 'CKEditor plugin', () => {
{
attachTo: domElement,
global: {
plugins: [ CKEditorPlugin ]
plugins: [ CkeditorPlugin ]
},
data: () => ( {
editor: TestEditor,
Expand Down
4 changes: 2 additions & 2 deletions tests/plugin/localcomponent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { nextTick } from 'vue';
import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import { CKEditor } from '../../src/plugin.js';
import { Ckeditor } from '../../src/plugin.js';
import { MockEditor } from '../_utils/mockeditor';

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

const firstComponent = mount( CKEditor, {
const firstComponent = mount( Ckeditor, {
props: {
editor: FooEditor
}
Expand Down