Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with pasting html to not initial tools #639

Merged
merged 3 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}