Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into catchup
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgibson committed Mar 20, 2024
2 parents 8a3d1e7 + 83402d2 commit 0588772
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/quill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 14 additions & 3 deletions packages/quill/src/core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -747,6 +748,12 @@ function expandModuleConfig(config: Record<string, unknown> | undefined) {
);
}

function omitUndefinedValuesFromOptions(obj: Options) {
return Object.fromEntries(
Object.entries(obj).filter((entry) => entry[1] !== undefined),
);
}

function expandConfig(
containerOrSelector: HTMLElement | string,
options: Options,
Expand Down Expand Up @@ -785,7 +792,11 @@ function expandConfig(
};
}

const config = { ...quillDefaults, ...themeDefaults, ...options };
const config = {
...quillDefaults,
...omitUndefinedValuesFromOptions(themeDefaults),
...omitUndefinedValuesFromOptions(options),
};

let registry = options.registry;
if (registry) {
Expand Down
9 changes: 0 additions & 9 deletions packages/quill/test/e2e/full.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<p>The Whale</p>');
Expand Down
16 changes: 16 additions & 0 deletions packages/quill/test/unit/core/quill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`, {
Expand All @@ -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'],
Expand Down

0 comments on commit 0588772

Please sign in to comment.