Skip to content

Commit

Permalink
theme toolbar's handlers overwritten fix
Browse files Browse the repository at this point in the history
  • Loading branch information
david ruty committed Apr 17, 2024
1 parent fb3882c commit 0768009
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions packages/quill/src/core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -784,50 +784,55 @@ function expandConfig(
if (!container) {
throw new Error('Invalid Quill container');
}

Check failure on line 787 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (chromium)

Delete `··`

Check failure on line 787 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (webkit)

Delete `··`

Check failure on line 787 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (firefox)

Delete `··`
const userOptions={...options};

Check failure on line 788 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (chromium)

Replace `={...options` with `·=·{·...options·`

Check failure on line 788 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (webkit)

Replace `={...options` with `·=·{·...options·`

Check failure on line 788 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (firefox)

Replace `={...options` with `·=·{·...options·`

const shouldUseDefaultTheme =
!options.theme || options.theme === Quill.DEFAULTS.theme;
!userOptions.theme || userOptions.theme === Quill.DEFAULTS.theme;
const theme = shouldUseDefaultTheme
? Theme
: Quill.import(`themes/${options.theme}`);
: Quill.import(`themes/${userOptions.theme}`);
if (!theme) {
throw new Error(`Invalid theme ${options.theme}. Did you register it?`);
throw new Error(`Invalid theme ${userOptions.theme}. Did you register it?`);
}

const { modules: quillModuleDefaults, ...quillDefaults } = Quill.DEFAULTS;
const { modules: themeModuleDefaults, ...themeDefaults } = theme.DEFAULTS;

const modules: ExpandedQuillOptions['modules'] = merge(
{},
expandModuleConfig(quillModuleDefaults),
expandModuleConfig(themeModuleDefaults),
expandModuleConfig(options.modules),
);
// Special case toolbar shorthand

Check failure on line 803 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (chromium)

Delete `··`

Check failure on line 803 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (webkit)

Delete `··`

Check failure on line 803 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (firefox)

Delete `··`
if (
modules != null &&
modules.toolbar &&
modules.toolbar.constructor !== Object
userOptions.modules != null &&
userOptions.modules.toolbar &&
userOptions.modules.toolbar.constructor !== Object
) {
modules.toolbar = {
container: modules.toolbar,
userOptions.modules.toolbar = {
container: userOptions.modules.toolbar

Check failure on line 810 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (chromium)

Insert `,`

Check failure on line 810 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (webkit)

Insert `,`

Check failure on line 810 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (firefox)

Insert `,`
};
}

const modules: ExpandedQuillOptions['modules'] = merge(
{},
expandModuleConfig(quillModuleDefaults),
expandModuleConfig(themeModuleDefaults),
expandModuleConfig(userOptions.modules),
);

Check failure on line 819 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (chromium)

Delete `⏎`

Check failure on line 819 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (webkit)

Delete `⏎`

Check failure on line 819 in packages/quill/src/core/quill.ts

View workflow job for this annotation

GitHub Actions / test / Unit Tests (firefox)

Delete `⏎`


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

let registry = options.registry;
let registry = userOptions.registry;
if (registry) {
if (options.formats) {
if (userOptions.formats) {
debug.warn('Ignoring "formats" option because "registry" is specified');
}
} else {
registry = options.formats
? createRegistryWithFormats(options.formats, config.registry, debug)
registry = userOptions.formats
? createRegistryWithFormats(userOptions.formats, config.registry, debug)
: config.registry;
}

Expand Down

0 comments on commit 0768009

Please sign in to comment.