🐛 Fix esm module incompatibilities on text-editor with node

This commit is contained in:
Andrey Antukh 2024-11-19 17:20:16 +01:00
parent 04a0d867b0
commit 7faa9e970e
19 changed files with 52 additions and 52 deletions

View file

@ -11,7 +11,7 @@ import commands from "./commands/index.js";
import ChangeController from './controllers/ChangeController.js'; import ChangeController from './controllers/ChangeController.js';
import SelectionController from './controllers/SelectionController.js'; import SelectionController from './controllers/SelectionController.js';
import { createSelectionImposterFromClientRects } from './selection/Imposter.js'; import { createSelectionImposterFromClientRects } from './selection/Imposter.js';
import { addEventListeners, removeEventListeners } from "./Event"; import { addEventListeners, removeEventListeners } from "./Event.js";
import { createRoot, createEmptyRoot } from './content/dom/Root.js'; import { createRoot, createEmptyRoot } from './content/dom/Root.js';
import { createParagraph, fixParagraph, getParagraph } from './content/dom/Paragraph.js'; import { createParagraph, fixParagraph, getParagraph } from './content/dom/Paragraph.js';
import { createEmptyInline, createInline } from './content/dom/Inline.js'; import { createEmptyInline, createInline } from './content/dom/Inline.js';

View file

