deps(TypeScript) - upgrade to v5, upgrade ts-loader, fix types error, fix pasteConfig getter wrapper (#2322)
* deps: upgrade typescript to v5, upgrade ts-loader to support newest TS
* Fix (??) type of `pasteConfig`
TypeScript 4.9 found something is wrong with this code, but it's unclear (to me) which line is wrong. This PR is a guess, do with it what you will.
In paste.ts there's a check to see if `pasteConfig === false`:
https://github.com/codex-team/editor.js/blob/next/src/components/modules/paste.ts#L287
However, this getter never returns false because if the LHS of the `||` is `false`, `{ }` is returned instead.
It seems like this meant to be `??` instead so that if `this.constructable[InternalBlockToolSettings.PasteConfig]` was `undefined` (missing), then `{}` would be returned instead. But maybe you meant `false` here - I don't know.
* feat: create alias for PasteConfig, fix lint
* fix: problems with types
* test: add case for disabling preventing default behavior of paste event handler, add cases for pasteConfig getter in BlockTool wrapper
* chore: upgrade CHANGELOG.md
* fix: interface naming convention
* chore: apply CHANGELOG.md suggestion
* refactor: create custom Editor instance inside test case
* fix: remove editor instance destroy after PR feedback
---------
Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
2023-04-02 17:52:42 +02:00
|
|
|
import { SanitizerConfig } from './sanitizer-config';
|
2022-11-21 21:28:53 +01:00
|
|
|
|
2018-11-23 17:11:50 +01:00
|
|
|
/**
|
|
|
|
* Tool onPaste configuration object
|
|
|
|
*/
|
deps(TypeScript) - upgrade to v5, upgrade ts-loader, fix types error, fix pasteConfig getter wrapper (#2322)
* deps: upgrade typescript to v5, upgrade ts-loader to support newest TS
* Fix (??) type of `pasteConfig`
TypeScript 4.9 found something is wrong with this code, but it's unclear (to me) which line is wrong. This PR is a guess, do with it what you will.
In paste.ts there's a check to see if `pasteConfig === false`:
https://github.com/codex-team/editor.js/blob/next/src/components/modules/paste.ts#L287
However, this getter never returns false because if the LHS of the `||` is `false`, `{ }` is returned instead.
It seems like this meant to be `??` instead so that if `this.constructable[InternalBlockToolSettings.PasteConfig]` was `undefined` (missing), then `{}` would be returned instead. But maybe you meant `false` here - I don't know.
* feat: create alias for PasteConfig, fix lint
* fix: problems with types
* test: add case for disabling preventing default behavior of paste event handler, add cases for pasteConfig getter in BlockTool wrapper
* chore: upgrade CHANGELOG.md
* fix: interface naming convention
* chore: apply CHANGELOG.md suggestion
* refactor: create custom Editor instance inside test case
* fix: remove editor instance destroy after PR feedback
---------
Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
2023-04-02 17:52:42 +02:00
|
|
|
interface PasteConfigSpecified {
|
2018-11-23 17:11:50 +01:00
|
|
|
/**
|
2022-11-21 21:28:53 +01:00
|
|
|
* Array of tags Tool can substitute.
|
|
|
|
*
|
|
|
|
* Could also contain a sanitize-config if you need to save some tag's attribute.
|
|
|
|
* For example:
|
|
|
|
* [
|
|
|
|
* {
|
|
|
|
* img: { src: true },
|
|
|
|
* }
|
|
|
|
* ],
|
2018-11-23 17:11:50 +01:00
|
|
|
* @type string[]
|
|
|
|
*/
|
2022-11-21 21:28:53 +01:00
|
|
|
tags?: (string | SanitizerConfig)[];
|
2018-11-23 17:11:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Object of string patterns Tool can substitute.
|
|
|
|
* Key is your internal key and value is RegExp
|
|
|
|
*
|
deps(TypeScript) - upgrade to v5, upgrade ts-loader, fix types error, fix pasteConfig getter wrapper (#2322)
* deps: upgrade typescript to v5, upgrade ts-loader to support newest TS
* Fix (??) type of `pasteConfig`
TypeScript 4.9 found something is wrong with this code, but it's unclear (to me) which line is wrong. This PR is a guess, do with it what you will.
In paste.ts there's a check to see if `pasteConfig === false`:
https://github.com/codex-team/editor.js/blob/next/src/components/modules/paste.ts#L287
However, this getter never returns false because if the LHS of the `||` is `false`, `{ }` is returned instead.
It seems like this meant to be `??` instead so that if `this.constructable[InternalBlockToolSettings.PasteConfig]` was `undefined` (missing), then `{}` would be returned instead. But maybe you meant `false` here - I don't know.
* feat: create alias for PasteConfig, fix lint
* fix: problems with types
* test: add case for disabling preventing default behavior of paste event handler, add cases for pasteConfig getter in BlockTool wrapper
* chore: upgrade CHANGELOG.md
* fix: interface naming convention
* chore: apply CHANGELOG.md suggestion
* refactor: create custom Editor instance inside test case
* fix: remove editor instance destroy after PR feedback
---------
Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
2023-04-02 17:52:42 +02:00
|
|
|
* @type {{[key: string]: RegExp}}
|
2018-11-23 17:11:50 +01:00
|
|
|
*/
|
|
|
|
patterns?: {[key: string]: RegExp};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object with arrays of extensions and MIME types Tool can substitute
|
|
|
|
*/
|
|
|
|
files?: {extensions?: string[], mimeTypes?: string[]};
|
|
|
|
}
|
deps(TypeScript) - upgrade to v5, upgrade ts-loader, fix types error, fix pasteConfig getter wrapper (#2322)
* deps: upgrade typescript to v5, upgrade ts-loader to support newest TS
* Fix (??) type of `pasteConfig`
TypeScript 4.9 found something is wrong with this code, but it's unclear (to me) which line is wrong. This PR is a guess, do with it what you will.
In paste.ts there's a check to see if `pasteConfig === false`:
https://github.com/codex-team/editor.js/blob/next/src/components/modules/paste.ts#L287
However, this getter never returns false because if the LHS of the `||` is `false`, `{ }` is returned instead.
It seems like this meant to be `??` instead so that if `this.constructable[InternalBlockToolSettings.PasteConfig]` was `undefined` (missing), then `{}` would be returned instead. But maybe you meant `false` here - I don't know.
* feat: create alias for PasteConfig, fix lint
* fix: problems with types
* test: add case for disabling preventing default behavior of paste event handler, add cases for pasteConfig getter in BlockTool wrapper
* chore: upgrade CHANGELOG.md
* fix: interface naming convention
* chore: apply CHANGELOG.md suggestion
* refactor: create custom Editor instance inside test case
* fix: remove editor instance destroy after PR feedback
---------
Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
2023-04-02 17:52:42 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Alias for PasteConfig with false
|
|
|
|
*/
|
|
|
|
export type PasteConfig = PasteConfigSpecified | false;
|