@domternal/vanilla 0.9.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,14 +21,14 @@ See <u>[Packages & Bundle Size](https://domternal.dev/v1/packages)</u> for a ful
21
21
  - **Vue components** - composable `Domternal` component, `useEditor`/`useEditorState` composables, toolbar, bubble menu, floating menu, emoji picker, notion color picker, custom node views (Vue 3.3+)
22
22
  - **Vanilla wrapper** - framework-free class-based API for Astro, Svelte, Solid, plain HTML, and Web Components - editor, toolbar, bubble menu, floating menu, emoji picker, notion color picker
23
23
  - **Notion-style block UX** - drag-to-reorder, block context menu, slash command, smart paste, keyboard reorder, floating Table of Contents
24
- - **65+ extensions across 15 packages** - nodes, marks, and behavior extensions
25
- - **120+ chainable commands** - `editor.chain().focus().toggleBold().run()`
24
+ - **70+ extensions across 16 packages** - nodes, marks, and behavior extensions
25
+ - **125+ chainable commands** - `editor.chain().focus().toggleBold().run()`
26
26
  - **Full table support** - cell merging, column resize, row/column controls, cell toolbar, all free and MIT licensed
27
27
  - **Tree-shakeable** - import only what you use, your bundler strips the rest
28
28
  - **~44 KB gzipped** (own code), <u>[see Packages](https://domternal.dev/v1/packages)</u> for full bundle breakdown with ProseMirror
29
29
  - **TypeScript first** - 100% typed, zero `any`
30
30
  - **15,000+ tests** - 4,000+ unit and 11,000+ E2E across 230+ Playwright specs and 4 demo apps
31
- - **Light and dark theme** - 70+ CSS custom properties for full visual control
31
+ - **Light and dark theme** - 120+ CSS custom properties for full visual control
32
32
  - **Inline styles export** - `getHTML({ styled: true })` produces inline CSS ready for email clients, CMS, and Google Docs
33
33
  - **SSR helpers** - `generateHTML`, `generateJSON`, `generateText` for server-side rendering
34
34
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Document, Paragraph, Text, BaseKeymap, History, PluginKey, defaultIcons, Editor, ToolbarController, positionFloatingOnce, defaultBubbleContexts, createBubbleMenuPlugin, createFloatingMenuPlugin, FloatingMenuController, positionFloating } from '@domternal/core';
1
+ import { Document, Paragraph, Text, BaseKeymap, History, PluginKey, defaultIcons, Editor, ToolbarController, positionFloatingOnce, refocusEditorAfterCommand, defaultBubbleContexts, createBubbleMenuPlugin, createFloatingMenuPlugin, FloatingMenuController, positionFloating } from '@domternal/core';
2
2
 
3
3
  // src/shared/isBrowser.ts
4
4
  var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
@@ -154,7 +154,7 @@ var DomternalEditor = class extends EventTarget {
154
154
  // === Internal ===
155
155
  #wireEditorEvents() {
156
156
  this.#transactionHandler = ({ transaction }) => {
157
- if (transaction.docChanged) {
157
+ if (transaction.docChanged && !transaction.getMeta("skipUpdate")) {
158
158
  this.#onUpdate?.({ editor: this.editor });
159
159
  this.dispatchEvent(
160
160
  new CustomEvent("update", { detail: { editor: this.editor } })
@@ -757,9 +757,7 @@ var DomternalToolbar = class extends EventTarget {
757
757
  return;
758
758
  }
759
759
  this.#controller.executeCommand(item);
760
- requestAnimationFrame(() => {
761
- this.#editor.view.focus();
762
- });
760
+ refocusEditorAfterCommand(this.#editor.view);
763
761
  }
764
762
  #onDropdownToggle(dd) {
765
763
  const wasOpen = this.#controller.openDropdown === dd.name;
@@ -791,9 +789,7 @@ var DomternalToolbar = class extends EventTarget {
791
789
  } else {
792
790
  this.#controller.executeCommand(item);
793
791
  }
794
- requestAnimationFrame(() => {
795
- this.#editor.view.focus();
796
- });
792
+ refocusEditorAfterCommand(this.#editor.view);
797
793
  }
798
794
  #onButtonFocus(name) {
799
795
  const index = this.#controller.getFlatIndex(name);
@@ -857,7 +853,7 @@ var DomternalToolbar = class extends EventTarget {
857
853
  #focusCurrentButton() {
858
854
  const buttons = this.host.querySelectorAll(".dm-toolbar-button");
859
855
  const btn = buttons.item(this.#controller.focusedIndex);
860
- btn.focus();
856
+ btn?.focus();
861
857
  }
862
858
  #focusDropdownItem(direction, first) {
863
859
  const panel = this.#dropdownPanelEl;
@@ -1560,9 +1556,7 @@ var DomternalBubbleMenu = class extends EventTarget {
1560
1556
  #onDropdownItemClick(sub) {
1561
1557
  this.closeDropdown();
1562
1558
  ToolbarController.executeItem(this.#editor, sub);
1563
- requestAnimationFrame(() => {
1564
- this.#editor.view.focus();
1565
- });
1559
+ refocusEditorAfterCommand(this.#editor.view);
1566
1560
  }
1567
1561
  // === Dropdown lifecycle ===
1568
1562
  #attachDropdownListeners(trigger, panel) {
@@ -1811,9 +1805,7 @@ var DomternalFloatingMenu = class extends EventTarget {
1811
1805
  #onItemClick(item) {
1812
1806
  if (this.#destroyed || !this.#controller) return;
1813
1807
  this.#controller.execute(item);
1814
- requestAnimationFrame(() => {
1815
- this.#editor.view.focus();
1816
- });
1808
+ refocusEditorAfterCommand(this.#editor.view);
1817
1809
  }
1818
1810
  #onKeyDown(event) {
1819
1811
  if (!this.#controller) return;