Skip to content

Commit

Permalink
Enable verbatimModuleSyntax for project
Browse files Browse the repository at this point in the history
  • Loading branch information
luin committed Aug 13, 2023
1 parent c5fa826 commit c51a09f
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 50 deletions.
3 changes: 1 addition & 2 deletions blots/block.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
AttributorStore,
BlockBlot,
Blot,
EmbedBlot,
LeafBlot,
Parent,
Scope,
} from 'parchment';
import type { Blot, Parent } from 'parchment';
import Delta from 'quill-delta';
import Break from './break';
import Inline from './inline';
Expand Down
5 changes: 3 additions & 2 deletions blots/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { EmbedBlot, Parent, Scope, ScrollBlot } from 'parchment';
import { EmbedBlot, Scope, ScrollBlot } from 'parchment';
import type { Parent } from 'parchment';
import Selection from '../core/selection';
import TextBlot from './text';
import { EmbedContextRange } from './embed';
import type { EmbedContextRange } from './embed';

class Cursor extends EmbedBlot {
static blotName = 'cursor';
Expand Down
3 changes: 2 additions & 1 deletion blots/inline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BlotConstructor, EmbedBlot, InlineBlot, Scope } from 'parchment';
import { EmbedBlot, InlineBlot, Scope } from 'parchment';
import type { BlotConstructor } from 'parchment';
import Break from './break';
import Text from './text';

Expand Down
6 changes: 3 additions & 3 deletions blots/scroll.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import {
Blot,
ContainerBlot,
EmbedBlot,
LeafBlot,
Parent,
ParentBlot,
Registry,
Scope,
ScrollBlot,
} from 'parchment';
import type { Blot, Parent } from 'parchment';
import Delta, { AttributeMap, Op } from 'quill-delta';
import Emitter, { EmitterSource } from '../core/emitter';
import Emitter from '../core/emitter';
import type { EmitterSource } from '../core/emitter';
import Block, { BlockEmbed } from './block';
import Break from './break';
import Container from './container';
Expand Down
3 changes: 2 additions & 1 deletion core/editor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import cloneDeep from 'lodash.clonedeep';
import isEqual from 'lodash.isequal';
import merge from 'lodash.merge';
import { LeafBlot, EmbedBlot, Scope, Blot, ParentBlot } from 'parchment';
import { LeafBlot, EmbedBlot, Scope, ParentBlot } from 'parchment';
import type { Blot } from 'parchment';
import Delta, { AttributeMap, Op } from 'quill-delta';
import Block, { BlockEmbed, bubbleFormats } from '../blots/block';
import Break from '../blots/break';
Expand Down
18 changes: 12 additions & 6 deletions core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,26 @@ import merge from 'lodash.merge';
import * as Parchment from 'parchment';
import Delta, { Op } from 'quill-delta';
import Block, { BlockEmbed } from '../blots/block';
import Scroll, { ScrollConstructor } from '../blots/scroll';
import Scroll from '../blots/scroll';
import type { ScrollConstructor } from '../blots/scroll';
import Clipboard from '../modules/clipboard';
import History from '../modules/history';
import Keyboard from '../modules/keyboard';
import Uploader from '../modules/uploader';
import Editor from './editor';
import Emitter, { EmitterSource } from './emitter';
import Emitter from './emitter';
import type { EmitterSource } from './emitter';
import instances from './instances';
import logger, { DebugLevel } from './logger';
import logger from './logger';
import type { DebugLevel } from './logger';
import Module from './module';
import Selection, { Bounds, Range } from './selection';
import Selection, { Range } from './selection';
import type { Bounds } from './selection';
import Composition from './composition';
import Theme, { ThemeConstructor } from './theme';
import scrollRectIntoView, { Rect } from './utils/scrollRectIntoView';
import Theme from './theme';
import type { ThemeConstructor } from './theme';
import scrollRectIntoView from './utils/scrollRectIntoView';
import type { Rect } from './utils/scrollRectIntoView';

const debug = logger('quill');

Expand Down
5 changes: 3 additions & 2 deletions core/selection.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { LeafBlot, Scope } from 'parchment';
import cloneDeep from 'lodash.clonedeep';
import isEqual from 'lodash.isequal';
import Emitter, { EmitterSource } from './emitter';
import Emitter from './emitter';
import type { EmitterSource } from './emitter';
import logger from './logger';
import Cursor from '../blots/cursor';
import Scroll from '../blots/scroll';
Expand Down Expand Up @@ -173,7 +174,7 @@ class Selection {
this.update();
}

