mirror of
https://github.com/codex-team/editor.js
synced 2024-05-15 12:57:38 +02:00
Fix issue with pasting html to non-initial tools (#639)
* Fix issue with pasting html to not initial tools * Bump version and add changelog
This commit is contained in:
parent
b2d85d3ae6
commit
afa158d5db
12
dist/editor.js
vendored
12
dist/editor.js
vendored
File diff suppressed because one or more lines are too long
52
dist/editor.licenses.txt
vendored
52
dist/editor.licenses.txt
vendored
|
@ -76,32 +76,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
regenerator-runtime
|
||||
MIT
|
||||
|
||||
@babel/register
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
codex-notifier
|
||||
MIT
|
||||
MIT License
|
||||
|
@ -402,3 +376,29 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
@babel/register
|
||||
MIT
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-2018 Sebastian McKenzie <sebmck@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Changelog
|
||||
|
||||
### 2.11.7
|
||||
|
||||
- `Fix` *Paste* — Fix pasting into non-initial Blocks
|
||||
|
||||
### 2.11.6
|
||||
|
||||
- `Fix` *Paste* — Polyfill for Microsoft Edge
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
shortcut: 'CMD+SHIFT+C'
|
||||
},
|
||||
|
||||
link: LinkTool,
|
||||
linkTool: LinkTool,
|
||||
|
||||
embed: Embed,
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@editorjs/editorjs",
|
||||
"version": "2.11.6",
|
||||
"version": "2.11.7",
|
||||
"description": "Editor.js — Native JS, based on API and Open Source",
|
||||
"main": "dist/editor.js",
|
||||
"types": "./types/index.d.ts",
|
||||
|
|
|
@ -345,11 +345,9 @@ export default class Paste extends Module {
|
|||
private handlePasteEvent = async (event: ClipboardEvent): Promise<void> => {
|
||||
const {BlockManager, Tools, Toolbar} = this.Editor;
|
||||
|
||||
const isInitialTool = BlockManager.currentBlock && Tools.isInitial(BlockManager.currentBlock.tool);
|
||||
|
||||
/** If target is native input or is not Block, use browser behaviour */
|
||||
if (
|
||||
!isInitialTool
|
||||
!BlockManager.currentBlock || this.isNativeBehaviour(event.target) && !event.clipboardData.types.includes('Files')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -577,11 +575,12 @@ export default class Paste extends Module {
|
|||
* @param {PasteData} dataToInsert
|
||||
*/
|
||||
private async processInlinePaste(dataToInsert: PasteData): Promise<void> {
|
||||
const initialTool = this.config.initialBlock,
|
||||
{BlockManager, Caret, Sanitizer, Tools} = this.Editor,
|
||||
{content, tool} = dataToInsert;
|
||||
const {BlockManager, Caret, Sanitizer, Tools} = this.Editor;
|
||||
const {content, tool} = dataToInsert;
|
||||
|
||||
if (tool === initialTool && content.textContent.length < Paste.PATTERN_PROCESSING_MAX_LENGTH) {
|
||||
const currentBlockIsInitial = Tools.isInitial(BlockManager.currentBlock.tool);
|
||||
|
||||
if (currentBlockIsInitial && content.textContent.length < Paste.PATTERN_PROCESSING_MAX_LENGTH) {
|
||||
const blockData = await this.processPattern(content.textContent);
|
||||
|
||||
if (blockData) {
|
||||
|
|
25
types/configs/paste-config.d.ts
vendored
25
types/configs/paste-config.d.ts
vendored
|
@ -10,14 +10,6 @@ export interface PasteConfig {
|
|||
*/
|
||||
tags?: string[];
|
||||
|
||||
/**
|
||||
* Handler to process pasted HTML tag
|
||||
*
|
||||
* @param {HTMLElement} element
|
||||
* @return {BlockToolData}
|
||||
*/
|
||||
handler?: (element: HTMLElement) => BlockToolData;
|
||||
|
||||
/**
|
||||
* Object of string patterns Tool can substitute.
|
||||
* Key is your internal key and value is RegExp
|
||||
|
@ -26,25 +18,8 @@ export interface PasteConfig {
|
|||
*/
|
||||
patterns?: {[key: string]: RegExp};
|
||||
|
||||
/**
|
||||
* Handler to process pasted patterns
|
||||
*
|
||||
* @param {string} text
|
||||
* @param {string} key
|
||||
* @return {BlockToolData}
|
||||
*/
|
||||
patternHandler?: (text: string, key: string) => BlockToolData;
|
||||
|
||||
/**
|
||||
* Object with arrays of extensions and MIME types Tool can substitute
|
||||
*/
|
||||
files?: {extensions?: string[], mimeTypes?: string[]};
|
||||
|
||||
/**
|
||||
* Handler to process pasted files
|
||||
*
|
||||
* @param {File} file
|
||||
* @return {BlockToolData}
|
||||
*/
|
||||
fileHandler?: (file: File) => BlockToolData;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue