Skip to content

Commit

Permalink
Fix issue with pasting html to non-initial tools (codex-team#639)
Browse files Browse the repository at this point in the history
* Fix issue with pasting html to not initial tools

* Bump version and add changelog
  • Loading branch information
gohabereg authored Mar 8, 2019
1 parent b2d85d3 commit afa158d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 66 deletions.
12 changes: 6 additions & 6 deletions dist/editor.js

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions dist/editor.licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
shortcut: 'CMD+SHIFT+C'
},

link: LinkTool,
linkTool: LinkTool,

embed: Embed,

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
13 changes: 6 additions & 7 deletions src/components/modules/paste.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;

const currentBlockIsInitial = Tools.isInitial(BlockManager.currentBlock.tool);

if (tool === initialTool && content.textContent.length < Paste.PATTERN_PROCESSING_MAX_LENGTH) {
if (currentBlockIsInitial && content.textContent.length < Paste.PATTERN_PROCESSING_MAX_LENGTH) {
const blockData = await this.processPattern(content.textContent);

if (blockData) {
Expand Down
25 changes: 0 additions & 25 deletions types/configs/paste-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}

0 comments on commit afa158d

Please sign in to comment.