From c092cd3c1bb29ec0a2cb6b4a339ad351f19734da Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Wed, 11 Nov 2020 21:22:49 -0800 Subject: [PATCH 1/7] Merge pull request #3223 from luin/ignore-nested-quill-mutations Ignore mutations happens in nested Quill instance (cherry picked from commit 8ce3ee33f757c29ab6d07998a9f1a5d52c9eb4b2) --- blots/scroll.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/blots/scroll.js b/blots/scroll.js index dfaa8b278b..4d6ff5cb43 100644 --- a/blots/scroll.js +++ b/blots/scroll.js @@ -164,6 +164,10 @@ class Scroll extends ScrollBlot { if (!Array.isArray(mutations)) { mutations = this.observer.takeRecords(); } + mutations = mutations.filter(({ target }) => { + const blot = this.find(target, true); + return blot && blot.scroll === this; + }); if (mutations.length > 0) { this.emitter.emit(Emitter.events.SCROLL_BEFORE_UPDATE, source, mutations); } From e61d5c1147c3d158b9873d35b93bac7ae3b496ac Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Thu, 21 Jan 2021 17:11:40 -0800 Subject: [PATCH 2/7] Merge pull request #3272 from luin/firefox-bullet Header/paragraph doesn't reset list numbering in Firefox (cherry picked from commit eeb976e5e7e955e75940653375f7dffea7e478ea) --- assets/core.styl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/assets/core.styl b/assets/core.styl index e562f97e92..98f6c7df18 100644 --- a/assets/core.styl +++ b/assets/core.styl @@ -57,7 +57,10 @@ resets(arr) margin: 0 padding: 0 p, h1, h2, h3, h4, h5, h6 - counter-reset: resets(0..MAX_INDENT) + @supports (counter-set: none) + counter-set: resets(0..MAX_INDENT) + @supports not (counter-set: none) + counter-reset: resets(0..MAX_INDENT) table border-collapse: collapse td From 2eaff9d6aa428c306a775758dbe9ce53481afc2e Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Thu, 21 Jan 2021 17:21:11 -0800 Subject: [PATCH 3/7] allow list completion on lists and headers (cherry picked from commit a6911aa4b85b29749e5f9788293e11c5cec31d3f) --- modules/keyboard.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/keyboard.js b/modules/keyboard.js index c94b13a90e..0d573b76f5 100644 --- a/modules/keyboard.js +++ b/modules/keyboard.js @@ -569,10 +569,8 @@ Keyboard.DEFAULTS = { shiftKey: null, collapsed: true, format: { - list: false, 'code-block': false, blockquote: false, - header: false, table: false, }, prefix: /^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/, From 9cab4bbc6a47f8337044b604acc440d6ad6a471b Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Thu, 21 Jan 2021 17:41:53 -0800 Subject: [PATCH 4/7] fix arrow keying past list item - in chrome it take two left arrows to go to prev list item - in firefox ctrl+left does not work (cherry picked from commit 9d16aa5377157286c9db2d769b27ea12f32f3a74) --- assets/core.styl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/core.styl b/assets/core.styl index 98f6c7df18..2627359dee 100644 --- a/assets/core.styl +++ b/assets/core.styl @@ -72,6 +72,10 @@ resets(arr) list-style-type: none padding-left: LIST_STYLE_OUTER_WIDTH position: relative + word-break: break-all + @supports (display: contents) + > .ql-ui + display: contents > .ql-ui:before display: inline-block margin-left: -1*LIST_STYLE_OUTER_WIDTH From 6390fb4bb5f8495d456f0a2bc7de0e514be70b28 Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Sat, 23 Jan 2021 19:04:02 -0800 Subject: [PATCH 5/7] fix breaking list items Without this a string with no space on a line will cause the break to occur after the bullet but with it a string with spaces may not break at the space. The latter is much more common and also the choice Paper makes (cherry picked from commit 232b6f46e977bf3c4b13c4398fbd0c0b99c6dad4) --- assets/core.styl | 1 - 1 file changed, 1 deletion(-) diff --git a/assets/core.styl b/assets/core.styl index 2627359dee..fb19d865f0 100644 --- a/assets/core.styl +++ b/assets/core.styl @@ -72,7 +72,6 @@ resets(arr) list-style-type: none padding-left: LIST_STYLE_OUTER_WIDTH position: relative - word-break: break-all @supports (display: contents) > .ql-ui display: contents From 52ff2590a9b37179bb888a5e1c2b12d9ebc7f827 Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Tue, 2 Feb 2021 17:16:26 -0800 Subject: [PATCH 6/7] Merge branch 'fix-cut-format' --- modules/clipboard.js | 3 ++- modules/keyboard.js | 32 ++++++++++++++++++-------------- test/unit/modules/clipboard.js | 27 +++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 15 deletions(-) diff --git a/modules/clipboard.js b/modules/clipboard.js index d10349a4bd..a7b2f9da26 100644 --- a/modules/clipboard.js +++ b/modules/clipboard.js @@ -19,6 +19,7 @@ import { ColorStyle } from '../formats/color'; import { DirectionAttribute, DirectionStyle } from '../formats/direction'; import { FontStyle } from '../formats/font'; import { SizeStyle } from '../formats/size'; +import { deleteRange } from './keyboard'; const debug = logger('quill:clipboard'); @@ -162,7 +163,7 @@ class Clipboard extends Module { e.clipboardData.setData('text/html', html); if (isCut) { this.raiseCallback('onCut', e); - this.quill.deleteText(range, Quill.sources.USER); + deleteRange({ range, quill: this.quill }); } } diff --git a/modules/keyboard.js b/modules/keyboard.js index 0d573b76f5..1de3fdd98e 100644 --- a/modules/keyboard.js +++ b/modules/keyboard.js @@ -328,19 +328,8 @@ class Keyboard extends Module { } handleDeleteRange(range, context) { - const lines = this.quill.getLines(range); - let formats = {}; - if (lines.length > 1) { - const firstFormats = lines[0].formats(); - const lastFormats = lines[lines.length - 1].formats(); - formats = AttributeMap.diff(lastFormats, firstFormats) || {}; - } - this.quill.deleteText(range, Quill.sources.USER); - if (Object.keys(formats).length > 0) { - this.raiseOnKeydownCallback(context.event); - this.quill.formatLine(range.index, 1, formats, Quill.sources.USER); - } - this.quill.setSelection(range.index, Quill.sources.SILENT); + this.raiseOnKeydownCallback(context.event); + deleteRange({ range, quill: this.quill }); this.quill.focus(); } @@ -796,6 +785,21 @@ function normalize(binding) { return binding; } +function deleteRange({ quill, range }) { + const lines = quill.getLines(range); + let formats = {}; + if (lines.length > 1) { + const firstFormats = lines[0].formats(); + const lastFormats = lines[lines.length - 1].formats(); + formats = AttributeMap.diff(lastFormats, firstFormats) || {}; + } + quill.deleteText(range, Quill.sources.USER); + if (Object.keys(formats).length > 0) { + quill.formatLine(range.index, 1, formats, Quill.sources.USER); + } + quill.setSelection(range.index, Quill.sources.SILENT); +} + function tableSide(table, row, cell, offset) { if (row.prev == null && row.next == null) { if (cell.prev == null && cell.next == null) { @@ -812,4 +816,4 @@ function tableSide(table, row, cell, offset) { return null; } -export { Keyboard as default, SHORTKEY, normalize }; +export { Keyboard as default, SHORTKEY, normalize, deleteRange }; diff --git a/test/unit/modules/clipboard.js b/test/unit/modules/clipboard.js index 8c1583d417..a2c338d46c 100644 --- a/test/unit/modules/clipboard.js +++ b/test/unit/modules/clipboard.js @@ -58,6 +58,33 @@ describe('Clipboard', function() { }); }); + describe('cut', () => { + beforeEach(function() { + this.clipboardData = {}; + this.clipboardEvent = { + clipboardData: { + setData: (type, data) => { + this.clipboardData[type] = data; + }, + }, + preventDefault: () => {}, + }; + }); + + it('keeps formats of first line', function(done) { + this.quill.clipboard.onCaptureCopy(this.clipboardEvent, true); + setTimeout(() => { + expect(this.quill.root).toEqualHTML('

