Skip to content

Commit

Permalink
Merge branch 'master' into ck/13009-rewrite-easy-image-into-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Feb 13, 2023
2 parents da1b306 + 0c5cbc9 commit d67b63c
Show file tree
Hide file tree
Showing 334 changed files with 12,758 additions and 3,616 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,25 @@ packages/ckeditor5-editor-inline/src/**/*.js
packages/ckeditor5-engine/src/**/*.js
packages/ckeditor5-enter/src/**/*.js
packages/ckeditor5-essentials/src/**/*.js
packages/ckeditor5-find-and-replace/src/**/*.js
packages/ckeditor5-font/src/**/*.js
packages/ckeditor5-heading/src/**/*.js
packages/ckeditor5-highlight/src/**/*.js
packages/ckeditor5-horizontal-line/src/**/*.js
packages/ckeditor5-html-embed/src/**/*.js
packages/ckeditor5-image/src/**/*.js
packages/ckeditor5-indent/src/**/*.js
packages/ckeditor5-language/src/**/*.js
packages/ckeditor5-link/src/**/*.js
packages/ckeditor5-list/src/**/*.js
packages/ckeditor5-markdown-gfm/src/**/*.js
packages/ckeditor5-mention/src/**/*.js
packages/ckeditor5-minimap/src/**/*.js
packages/ckeditor5-page-break/src/**/*.js
packages/ckeditor5-paragraph/src/**/*.js
packages/ckeditor5-paste-from-office/src/**/*.js
packages/ckeditor5-remove-format/src/**/*.js
packages/ckeditor5-restricted-editing/src/**/*.js
packages/ckeditor5-select-all/src/**/*.js
packages/ckeditor5-typing/src/**/*.js
packages/ckeditor5-ui/src/**/*.js
Expand Down
1 change: 1 addition & 0 deletions docs/features/read-only.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Some use cases might require hiding the editor toolbar when entering the read-on
```js
ClassicEditor
.create( document.querySelector( '#editor' ), {
// The editor's configuration.
// ...
} )
.then( editor => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
category: abbreviation-plugin
menu-title: Creating a toolbar button
menu-title: Defining a model and a view
order: 24
modified_at: 2022-07-15
---

# Creating a toolbar button
# Defining a model and a view

This guide will show you how to create a simple abbreviation plugin for CKEditor 5.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,15 @@ export default class AbbreviationUI extends Plugin {
// ...

editor.ui.componentFactory.add( 'abbreviation', () => {
this._showUI();
// Button initialization.
// ...

// Show the UI on button click.
this.listenTo( button, 'execute', () => {
this._showUI();
} );

return button;
} );
}

Expand Down
6 changes: 5 additions & 1 deletion docs/installation/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ You can do that using the {@link module:core/editor/editorconfig~EditorConfig#ex

```js
function MyPlugin( editor ) {
// Plugin code.
// ...
}
```
Expand All @@ -125,10 +126,12 @@ or
```js
class MyPlugin {
constructor( editor ) {
// Constructor code.
// ...
}

init() {
// Initializations code.
// ...
}
}
Expand All @@ -141,6 +144,7 @@ import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

