Skip to content

Commit

Permalink
Make Quill an ESM package (#4047)
Browse files Browse the repository at this point in the history
  • Loading branch information
luin authored Mar 12, 2024
1 parent 6e2ae54 commit 80f22d8
Show file tree
Hide file tree
Showing 99 changed files with 494 additions and 467 deletions.
25 changes: 19 additions & 6 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions packages/quill/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": [
"eslint:recommended",
"plugin:prettier/recommended",
"plugin:import/recommended"
"plugin:import/recommended",
"plugin:require-extensions/recommended"
],
"env": {
"browser": true,
Expand All @@ -27,7 +28,7 @@
"plugin:import/typescript"
],
"excludedFiles": "*.d.ts",
"plugins": ["@typescript-eslint"],
"plugins": ["@typescript-eslint", "require-extensions"],
"rules": {
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/ban-ts-comment": "off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const pkg = require('./package.json');
module.exports = {
presets: [
['@babel/preset-env', { modules: false }],
'@babel/preset-typescript'
'@babel/preset-typescript',
],
plugins: [
['transform-define', { QUILL_VERSION: pkg.version }],
'./scripts/babel-svg-inline-import',
'./scripts/babel-svg-inline-import.cjs',
],
};
4 changes: 3 additions & 1 deletion packages/quill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"author": "Jason Chen <[email protected]>",
"homepage": "https://quilljs.com",
"main": "quill.js",
"type": "module",
"dependencies": {
"eventemitter3": "^5.0.1",
"lodash-es": "^4.17.21",
"parchment": "^3.0.0-alpha.2",
"parchment": "0.0.0-experimental-c450721b1-20240312",
"quill-delta": "^5.1.0"
},
"devDependencies": {
Expand All @@ -34,6 +35,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-require-extensions": "^0.1.3",
"highlight.js": "^9.18.1",
"html-loader": "^4.2.0",
"html-webpack-plugin": "^5.5.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default defineConfig({
{ name: 'Safari', use: { ...devices['Desktop Safari'] } },
],
webServer: {
command: `npx webpack serve --config test/e2e/__dev_server__/webpack.config.ts --env port=${port}`,
command: `npx webpack serve --config test/e2e/__dev_server__/webpack.config.cjs --env port=${port}`,
port,
ignoreHTTPSErrors: true,
reuseExistingServer: !process.env.CI,
Expand Down
6 changes: 3 additions & 3 deletions packages/quill/src/blots/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
} from 'parchment';
import type { Blot, Parent } from 'parchment';
import Delta from 'quill-delta';
import Break from './break';
import Inline from './inline';
import TextBlot from './text';
import Break from './break.js';
import Inline from './inline.js';
import TextBlot from './text.js';

const NEWLINE_LENGTH = 1;

Expand Down
6 changes: 3 additions & 3 deletions packages/quill/src/blots/cursor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EmbedBlot, Scope } from 'parchment';
import type { Parent, ScrollBlot } from 'parchment';
import type Selection from '../core/selection';
import TextBlot from './text';
import type { EmbedContextRange } from './embed';
import type Selection from '../core/selection.js';
import TextBlot from './text.js';
import type { EmbedContextRange } from './embed.js';

class Cursor extends EmbedBlot {
static blotName = 'cursor';
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/blots/embed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ScrollBlot } from 'parchment';
import { EmbedBlot } from 'parchment';
import TextBlot from './text';
import TextBlot from './text.js';

const GUARD_TEXT = '\uFEFF';

Expand Down
4 changes: 2 additions & 2 deletions packages/quill/src/blots/inline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EmbedBlot, InlineBlot, Scope } from 'parchment';
import type { BlotConstructor } from 'parchment';
import Break from './break';
import Text from './text';
import Break from './break.js';
import Text from './text.js';