0178

'); + expect(this.quill.getSelection()).toEqual(new Range(2)); + expect(this.clipboardData['text/plain']).toEqual('23\n56'); + expect(this.clipboardData['text/html']).toEqual( + '

23

56

', + ); + done(); + }, 2); + }); + }); + it('dangerouslyPasteHTML(html)', function() { this.quill.clipboard.dangerouslyPasteHTML('abcd'); expect(this.quill.root).toEqualHTML( From 6428be828181c018cbe616edaba6fcc4cece7ffc Mon Sep 17 00:00:00 2001 From: Jason Chen Date: Sun, 21 Feb 2021 12:46:47 -0800 Subject: [PATCH 7/7] Merge pull request #3293 from quilljs/firefox-checkbox Fix checkbox not checkable on Firefox (cherry picked from commit 1f0530a01108c533fe2af07587001f530921983a) --- assets/core.styl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/core.styl b/assets/core.styl index fb19d865f0..d2781ab0c7 100644 --- a/assets/core.styl +++ b/assets/core.styl @@ -72,9 +72,7 @@ resets(arr) list-style-type: none padding-left: LIST_STYLE_OUTER_WIDTH position: relative - @supports (display: contents) - > .ql-ui - display: contents + > .ql-ui:before display: inline-block margin-left: -1*LIST_STYLE_OUTER_WIDTH @@ -83,6 +81,12 @@ resets(arr) white-space: nowrap width: LIST_STYLE_WIDTH + @supports (display: contents) + li[data-list=bullet], + li[data-list=ordered] + > .ql-ui + display: contents + li[data-list=checked], li[data-list=unchecked] > .ql-ui