diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fe45169a2..709c47d0b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - Include source maps for Parchment - **Clipboard** Support pasting links copied from iOS share sheets +- Fix config parsing where undefined values were kept # 2.0.0-rc.3 diff --git a/package-lock.json b/package-lock.json index acb31d6882..a235b62280 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12190,8 +12190,9 @@ } }, "node_modules/parchment": { - "version": "3.0.0-alpha.2", - "license": "BSD-3-Clause" + "version": "3.0.0-rc.0", + "resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0-rc.0.tgz", + "integrity": "sha512-JyVx3qaAkFPOCrJpENNYnQkxBYRbo9oPEU2LMJX4g1czXmwtzLDWztFRe90BXrw/LBRLDfZpHcL8TvIGkS1vIA==" }, "node_modules/parent-module": { "version": "1.0.1", @@ -16071,7 +16072,7 @@ "@reedsy/quill-delta": "^5.1.0-reedsy.3.0.0", "eventemitter3": "^5.0.1", "lodash-es": "^4.17.21", - "parchment": "3.0.0-alpha.2", + "parchment": "3.0.0-rc.0", "quill-delta": "^5.1.0" }, "devDependencies": { diff --git a/packages/quill/package.json b/packages/quill/package.json index 11b073862e..d0f4c43dad 100644 --- a/packages/quill/package.json +++ b/packages/quill/package.json @@ -10,7 +10,7 @@ "@reedsy/quill-delta": "^5.1.0-reedsy.3.0.0", "eventemitter3": "^5.0.1", "lodash-es": "^4.17.21", - "parchment": "3.0.0-alpha.2", + "parchment": "3.0.0-rc.0", "quill-delta": "^5.1.0" }, "devDependencies": { diff --git a/packages/quill/src/core/quill.ts b/packages/quill/src/core/quill.ts index a20b7d1151..b20aa4bdfd 100644 --- a/packages/quill/src/core/quill.ts +++ b/packages/quill/src/core/quill.ts @@ -16,9 +16,10 @@ import instances from './instances.js'; import logger from './logger.js'; import type { DebugLevel } from './logger.js'; import Module from './module.js'; -import Selection, { Range } from './selection.js'; +import type Selection from './selection.js'; +import { Range } from './selection.js'; import type { Bounds } from './selection.js'; -import Composition from './composition.js'; +import type Composition from './composition.js'; import Theme from './theme.js'; import type { ThemeConstructor } from './theme.js'; import scrollRectIntoView from './utils/scrollRectIntoView.js'; @@ -747,6 +748,12 @@ function expandModuleConfig(config: Record | undefined) { ); } +function omitUndefinedValuesFromOptions(obj: Options) { + return Object.fromEntries( + Object.entries(obj).filter((entry) => entry[1] !== undefined), + ); +} + function expandConfig( containerOrSelector: HTMLElement | string, options: Options, @@ -785,7 +792,11 @@ function expandConfig( }; } - const config = { ...quillDefaults, ...themeDefaults, ...options }; + const config = { + ...quillDefaults, + ...omitUndefinedValuesFromOptions(themeDefaults), + ...omitUndefinedValuesFromOptions(options), + }; let registry = options.registry; if (registry) { diff --git a/packages/quill/test/e2e/full.spec.ts b/packages/quill/test/e2e/full.spec.ts index f81279ac91..01e2b75a1b 100644 --- a/packages/quill/test/e2e/full.spec.ts +++ b/packages/quill/test/e2e/full.spec.ts @@ -3,15 +3,6 @@ import { getSelectionInTextNode, SHORTKEY } from './utils/index.js'; import { test, CHAPTER, P1, P2 } from './fixtures/index.js'; test('compose an epic', async ({ page, editorPage }) => { - const type = page.type.bind(page); - page.type = async (selector, text, options) => { - options = { - delay: 1, - ...options, - }; - return type(selector, text, options); - }; - await editorPage.open(); await editorPage.root.pressSequentially('The Whale'); expect(await editorPage.root.innerHTML()).toEqual('

The Whale

'); diff --git a/packages/quill/test/unit/core/quill.spec.ts b/packages/quill/test/unit/core/quill.spec.ts index 6e0a4fb93f..3aefc88853 100644 --- a/packages/quill/test/unit/core/quill.spec.ts +++ b/packages/quill/test/unit/core/quill.spec.ts @@ -790,6 +790,13 @@ describe('Quill', () => { expect(config.registry).toBe(globalRegistry); }); + test('registry with undefined values', () => { + const config = expandConfig(`#${testContainerId}`, { + registry: undefined, + }); + expect(config.registry).toBe(globalRegistry); + }); + describe('formats', () => { test('null value allows all formats', () => { const config = expandConfig(`#${testContainerId}`, { @@ -800,6 +807,15 @@ describe('Quill', () => { expect(config.registry.query('bold')).toBeTruthy(); }); + test('undefined value allows all formats', () => { + const config = expandConfig(`#${testContainerId}`, { + formats: undefined, + }); + + expect(config.registry.query('cursor')).toBeTruthy(); + expect(config.registry.query('bold')).toBeTruthy(); + }); + test('always allows core formats', () => { const config = expandConfig(`#${testContainerId}`, { formats: ['bold'],