From 80f22d8088028fc2b407d618b02b22af3fc6c610 Mon Sep 17 00:00:00 2001 From: Zihua Li Date: Tue, 12 Mar 2024 21:45:14 +0800 Subject: [PATCH] Make Quill an ESM package (#4047) --- package-lock.json | 25 ++++-- packages/quill/.eslintrc.json | 5 +- .../{babel.config.js => babel.config.cjs} | 4 +- packages/quill/package.json | 4 +- packages/quill/playwright.config.ts | 2 +- ...-import.js => babel-svg-inline-import.cjs} | 0 packages/quill/src/blots/block.ts | 6 +- packages/quill/src/blots/cursor.ts | 6 +- packages/quill/src/blots/embed.ts | 2 +- packages/quill/src/blots/inline.ts | 4 +- packages/quill/src/blots/scroll.ts | 10 +-- packages/quill/src/core.ts | 30 +++---- packages/quill/src/core/composition.ts | 6 +- packages/quill/src/core/editor.ts | 12 +-- packages/quill/src/core/emitter.ts | 4 +- packages/quill/src/core/instances.ts | 2 +- packages/quill/src/core/module.ts | 2 +- packages/quill/src/core/quill.ts | 42 +++++----- packages/quill/src/core/selection.ts | 10 +-- packages/quill/src/core/theme.ts | 12 +-- packages/quill/src/formats/background.ts | 2 +- packages/quill/src/formats/blockquote.ts | 2 +- packages/quill/src/formats/bold.ts | 2 +- packages/quill/src/formats/code.ts | 14 ++-- packages/quill/src/formats/formula.ts | 2 +- packages/quill/src/formats/header.ts | 2 +- packages/quill/src/formats/image.ts | 2 +- packages/quill/src/formats/italic.ts | 2 +- packages/quill/src/formats/link.ts | 2 +- packages/quill/src/formats/list.ts | 8 +- packages/quill/src/formats/script.ts | 2 +- packages/quill/src/formats/strike.ts | 2 +- packages/quill/src/formats/table.ts | 4 +- packages/quill/src/formats/underline.ts | 2 +- packages/quill/src/formats/video.ts | 4 +- packages/quill/src/modules/clipboard.ts | 30 +++---- packages/quill/src/modules/history.ts | 8 +- packages/quill/src/modules/input.ts | 8 +- packages/quill/src/modules/keyboard.ts | 10 +-- .../modules/normalizeExternalHTML/index.ts | 4 +- packages/quill/src/modules/syntax.ts | 18 ++--- packages/quill/src/modules/table.ts | 6 +- packages/quill/src/modules/tableEmbed.ts | 2 +- packages/quill/src/modules/toolbar.ts | 8 +- packages/quill/src/modules/uiNode.ts | 4 +- packages/quill/src/modules/uploader.ts | 8 +- packages/quill/src/quill.ts | 78 +++++++++---------- packages/quill/src/themes/base.ts | 28 +++---- packages/quill/src/themes/bubble.ts | 18 ++--- packages/quill/src/themes/snow.ts | 20 ++--- packages/quill/src/ui/color-picker.ts | 2 +- packages/quill/src/ui/icon-picker.ts | 2 +- packages/quill/src/ui/tooltip.ts | 4 +- .../{webpack.config.ts => webpack.config.cjs} | 19 ++--- packages/quill/test/e2e/fixtures/index.ts | 4 +- packages/quill/test/e2e/full.spec.ts | 4 +- packages/quill/test/e2e/history.spec.ts | 4 +- packages/quill/test/e2e/list.spec.ts | 4 +- .../quill/test/e2e/pageobjects/EditorPage.ts | 2 +- .../quill/test/e2e/replaceSelection.spec.ts | 2 +- packages/quill/test/fuzz/editor.spec.ts | 10 +-- packages/quill/test/fuzz/tableEmbed.spec.ts | 6 +- .../quill/test/unit/__helpers__/expect.ts | 2 +- .../quill/test/unit/__helpers__/factory.ts | 18 ++--- .../quill/test/unit/blots/block-embed.spec.ts | 6 +- packages/quill/test/unit/blots/block.spec.ts | 6 +- packages/quill/test/unit/blots/inline.spec.ts | 6 +- packages/quill/test/unit/blots/scroll.spec.ts | 16 ++-- .../quill/test/unit/core/composition.spec.ts | 10 +-- packages/quill/test/unit/core/editor.spec.ts | 52 ++++++------- packages/quill/test/unit/core/emitter.spec.ts | 4 +- packages/quill/test/unit/core/quill.spec.ts | 16 ++-- .../quill/test/unit/core/selection.spec.ts | 26 +++---- .../quill/test/unit/formats/align.spec.ts | 6 +- packages/quill/test/unit/formats/bold.spec.ts | 4 +- packages/quill/test/unit/formats/code.spec.ts | 13 ++-- .../quill/test/unit/formats/color.spec.ts | 8 +- .../quill/test/unit/formats/header.spec.ts | 8 +- .../quill/test/unit/formats/indent.spec.ts | 8 +- packages/quill/test/unit/formats/link.spec.ts | 8 +- packages/quill/test/unit/formats/list.spec.ts | 12 +-- .../quill/test/unit/formats/script.spec.ts | 6 +- .../quill/test/unit/formats/table.spec.ts | 8 +- .../quill/test/unit/modules/clipboard.spec.ts | 32 ++++---- .../quill/test/unit/modules/history.spec.ts | 18 ++--- .../quill/test/unit/modules/keyboard.spec.ts | 5 +- .../normalizers/googleDocs.spec.ts | 2 +- .../normalizers/msWord.spec.ts | 2 +- .../quill/test/unit/modules/syntax.spec.ts | 10 +-- .../quill/test/unit/modules/table.spec.ts | 10 +-- .../test/unit/modules/tableEmbed.spec.ts | 2 +- .../quill/test/unit/modules/toolbar.spec.ts | 30 +++---- .../quill/test/unit/modules/uiNode.spec.ts | 6 +- .../test/unit/theme/base/tooltip.spec.ts | 8 +- packages/quill/test/unit/ui/picker.spec.ts | 2 +- packages/quill/tsconfig.json | 3 +- .../{webpack.common.ts => webpack.common.cjs} | 14 ++-- .../{webpack.config.ts => webpack.config.cjs} | 19 ++--- .../website/src/playground/react/Editor.js | 2 +- 99 files changed, 494 insertions(+), 467 deletions(-) rename packages/quill/{babel.config.js => babel.config.cjs} (72%) rename packages/quill/scripts/{babel-svg-inline-import.js => babel-svg-inline-import.cjs} (100%) rename packages/quill/test/e2e/__dev_server__/{webpack.config.ts => webpack.config.cjs} (56%) rename packages/quill/{webpack.common.ts => webpack.common.cjs} (84%) rename packages/quill/{webpack.config.ts => webpack.config.cjs} (69%) diff --git a/package-lock.json b/package-lock.json index de4279d348..ae555a12a8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9449,6 +9449,18 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/eslint-plugin-require-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz", + "integrity": "sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "*" + } + }, "node_modules/eslint-scope": { "version": "7.2.2", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", @@ -14407,11 +14419,6 @@ "tslib": "^2.0.3" } }, - "node_modules/parchment": { - "version": "3.0.0-alpha.2", - "resolved": "https://registry.npmjs.org/parchment/-/parchment-3.0.0-alpha.2.tgz", - "integrity": "sha512-r/DoIj7e8efiTWUg+BHUlolpdE9/iNVtcFg8i7SvdlF7a7fgTAAwcXrpamNrf49IsGykyDcsfUZKGFVwMXZcyg==" - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -18894,7 +18901,7 @@ "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": { @@ -18920,6 +18927,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", @@ -18950,6 +18958,11 @@ "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==" }, + "packages/quill/node_modules/parchment": { + "version": "0.0.0-experimental-c450721b1-20240312", + "resolved": "https://registry.npmjs.org/parchment/-/parchment-0.0.0-experimental-c450721b1-20240312.tgz", + "integrity": "sha512-jz9gsrEMJgf9lHL9cXNIlf9ZNUqmgZ4LXorXXd8DRQHaBjnS1AIawRtmOjp/VOhv8G1lH0ZRmjic11WyCFi/7w==" + }, "packages/website": { "version": "2.0.0-rc.2", "license": "BSD-3-Clause", diff --git a/packages/quill/.eslintrc.json b/packages/quill/.eslintrc.json index 5fdfa4a528..edf5dc5f30 100644 --- a/packages/quill/.eslintrc.json +++ b/packages/quill/.eslintrc.json @@ -2,7 +2,8 @@ "extends": [ "eslint:recommended", "plugin:prettier/recommended", - "plugin:import/recommended" + "plugin:import/recommended", + "plugin:require-extensions/recommended" ], "env": { "browser": true, @@ -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", diff --git a/packages/quill/babel.config.js b/packages/quill/babel.config.cjs similarity index 72% rename from packages/quill/babel.config.js rename to packages/quill/babel.config.cjs index 847b088784..4bc6b98901 100644 --- a/packages/quill/babel.config.js +++ b/packages/quill/babel.config.cjs @@ -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', ], }; diff --git a/packages/quill/package.json b/packages/quill/package.json index a6191cc2d2..d933aad744 100644 --- a/packages/quill/package.json +++ b/packages/quill/package.json @@ -5,10 +5,11 @@ "author": "Jason Chen ", "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": { @@ -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", diff --git a/packages/quill/playwright.config.ts b/packages/quill/playwright.config.ts index 2b866a9a72..9fa19c6057 100644 --- a/packages/quill/playwright.config.ts +++ b/packages/quill/playwright.config.ts @@ -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, diff --git a/packages/quill/scripts/babel-svg-inline-import.js b/packages/quill/scripts/babel-svg-inline-import.cjs similarity index 100% rename from packages/quill/scripts/babel-svg-inline-import.js rename to packages/quill/scripts/babel-svg-inline-import.cjs diff --git a/packages/quill/src/blots/block.ts b/packages/quill/src/blots/block.ts index a1901a3c2b..e1f1607e61 100644 --- a/packages/quill/src/blots/block.ts +++ b/packages/quill/src/blots/block.ts @@ -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; diff --git a/packages/quill/src/blots/cursor.ts b/packages/quill/src/blots/cursor.ts index e4eec1f008..4dfb482904 100644 --- a/packages/quill/src/blots/cursor.ts +++ b/packages/quill/src/blots/cursor.ts @@ -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'; diff --git a/packages/quill/src/blots/embed.ts b/packages/quill/src/blots/embed.ts index a624982b07..2e019f7613 100644 --- a/packages/quill/src/blots/embed.ts +++ b/packages/quill/src/blots/embed.ts @@ -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'; diff --git a/packages/quill/src/blots/inline.ts b/packages/quill/src/blots/inline.ts index 4acf5780fc..b91a3cfeb7 100644 --- a/packages/quill/src/blots/inline.ts +++ b/packages/quill/src/blots/inline.ts @@ -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]; diff --git a/packages/quill/src/blots/scroll.ts b/packages/quill/src/blots/scroll.ts index 4695d8c3a4..07fc2458db 100644 --- a/packages/quill/src/blots/scroll.ts +++ b/packages/quill/src/blots/scroll.ts @@ -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 = | { diff --git a/packages/quill/src/core.ts b/packages/quill/src/core.ts index 545ef2f552..6de723d644 100644 --- a/packages/quill/src/core.ts +++ b/packages/quill/src/core.ts @@ -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 }; diff --git a/packages/quill/src/core/composition.ts b/packages/quill/src/core/composition.ts index dd79ffabe0..2a7038b46e 100644 --- a/packages/quill/src/core/composition.ts +++ b/packages/quill/src/core/composition.ts @@ -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; diff --git a/packages/quill/src/core/editor.ts b/packages/quill/src/core/editor.ts index b73d82ec33..a19485840d 100644 --- a/packages/quill/src/core/editor.ts +++ b/packages/quill/src/core/editor.ts @@ -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 = /^[ -~]*$/; diff --git a/packages/quill/src/core/emitter.ts b/packages/quill/src/core/emitter.ts index d151f484e1..7e981ed47b 100644 --- a/packages/quill/src/core/emitter.ts +++ b/packages/quill/src/core/emitter.ts @@ -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']; diff --git a/packages/quill/src/core/instances.ts b/packages/quill/src/core/instances.ts index 8293708a4f..0481949781 100644 --- a/packages/quill/src/core/instances.ts +++ b/packages/quill/src/core/instances.ts @@ -1,3 +1,3 @@ -import type Quill from '../core'; +import type Quill from '../core.js'; export default new WeakMap(); diff --git a/packages/quill/src/core/module.ts b/packages/quill/src/core/module.ts index 3dcfce54e0..fca5b385df 100644 --- a/packages/quill/src/core/module.ts +++ b/packages/quill/src/core/module.ts @@ -1,4 +1,4 @@ -import type Quill from './quill'; +import type Quill from './quill.js'; abstract class Module { static DEFAULTS = {}; diff --git a/packages/quill/src/core/quill.ts b/packages/quill/src/core/quill.ts index df5992e69f..7f7c1489e6 100644 --- a/packages/quill/src/core/quill.ts +++ b/packages/quill/src/core/quill.ts @@ -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'); diff --git a/packages/quill/src/core/selection.ts b/packages/quill/src/core/selection.ts index 9c3f87ffb7..5fc45cf70a 100644 --- a/packages/quill/src/core/selection.ts +++ b/packages/quill/src/core/selection.ts @@ -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'); diff --git a/packages/quill/src/core/theme.ts b/packages/quill/src/core/theme.ts index 0e1d17ed5c..e5bc1f51dc 100644 --- a/packages/quill/src/core/theme.ts +++ b/packages/quill/src/core/theme.ts @@ -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 & { diff --git a/packages/quill/src/formats/background.ts b/packages/quill/src/formats/background.ts index 07c764d0ff..b305d0e919 100644 --- a/packages/quill/src/formats/background.ts +++ b/packages/quill/src/formats/background.ts @@ -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, diff --git a/packages/quill/src/formats/blockquote.ts b/packages/quill/src/formats/blockquote.ts index 909c2e5ea5..487e99a8a3 100644 --- a/packages/quill/src/formats/blockquote.ts +++ b/packages/quill/src/formats/blockquote.ts @@ -1,4 +1,4 @@ -import Block from '../blots/block'; +import Block from '../blots/block.js'; class Blockquote extends Block { static blotName = 'blockquote'; diff --git a/packages/quill/src/formats/bold.ts b/packages/quill/src/formats/bold.ts index 7f70218726..93b1f3aeb4 100644 --- a/packages/quill/src/formats/bold.ts +++ b/packages/quill/src/formats/bold.ts @@ -1,4 +1,4 @@ -import Inline from '../blots/inline'; +import Inline from '../blots/inline.js'; class Bold extends Inline { static blotName = 'bold'; diff --git a/packages/quill/src/formats/code.ts b/packages/quill/src/formats/code.ts index 1131995745..db124ffb64 100644 --- a/packages/quill/src/formats/code.ts +++ b/packages/quill/src/formats/code.ts @@ -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) { diff --git a/packages/quill/src/formats/formula.ts b/packages/quill/src/formats/formula.ts index 258a5eea33..ded4e89160 100644 --- a/packages/quill/src/formats/formula.ts +++ b/packages/quill/src/formats/formula.ts @@ -1,4 +1,4 @@ -import Embed from '../blots/embed'; +import Embed from '../blots/embed.js'; class Formula extends Embed { static blotName = 'formula'; diff --git a/packages/quill/src/formats/header.ts b/packages/quill/src/formats/header.ts index 24a7a405ce..c3a10e358a 100644 --- a/packages/quill/src/formats/header.ts +++ b/packages/quill/src/formats/header.ts @@ -1,4 +1,4 @@ -import Block from '../blots/block'; +import Block from '../blots/block.js'; class Header extends Block { static blotName = 'header'; diff --git a/packages/quill/src/formats/image.ts b/packages/quill/src/formats/image.ts index 4e9a8b80ba..e68f56a0b3 100644 --- a/packages/quill/src/formats/image.ts +++ b/packages/quill/src/formats/image.ts @@ -1,5 +1,5 @@ import { EmbedBlot } from 'parchment'; -import { sanitize } from './link'; +import { sanitize } from './link.js'; const ATTRIBUTES = ['alt', 'height', 'width']; diff --git a/packages/quill/src/formats/italic.ts b/packages/quill/src/formats/italic.ts index 16c690d04b..dbc1233d8d 100644 --- a/packages/quill/src/formats/italic.ts +++ b/packages/quill/src/formats/italic.ts @@ -1,4 +1,4 @@ -import Bold from './bold'; +import Bold from './bold.js'; class Italic extends Bold { static blotName = 'italic'; diff --git a/packages/quill/src/formats/link.ts b/packages/quill/src/formats/link.ts index e832099630..5412355b85 100644 --- a/packages/quill/src/formats/link.ts +++ b/packages/quill/src/formats/link.ts @@ -1,4 +1,4 @@ -import Inline from '../blots/inline'; +import Inline from '../blots/inline.js'; class Link extends Inline { static blotName = 'link'; diff --git a/packages/quill/src/formats/list.ts b/packages/quill/src/formats/list.ts index d422a713c3..ed1352fb19 100644 --- a/packages/quill/src/formats/list.ts +++ b/packages/quill/src/formats/list.ts @@ -1,7 +1,7 @@ -import Block from '../blots/block'; -import Container from '../blots/container'; -import type Scroll from '../blots/scroll'; -import Quill from '../core/quill'; +import Block from '../blots/block.js'; +import Container from '../blots/container.js'; +import type Scroll from '../blots/scroll.js'; +import Quill from '../core/quill.js'; class ListContainer extends Container {} ListContainer.blotName = 'list-container'; diff --git a/packages/quill/src/formats/script.ts b/packages/quill/src/formats/script.ts index 68d77e2e09..1bb988aa80 100644 --- a/packages/quill/src/formats/script.ts +++ b/packages/quill/src/formats/script.ts @@ -1,4 +1,4 @@ -import Inline from '../blots/inline'; +import Inline from '../blots/inline.js'; class Script extends Inline { static blotName = 'script'; diff --git a/packages/quill/src/formats/strike.ts b/packages/quill/src/formats/strike.ts index c4017cc201..fe73e6187d 100644 --- a/packages/quill/src/formats/strike.ts +++ b/packages/quill/src/formats/strike.ts @@ -1,4 +1,4 @@ -import Bold from './bold'; +import Bold from './bold.js'; class Strike extends Bold { static blotName = 'strike'; diff --git a/packages/quill/src/formats/table.ts b/packages/quill/src/formats/table.ts index 2f891e10c9..54637085ef 100644 --- a/packages/quill/src/formats/table.ts +++ b/packages/quill/src/formats/table.ts @@ -1,6 +1,6 @@ import type { LinkedList } from 'parchment'; -import Block from '../blots/block'; -import Container from '../blots/container'; +import Block from '../blots/block.js'; +import Container from '../blots/container.js'; class TableCell extends Block { static blotName = 'table'; diff --git a/packages/quill/src/formats/underline.ts b/packages/quill/src/formats/underline.ts index 940b494d5b..9a046554b8 100644 --- a/packages/quill/src/formats/underline.ts +++ b/packages/quill/src/formats/underline.ts @@ -1,4 +1,4 @@ -import Inline from '../blots/inline'; +import Inline from '../blots/inline.js'; class Underline extends Inline { static blotName = 'underline'; diff --git a/packages/quill/src/formats/video.ts b/packages/quill/src/formats/video.ts index edd4ffad02..84d4bb15cf 100644 --- a/packages/quill/src/formats/video.ts +++ b/packages/quill/src/formats/video.ts @@ -1,5 +1,5 @@ -import { BlockEmbed } from '../blots/block'; -import Link from './link'; +import { BlockEmbed } from '../blots/block.js'; +import Link from './link.js'; const ATTRIBUTES = ['height', 'width']; diff --git a/packages/quill/src/modules/clipboard.ts b/packages/quill/src/modules/clipboard.ts index 4f7243e298..ead9758d29 100644 --- a/packages/quill/src/modules/clipboard.ts +++ b/packages/quill/src/modules/clipboard.ts @@ -8,21 +8,21 @@ import { StyleAttributor, } from 'parchment'; import Delta from 'quill-delta'; -import { BlockEmbed } from '../blots/block'; -import type { EmitterSource } from '../core/emitter'; -import logger from '../core/logger'; -import Module from '../core/module'; -import Quill from '../core/quill'; -import type { Range } from '../core/selection'; -import { AlignAttribute, AlignStyle } from '../formats/align'; -import { BackgroundStyle } from '../formats/background'; -import CodeBlock from '../formats/code'; -import { ColorStyle } from '../formats/color'; -import { DirectionAttribute, DirectionStyle } from '../formats/direction'; -import { FontStyle } from '../formats/font'; -import { SizeStyle } from '../formats/size'; -import { deleteRange } from './keyboard'; -import normalizeExternalHTML from './normalizeExternalHTML'; +import { BlockEmbed } from '../blots/block.js'; +import type { EmitterSource } from '../core/emitter.js'; +import logger from '../core/logger.js'; +import Module from '../core/module.js'; +import Quill from '../core/quill.js'; +import type { Range } from '../core/selection.js'; +import { AlignAttribute, AlignStyle } from '../formats/align.js'; +import { BackgroundStyle } from '../formats/background.js'; +import CodeBlock from '../formats/code.js'; +import { ColorStyle } from '../formats/color.js'; +import { DirectionAttribute, DirectionStyle } from '../formats/direction.js'; +import { FontStyle } from '../formats/font.js'; +import { SizeStyle } from '../formats/size.js'; +import { deleteRange } from './keyboard.js'; +import normalizeExternalHTML from './normalizeExternalHTML/index.js'; const debug = logger('quill:clipboard'); diff --git a/packages/quill/src/modules/history.ts b/packages/quill/src/modules/history.ts index 73cf47ada6..3dece48901 100644 --- a/packages/quill/src/modules/history.ts +++ b/packages/quill/src/modules/history.ts @@ -1,9 +1,9 @@ import { Scope } from 'parchment'; import type Delta from 'quill-delta'; -import Module from '../core/module'; -import Quill from '../core/quill'; -import type Scroll from '../blots/scroll'; -import type { Range } from '../core/selection'; +import Module from '../core/module.js'; +import Quill from '../core/quill.js'; +import type Scroll from '../blots/scroll.js'; +import type { Range } from '../core/selection.js'; export interface HistoryOptions { userOnly: boolean; diff --git a/packages/quill/src/modules/input.ts b/packages/quill/src/modules/input.ts index 9b521d8282..c9b7e83eaf 100644 --- a/packages/quill/src/modules/input.ts +++ b/packages/quill/src/modules/input.ts @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; -import Module from '../core/module'; -import Quill from '../core/quill'; -import type { Range } from '../core/selection'; -import { deleteRange } from './keyboard'; +import Module from '../core/module.js'; +import Quill from '../core/quill.js'; +import type { Range } from '../core/selection.js'; +import { deleteRange } from './keyboard.js'; const INSERT_TYPES = ['insertText', 'insertReplacementText']; diff --git a/packages/quill/src/modules/keyboard.ts b/packages/quill/src/modules/keyboard.ts index 77e95b890b..3301046410 100644 --- a/packages/quill/src/modules/keyboard.ts +++ b/packages/quill/src/modules/keyboard.ts @@ -2,11 +2,11 @@ import { cloneDeep, isEqual } from 'lodash-es'; import Delta, { AttributeMap } from 'quill-delta'; import { EmbedBlot, Scope, TextBlot } from 'parchment'; import type { Blot, BlockBlot } from 'parchment'; -import Quill from '../core/quill'; -import logger from '../core/logger'; -import Module from '../core/module'; -import type { BlockEmbed } from '../blots/block'; -import type { Range } from '../core/selection'; +import Quill from '../core/quill.js'; +import logger from '../core/logger.js'; +import Module from '../core/module.js'; +import type { BlockEmbed } from '../blots/block.js'; +import type { Range } from '../core/selection.js'; const debug = logger('quill:keyboard'); diff --git a/packages/quill/src/modules/normalizeExternalHTML/index.ts b/packages/quill/src/modules/normalizeExternalHTML/index.ts index 87468ea961..59d56f6dd3 100644 --- a/packages/quill/src/modules/normalizeExternalHTML/index.ts +++ b/packages/quill/src/modules/normalizeExternalHTML/index.ts @@ -1,5 +1,5 @@ -import googleDocs from './normalizers/googleDocs'; -import msWord from './normalizers/msWord'; +import googleDocs from './normalizers/googleDocs.js'; +import msWord from './normalizers/msWord.js'; const NORMALIZERS = [msWord, googleDocs]; diff --git a/packages/quill/src/modules/syntax.ts b/packages/quill/src/modules/syntax.ts index 6ca5931f7a..ed8214e81f 100644 --- a/packages/quill/src/modules/syntax.ts +++ b/packages/quill/src/modules/syntax.ts @@ -1,15 +1,15 @@ import Delta from 'quill-delta'; import { ClassAttributor, Scope } from 'parchment'; import type { Blot, ScrollBlot } from 'parchment'; -import Inline from '../blots/inline'; -import Quill from '../core/quill'; -import Module from '../core/module'; -import { blockDelta } from '../blots/block'; -import BreakBlot from '../blots/break'; -import CursorBlot from '../blots/cursor'; -import TextBlot, { escapeText } from '../blots/text'; -import CodeBlock, { CodeBlockContainer } from '../formats/code'; -import { traverse } from './clipboard'; +import Inline from '../blots/inline.js'; +import Quill from '../core/quill.js'; +import Module from '../core/module.js'; +import { blockDelta } from '../blots/block.js'; +import BreakBlot from '../blots/break.js'; +import CursorBlot from '../blots/cursor.js'; +import TextBlot, { escapeText } from '../blots/text.js'; +import CodeBlock, { CodeBlockContainer } from '../formats/code.js'; +import { traverse } from './clipboard.js'; const TokenAttributor = new ClassAttributor('code-token', 'hljs', { scope: Scope.INLINE, diff --git a/packages/quill/src/modules/table.ts b/packages/quill/src/modules/table.ts index c315ce0858..531e36bb0c 100644 --- a/packages/quill/src/modules/table.ts +++ b/packages/quill/src/modules/table.ts @@ -1,13 +1,13 @@ import Delta from 'quill-delta'; -import Quill from '../core/quill'; -import Module from '../core/module'; +import Quill from '../core/quill.js'; +import Module from '../core/module.js'; import { TableCell, TableRow, TableBody, TableContainer, tableId, -} from '../formats/table'; +} from '../formats/table.js'; class Table extends Module { static register() { diff --git a/packages/quill/src/modules/tableEmbed.ts b/packages/quill/src/modules/tableEmbed.ts index eb2f7aa1f3..0d47efd727 100644 --- a/packages/quill/src/modules/tableEmbed.ts +++ b/packages/quill/src/modules/tableEmbed.ts @@ -1,6 +1,6 @@ import Delta, { OpIterator } from 'quill-delta'; import type { Op, AttributeMap } from 'quill-delta'; -import Module from '../core/module'; +import Module from '../core/module.js'; export type CellData = { content?: Delta['ops']; diff --git a/packages/quill/src/modules/toolbar.ts b/packages/quill/src/modules/toolbar.ts index 5794bd765d..78af61e5c8 100644 --- a/packages/quill/src/modules/toolbar.ts +++ b/packages/quill/src/modules/toolbar.ts @@ -1,9 +1,9 @@ import Delta from 'quill-delta'; import { EmbedBlot, Scope } from 'parchment'; -import Quill from '../core/quill'; -import logger from '../core/logger'; -import Module from '../core/module'; -import type { Range } from '../core/selection'; +import Quill from '../core/quill.js'; +import logger from '../core/logger.js'; +import Module from '../core/module.js'; +import type { Range } from '../core/selection.js'; const debug = logger('quill:toolbar'); diff --git a/packages/quill/src/modules/uiNode.ts b/packages/quill/src/modules/uiNode.ts index 4b88b1a24c..780713a3ba 100644 --- a/packages/quill/src/modules/uiNode.ts +++ b/packages/quill/src/modules/uiNode.ts @@ -1,6 +1,6 @@ import { ParentBlot } from 'parchment'; -import Module from '../core/module'; -import Quill from '../core/quill'; +import Module from '../core/module.js'; +import Quill from '../core/quill.js'; const isMac = /Mac/i.test(navigator.platform); diff --git a/packages/quill/src/modules/uploader.ts b/packages/quill/src/modules/uploader.ts index e2399cb97d..940c6ecb40 100644 --- a/packages/quill/src/modules/uploader.ts +++ b/packages/quill/src/modules/uploader.ts @@ -1,8 +1,8 @@ import Delta from 'quill-delta'; -import type Quill from '../core/quill'; -import Emitter from '../core/emitter'; -import Module from '../core/module'; -import type { Range } from '../core/selection'; +import type Quill from '../core/quill.js'; +import Emitter from '../core/emitter.js'; +import Module from '../core/module.js'; +import type { Range } from '../core/selection.js'; interface UploaderOptions { mimetypes: string[]; diff --git a/packages/quill/src/quill.ts b/packages/quill/src/quill.ts index e55bb3af59..6418df9583 100644 --- a/packages/quill/src/quill.ts +++ b/packages/quill/src/quill.ts @@ -1,47 +1,47 @@ -import Quill from './core'; +import Quill from './core.js'; -import { AlignClass, AlignStyle } from './formats/align'; +import { AlignClass, AlignStyle } from './formats/align.js'; import { DirectionAttribute, DirectionClass, DirectionStyle, -} from './formats/direction'; -import Indent from './formats/indent'; - -import Blockquote from './formats/blockquote'; -import Header from './formats/header'; -import List from './formats/list'; - -import { BackgroundClass, BackgroundStyle } from './formats/background'; -import { ColorClass, ColorStyle } from './formats/color'; -import { FontClass, FontStyle } from './formats/font'; -import { SizeClass, SizeStyle } from './formats/size'; - -import Bold from './formats/bold'; -import Italic from './formats/italic'; -import Link from './formats/link'; -import Script from './formats/script'; -import Strike from './formats/strike'; -import Underline from './formats/underline'; - -import Formula from './formats/formula'; -import Image from './formats/image'; -import Video from './formats/video'; - -import CodeBlock, { Code as InlineCode } from './formats/code'; - -import Syntax from './modules/syntax'; -import Table from './modules/table'; -import Toolbar from './modules/toolbar'; - -import Icons from './ui/icons'; -import Picker from './ui/picker'; -import ColorPicker from './ui/color-picker'; -import IconPicker from './ui/icon-picker'; -import Tooltip from './ui/tooltip'; - -import BubbleTheme from './themes/bubble'; -import SnowTheme from './themes/snow'; +} from './formats/direction.js'; +import Indent from './formats/indent.js'; + +import Blockquote from './formats/blockquote.js'; +import Header from './formats/header.js'; +import List from './formats/list.js'; + +import { BackgroundClass, BackgroundStyle } from './formats/background.js'; +import { ColorClass, ColorStyle } from './formats/color.js'; +import { FontClass, FontStyle } from './formats/font.js'; +import { SizeClass, SizeStyle } from './formats/size.js'; + +import Bold from './formats/bold.js'; +import Italic from './formats/italic.js'; +import Link from './formats/link.js'; +import Script from './formats/script.js'; +import Strike from './formats/strike.js'; +import Underline from './formats/underline.js'; + +import Formula from './formats/formula.js'; +import Image from './formats/image.js'; +import Video from './formats/video.js'; + +import CodeBlock, { Code as InlineCode } from './formats/code.js'; + +import Syntax from './modules/syntax.js'; +import Table from './modules/table.js'; +import Toolbar from './modules/toolbar.js'; + +import Icons from './ui/icons.js'; +import Picker from './ui/picker.js'; +import ColorPicker from './ui/color-picker.js'; +import IconPicker from './ui/icon-picker.js'; +import Tooltip from './ui/tooltip.js'; + +import BubbleTheme from './themes/bubble.js'; +import SnowTheme from './themes/snow.js'; Quill.register( { diff --git a/packages/quill/src/themes/base.ts b/packages/quill/src/themes/base.ts index 8d7edf63b8..3caf771ad1 100644 --- a/packages/quill/src/themes/base.ts +++ b/packages/quill/src/themes/base.ts @@ -1,18 +1,18 @@ import { merge } from 'lodash-es'; -import type Quill from '../core/quill'; -import Emitter from '../core/emitter'; -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'; -import Tooltip from '../ui/tooltip'; -import type { Range } from '../core/selection'; -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 type Selection from '../core/selection'; +import type Quill from '../core/quill.js'; +import Emitter from '../core/emitter.js'; +import Theme from '../core/theme.js'; +import type { ThemeOptions } from '../core/theme.js'; +import ColorPicker from '../ui/color-picker.js'; +import IconPicker from '../ui/icon-picker.js'; +import Picker from '../ui/picker.js'; +import Tooltip from '../ui/tooltip.js'; +import type { Range } from '../core/selection.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 type Selection from '../core/selection.js'; const ALIGNS = [false, 'center', 'right', 'justify']; diff --git a/packages/quill/src/themes/bubble.ts b/packages/quill/src/themes/bubble.ts index 85dcb2e4dc..63bf9ff8e3 100644 --- a/packages/quill/src/themes/bubble.ts +++ b/packages/quill/src/themes/bubble.ts @@ -1,13 +1,13 @@ import { merge } from 'lodash-es'; -import Emitter from '../core/emitter'; -import BaseTheme, { BaseTooltip } from './base'; -import { Range } from '../core/selection'; -import type { Bounds } from '../core/selection'; -import icons from '../ui/icons'; -import type Quill from '../core'; -import type { ThemeOptions } from '../core/theme'; -import type Toolbar from '../modules/toolbar'; -import type { ToolbarConfig } from '../modules/toolbar'; +import Emitter from '../core/emitter.js'; +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 type { ThemeOptions } from '../core/theme.js'; +import type Toolbar from '../modules/toolbar.js'; +import type { ToolbarConfig } from '../modules/toolbar.js'; const TOOLBAR_CONFIG: ToolbarConfig = [ ['bold', 'italic', 'link'], diff --git a/packages/quill/src/themes/snow.ts b/packages/quill/src/themes/snow.ts index 820ca25640..e99daebd0a 100644 --- a/packages/quill/src/themes/snow.ts +++ b/packages/quill/src/themes/snow.ts @@ -1,14 +1,14 @@ import { merge } from 'lodash-es'; -import Emitter from '../core/emitter'; -import BaseTheme, { BaseTooltip } from './base'; -import LinkBlot from '../formats/link'; -import { Range } from '../core/selection'; -import icons from '../ui/icons'; -import type Quill from '../core'; -import type { Context } from '../modules/keyboard'; -import type Toolbar from '../modules/toolbar'; -import type { ToolbarConfig } from '../modules/toolbar'; -import type { ThemeOptions } from '../core/theme'; +import Emitter from '../core/emitter.js'; +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 type { Context } from '../modules/keyboard.js'; +import type Toolbar from '../modules/toolbar.js'; +import type { ToolbarConfig } from '../modules/toolbar.js'; +import type { ThemeOptions } from '../core/theme.js'; const TOOLBAR_CONFIG: ToolbarConfig = [ [{ header: ['1', '2', '3', false] }], diff --git a/packages/quill/src/ui/color-picker.ts b/packages/quill/src/ui/color-picker.ts index 70af5d6502..f585578135 100644 --- a/packages/quill/src/ui/color-picker.ts +++ b/packages/quill/src/ui/color-picker.ts @@ -1,4 +1,4 @@ -import Picker from './picker'; +import Picker from './picker.js'; class ColorPicker extends Picker { constructor(select: HTMLSelectElement, label: string) { diff --git a/packages/quill/src/ui/icon-picker.ts b/packages/quill/src/ui/icon-picker.ts index 6e4e70371c..883f21c607 100644 --- a/packages/quill/src/ui/icon-picker.ts +++ b/packages/quill/src/ui/icon-picker.ts @@ -1,4 +1,4 @@ -import Picker from './picker'; +import Picker from './picker.js'; class IconPicker extends Picker { defaultItem: HTMLElement | null; diff --git a/packages/quill/src/ui/tooltip.ts b/packages/quill/src/ui/tooltip.ts index 82ff487609..07bf0013f8 100644 --- a/packages/quill/src/ui/tooltip.ts +++ b/packages/quill/src/ui/tooltip.ts @@ -1,5 +1,5 @@ -import type Quill from '../core'; -import type { Bounds } from '../core/selection'; +import type Quill from '../core.js'; +import type { Bounds } from '../core/selection.js'; const isScrollable = (el: Element) => { const { overflowY } = getComputedStyle(el, null); diff --git a/packages/quill/test/e2e/__dev_server__/webpack.config.ts b/packages/quill/test/e2e/__dev_server__/webpack.config.cjs similarity index 56% rename from packages/quill/test/e2e/__dev_server__/webpack.config.ts rename to packages/quill/test/e2e/__dev_server__/webpack.config.cjs index babd22724c..bc1b18fab4 100644 --- a/packages/quill/test/e2e/__dev_server__/webpack.config.ts +++ b/packages/quill/test/e2e/__dev_server__/webpack.config.cjs @@ -1,12 +1,13 @@ -import path from 'path'; -import HtmlWebpackPlugin from 'html-webpack-plugin'; -import common from '../../../webpack.common'; -import { merge } from 'webpack-merge'; -import type { Configuration } from 'webpack'; -import 'webpack-dev-server'; +/*eslint-env node*/ -export default (env: Record) => - merge(common, { +const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const common = require('../../../webpack.common.cjs'); +const { merge } = require('webpack-merge'); +require('webpack-dev-server'); + +module.exports = (env) => + merge(common, { plugins: [ new HtmlWebpackPlugin({ publicPath: '/', @@ -18,7 +19,7 @@ export default (env: Record) => }), ], devServer: { - port: env.port as string, + port: env.port, server: 'https', hot: false, liveReload: false, diff --git a/packages/quill/test/e2e/fixtures/index.ts b/packages/quill/test/e2e/fixtures/index.ts index 967061a37b..fb4ac01f42 100644 --- a/packages/quill/test/e2e/fixtures/index.ts +++ b/packages/quill/test/e2e/fixtures/index.ts @@ -1,6 +1,6 @@ import { test as base } from '@playwright/test'; -import EditorPage from '../pageobjects/EditorPage'; -import Composition from './Composition'; +import EditorPage from '../pageobjects/EditorPage.js'; +import Composition from './Composition.js'; export const test = base.extend<{ editorPage: EditorPage; diff --git a/packages/quill/test/e2e/full.spec.ts b/packages/quill/test/e2e/full.spec.ts index 9f1c23a90a..01e2b75a1b 100644 --- a/packages/quill/test/e2e/full.spec.ts +++ b/packages/quill/test/e2e/full.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@playwright/test'; -import { getSelectionInTextNode, SHORTKEY } from './utils'; -import { test, CHAPTER, P1, P2 } from './fixtures'; +import { getSelectionInTextNode, SHORTKEY } from './utils/index.js'; +import { test, CHAPTER, P1, P2 } from './fixtures/index.js'; test('compose an epic', async ({ page, editorPage }) => { await editorPage.open(); diff --git a/packages/quill/test/e2e/history.spec.ts b/packages/quill/test/e2e/history.spec.ts index 5832e55ffe..80027dcc4b 100644 --- a/packages/quill/test/e2e/history.spec.ts +++ b/packages/quill/test/e2e/history.spec.ts @@ -1,7 +1,7 @@ import { expect } from '@playwright/test'; import type { Page } from '@playwright/test'; -import { test } from './fixtures'; -import { SHORTKEY } from './utils'; +import { test } from './fixtures/index.js'; +import { SHORTKEY } from './utils/index.js'; const undo = (page: Page) => page.keyboard.press(`${SHORTKEY}+z`); const redo = (page: Page) => page.keyboard.press(`${SHORTKEY}+Shift+z`); diff --git a/packages/quill/test/e2e/list.spec.ts b/packages/quill/test/e2e/list.spec.ts index ca84d87e5d..346be210ad 100644 --- a/packages/quill/test/e2e/list.spec.ts +++ b/packages/quill/test/e2e/list.spec.ts @@ -1,6 +1,6 @@ import { expect } from '@playwright/test'; -import { test } from './fixtures'; -import { isMac } from './utils'; +import { test } from './fixtures/index.js'; +import { isMac } from './utils/index.js'; const listTypes = ['bullet', 'checked']; diff --git a/packages/quill/test/e2e/pageobjects/EditorPage.ts b/packages/quill/test/e2e/pageobjects/EditorPage.ts index cf5db9b0ed..0e770e0891 100644 --- a/packages/quill/test/e2e/pageobjects/EditorPage.ts +++ b/packages/quill/test/e2e/pageobjects/EditorPage.ts @@ -1,5 +1,5 @@ import type { Page } from '@playwright/test'; -import type Composition from '../fixtures/Composition'; +import type Composition from '../fixtures/Composition.js'; interface Op { insert?: string | Record; diff --git a/packages/quill/test/e2e/replaceSelection.spec.ts b/packages/quill/test/e2e/replaceSelection.spec.ts index 834a24599b..860beb2bbe 100644 --- a/packages/quill/test/e2e/replaceSelection.spec.ts +++ b/packages/quill/test/e2e/replaceSelection.spec.ts @@ -1,5 +1,5 @@ import { expect } from '@playwright/test'; -import { test } from './fixtures'; +import { test } from './fixtures/index.js'; test.describe('replace selection', () => { test.beforeEach(async ({ editorPage }) => { diff --git a/packages/quill/test/fuzz/editor.spec.ts b/packages/quill/test/fuzz/editor.spec.ts index 8cfeff9f14..78f7751dd7 100644 --- a/packages/quill/test/fuzz/editor.spec.ts +++ b/packages/quill/test/fuzz/editor.spec.ts @@ -1,10 +1,10 @@ import type { Op } from 'quill-delta'; import Delta, { AttributeMap } from 'quill-delta'; -import { choose, randomInt, runFuzz } from './__helpers__/utils'; -import { AlignClass } from '../../src/formats/align'; -import { FontClass } from '../../src/formats/font'; -import { SizeClass } from '../../src/formats/size'; -import Quill from '../../src/quill'; +import { choose, randomInt, runFuzz } from './__helpers__/utils.js'; +import { AlignClass } from '../../src/formats/align.js'; +import { FontClass } from '../../src/formats/font.js'; +import { SizeClass } from '../../src/formats/size.js'; +import Quill from '../../src/quill.js'; import { describe, expect, test } from 'vitest'; type AttributeDef = { name: string; values: (number | string | boolean)[] }; diff --git a/packages/quill/test/fuzz/tableEmbed.spec.ts b/packages/quill/test/fuzz/tableEmbed.spec.ts index c3b21e9820..a8d717f2cd 100644 --- a/packages/quill/test/fuzz/tableEmbed.spec.ts +++ b/packages/quill/test/fuzz/tableEmbed.spec.ts @@ -1,12 +1,12 @@ import type { AttributeMap } from 'quill-delta'; import Delta from 'quill-delta'; -import TableEmbed from '../../src/modules/tableEmbed'; +import TableEmbed from '../../src/modules/tableEmbed.js'; import type { CellData, TableData, TableRowColumnOp, -} from '../../src/modules/tableEmbed'; -import { choose, randomInt } from './__helpers__/utils'; +} from '../../src/modules/tableEmbed.js'; +import { choose, randomInt } from './__helpers__/utils.js'; import { beforeAll, describe, expect, test } from 'vitest'; const getRandomRowColumnId = () => { diff --git a/packages/quill/test/unit/__helpers__/expect.ts b/packages/quill/test/unit/__helpers__/expect.ts index 2262db1e19..6df26a2bc6 100644 --- a/packages/quill/test/unit/__helpers__/expect.ts +++ b/packages/quill/test/unit/__helpers__/expect.ts @@ -1,5 +1,5 @@ import { expect } from 'vitest'; -import { normalizeHTML } from './utils'; +import { normalizeHTML } from './utils.js'; const sortAttributes = (element: HTMLElement) => { const attributes = Array.from(element.attributes); diff --git a/packages/quill/test/unit/__helpers__/factory.ts b/packages/quill/test/unit/__helpers__/factory.ts index 445fe94272..6fa4b7f49d 100644 --- a/packages/quill/test/unit/__helpers__/factory.ts +++ b/packages/quill/test/unit/__helpers__/factory.ts @@ -1,15 +1,15 @@ import { Registry } from 'parchment'; import type { Attributor } from 'parchment'; -import Block from '../../../src/blots/block'; -import Break from '../../../src/blots/break'; -import Cursor from '../../../src/blots/cursor'; -import Scroll from '../../../src/blots/scroll'; -import TextBlot from '../../../src/blots/text'; -import ListItem, { ListContainer } from '../../../src/formats/list'; -import Inline from '../../../src/blots/inline'; -import Emitter from '../../../src/core/emitter'; -import { normalizeHTML } from './utils'; +import Block from '../../../src/blots/block.js'; +import Break from '../../../src/blots/break.js'; +import Cursor from '../../../src/blots/cursor.js'; +import Scroll from '../../../src/blots/scroll.js'; +import TextBlot from '../../../src/blots/text.js'; +import ListItem, { ListContainer } from '../../../src/formats/list.js'; +import Inline from '../../../src/blots/inline.js'; +import Emitter from '../../../src/core/emitter.js'; +import { normalizeHTML } from './utils.js'; export const createRegistry = (formats: unknown[] = []) => { const registry = new Registry(); diff --git a/packages/quill/test/unit/blots/block-embed.spec.ts b/packages/quill/test/unit/blots/block-embed.spec.ts index 6ec118bdeb..6fe2ff8fb5 100644 --- a/packages/quill/test/unit/blots/block-embed.spec.ts +++ b/packages/quill/test/unit/blots/block-embed.spec.ts @@ -2,9 +2,9 @@ import { describe, expect, test } from 'vitest'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import Video from '../../../src/formats/video'; -import Image from '../../../src/formats/image'; +} from '../__helpers__/factory.js'; +import Video from '../../../src/formats/video.js'; +import Image from '../../../src/formats/image.js'; const createScroll = (html: string) => baseCreateScroll(html, createRegistry([Video, Image])); diff --git a/packages/quill/test/unit/blots/block.spec.ts b/packages/quill/test/unit/blots/block.spec.ts index 21c1a22316..aa62bed406 100644 --- a/packages/quill/test/unit/blots/block.spec.ts +++ b/packages/quill/test/unit/blots/block.spec.ts @@ -2,9 +2,9 @@ import { describe, expect, test } from 'vitest'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import Header from '../../../src/formats/header'; -import Bold from '../../../src/formats/bold'; +} from '../__helpers__/factory.js'; +import Header from '../../../src/formats/header.js'; +import Bold from '../../../src/formats/bold.js'; const createScroll = (html: string) => baseCreateScroll(html, createRegistry([Header, Bold])); diff --git a/packages/quill/test/unit/blots/inline.spec.ts b/packages/quill/test/unit/blots/inline.spec.ts index 4f6cacfde2..0459e56bdf 100644 --- a/packages/quill/test/unit/blots/inline.spec.ts +++ b/packages/quill/test/unit/blots/inline.spec.ts @@ -1,7 +1,7 @@ import { describe, expect, test } from 'vitest'; -import { createRegistry, createScroll } from '../__helpers__/factory'; -import Bold from '../../../src/formats/bold'; -import Italic from '../../../src/formats/italic'; +import { createRegistry, createScroll } from '../__helpers__/factory.js'; +import Bold from '../../../src/formats/bold.js'; +import Italic from '../../../src/formats/italic.js'; describe('Inline', () => { test('format order', () => { diff --git a/packages/quill/test/unit/blots/scroll.spec.ts b/packages/quill/test/unit/blots/scroll.spec.ts index a8ca068656..a977373e44 100644 --- a/packages/quill/test/unit/blots/scroll.spec.ts +++ b/packages/quill/test/unit/blots/scroll.spec.ts @@ -1,13 +1,13 @@ import { describe, expect, test, vitest } from 'vitest'; -import Emitter from '../../../src/core/emitter'; -import Selection, { Range } from '../../../src/core/selection'; -import Cursor from '../../../src/blots/cursor'; -import Scroll from '../../../src/blots/scroll'; +import Emitter from '../../../src/core/emitter.js'; +import Selection, { Range } from '../../../src/core/selection.js'; +import Cursor from '../../../src/blots/cursor.js'; +import Scroll from '../../../src/blots/scroll.js'; import Delta from 'quill-delta'; -import { createRegistry } from '../__helpers__/factory'; -import { normalizeHTML, sleep } from '../__helpers__/utils'; -import Underline from '../../../src/formats/underline'; -import Strike from '../../../src/formats/strike'; +import { createRegistry } from '../__helpers__/factory.js'; +import { normalizeHTML, sleep } from '../__helpers__/utils.js'; +import Underline from '../../../src/formats/underline.js'; +import Strike from '../../../src/formats/strike.js'; const createScroll = (html: string) => { const emitter = new Emitter(); diff --git a/packages/quill/test/unit/core/composition.spec.ts b/packages/quill/test/unit/core/composition.spec.ts index 2a68f4d332..c306318599 100644 --- a/packages/quill/test/unit/core/composition.spec.ts +++ b/packages/quill/test/unit/core/composition.spec.ts @@ -1,9 +1,9 @@ -import Emitter from '../../../src/core/emitter'; -import Composition from '../../../src/core/composition'; -import Scroll from '../../../src/blots/scroll'; +import Emitter from '../../../src/core/emitter.js'; +import Composition from '../../../src/core/composition.js'; +import Scroll from '../../../src/blots/scroll.js'; import { describe, expect, test, vitest } from 'vitest'; -import { createRegistry } from '../__helpers__/factory'; -import Quill from '../../../src/core'; +import { createRegistry } from '../__helpers__/factory.js'; +import Quill from '../../../src/core.js'; describe('Composition', () => { test('triggers events on compositionstart', async () => { diff --git a/packages/quill/test/unit/core/editor.spec.ts b/packages/quill/test/unit/core/editor.spec.ts index 2519cce417..0c595332bb 100644 --- a/packages/quill/test/unit/core/editor.spec.ts +++ b/packages/quill/test/unit/core/editor.spec.ts @@ -1,32 +1,32 @@ import Delta from 'quill-delta'; -import Editor from '../../../src/core/editor'; -import Block from '../../../src/blots/block'; -import { Range } from '../../../src/core/selection'; -import Scroll from '../../../src/blots/scroll'; +import Editor from '../../../src/core/editor.js'; +import Block from '../../../src/blots/block.js'; +import { Range } from '../../../src/core/selection.js'; +import Scroll from '../../../src/blots/scroll.js'; import { Registry } from 'parchment'; -import Text from '../../../src/blots/text'; -import Emitter from '../../../src/core/emitter'; -import Break from '../../../src/blots/break'; +import Text from '../../../src/blots/text.js'; +import Emitter from '../../../src/core/emitter.js'; +import Break from '../../../src/blots/break.js'; import { describe, expect, test } from 'vitest'; -import { createRegistry } from '../__helpers__/factory'; -import List, { ListContainer } from '../../../src/formats/list'; -import Bold from '../../../src/formats/bold'; -import Image from '../../../src/formats/image'; -import Link from '../../../src/formats/link'; -import { FontClass } from '../../../src/formats/font'; -import Header from '../../../src/formats/header'; -import Italic from '../../../src/formats/italic'; -import { AlignClass } from '../../../src/formats/align'; -import Video from '../../../src/formats/video'; -import Strike from '../../../src/formats/strike'; -import Underline from '../../../src/formats/underline'; -import CodeBlock, { CodeBlockContainer } from '../../../src/formats/code'; -import { SizeClass } from '../../../src/formats/size'; -import Blockquote from '../../../src/formats/blockquote'; -import IndentClass from '../../../src/formats/indent'; -import { ColorClass } from '../../../src/formats/color'; -import Quill from '../../../src/core'; -import { normalizeHTML } from '../__helpers__/utils'; +import { createRegistry } from '../__helpers__/factory.js'; +import List, { ListContainer } from '../../../src/formats/list.js'; +import Bold from '../../../src/formats/bold.js'; +import Image from '../../../src/formats/image.js'; +import Link from '../../../src/formats/link.js'; +import { FontClass } from '../../../src/formats/font.js'; +import Header from '../../../src/formats/header.js'; +import Italic from '../../../src/formats/italic.js'; +import { AlignClass } from '../../../src/formats/align.js'; +import Video from '../../../src/formats/video.js'; +import Strike from '../../../src/formats/strike.js'; +import Underline from '../../../src/formats/underline.js'; +import CodeBlock, { CodeBlockContainer } from '../../../src/formats/code.js'; +import { SizeClass } from '../../../src/formats/size.js'; +import Blockquote from '../../../src/formats/blockquote.js'; +import IndentClass from '../../../src/formats/indent.js'; +import { ColorClass } from '../../../src/formats/color.js'; +import Quill from '../../../src/core.js'; +import { normalizeHTML } from '../__helpers__/utils.js'; const createEditor = (html: string) => { const container = document.createElement('div'); diff --git a/packages/quill/test/unit/core/emitter.spec.ts b/packages/quill/test/unit/core/emitter.spec.ts index 78061f553c..35bccc7383 100644 --- a/packages/quill/test/unit/core/emitter.spec.ts +++ b/packages/quill/test/unit/core/emitter.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest'; -import Emitter from '../../../src/core/emitter'; -import Quill from '../../../src/core'; +import Emitter from '../../../src/core/emitter.js'; +import Quill from '../../../src/core.js'; describe('emitter', () => { test('emit and on', () => { diff --git a/packages/quill/test/unit/core/quill.spec.ts b/packages/quill/test/unit/core/quill.spec.ts index c6359d5bb0..6dda6b881c 100644 --- a/packages/quill/test/unit/core/quill.spec.ts +++ b/packages/quill/test/unit/core/quill.spec.ts @@ -1,14 +1,14 @@ -import '../../../src/quill'; +import '../../../src/quill.js'; import Delta from 'quill-delta'; import { beforeEach, describe, expect, test, vitest } from 'vitest'; import type { MockedFunction } from 'vitest'; -import Emitter from '../../../src/core/emitter'; -import Theme from '../../../src/core/theme'; -import Toolbar from '../../../src/modules/toolbar'; -import Quill, { expandConfig, overload } from '../../../src/core/quill'; -import { Range } from '../../../src/core/selection'; -import Snow from '../../../src/themes/snow'; -import { normalizeHTML } from '../__helpers__/utils'; +import Emitter from '../../../src/core/emitter.js'; +import Theme from '../../../src/core/theme.js'; +import Toolbar from '../../../src/modules/toolbar.js'; +import Quill, { expandConfig, overload } from '../../../src/core/quill.js'; +import { Range } from '../../../src/core/selection.js'; +import Snow from '../../../src/themes/snow.js'; +import { normalizeHTML } from '../__helpers__/utils.js'; const createContainer = (html: string | { html: string } = '') => { const container = document.createElement('div'); diff --git a/packages/quill/test/unit/core/selection.spec.ts b/packages/quill/test/unit/core/selection.spec.ts index 4b866304f2..168a7240bc 100644 --- a/packages/quill/test/unit/core/selection.spec.ts +++ b/packages/quill/test/unit/core/selection.spec.ts @@ -1,17 +1,17 @@ -import Selection, { Range } from '../../../src/core/selection'; -import Cursor from '../../../src/blots/cursor'; -import Emitter from '../../../src/core/emitter'; +import Selection, { Range } from '../../../src/core/selection.js'; +import Cursor from '../../../src/blots/cursor.js'; +import Emitter from '../../../src/core/emitter.js'; import { expect, describe, test } from 'vitest'; -import { createRegistry, createScroll } from '../__helpers__/factory'; -import Bold from '../../../src/formats/bold'; -import Underline from '../../../src/formats/underline'; -import Image from '../../../src/formats/image'; -import Link from '../../../src/formats/link'; -import Italic from '../../../src/formats/italic'; -import Strike from '../../../src/formats/strike'; -import { ColorStyle } from '../../../src/formats/color'; -import { BackgroundStyle } from '../../../src/formats/background'; -import { SizeClass } from '../../../src/formats/size'; +import { createRegistry, createScroll } from '../__helpers__/factory.js'; +import Bold from '../../../src/formats/bold.js'; +import Underline from '../../../src/formats/underline.js'; +import Image from '../../../src/formats/image.js'; +import Link from '../../../src/formats/link.js'; +import Italic from '../../../src/formats/italic.js'; +import Strike from '../../../src/formats/strike.js'; +import { ColorStyle } from '../../../src/formats/color.js'; +import { BackgroundStyle } from '../../../src/formats/background.js'; +import { SizeClass } from '../../../src/formats/size.js'; const createSelection = (html: string, container = document.body) => { const scroll = createScroll( diff --git a/packages/quill/test/unit/formats/align.spec.ts b/packages/quill/test/unit/formats/align.spec.ts index 33f478162a..b8ba44bd35 100644 --- a/packages/quill/test/unit/formats/align.spec.ts +++ b/packages/quill/test/unit/formats/align.spec.ts @@ -1,11 +1,11 @@ import Delta from 'quill-delta'; -import Editor from '../../../src/core/editor'; +import Editor from '../../../src/core/editor.js'; import { describe, test, expect } from 'vitest'; import { createRegistry, createScroll as baseCreateScroll, -} from '../__helpers__/factory'; -import { AlignClass } from '../../../src/formats/align'; +} from '../__helpers__/factory.js'; +import { AlignClass } from '../../../src/formats/align.js'; const createScroll = (html: string) => baseCreateScroll(html, createRegistry([AlignClass])); diff --git a/packages/quill/test/unit/formats/bold.spec.ts b/packages/quill/test/unit/formats/bold.spec.ts index 048803e256..250e25d0c4 100644 --- a/packages/quill/test/unit/formats/bold.spec.ts +++ b/packages/quill/test/unit/formats/bold.spec.ts @@ -2,8 +2,8 @@ import { describe, expect, test } from 'vitest'; import { createRegistry, createScroll as baseCreateScroll, -} from '../__helpers__/factory'; -import Bold from '../../../src/formats/bold'; +} from '../__helpers__/factory.js'; +import Bold from '../../../src/formats/bold.js'; const createScroll = (html: string) => baseCreateScroll(html, createRegistry([Bold])); diff --git a/packages/quill/test/unit/formats/code.spec.ts b/packages/quill/test/unit/formats/code.spec.ts index 9caed27319..abcb6c881a 100644 --- a/packages/quill/test/unit/formats/code.spec.ts +++ b/packages/quill/test/unit/formats/code.spec.ts @@ -1,13 +1,16 @@ import Delta from 'quill-delta'; -import Editor from '../../../src/core/editor'; +import Editor from '../../../src/core/editor.js'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; +} from '../__helpers__/factory.js'; import { describe, expect, test } from 'vitest'; -import CodeBlock, { Code, CodeBlockContainer } from '../../../src/formats/code'; -import Italic from '../../../src/formats/italic'; -import Header from '../../../src/formats/header'; +import CodeBlock, { + Code, + CodeBlockContainer, +} from '../../../src/formats/code.js'; +import Italic from '../../../src/formats/italic.js'; +import Header from '../../../src/formats/header.js'; const createScroll = (html: string) => baseCreateScroll( diff --git a/packages/quill/test/unit/formats/color.spec.ts b/packages/quill/test/unit/formats/color.spec.ts index d124a141f3..332d6d9c44 100644 --- a/packages/quill/test/unit/formats/color.spec.ts +++ b/packages/quill/test/unit/formats/color.spec.ts @@ -1,12 +1,12 @@ import Delta from 'quill-delta'; -import Editor from '../../../src/core/editor'; +import Editor from '../../../src/core/editor.js'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import { ColorStyle } from '../../../src/formats/color'; +} from '../__helpers__/factory.js'; +import { ColorStyle } from '../../../src/formats/color.js'; import { describe, expect, test } from 'vitest'; -import Bold from '../../../src/formats/bold'; +import Bold from '../../../src/formats/bold.js'; const createScroll = (html: string) => baseCreateScroll(html, createRegistry([ColorStyle, Bold])); diff --git a/packages/quill/test/unit/formats/header.spec.ts b/packages/quill/test/unit/formats/header.spec.ts index 0070c1a4b3..507967b8be 100644 --- a/packages/quill/test/unit/formats/header.spec.ts +++ b/packages/quill/test/unit/formats/header.spec.ts @@ -2,10 +2,10 @@ import Delta from 'quill-delta'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import Editor from '../../../src/core/editor'; -import Header from '../../../src/formats/header'; -import Italic from '../../../src/formats/italic'; +} from '../__helpers__/factory.js'; +import Editor from '../../../src/core/editor.js'; +import Header from '../../../src/formats/header.js'; +import Italic from '../../../src/formats/italic.js'; import { describe, expect, test } from 'vitest'; const createScroll = (html: string) => diff --git a/packages/quill/test/unit/formats/indent.spec.ts b/packages/quill/test/unit/formats/indent.spec.ts index f0bcc37012..a3b5b5f6c8 100644 --- a/packages/quill/test/unit/formats/indent.spec.ts +++ b/packages/quill/test/unit/formats/indent.spec.ts @@ -2,10 +2,10 @@ import Delta from 'quill-delta'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import Editor from '../../../src/core/editor'; -import List, { ListContainer } from '../../../src/formats/list'; -import IndentClass from '../../../src/formats/indent'; +} from '../__helpers__/factory.js'; +import Editor from '../../../src/core/editor.js'; +import List, { ListContainer } from '../../../src/formats/list.js'; +import IndentClass from '../../../src/formats/indent.js'; import { describe, expect, test } from 'vitest'; const createScroll = (html: string) => diff --git a/packages/quill/test/unit/formats/link.spec.ts b/packages/quill/test/unit/formats/link.spec.ts index 416f4c6dab..aeaa3a3c03 100644 --- a/packages/quill/test/unit/formats/link.spec.ts +++ b/packages/quill/test/unit/formats/link.spec.ts @@ -2,11 +2,11 @@ import Delta from 'quill-delta'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import Editor from '../../../src/core/editor'; -import Link from '../../../src/formats/link'; +} from '../__helpers__/factory.js'; +import Editor from '../../../src/core/editor.js'; +import Link from '../../../src/formats/link.js'; import { describe, expect, test } from 'vitest'; -import { SizeClass } from '../../../src/formats/size'; +import { SizeClass } from '../../../src/formats/size.js'; const createScroll = (html: string) => baseCreateScroll(html, createRegistry([Link, SizeClass])); diff --git a/packages/quill/test/unit/formats/list.spec.ts b/packages/quill/test/unit/formats/list.spec.ts index a4a3f1af06..a12f020706 100644 --- a/packages/quill/test/unit/formats/list.spec.ts +++ b/packages/quill/test/unit/formats/list.spec.ts @@ -2,13 +2,13 @@ import Delta from 'quill-delta'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; -import Editor from '../../../src/core/editor'; +} from '../__helpers__/factory.js'; +import Editor from '../../../src/core/editor.js'; import { describe, expect, test } from 'vitest'; -import List, { ListContainer } from '../../../src/formats/list'; -import IndentClass from '../../../src/formats/indent'; -import { AlignClass } from '../../../src/formats/align'; -import Video from '../../../src/formats/video'; +import List, { ListContainer } from '../../../src/formats/list.js'; +import IndentClass from '../../../src/formats/indent.js'; +import { AlignClass } from '../../../src/formats/align.js'; +import Video from '../../../src/formats/video.js'; const createScroll = (html: string) => baseCreateScroll( diff --git a/packages/quill/test/unit/formats/script.spec.ts b/packages/quill/test/unit/formats/script.spec.ts index e5ec272453..e5275ac90a 100644 --- a/packages/quill/test/unit/formats/script.spec.ts +++ b/packages/quill/test/unit/formats/script.spec.ts @@ -1,9 +1,9 @@ -import Editor from '../../../src/core/editor'; -import Script from '../../../src/formats/script'; +import Editor from '../../../src/core/editor.js'; +import Script from '../../../src/formats/script.js'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; +} from '../__helpers__/factory.js'; import { describe, expect, test } from 'vitest'; const createScroll = (html: string) => diff --git a/packages/quill/test/unit/formats/table.spec.ts b/packages/quill/test/unit/formats/table.spec.ts index 515c218339..3cef833100 100644 --- a/packages/quill/test/unit/formats/table.spec.ts +++ b/packages/quill/test/unit/formats/table.spec.ts @@ -1,17 +1,17 @@ import Delta from 'quill-delta'; -import Editor from '../../../src/core/editor'; +import Editor from '../../../src/core/editor.js'; import { createScroll as baseCreateScroll, createRegistry, -} from '../__helpers__/factory'; +} from '../__helpers__/factory.js'; import { describe, expect, test } from 'vitest'; import { TableBody, TableCell, TableContainer, TableRow, -} from '../../../src/formats/table'; -import Header from '../../../src/formats/header'; +} from '../../../src/formats/table.js'; +import Header from '../../../src/formats/header.js'; const createScroll = (html: string) => baseCreateScroll( diff --git a/packages/quill/test/unit/modules/clipboard.spec.ts b/packages/quill/test/unit/modules/clipboard.spec.ts index 538156ac6c..a7e929dd44 100644 --- a/packages/quill/test/unit/modules/clipboard.spec.ts +++ b/packages/quill/test/unit/modules/clipboard.spec.ts @@ -1,31 +1,31 @@ import Delta from 'quill-delta'; import { describe, expect, test, vitest } from 'vitest'; -import Quill from '../../../src/core'; -import { Range } from '../../../src/core/selection'; -import Bold from '../../../src/formats/bold'; -import Header from '../../../src/formats/header'; -import Image from '../../../src/formats/image'; -import IndentClass from '../../../src/formats/indent'; -import Italic from '../../../src/formats/italic'; -import Link from '../../../src/formats/link'; -import List, { ListContainer } from '../../../src/formats/list'; +import Quill from '../../../src/core.js'; +import { Range } from '../../../src/core/selection.js'; +import Bold from '../../../src/formats/bold.js'; +import Header from '../../../src/formats/header.js'; +import Image from '../../../src/formats/image.js'; +import IndentClass from '../../../src/formats/indent.js'; +import Italic from '../../../src/formats/italic.js'; +import Link from '../../../src/formats/link.js'; +import List, { ListContainer } from '../../../src/formats/list.js'; import { TableBody, TableCell, TableContainer, TableRow, -} from '../../../src/formats/table'; -import Video from '../../../src/formats/video'; -import { createRegistry } from '../__helpers__/factory'; -import { sleep } from '../__helpers__/utils'; +} from '../../../src/formats/table.js'; +import Video from '../../../src/formats/video.js'; +import { createRegistry } from '../__helpers__/factory.js'; +import { sleep } from '../__helpers__/utils.js'; import type { RegistryDefinition } from 'parchment'; import { DirectionAttribute, DirectionClass, DirectionStyle, -} from '../../../src/formats/direction'; -import CodeBlock from '../../../src/formats/code'; -import { ColorClass, ColorStyle } from '../../../src/formats/color'; +} from '../../../src/formats/direction.js'; +import CodeBlock from '../../../src/formats/code.js'; +import { ColorClass, ColorStyle } from '../../../src/formats/color.js'; describe('Clipboard', () => { describe('events', () => { diff --git a/packages/quill/test/unit/modules/history.spec.ts b/packages/quill/test/unit/modules/history.spec.ts index d8ab3e8652..28c69ce14e 100644 --- a/packages/quill/test/unit/modules/history.spec.ts +++ b/packages/quill/test/unit/modules/history.spec.ts @@ -1,14 +1,14 @@ import Delta from 'quill-delta'; import { describe, expect, test, vitest } from 'vitest'; -import Quill from '../../../src/core'; -import { getLastChangeIndex } from '../../../src/modules/history'; -import type { HistoryOptions } from '../../../src/modules/history'; -import { createRegistry, createScroll } from '../__helpers__/factory'; -import { sleep } from '../__helpers__/utils'; -import Bold from '../../../src/formats/bold'; -import Image from '../../../src/formats/image'; -import Link from '../../../src/formats/link'; -import { AlignClass } from '../../../src/formats/align'; +import Quill from '../../../src/core.js'; +import { getLastChangeIndex } from '../../../src/modules/history.js'; +import type { HistoryOptions } from '../../../src/modules/history.js'; +import { createRegistry, createScroll } from '../__helpers__/factory.js'; +import { sleep } from '../__helpers__/utils.js'; +import Bold from '../../../src/formats/bold.js'; +import Image from '../../../src/formats/image.js'; +import Link from '../../../src/formats/link.js'; +import { AlignClass } from '../../../src/formats/align.js'; describe('History', () => { const scroll = createScroll( diff --git a/packages/quill/test/unit/modules/keyboard.spec.ts b/packages/quill/test/unit/modules/keyboard.spec.ts index e109b5f53e..405e1928cd 100644 --- a/packages/quill/test/unit/modules/keyboard.spec.ts +++ b/packages/quill/test/unit/modules/keyboard.spec.ts @@ -1,5 +1,8 @@ import { describe, expect, test } from 'vitest'; -import Keyboard, { SHORTKEY, normalize } from '../../../src/modules/keyboard'; +import Keyboard, { + SHORTKEY, + normalize, +} from '../../../src/modules/keyboard.js'; const assert = (value: T | null | undefined): T => { if (value == null) { diff --git a/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/googleDocs.spec.ts b/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/googleDocs.spec.ts index 5d4c1a6ae3..071607d5e5 100644 --- a/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/googleDocs.spec.ts +++ b/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/googleDocs.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import normalize from '../../../../../src/modules/normalizeExternalHTML/normalizers/googleDocs'; +import normalize from '../../../../../src/modules/normalizeExternalHTML/normalizers/googleDocs.js'; describe('Google Docs', () => { test('remove unnecessary b tags', () => { diff --git a/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/msWord.spec.ts b/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/msWord.spec.ts index 860a7ac699..255f7803cb 100644 --- a/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/msWord.spec.ts +++ b/packages/quill/test/unit/modules/normalizeExternalHTML/normalizers/msWord.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import normalize from '../../../../../src/modules/normalizeExternalHTML/normalizers/msWord'; +import normalize from '../../../../../src/modules/normalizeExternalHTML/normalizers/msWord.js'; describe('Microsoft Word', () => { test('keep the list style', () => { diff --git a/packages/quill/test/unit/modules/syntax.spec.ts b/packages/quill/test/unit/modules/syntax.spec.ts index 32e911a1f5..afdd5a5148 100644 --- a/packages/quill/test/unit/modules/syntax.spec.ts +++ b/packages/quill/test/unit/modules/syntax.spec.ts @@ -1,11 +1,11 @@ import hljs from 'highlight.js'; import Delta from 'quill-delta'; import { afterAll, beforeAll, describe, expect, test } from 'vitest'; -import Quill from '../../../src/core'; -import Bold from '../../../src/formats/bold'; -import Syntax, { CodeBlock, CodeToken } from '../../../src/modules/syntax'; -import { createRegistry } from '../__helpers__/factory'; -import { normalizeHTML, sleep } from '../__helpers__/utils'; +import Quill from '../../../src/core.js'; +import Bold from '../../../src/formats/bold.js'; +import Syntax, { CodeBlock, CodeToken } from '../../../src/modules/syntax.js'; +import { createRegistry } from '../__helpers__/factory.js'; +import { normalizeHTML, sleep } from '../__helpers__/utils.js'; const HIGHLIGHT_INTERVAL = 10; diff --git a/packages/quill/test/unit/modules/table.spec.ts b/packages/quill/test/unit/modules/table.spec.ts index c61830ad1c..89840d1ba8 100644 --- a/packages/quill/test/unit/modules/table.spec.ts +++ b/packages/quill/test/unit/modules/table.spec.ts @@ -1,15 +1,15 @@ import Delta from 'quill-delta'; -import Quill from '../../../src/core'; +import Quill from '../../../src/core.js'; import { describe, expect, test } from 'vitest'; -import { createRegistry } from '../__helpers__/factory'; +import { createRegistry } from '../__helpers__/factory.js'; import { TableBody, TableCell, TableContainer, TableRow, -} from '../../../src/formats/table'; -import { normalizeHTML } from '../__helpers__/utils'; -import Table from '../../../src/modules/table'; +} from '../../../src/formats/table.js'; +import { normalizeHTML } from '../__helpers__/utils.js'; +import Table from '../../../src/modules/table.js'; const createQuill = (html: string) => { Quill.register({ 'modules/table': Table }, true); diff --git a/packages/quill/test/unit/modules/tableEmbed.spec.ts b/packages/quill/test/unit/modules/tableEmbed.spec.ts index a83eaa8f16..16dfd398c3 100644 --- a/packages/quill/test/unit/modules/tableEmbed.spec.ts +++ b/packages/quill/test/unit/modules/tableEmbed.spec.ts @@ -1,5 +1,5 @@ import Delta from 'quill-delta'; -import { tableHandler } from '../../../src/modules/tableEmbed'; +import { tableHandler } from '../../../src/modules/tableEmbed.js'; import { afterEach, beforeEach, describe, expect, test } from 'vitest'; describe('tableHandler', () => { diff --git a/packages/quill/test/unit/modules/toolbar.spec.ts b/packages/quill/test/unit/modules/toolbar.spec.ts index c42e5d0d35..e8c0a4807a 100644 --- a/packages/quill/test/unit/modules/toolbar.spec.ts +++ b/packages/quill/test/unit/modules/toolbar.spec.ts @@ -1,19 +1,19 @@ import { describe, expect, test } from 'vitest'; -import Quill from '../../../src/core/quill'; -import Toolbar, { addControls } from '../../../src/modules/toolbar'; -import { normalizeHTML } from '../__helpers__/utils'; -import SnowTheme from '../../../src/themes/snow'; -import Clipboard from '../../../src/modules/clipboard'; -import Keyboard from '../../../src/modules/keyboard'; -import History from '../../../src/modules/history'; -import Uploader from '../../../src/modules/uploader'; -import { createRegistry } from '../__helpers__/factory'; -import Input from '../../../src/modules/input'; -import { SizeClass } from '../../../src/formats/size'; -import Bold from '../../../src/formats/bold'; -import Link from '../../../src/formats/link'; -import { AlignClass } from '../../../src/formats/align'; -import UINode from '../../../src/modules/uiNode'; +import Quill from '../../../src/core/quill.js'; +import Toolbar, { addControls } from '../../../src/modules/toolbar.js'; +import { normalizeHTML } from '../__helpers__/utils.js'; +import SnowTheme from '../../../src/themes/snow.js'; +import Clipboard from '../../../src/modules/clipboard.js'; +import Keyboard from '../../../src/modules/keyboard.js'; +import History from '../../../src/modules/history.js'; +import Uploader from '../../../src/modules/uploader.js'; +import { createRegistry } from '../__helpers__/factory.js'; +import Input from '../../../src/modules/input.js'; +import { SizeClass } from '../../../src/formats/size.js'; +import Bold from '../../../src/formats/bold.js'; +import Link from '../../../src/formats/link.js'; +import { AlignClass } from '../../../src/formats/align.js'; +import UINode from '../../../src/modules/uiNode.js'; const createContainer = (html = '') => { const container = document.body.appendChild(document.createElement('div')); diff --git a/packages/quill/test/unit/modules/uiNode.spec.ts b/packages/quill/test/unit/modules/uiNode.spec.ts index 19eaa8fb88..d9737b43f7 100644 --- a/packages/quill/test/unit/modules/uiNode.spec.ts +++ b/packages/quill/test/unit/modules/uiNode.spec.ts @@ -1,9 +1,9 @@ -import '../../../src/quill'; +import '../../../src/quill.js'; import { describe, expect, test } from 'vitest'; import UINode, { TTL_FOR_VALID_SELECTION_CHANGE, -} from '../../../src/modules/uiNode'; -import Quill, { Delta } from '../../../src/core'; +} from '../../../src/modules/uiNode.js'; +import Quill, { Delta } from '../../../src/core.js'; // Fake timer is not supported in browser mode yet. const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); diff --git a/packages/quill/test/unit/theme/base/tooltip.spec.ts b/packages/quill/test/unit/theme/base/tooltip.spec.ts index c009c72ccb..ebc3bfecb1 100644 --- a/packages/quill/test/unit/theme/base/tooltip.spec.ts +++ b/packages/quill/test/unit/theme/base/tooltip.spec.ts @@ -1,8 +1,8 @@ import { describe, expect, test } from 'vitest'; -import Quill from '../../../../src/core'; -import Video from '../../../../src/formats/video'; -import { BaseTooltip } from '../../../../src/themes/base'; -import { createRegistry } from '../../__helpers__/factory'; +import Quill from '../../../../src/core.js'; +import Video from '../../../../src/formats/video.js'; +import { BaseTooltip } from '../../../../src/themes/base.js'; +import { createRegistry } from '../../__helpers__/factory.js'; class Tooltip extends BaseTooltip { static TEMPLATE = ''; diff --git a/packages/quill/test/unit/ui/picker.spec.ts b/packages/quill/test/unit/ui/picker.spec.ts index 8973a73270..2eb14e43a2 100644 --- a/packages/quill/test/unit/ui/picker.spec.ts +++ b/packages/quill/test/unit/ui/picker.spec.ts @@ -1,5 +1,5 @@ import { describe, expect, test } from 'vitest'; -import Picker from '../../../src/ui/picker'; +import Picker from '../../../src/ui/picker.js'; describe('Picker', () => { const setup = () => { diff --git a/packages/quill/tsconfig.json b/packages/quill/tsconfig.json index c99fce116e..ad105b7c1e 100644 --- a/packages/quill/tsconfig.json +++ b/packages/quill/tsconfig.json @@ -1,8 +1,7 @@ { "ts-node": { "compilerOptions": { - "esModuleInterop": true, - "module": "commonjs" + "esModuleInterop": true } }, "compilerOptions": { diff --git a/packages/quill/webpack.common.ts b/packages/quill/webpack.common.cjs similarity index 84% rename from packages/quill/webpack.common.ts rename to packages/quill/webpack.common.cjs index bb6cbc7ff4..59122d876e 100644 --- a/packages/quill/webpack.common.ts +++ b/packages/quill/webpack.common.cjs @@ -1,6 +1,7 @@ -import { resolve } from 'path'; -import type { Configuration } from 'webpack'; -import MiniCssExtractPlugin from 'mini-css-extract-plugin'; +/*eslint-env node*/ + +const { resolve } = require('path'); +const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const tsRules = { test: /\.ts$/, @@ -27,7 +28,7 @@ const stylRules = { use: [MiniCssExtractPlugin.loader, 'css-loader', 'stylus-loader'], }; -export default { +module.exports = { entry: { quill: './src/quill.ts', 'quill.core': './src/core.ts', @@ -47,6 +48,9 @@ export default { }, resolve: { extensions: ['.js', '.styl', '.ts'], + extensionAlias: { + '.js': ['.ts', '.js'], + }, }, module: { rules: [tsRules, stylRules, svgRules], @@ -56,4 +60,4 @@ export default { filename: '[name]', }), ], -} satisfies Configuration; +}; diff --git a/packages/quill/webpack.config.ts b/packages/quill/webpack.config.cjs similarity index 69% rename from packages/quill/webpack.config.ts rename to packages/quill/webpack.config.cjs index b9d3997f75..41d6c907f8 100644 --- a/packages/quill/webpack.config.ts +++ b/packages/quill/webpack.config.cjs @@ -1,10 +1,11 @@ -import { BannerPlugin, DefinePlugin } from 'webpack'; -import type { Configuration } from 'webpack'; -import common from './webpack.common'; -import { merge } from 'webpack-merge'; -import 'webpack-dev-server'; -import { readFileSync } from 'fs'; -import { join, resolve } from 'path'; +/*eslint-env node*/ + +const { BannerPlugin, DefinePlugin } = require('webpack'); +const common = require('./webpack.common.cjs'); +const { merge } = require('webpack-merge'); +require('webpack-dev-server'); +const { readFileSync } = require('fs'); +const { join, resolve } = require('path'); const pkg = JSON.parse(readFileSync(join(__dirname, 'package.json'), 'utf8')); @@ -22,8 +23,8 @@ const constantPack = new DefinePlugin({ QUILL_VERSION: JSON.stringify(pkg.version), }); -export default (env: Record) => - merge(common, { +module.exports = (env) => + merge(common, { mode: env.production ? 'production' : 'development', devtool: 'source-map', plugins: [bannerPack, constantPack], diff --git a/packages/website/src/playground/react/Editor.js b/packages/website/src/playground/react/Editor.js index eedc8ed377..6e2718cb06 100644 --- a/packages/website/src/playground/react/Editor.js +++ b/packages/website/src/playground/react/Editor.js @@ -44,7 +44,7 @@ const Editor = forwardRef( ref.current = null; container.innerHTML = ''; }; - }, []); + }, [ref]); return
; },