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 event source when deleting a link with shortcuts #4200

Merged
merged 1 commit into from
May 13, 2024
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
2 changes: 1 addition & 1 deletion packages/quill/src/core/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ abstract class Module<T extends {} = {}> {
static DEFAULTS = {};

constructor(
protected quill: Quill,
public quill: Quill,
protected options: Partial<T> = {},
) {}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/quill/src/modules/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { Range } from '../core/selection.js';

const debug = logger('quill:toolbar');

type Handler = (value: any) => void;
type Handler = (this: Toolbar, value: any) => void;

export type ToolbarConfig = Array<
string[] | Array<string | Record<string, unknown>>
Expand Down Expand Up @@ -262,7 +262,7 @@ Toolbar.DEFAULTS = {
}
});
} else {
this.quill.removeFormat(range, Quill.sources.USER);
this.quill.removeFormat(range.index, range.length, Quill.sources.USER);
}
},
direction(value) {
Expand All @@ -276,7 +276,9 @@ Toolbar.DEFAULTS = {
},
indent(value) {
const range = this.quill.getSelection();
// @ts-expect-error
const formats = this.quill.getFormat(range);
// @ts-expect-error
const indent = parseInt(formats.indent || 0, 10);
if (value === '+1' || value === '-1') {
let modifier = value === '+1' ? 1 : -1;
Expand All @@ -292,6 +294,7 @@ Toolbar.DEFAULTS = {
},
list(value) {
const range = this.quill.getSelection();
// @ts-expect-error
const formats = this.quill.getFormat(range);
if (value === 'check') {
if (formats.list === 'checked' || formats.list === 'unchecked') {
Expand Down
7 changes: 4 additions & 3 deletions packages/quill/src/themes/bubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BaseTheme, { BaseTooltip } from './base.js';
import { Range } from '../core/selection.js';
import type { Bounds } from '../core/selection.js';
import icons from '../ui/icons.js';
import type Quill from '../core.js';
import Quill from '../core/quill.js';
import type { ThemeOptions } from '../core/theme.js';
import type Toolbar from '../modules/toolbar.js';
import type { ToolbarConfig } from '../modules/toolbar.js';
Expand Down Expand Up @@ -135,14 +135,15 @@ BubbleTheme.DEFAULTS = merge({}, BaseTheme.DEFAULTS, {
handlers: {
link(value: string) {
if (!value) {
this.quill.format('link', false);
this.quill.format('link', false, Quill.sources.USER);
} else {
// @ts-expect-error
this.quill.theme.tooltip.edit();
}
},
},
},
},
});
} satisfies ThemeOptions);

export { BubbleTooltip, BubbleTheme as default };
7 changes: 4 additions & 3 deletions packages/quill/src/themes/snow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BaseTheme, { BaseTooltip } from './base.js';
import LinkBlot from '../formats/link.js';
import { Range } from '../core/selection.js';
import icons from '../ui/icons.js';
import type Quill from '../core.js';
import Quill from '../core/quill.js';
import type { Context } from '../modules/keyboard.js';
import type Toolbar from '../modules/toolbar.js';
import type { ToolbarConfig } from '../modules/toolbar.js';
Expand Down Expand Up @@ -136,15 +136,16 @@ SnowTheme.DEFAULTS = merge({}, BaseTheme.DEFAULTS, {
) {
preview = `mailto:${preview}`;
}
// @ts-expect-error
const { tooltip } = this.quill.theme;
tooltip.edit('link', preview);
} else {
this.quill.format('link', false);
this.quill.format('link', false, Quill.sources.USER);
}
},
},
},
},
});
} satisfies ThemeOptions);

export default SnowTheme;
Loading