@ -6,7 +6,7 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { mapContentFragmentFromHTML, mapContentFragmentFromString } from '~/editor/content/dom/Content'; import { mapContentFragmentFromHTML, mapContentFragmentFromString } from '../content/dom/Content.js';
/** /**
* When the user pastes some HTML, what we do is generate * When the user pastes some HTML, what we do is generate

View file

@ -6,13 +6,13 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { createInline } from "./Inline"; import { createInline } from "./Inline.js";
import { import {
createEmptyParagraph, createEmptyParagraph,
createParagraph, createParagraph,
isLikeParagraph, isLikeParagraph,
} from "./Paragraph"; } from "./Paragraph.js";
import { isDisplayBlock, normalizeStyles } from "./Style"; import { isDisplayBlock, normalizeStyles } from "./Style.js";
/** /**
* Maps any HTML into a valid content DOM element. * Maps any HTML into a valid content DOM element.

View file

@ -1,5 +1,5 @@
import { describe, test, expect } from 'vitest'; import { describe, test, expect } from 'vitest';
import { mapContentFragmentFromHTML, mapContentFragmentFromString } from './Content'; import { mapContentFragmentFromHTML, mapContentFragmentFromString } from './Content.js';
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe('Content', () => { describe('Content', () => {

View file

@ -6,7 +6,7 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { setStyles } from "./Style"; import { setStyles } from "./Style.js";
/** /**
* @typedef {Object} CreateElementOptions * @typedef {Object} CreateElementOptions

View file

@ -1,5 +1,5 @@
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
import { createElement, isElement, createRandomId, isOffsetAtStart, isOffsetAtEnd } from "./Element"; import { createElement, isElement, createRandomId, isOffsetAtStart, isOffsetAtEnd } from "./Element.js";
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("Element", () => { describe("Element", () => {

View file

@ -11,10 +11,10 @@ import {
isElement, isElement,
isOffsetAtStart, isOffsetAtStart,
isOffsetAtEnd, isOffsetAtEnd,
} from "./Element"; } from "./Element.js";
import { createLineBreak, isLineBreak } from "./LineBreak"; import { createLineBreak, isLineBreak } from "./LineBreak.js";
import { setStyles, mergeStyles } from "./Style"; import { setStyles, mergeStyles } from "./Style.js";
import { createRandomId } from "./Element"; import { createRandomId } from "./Element.js";
export const TAG = "SPAN"; export const TAG = "SPAN";
export const TYPE = "inline"; export const TYPE = "inline";

View file

@ -1,6 +1,6 @@
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
import { createEmptyInline, createInline, getInline, getInlineLength, isInline, isInlineEnd, isInlineStart, isLikeInline, splitInline, TAG, TYPE } from "./Inline"; import { createEmptyInline, createInline, getInline, getInlineLength, isInline, isInlineEnd, isInlineStart, isLikeInline, splitInline, TAG, TYPE } from "./Inline.js";
import { createLineBreak } from "./LineBreak"; import { createLineBreak } from "./LineBreak.js";
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("Inline", () => { describe("Inline", () => {

View file

@ -1,5 +1,5 @@
import { describe, expect, test } from 'vitest'; import { describe, expect, test } from 'vitest';
import { createLineBreak } from './LineBreak'; import { createLineBreak } from './LineBreak.js';
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe('LineBreak', () => { describe('LineBreak', () => {

View file

@ -11,7 +11,7 @@ import {
isElement, isElement,
isOffsetAtStart, isOffsetAtStart,
isOffsetAtEnd, isOffsetAtEnd,
} from "./Element"; } from "./Element.js";
import { import {
isInline, isInline,
isLikeInline, isLikeInline,
@ -21,11 +21,11 @@ import {
createEmptyInline, createEmptyInline,
isInlineEnd, isInlineEnd,
splitInline, splitInline,
} from "./Inline"; } from "./Inline.js";
import { createLineBreak, isLineBreak } from "./LineBreak"; import { createLineBreak, isLineBreak } from "./LineBreak.js";
import { setStyles } from "./Style"; import { setStyles } from "./Style.js";
import { createRandomId } from "./Element"; import { createRandomId } from "./Element.js";
import { isEmptyTextNode, isTextNode } from './TextNode'; import { isEmptyTextNode, isTextNode } from './TextNode.js';
export const TAG = "DIV"; export const TAG = "DIV";
export const TYPE = "paragraph"; export const TYPE = "paragraph";

View file

@ -12,8 +12,8 @@ import {
splitParagraph, splitParagraph,
splitParagraphAtNode, splitParagraphAtNode,
isEmptyParagraph, isEmptyParagraph,
} from "./Paragraph"; } from "./Paragraph.js";
import { createInline, isInline } from "./Inline"; import { createInline, isInline } from "./Inline.js";
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("Paragraph", () => { describe("Paragraph", () => {

View file

@ -6,10 +6,10 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { createElement, isElement } from "./Element"; import { createElement, isElement } from "./Element.js";
import { createEmptyParagraph, isParagraph } from "./Paragraph"; import { createEmptyParagraph, isParagraph } from "./Paragraph.js";
import { setStyles } from "./Style"; import { setStyles } from "./Style.js";
import { createRandomId } from "./Element"; import { createRandomId } from "./Element.js";
export const TAG = "DIV"; export const TAG = "DIV";
export const TYPE = "root"; export const TYPE = "root";

View file

@ -1,5 +1,5 @@
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
import { createEmptyRoot, createRoot, setRootStyles, TAG, TYPE } from './Root' import { createEmptyRoot, createRoot, setRootStyles, TAG, TYPE } from './Root.js'
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("Root", () => { describe("Root", () => {

View file

@ -6,7 +6,7 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { getFills } from "./Color"; import { getFills } from "./Color.js";
const DEFAULT_FONT_SIZE = "16px"; const DEFAULT_FONT_SIZE = "16px";
const DEFAULT_LINE_HEIGHT = "1.2"; const DEFAULT_LINE_HEIGHT = "1.2";

View file

@ -1,5 +1,5 @@
import { describe, test, expect, vi } from "vitest"; import { describe, test, expect, vi } from "vitest";
import { getStyles, isDisplayBlock, isDisplayInline, setStyle, setStyles } from "./Style"; import { getStyles, isDisplayBlock, isDisplayInline, setStyle, setStyles } from "./Style.js";
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("Style", () => { describe("Style", () => {

View file

@ -6,10 +6,10 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { isInline } from "./Inline"; import { isInline } from "./Inline.js";
import { isLineBreak } from "./LineBreak"; import { isLineBreak } from "./LineBreak.js";
import { isParagraph } from "./Paragraph"; import { isParagraph } from "./Paragraph.js";
import { isRoot } from "./Root"; import { isRoot } from "./Root.js";
/** /**
* Returns true if the node is "like" * Returns true if the node is "like"

View file

@ -1,6 +1,6 @@
import { describe, test, expect } from 'vitest'; import { describe, test, expect } from 'vitest';
import { isTextNode, getTextNodeLength } from './TextNode'; import { isTextNode, getTextNodeLength } from './TextNode.js';
import { createLineBreak } from './LineBreak'; import { createLineBreak } from './LineBreak.js';
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("TextNode", () => { describe("TextNode", () => {

View file

@ -1,9 +1,9 @@
import { describe, test, expect } from "vitest"; import { describe, test, expect } from "vitest";
import TextNodeIterator from "./TextNodeIterator"; import TextNodeIterator from "./TextNodeIterator.js";
import { createInline } from "./Inline"; import { createInline } from "./Inline.js";
import { createParagraph } from "./Paragraph"; import { createParagraph } from "./Paragraph.js";
import { createRoot } from "./Root"; import { createRoot } from "./Root.js";
import { createLineBreak } from "./LineBreak"; import { createLineBreak } from "./LineBreak.js";
/* @vitest-environment jsdom */ /* @vitest-environment jsdom */
describe("TextNodeIterator", () => { describe("TextNodeIterator", () => {

View file

@ -6,7 +6,7 @@
* Copyright (c) KALEIDOS INC * Copyright (c) KALEIDOS INC
*/ */
import { createLineBreak, isLineBreak } from "~/editor/content/dom/LineBreak"; import { createLineBreak, isLineBreak } from "../content/dom/LineBreak.js";
import { import {
createInline, createInline,
createInlineFrom, createInlineFrom,
@ -19,7 +19,7 @@ import {
mergeInlines, mergeInlines,
splitInline, splitInline,
createEmptyInline, createEmptyInline,
} from "~/editor/content/dom/Inline"; } from "../content/dom/Inline.js";
import { import {
createEmptyParagraph, createEmptyParagraph,
isEmptyParagraph, isEmptyParagraph,
@ -32,21 +32,21 @@ import {
splitParagraphAtNode, splitParagraphAtNode,
mergeParagraphs, mergeParagraphs,
fixParagraph, fixParagraph,
} from "~/editor/content/dom/Paragraph"; } from "../content/dom/Paragraph.js";
import { import {
removeBackward, removeBackward,
removeForward, removeForward,
replaceWith, replaceWith,
insertInto, insertInto,
removeSlice, removeSlice,
} from "~/editor/content/Text"; } from "../content/Text.js";
import { getTextNodeLength, getClosestTextNode, isTextNode } from "~/editor/content/dom/TextNode"; import { getTextNodeLength, getClosestTextNode, isTextNode } from "../content/dom/TextNode.js";
import TextNodeIterator from "~/editor/content/dom/TextNodeIterator"; import TextNodeIterator from "../content/dom/TextNodeIterator.js";
import TextEditor from "~/editor/TextEditor"; import TextEditor from "../TextEditor.js";
import CommandMutations from "~/editor/commands/CommandMutations"; import CommandMutations from "../commands/CommandMutations.js";
import { setRootStyles } from "~/editor/content/dom/Root"; import { setRootStyles } from "../content/dom/Root.js";
import { SelectionDirection } from "./SelectionDirection"; import { SelectionDirection } from "./SelectionDirection.js";
import SafeGuard from './SafeGuard'; import SafeGuard from "./SafeGuard.js";
const SAFE_GUARD = true; const SAFE_GUARD = true;
const SAFE_GUARD_TIME = true; const SAFE_GUARD_TIME = true;