getBounds(index: number, length = 0): Bounds | null {
getBounds(index: number, length = 0) {
const scrollLength = this.scroll.length();
index = Math.min(index, scrollLength - 1);
length = Math.min(index + length, scrollLength - 1) - index;
Expand Down
2 changes: 1 addition & 1 deletion core/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Quill from '../core';
import Clipboard from '../modules/clipboard';
import History from '../modules/history';
import Keyboard from '../modules/keyboard';
import { ToolbarProps } from '../modules/toolbar';
import type { ToolbarProps } from '../modules/toolbar';
import Uploader from '../modules/uploader';

export interface ThemeOptions {
Expand Down
3 changes: 2 additions & 1 deletion e2e/history.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page, expect } from '@playwright/test';
import { expect } from '@playwright/test';
import type { Page } from '@playwright/test';
import { test } from './fixtures';
import { SHORTKEY } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion modules/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'parchment';
import Delta from 'quill-delta';
import { BlockEmbed } from '../blots/block';
import { EmitterSource } from '../core/emitter';
import type { EmitterSource } from '../core/emitter';
import logger from '../core/logger';
import Module from '../core/module';
import Quill from '../core/quill';
Expand Down
3 changes: 2 additions & 1 deletion modules/keyboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import cloneDeep from 'lodash.clonedeep';
import isEqual from 'lodash.isequal';
import Delta, { AttributeMap } from 'quill-delta';
import { BlockBlot, Blot, EmbedBlot, Scope, TextBlot } from 'parchment';
import { BlockBlot, EmbedBlot, Scope, TextBlot } from 'parchment';
import type { Blot } from 'parchment';
import Quill from '../core/quill';
import logger from '../core/logger';
import Module from '../core/module';
Expand Down
3 changes: 2 additions & 1 deletion modules/syntax.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Delta from 'quill-delta';
import { Blot, ClassAttributor, Scope, ScrollBlot } from 'parchment';
import { ClassAttributor, Scope, ScrollBlot } from 'parchment';
import type { Blot } from 'parchment';
import Inline from '../blots/inline';
import Quill from '../core/quill';
import Module from '../core/module';
Expand Down
3 changes: 2 additions & 1 deletion test/fuzz/tableEmbed.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Delta, { AttributeMap } from 'quill-delta';
import TableEmbed, {
import TableEmbed from '../../modules/tableEmbed';
import type {
CellData,
TableData,
TableRowColumnOp,
Expand Down
10 changes: 2 additions & 8 deletions test/unit/core/quill.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import '../../../quill';
import Delta from 'quill-delta';
import {
MockedFunction,
beforeEach,
describe,
expect,
test,
vitest,
} from 'vitest';
import { beforeEach, describe, expect, test, vitest } from 'vitest';
import type { MockedFunction } from 'vitest';
import Emitter from '../../../core/emitter';
import Theme from '../../../core/theme';
import Toolbar from '../../../modules/toolbar';
Expand Down
3 changes: 2 additions & 1 deletion test/unit/modules/history.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Delta from 'quill-delta';
import { describe, expect, test, vitest } from 'vitest';
import Quill from '../../../core';
import { HistoryOptions, getLastChangeIndex } from '../../../modules/history';
import { getLastChangeIndex } from '../../../modules/history';
import type { HistoryOptions } from '../../../modules/history';
import { createRegistry, createScroll } from '../__helpers__/factory';
import { sleep } from '../__helpers__/utils';
import Bold from '../../../formats/bold';
Expand Down
46 changes: 36 additions & 10 deletions test/unit/modules/keyboard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { describe, expect, test } from 'vitest';
import Keyboard, { SHORTKEY, normalize } from '../../../modules/keyboard';

const assert = <T>(value: T | null | undefined): T => {
if (value == null) {
throw new Error();
}
return value;
};

const createKeyboardEvent = (key: string, override?: Partial<KeyboardEvent>) =>
new KeyboardEvent('keydown', {
key,
Expand All @@ -17,9 +24,14 @@ describe('Keyboard', () => {
const binding = normalize({
key: 'a',
});
expect(Keyboard.match(createKeyboardEvent('a'), binding!)).toBe(true);
expect(Keyboard.match(createKeyboardEvent('a'), assert(binding))).toBe(
true,
);
expect(
Keyboard.match(createKeyboardEvent('A', { altKey: true }), binding!),
Keyboard.match(
createKeyboardEvent('A', { altKey: true }),
assert(binding),
),
).toBe(false);
});

Expand All @@ -28,9 +40,14 @@ describe('Keyboard', () => {
key: 'a',
altKey: true,
});
expect(Keyboard.match(createKeyboardEvent('a'), binding!)).toBe(false);
expect(Keyboard.match(createKeyboardEvent('a'), assert(binding))).toBe(
false,
);
expect(
Keyboard.match(createKeyboardEvent('a', { altKey: true }), binding!),
Keyboard.match(
createKeyboardEvent('a', { altKey: true }),
assert(binding),
),
).toBe(true);
});

Expand All @@ -39,9 +56,14 @@ describe('Keyboard', () => {
key: 'a',
altKey: null,
});
expect(Keyboard.match(createKeyboardEvent('a'), binding!)).toBe(true);
expect(Keyboard.match(createKeyboardEvent('a'), assert(binding))).toBe(
true,
);
expect(
Keyboard.match(createKeyboardEvent('a', { altKey: true }), binding!),
Keyboard.match(
createKeyboardEvent('a', { altKey: true }),
assert(binding),
),
).toBe(true);
});

Expand All @@ -50,11 +72,13 @@ describe('Keyboard', () => {
key: 'a',
shortKey: true,
});
expect(Keyboard.match(createKeyboardEvent('a'), binding!)).toBe(false);
expect(Keyboard.match(createKeyboardEvent('a'), assert(binding))).toBe(
false,
);
expect(
Keyboard.match(
createKeyboardEvent('a', { [SHORTKEY]: true }),
binding!,
assert(binding),
),
).toBe(true);
});
Expand All @@ -64,11 +88,13 @@ describe('Keyboard', () => {
key: 'a',
[SHORTKEY]: true,
});
expect(Keyboard.match(createKeyboardEvent('a'), binding!)).toBe(false);
expect(Keyboard.match(createKeyboardEvent('a'), assert(binding))).toBe(
false,
);
expect(
Keyboard.match(
createKeyboardEvent('a', { [SHORTKEY]: true }),
binding!,
assert(binding),
),
).toBe(true);
});
Expand Down
3 changes: 2 additions & 1 deletion themes/base.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import merge from 'lodash.merge';
import Quill from '../core/quill';
import Emitter from '../core/emitter';
import Theme, { ThemeOptions } from '../core/theme';
import Theme from '../core/theme';
import type { ThemeOptions } from '../core/theme';
import ColorPicker from '../ui/color-picker';
import IconPicker from '../ui/icon-picker';
import Picker from '../ui/picker';
Expand Down
8 changes: 5 additions & 3 deletions themes/bubble.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import merge from 'lodash.merge';
import Emitter from '../core/emitter';
import BaseTheme, { BaseTooltip } from './base';
import { Bounds, Range } from '../core/selection';
import { Range } from '../core/selection';
import type { Bounds } from '../core/selection';
import icons from '../ui/icons';
import Quill from '../core';
import { ThemeOptions } from '../core/theme';
import Toolbar, { ToolbarConfig } from '../modules/toolbar';
import type { ThemeOptions } from '../core/theme';
import Toolbar from '../modules/toolbar';
import type { ToolbarConfig } from '../modules/toolbar';