function MyUploadAdapterPlugin( editor ) {
editor.plugins.get( 'FileRepository' ).createUploadAdapter = function( loader ) {
// Custom upload adapter.
// ...
};
}
Expand All @@ -149,7 +153,7 @@ function MyUploadAdapterPlugin( editor ) {
ClassicEditor
.create( document.querySelector( '#editor' ), {
extraPlugins: [ MyUploadAdapterPlugin ],

// More of the editor's configuration.
// ...
} )
.catch( error => {
Expand Down
8 changes: 7 additions & 1 deletion packages/ckeditor5-alignment/src/alignmentcommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { first } from 'ckeditor5/src/utils';
import type { Element, Writer } from 'ckeditor5/src/engine';

import { isDefault } from './utils';
import type { SupportedOption } from './alignmentediting';
import type { SupportedOption } from './alignmentconfig';

const ALIGNMENT = 'alignment';

Expand Down Expand Up @@ -109,3 +109,9 @@ function setAlignmentOnSelection( blocks: Array<Element>, writer: Writer, alignm
writer.setAttribute( ALIGNMENT, alignment, block );
}
}

declare module '@ckeditor/ckeditor5-core' {
interface CommandsMap {
alignment: AlignmentCommand;
}
}
89 changes: 89 additions & 0 deletions packages/ckeditor5-alignment/src/alignmentconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/**
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/**
* @module alignment/alignmentconfig
*/

/**
* The configuration of the {@link module:alignment/alignment~Alignment alignment feature}.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* alignment: {
* options: [ 'left', 'right' ]
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
*/
export type AlignmentConfig = {
options?: Array<SupportedOption | AlignmentFormat>;
};

/**
* Available alignment options.
*
* The available options are: `'left'`, `'right'`, `'center'` and `'justify'`. Other values are ignored.
*
* **Note:** It is recommended to always use `'left'` or `'right'` as these are default values which the user should
* normally be able to choose depending on the
* {@glink features/ui-language#setting-the-language-of-the-content language of the editor content}.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* alignment: {
* options: [ 'left', 'right' ]
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* By default the alignment is set inline using the `text-align` CSS property. To further customize the alignment,
* you can provide names of classes for each alignment option using the `className` property.
*
* **Note:** Once you define the `className` property for one option, you need to specify it for all other options.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* alignment: {
* options: [
* { name: 'left', className: 'my-align-left' },
* { name: 'right', className: 'my-align-right' }
* ]
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* See the demo of {@glink features/text-alignment#configuring-alignment-options custom alignment options}.
*/
export type AlignmentFormat = {
name: SupportedOption;
className?: string;
};

export type SupportedOption = 'left' | 'right' | 'center' | 'justify';

declare module '@ckeditor/ckeditor5-core' {

interface EditorConfig {

/**
* The configuration of the {@link module:alignment/alignment~Alignment alignment feature}.
*
* Read more in {@link module:alignment/alignmentconfig~AlignmentConfig}.
*/
alignment?: AlignmentConfig;
}
}
83 changes: 1 addition & 82 deletions packages/ckeditor5-alignment/src/alignmentediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type { AttributeDescriptor } from 'ckeditor5/src/engine';

import AlignmentCommand from './alignmentcommand';
import { isDefault, isSupported, normalizeAlignmentOptions, supportedOptions } from './utils';
import type { AlignmentFormat, SupportedOption } from './alignmentconfig';

/**
* The alignment editing feature. It introduces the {@link module:alignment/alignmentcommand~AlignmentCommand command} and adds
Expand Down Expand Up @@ -179,90 +180,8 @@ function buildClassDefinition( options: Array<AlignmentFormat> ) {
return definition;
}

/**
* The configuration of the {@link module:alignment/alignment~Alignment alignment feature}.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* alignment: {
* options: [ 'left', 'right' ]
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* See {@link module:core/editor/editorconfig~EditorConfig all editor configuration options}.
*/
export type AlignmentConfig = {
options?: Array<SupportedOption | AlignmentFormat>;
};

/**
* Available alignment options.
*
* The available options are: `'left'`, `'right'`, `'center'` and `'justify'`. Other values are ignored.
*
* **Note:** It is recommended to always use `'left'` or `'right'` as these are default values which the user should
* normally be able to choose depending on the
* {@glink features/ui-language#setting-the-language-of-the-content language of the editor content}.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* alignment: {
* options: [ 'left', 'right' ]
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* By default the alignment is set inline using the `text-align` CSS property. To further customize the alignment,
* you can provide names of classes for each alignment option using the `className` property.
*
* **Note:** Once you define the `className` property for one option, you need to specify it for all other options.
*
* ```ts
* ClassicEditor
* .create( editorElement, {
* alignment: {
* options: [
* { name: 'left', className: 'my-align-left' },
* { name: 'right', className: 'my-align-right' }
* ]
* }
* } )
* .then( ... )
* .catch( ... );
* ```
*
* See the demo of {@glink features/text-alignment#configuring-alignment-options custom alignment options}.
*/
export type AlignmentFormat = {
name: SupportedOption;
className?: string;
};

export type SupportedOption = 'left' | 'right' | 'center' | 'justify';

declare module '@ckeditor/ckeditor5-core' {
interface CommandsMap {
alignment: AlignmentCommand;
}

interface PluginsMap {
[ AlignmentEditing.pluginName ]: AlignmentEditing;
}

interface EditorConfig {

/**
* The configuration of the {@link module:alignment/alignment~Alignment alignment feature}.
*
* Read more in {@link module:alignment/alignment~AlignmentConfig}.
*/
alignment?: AlignmentConfig;
}
}
9 changes: 5 additions & 4 deletions packages/ckeditor5-alignment/src/alignmentui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { Plugin, icons } from 'ckeditor5/src/core';
import { ButtonView, createDropdown, addToolbarToDropdown } from 'ckeditor5/src/ui';

import { isSupported, normalizeAlignmentOptions } from './utils';
import type { SupportedOption } from './alignmentediting';
import type { SupportedOption } from './alignmentconfig';
import type AlignmentCommand from './alignmentcommand';

const iconsMap = new Map( [
[ 'left', icons.alignLeft ],
Expand All @@ -31,7 +32,7 @@ export default class AlignmentUI extends Plugin {
* Returns the localized option titles provided by the plugin.
*
* The following localized titles corresponding with
* {@link module:alignment/alignment~AlignmentConfig#options} are available:
* {@link module:alignment/alignmentconfig~AlignmentConfig#options} are available:
*
* * `'left'`,
* * `'right'`,
Expand Down Expand Up @@ -100,7 +101,7 @@ export default class AlignmentUI extends Plugin {

// The default icon depends on the direction of the content.
const defaultIcon = locale.contentLanguageDirection === 'rtl' ? iconsMap.get( 'right' ) : iconsMap.get( 'left' );
const command = editor.commands.get( 'alignment' )!;
const command: AlignmentCommand = editor.commands.get( 'alignment' )!;

// Change icon to reflect current selection's alignment.
dropdownView.buttonView.bind( 'icon' ).to( command, 'value', value => iconsMap.get( value ) || defaultIcon );
Expand All @@ -127,7 +128,7 @@ export default class AlignmentUI extends Plugin {
const editor = this.editor;

editor.ui.componentFactory.add( `alignment:${ option }`, locale => {
const command = editor.commands.get( 'alignment' )!;
const command: AlignmentCommand = editor.commands.get( 'alignment' )!;
const buttonView = new ButtonView( locale );

buttonView.set( {
Expand Down
2 changes: 1 addition & 1 deletion packages/ckeditor5-alignment/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { CKEditorError, logWarning, type Locale } from 'ckeditor5/src/utils';
import type { AlignmentFormat, SupportedOption } from './alignmentediting';
import type { AlignmentFormat, SupportedOption } from './alignmentconfig';

/**
* @module alignment/utils
Expand Down
6 changes: 5 additions & 1 deletion packages/ckeditor5-autoformat/src/blockautoformatediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { first } from 'ckeditor5/src/utils';

import type Autoformat from './autoformat';

import type { Delete } from 'ckeditor5/src/typing';

/**
* The block autoformatting engine. It allows to format various block patterns. For example,
* it can be configured to turn a paragraph starting with `*` and followed by a space into a list item.
Expand Down Expand Up @@ -170,7 +172,9 @@ export default function blockAutoformatEditing(
range.detach();

editor.model.enqueueChange( () => {
editor.plugins.get( 'Delete' ).requestUndoOnBackspace();
const deletePlugin: Delete = editor.plugins.get( 'Delete' );

deletePlugin.requestUndoOnBackspace();
} );
} );
} );
Expand Down
6 changes: 4 additions & 2 deletions packages/ckeditor5-autoformat/src/inlineautoformatediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type {
Range,
Writer
} from 'ckeditor5/src/engine';
import type { LastTextLineData } from 'ckeditor5/src/typing';
import type { Delete, LastTextLineData } from 'ckeditor5/src/typing';

import type Autoformat from './autoformat';

Expand Down Expand Up @@ -200,7 +200,9 @@ export default function inlineAutoformatEditing(
}

model.enqueueChange( () => {
editor.plugins.get( 'Delete' ).requestUndoOnBackspace();
const deletePlugin: Delete = editor.plugins.get( 'Delete' );

deletePlugin.requestUndoOnBackspace();
} );
} );
} );
Expand Down
Loading

0 comments on commit d67b63c

Please sign in to comment.