Skip to content

Commit

Permalink
Implemented use of official CKEditor5 typings.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemyslaw-zan committed Feb 28, 2023
1 parent ef84284 commit 20be1d5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 41 deletions.
17 changes: 0 additions & 17 deletions packages/ckeditor5-package-generator/lib/templates/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,6 @@
"@ckeditor/ckeditor5-theme-lark": ">=<%= packageVersions.ckeditor5 %>",
"@ckeditor/ckeditor5-upload": ">=<%= packageVersions.ckeditor5 %>",
"@types/chai": "^4.3.1",
"@types/ckeditor__ckeditor5-autoformat": "latest",
"@types/ckeditor__ckeditor5-basic-styles": "latest",
"@types/ckeditor__ckeditor5-block-quote": "latest",
"@types/ckeditor__ckeditor5-code-block": "latest",
"@types/ckeditor__ckeditor5-core": "latest",
"@types/ckeditor__ckeditor5-editor-classic": "latest",
"@types/ckeditor__ckeditor5-essentials": "latest",
"@types/ckeditor__ckeditor5-heading": "latest",
"@types/ckeditor__ckeditor5-image": "latest",
"@types/ckeditor__ckeditor5-indent": "latest",
"@types/ckeditor__ckeditor5-link": "latest",
"@types/ckeditor__ckeditor5-list": "latest",
"@types/ckeditor__ckeditor5-ui": "latest",
"@types/ckeditor__ckeditor5-media-embed": "latest",
"@types/ckeditor__ckeditor5-paragraph": "latest",
"@types/ckeditor__ckeditor5-table": "latest",
"@types/ckeditor__ckeditor5-upload": "latest",
"@types/mocha": "^9.1.1",
"@typescript-eslint/eslint-plugin": "~5.43.0",
"@typescript-eslint/parser": "^5.18.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { Plugin } from 'ckeditor5/src/core';
import { ButtonView } from 'ckeditor5/src/ui';

import type { EditorWithUI } from 'ckeditor__ckeditor5-core/src/editor/editorwithui';

import ckeditor5Icon from '../theme/icons/ckeditor.svg';

export default class <%= formattedNames.plugin.pascalCase %> extends Plugin {
public static override get pluginName(): string {
public static get pluginName(): '<%= formattedNames.plugin.pascalCase %>' {
return '<%= formattedNames.plugin.pascalCase %>';
}

public override init(): void {
const editor = this.editor as EditorWithUI;
public init(): void {
const editor = this.editor;
const t = editor.t;
const model = editor.model;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
import { expect } from 'chai';
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Heading from '@ckeditor/ckeditor5-heading/src/heading';
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import { Essentials } from '@ckeditor/ckeditor5-essentials';
import { Paragraph } from '@ckeditor/ckeditor5-paragraph';
import { Heading } from '@ckeditor/ckeditor5-heading';
import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic';
import <%= formattedNames.plugin.pascalCase %> from '../src/<%= formattedNames.plugin.lowerCaseMerged %>';

import type { EditorWithUI } from 'ckeditor__ckeditor5-core/src/editor/editorwithui';
import type { DataApi } from 'ckeditor__ckeditor5-core/src/editor/utils/dataapimixin';

interface Editor extends EditorWithUI, DataApi {}

describe( '<%= formattedNames.plugin.pascalCase %>', () => {
it( 'should be named', () => {
expect( <%= formattedNames.plugin.pascalCase %>.pluginName ).to.equal( '<%= formattedNames.plugin.pascalCase %>' );
} );

describe( 'init()', () => {
let domElement: HTMLElement, editor: Editor;
let domElement: HTMLElement, editor: ClassicEditor;

beforeEach( async () => {
domElement = document.createElement( 'div' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"./src",
"./tests",
"./typings"
],
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,3 @@ declare module '*.svg' {
const content: string;
export default content;
}

declare module 'ckeditor5/src/core' {
export * from 'ckeditor__ckeditor5-core';
}

declare module 'ckeditor5/src/ui' {
export * from 'ckeditor__ckeditor5-ui';
}

0 comments on commit 20be1d5

Please sign in to comment.