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

Implemented use of official CKEditor5 typings #137

Merged
merged 3 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"plugins": [
{
"name": "<%= formattedNames.plugin.spacedOut %>",
"className": "<%= formattedNames.plugin.pascalCase %>",
"description": "Adds text to the editor.",
"path": "src/<%= formattedNames.plugin.lowerCaseMerged %>.<%= programmingLanguage %>",
"uiComponents": [
{
"name": "<%= formattedNames.plugin.camelCase %>Button",
"type": "Button",
"iconPath": "theme/icons/ckeditor.svg"
}
]
}
]
"plugins": [
{
"name": "<%= formattedNames.plugin.spacedOut %>",
"className": "<%= formattedNames.plugin.pascalCase %>",
"description": "Adds text to the editor.",
"path": "src/<%= formattedNames.plugin.lowerCaseMerged %>.<%= programmingLanguage %>",
"uiComponents": [
{
"name": "<%= formattedNames.plugin.camelCase %>Button",
"type": "Button",
"iconPath": "theme/icons/ckeditor.svg"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"<%= formattedNames.plugin.spacedOut %>": "Content for a tooltip is displayed when a user hovers the CKEditor 5 icon."
"<%= formattedNames.plugin.spacedOut %>": "Content for a tooltip is displayed when a user hovers the CKEditor 5 icon."
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
"build",
"ckeditor5-metadata.json"
],
"dependencies": {
"ckeditor5": ">=<%= packageVersions.ckeditor5 %>"
},
"devDependencies": {
"@ckeditor/ckeditor5-autoformat": ">=<%= packageVersions.ckeditor5 %>",
"@ckeditor/ckeditor5-basic-styles": ">=<%= packageVersions.ckeditor5 %>",
Expand All @@ -47,6 +44,7 @@
"@ckeditor/ckeditor5-table": ">=<%= packageVersions.ckeditor5 %>",
"@ckeditor/ckeditor5-theme-lark": ">=<%= packageVersions.ckeditor5 %>",
"@ckeditor/ckeditor5-upload": ">=<%= packageVersions.ckeditor5 %>",
"ckeditor5": ">=<%= packageVersions.ckeditor5 %>",
"eslint": "^7.32.0",
"eslint-config-ckeditor5": ">=<%= packageVersions.eslintConfigCkeditor5 %>",
"http-server": "^14.1.0",
Expand All @@ -55,6 +53,9 @@
"stylelint": "^13.13.1",
"stylelint-config-ckeditor5": ">=<%= packageVersions.stylelintConfigCkeditor5 %>"
},
"peerDependencies": {
"ckeditor5": ">=<%= packageVersions.ckeditor5 %>"
},
"scripts": {
"dll:build": "ckeditor5-package-tools dll:build",
"dll:serve": "http-server ./ -o sample/dll.html",
Expand Down
24 changes: 4 additions & 20 deletions packages/ckeditor5-package-generator/lib/templates/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
"build",
"ckeditor5-metadata.json"
],
"dependencies": {
"ckeditor5": ">=<%= packageVersions.ckeditor5 %>"
},
"devDependencies": {
"@ckeditor/ckeditor5-autoformat": ">=<%= packageVersions.ckeditor5 %>",
"@ckeditor/ckeditor5-basic-styles": ">=<%= packageVersions.ckeditor5 %>",
Expand All @@ -49,26 +46,10 @@
"@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",
"ckeditor5": ">=<%= packageVersions.ckeditor5 %>",
"eslint": "^7.32.0",
"eslint-config-ckeditor5": ">=<%= packageVersions.eslintConfigCkeditor5 %>",
"http-server": "^14.1.0",
Expand All @@ -79,6 +60,9 @@
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
},
"peerDependencies": {
"ckeditor5": ">=<%= packageVersions.ckeditor5 %>"
},
"scripts": {
"ts:build": "tsc -p ./tsconfig.release.json",
"ts:clear": "npx rimraf \"src/**/*.@(js|d.ts)\"",
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
@@ -1,25 +1,25 @@
{
"compilerOptions": {
"lib": [
"DOM"
],
"noImplicitAny": true,
"noImplicitOverride": true,
"strict": true,
"module": "es6",
"target": "es2020",
"sourceMap": true,
"allowJs": true,
"moduleResolution": "node",
"typeRoots": [
"typings",
"node_modules/@types"
]
},
"include": [
"./sample",
"./src",
"./tests",
"./typings"
],
"compilerOptions": {
"lib": [
"DOM"
],
"noImplicitAny": true,
"noImplicitOverride": true,
"strict": true,
"module": "es6",
"target": "es2020",
"sourceMap": true,
"allowJs": true,
"moduleResolution": "node",
"typeRoots": [
"typings",
"node_modules/@types"
]
},
"include": [
"./sample",
"./src",
"./tests",
"./typings"
]
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"declaration": true
},
"exclude": [
"./tests/",
"./sample/"
]
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"declaration": true
},
"exclude": [
"./tests/",
"./sample/"
]
}
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';
}