Skip to content

Commit

Permalink
Better type checking for config prop
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsManta committed Mar 29, 2024
1 parent 84d864f commit 47eca6b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
3 changes: 2 additions & 1 deletion packages/ckeditor5-build-taskworld/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
'ckeditor5-rules/ckeditor-imports': 'off',
'ckeditor5-rules/license-header': 'off',
'ckeditor5-rules/no-cross-package-svg-imports': 'off',
'ckeditor5-rules/no-relative-imports': 'off'
'ckeditor5-rules/no-relative-imports': 'off',
'ckeditor5-rules/require-file-extensions-in-imports': 'off'
}
};
36 changes: 20 additions & 16 deletions packages/ckeditor5-build-taskworld/src/ckeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@

import { ClassicEditor as ClassicEditorBase } from '../../ckeditor5-editor-classic/src/index.js';

import { Autoformat } from '../../ckeditor5-autoformat/src/index.js';
import { BlockQuote } from '../../ckeditor5-block-quote/src/index.js';
import { CodeBlock } from '../../ckeditor5-code-block/src/index.js';
import { Essentials } from '../../ckeditor5-essentials/src/index.js';
import { Heading } from '../../ckeditor5-heading/src/index.js';
import { HorizontalLine } from '../../ckeditor5-horizontal-line/src/index.js';
import { Indent } from '../../ckeditor5-indent/src/index.js';
import { AutoLink, Link } from '../../ckeditor5-link/src/index.js';
import { List } from '../../ckeditor5-list/src/index.js';
import { Paragraph } from '../../ckeditor5-paragraph/src/index.js';
import { RemoveFormat } from '../../ckeditor5-remove-format/src/index.js';
import { Bold, Code, Italic, Strikethrough, Underline } from '../../ckeditor5-basic-styles/src/index.js';
import { Markdown } from '../../ckeditor5-markdown-gfm/src/index.js';
import MarkdownGuide from './markdownguide.js';
import { Mention } from '../../ckeditor5-mention/src/index.js';
import { Image, ImageUpload, ImageStyle, ImageToolbar, AutoImage } from '../../ckeditor5-image/src/index.js';
import { Autoformat } from '../../ckeditor5-autoformat/src/index';
import { BlockQuote } from '../../ckeditor5-block-quote/src/index';
import { CodeBlock } from '../../ckeditor5-code-block/src/index';
import { Essentials } from '../../ckeditor5-essentials/src/index';
import { Heading } from '../../ckeditor5-heading/src/index';
import { HorizontalLine } from '../../ckeditor5-horizontal-line/src/index';
import { Indent } from '../../ckeditor5-indent/src/index';
import { AutoLink, Link, type LinkConfig } from '../../ckeditor5-link/src/index';
import { List } from '../../ckeditor5-list/src/index';
import { Paragraph } from '../../ckeditor5-paragraph/src/index';
import { RemoveFormat } from '../../ckeditor5-remove-format/src/index';
import { Bold, Code, Italic, Strikethrough, Underline } from '../../ckeditor5-basic-styles/src/index';
import { Markdown } from '../../ckeditor5-markdown-gfm/src/index';
import { MarkdownGuide, type MarkdownGuideURL } from './markdownguide';
import { Mention, type MentionConfig } from '../../ckeditor5-mention/src/index';
import { Image, ImageUpload, ImageStyle, ImageToolbar, AutoImage, type ImageConfig } from '../../ckeditor5-image/src/index';

// Ensure augmentation.ts from plugins are explicitly imported in d.ts files
// so the type `EditorConfig` is properly aligned with the plugins
export { LinkConfig, MarkdownGuideURL, MentionConfig, ImageConfig };

export default class ClassicEditor extends ClassicEditorBase { }

Expand Down
9 changes: 2 additions & 7 deletions packages/ckeditor5-build-taskworld/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { createElement, type ReactElement } from 'react';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import EditorEngine from './ckeditor.js';
import { type EditorConfig } from 'ckeditor5/src/core.js';

/**
* @see https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/react.html#component-properties
*/
export default function TaskworldCKEditor( props: {
data?: string;
placeholder?: string;
config: object;
config: EditorConfig;
disabled?: boolean;
onReady: ( editor: EditorEngine ) => void;
onChange?: ( event: any, editor: EditorEngine ) => void;
Expand All @@ -22,12 +23,6 @@ export default function TaskworldCKEditor( props: {

export { default as EditorEngine } from './ckeditor.js';

declare module '@ckeditor/ckeditor5-core' {
interface EditorConfig {
markdownGuideURL?: string;
}
}

// Allow injecting translation object
// See https://ckeditor.com/docs/ckeditor5/latest/framework/deep-dive/ui/localization.html#:~:text=extending%20the%20global-,window.CKEDITOR_TRANSLATIONS%20object,-.%0AThis%20can
declare global {
Expand Down
10 changes: 9 additions & 1 deletion packages/ckeditor5-build-taskworld/src/markdownguide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@ import { Plugin } from '../../ckeditor5-core/src/index.js';
import { LinkView } from '@ckeditor/ckeditor5-ui';
import icon from './markdown.svg';

export type MarkdownGuideURL = string;

declare module '@ckeditor/ckeditor5-core' {
interface EditorConfig {
markdownGuideURL?: MarkdownGuideURL;
}
}

/**
* @extends module:core/plugin~Plugin
*/
export default class MarkdownGuide extends Plugin {
export class MarkdownGuide extends Plugin {
/**
* @inheritDoc
*/
Expand Down

0 comments on commit 47eca6b

Please sign in to comment.