const TOOLBAR_CONFIG: ToolbarConfig = [
['bold', 'italic', 'link'],
Expand Down
7 changes: 4 additions & 3 deletions themes/snow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import LinkBlot from '../formats/link';
import { Range } from '../core/selection';
import icons from '../ui/icons';
import Quill from '../core';
import { Context } from '../modules/keyboard';
import Toolbar, { ToolbarConfig } from '../modules/toolbar';
import { ThemeOptions } from '../core/theme';
import type { Context } from '../modules/keyboard';
import Toolbar from '../modules/toolbar';
import type { ToolbarConfig } from '../modules/toolbar';
import type { ThemeOptions } from '../core/theme';

const TOOLBAR_CONFIG: ToolbarConfig = [
[{ header: ['1', '2', '3', false] }],
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"noEmit": true,
"strictNullChecks": true,
"noImplicitAny": true,
"verbatimModuleSyntax": true,
"noUnusedLocals": true
},
"include": ["./**/*"]
Expand Down
2 changes: 1 addition & 1 deletion ui/tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Quill from '../core';
import { Bounds } from '../core/selection';
import type { Bounds } from '../core/selection';

const isScrollable = (el: Element) => {
const { overflowY } = getComputedStyle(el, null);
Expand Down

0 comments on commit c51a09f

Please sign in to comment.