class Inline extends InlineBlot {
static allowedChildren: BlotConstructor[] = [Inline, Break, EmbedBlot, Text];
Expand Down
10 changes: 5 additions & 5 deletions packages/quill/src/blots/scroll.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ContainerBlot, LeafBlot, Scope, ScrollBlot } from 'parchment';
import type { Blot, Parent, EmbedBlot, ParentBlot, Registry } from 'parchment';
import Delta, { AttributeMap, Op } from 'quill-delta';
import Emitter from '../core/emitter';
import type { EmitterSource } from '../core/emitter';
import Block, { BlockEmbed, bubbleFormats } from './block';
import Break from './break';
import Container from './container';
import Emitter from '../core/emitter.js';
import type { EmitterSource } from '../core/emitter.js';
import Block, { BlockEmbed, bubbleFormats } from './block.js';
import Break from './break.js';
import Container from './container.js';

type RenderBlock =
| {
Expand Down
30 changes: 15 additions & 15 deletions packages/quill/src/core.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import Quill from './core/quill';
import Quill from './core/quill.js';

import Block, { BlockEmbed } from './blots/block';
import Break from './blots/break';
import Container from './blots/container';
import Cursor from './blots/cursor';
import Embed from './blots/embed';
import Inline from './blots/inline';
import Scroll from './blots/scroll';
import TextBlot from './blots/text';
import Block, { BlockEmbed } from './blots/block.js';
import Break from './blots/break.js';
import Container from './blots/container.js';
import Cursor from './blots/cursor.js';
import Embed from './blots/embed.js';
import Inline from './blots/inline.js';
import Scroll from './blots/scroll.js';
import TextBlot from './blots/text.js';

import Clipboard from './modules/clipboard';
import History from './modules/history';
import Keyboard from './modules/keyboard';
import Uploader from './modules/uploader';
import Clipboard from './modules/clipboard.js';
import History from './modules/history.js';
import Keyboard from './modules/keyboard.js';
import Uploader from './modules/uploader.js';
import Delta, { Op, OpIterator, AttributeMap } from 'quill-delta';
import Input from './modules/input';
import UINode from './modules/uiNode';
import Input from './modules/input.js';
import UINode from './modules/uiNode.js';

export { Delta, Op, OpIterator, AttributeMap };

Expand Down
6 changes: 3 additions & 3 deletions packages/quill/src/core/composition.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Embed from '../blots/embed';
import type Scroll from '../blots/scroll';
import Emitter from './emitter';
import Embed from '../blots/embed.js';
import type Scroll from '../blots/scroll.js';
import Emitter from './emitter.js';

class Composition {
isComposing = false;
Expand Down
12 changes: 6 additions & 6 deletions packages/quill/src/core/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { cloneDeep, isEqual, merge } from 'lodash-es';
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';
import CursorBlot from '../blots/cursor';
import type Scroll from '../blots/scroll';
import TextBlot, { escapeText } from '../blots/text';
import { Range } from './selection';
import Block, { BlockEmbed, bubbleFormats } from '../blots/block.js';
import Break from '../blots/break.js';
import CursorBlot from '../blots/cursor.js';
import type Scroll from '../blots/scroll.js';
import TextBlot, { escapeText } from '../blots/text.js';
import { Range } from './selection.js';

const ASCII = /^[ -~]*$/;

Expand Down
4 changes: 2 additions & 2 deletions packages/quill/src/core/emitter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter } from 'eventemitter3';
import instances from './instances';
import logger from './logger';
import instances from './instances.js';
import logger from './logger.js';

const debug = logger('quill:events');
const EVENTS = ['selectionchange', 'mousedown', 'mouseup', 'click'];
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/core/instances.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type Quill from '../core';
import type Quill from '../core.js';

export default new WeakMap<Node, Quill>();
2 changes: 1 addition & 1 deletion packages/quill/src/core/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type Quill from './quill';
import type Quill from './quill.js';

abstract class Module<T extends {} = {}> {
static DEFAULTS = {};
Expand Down
42 changes: 21 additions & 21 deletions packages/quill/src/core/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@ import { cloneDeep, merge } from 'lodash-es';
import * as Parchment from 'parchment';
import type { Op } from 'quill-delta';
import Delta from 'quill-delta';
import type { BlockEmbed } from '../blots/block';
import type Block from '../blots/block';
import type Scroll from '../blots/scroll';
import type Clipboard from '../modules/clipboard';
import type History from '../modules/history';
import type Keyboard from '../modules/keyboard';
import type Uploader from '../modules/uploader';
import Editor from './editor';
import Emitter from './emitter';
import type { EmitterSource } from './emitter';
import instances from './instances';
import logger from './logger';
import type { DebugLevel } from './logger';
import Module from './module';
import Selection, { Range } from './selection';
import type { Bounds } from './selection';
import Composition from './composition';
import Theme from './theme';
import type { ThemeConstructor } from './theme';
import scrollRectIntoView from './utils/scrollRectIntoView';
import type { Rect } from './utils/scrollRectIntoView';
import type { BlockEmbed } from '../blots/block.js';
import type Block from '../blots/block.js';
import type Scroll from '../blots/scroll.js';
import type Clipboard from '../modules/clipboard.js';
import type History from '../modules/history.js';
import type Keyboard from '../modules/keyboard.js';
import type Uploader from '../modules/uploader.js';
import Editor from './editor.js';
import Emitter from './emitter.js';
import type { EmitterSource } from './emitter.js';
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 { Bounds } from './selection.js';
import Composition from './composition.js';
import Theme from './theme.js';
import type { ThemeConstructor } from './theme.js';
import scrollRectIntoView from './utils/scrollRectIntoView.js';
import type { Rect } from './utils/scrollRectIntoView.js';

const debug = logger('quill');

Expand Down
10 changes: 5 additions & 5 deletions packages/quill/src/core/selection.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { LeafBlot, Scope } from 'parchment';
import { cloneDeep, isEqual } from 'lodash-es';
import Emitter from './emitter';
import type { EmitterSource } from './emitter';
import logger from './logger';
import type Cursor from '../blots/cursor';
import type Scroll from '../blots/scroll';
import Emitter from './emitter.js';
import type { EmitterSource } from './emitter.js';
import logger from './logger.js';
import type Cursor from '../blots/cursor.js';
import type Scroll from '../blots/scroll.js';

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

Expand Down
12 changes: 6 additions & 6 deletions packages/quill/src/core/theme.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type Quill from '../core';
import type Clipboard from '../modules/clipboard';
import type History from '../modules/history';
import type Keyboard from '../modules/keyboard';
import type { ToolbarProps } from '../modules/toolbar';
import type Uploader from '../modules/uploader';
import type Quill from '../core.js';
import type Clipboard from '../modules/clipboard.js';
import type History from '../modules/history.js';
import type Keyboard from '../modules/keyboard.js';
import type { ToolbarProps } from '../modules/toolbar.js';
import type Uploader from '../modules/uploader.js';

export interface ThemeOptions {
modules: Record<string, unknown> & {
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/formats/background.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ClassAttributor, Scope } from 'parchment';
import { ColorAttributor } from './color';
import { ColorAttributor } from './color.js';

const BackgroundClass = new ClassAttributor('background', 'ql-bg', {
scope: Scope.INLINE,
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/formats/blockquote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Block from '../blots/block';
import Block from '../blots/block.js';

class Blockquote extends Block {
static blotName = 'blockquote';
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/formats/bold.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Inline from '../blots/inline';
import Inline from '../blots/inline.js';

class Bold extends Inline {
static blotName = 'bold';
Expand Down
14 changes: 7 additions & 7 deletions packages/quill/src/formats/code.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Block from '../blots/block';
import Break from '../blots/break';
import Cursor from '../blots/cursor';
import Inline from '../blots/inline';
import TextBlot, { escapeText } from '../blots/text';
import Container from '../blots/container';
import Quill from '../core/quill';
import Block from '../blots/block.js';
import Break from '../blots/break.js';
import Cursor from '../blots/cursor.js';
import Inline from '../blots/inline.js';
import TextBlot, { escapeText } from '../blots/text.js';
import Container from '../blots/container.js';
import Quill from '../core/quill.js';

class CodeBlockContainer extends Container {
static create(value: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/formats/formula.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Embed from '../blots/embed';
import Embed from '../blots/embed.js';

class Formula extends Embed {
static blotName = 'formula';
Expand Down
2 changes: 1 addition & 1 deletion packages/quill/src/formats/header.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Block from '../blots/block';
import Block from '../blots/block.js';

class Header extends Block {
static blotName = 'header';
Expand Down
Loading

0 comments on commit 80f22d8

Please sign in to comment.