@domternal/react 0.11.2 → 0.12.1
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/dist/index.d.ts +6 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/useEditor.d.ts +6 -0
- package/dist/useEditor.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,12 @@ declare const DEFAULT_EXTENSIONS: AnyExtension[];
|
|
|
7
7
|
interface UseEditorOptions {
|
|
8
8
|
/** Custom extensions to add to the editor. */
|
|
9
9
|
extensions?: AnyExtension[];
|
|
10
|
+
/**
|
|
11
|
+
* Whether the built-in History extension is included. Disable it when an
|
|
12
|
+
* extension brings its own undo/redo, such as collaborative editing.
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
history?: boolean;
|
|
10
16
|
/** Initial editor content (HTML string or JSON). */
|
|
11
17
|
content?: Content;
|
|
12
18
|
/** Whether the editor is editable. @default true */
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext, forwardRef, useImperativeHandle, useRef, useEffect, useState, useMemo, useCallback, useSyncExternalStore, useContext, Fragment, useLayoutEffect, createElement } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Document, Paragraph, Text, BaseKeymap, History, Editor, refocusEditorAfterCommand, positionFloatingOnce, PluginKey, createFloatingMenuPlugin, FloatingMenuController, defaultIcons, positionFloating, ToolbarController, defaultBubbleContexts, createBubbleMenuPlugin } from '@domternal/core';
|
|
3
3
|
export { Editor, generateHTML, generateJSON, generateText } from '@domternal/core';
|
|
4
4
|
import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
@@ -10,6 +10,7 @@ var DEFAULT_EXTENSIONS = [Document, Paragraph, Text, BaseKeymap, History];
|
|
|
10
10
|
function useEditor(options = {}, deps) {
|
|
11
11
|
const {
|
|
12
12
|
extensions = [],
|
|
13
|
+
history = true,
|
|
13
14
|
content = "",
|
|
14
15
|
editable = true,
|
|
15
16
|
autofocus = false,
|
|
@@ -45,9 +46,10 @@ function useEditor(options = {}, deps) {
|
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
function buildEditorInstance(element, initialContent, focus) {
|
|
49
|
+
const defaults = history ? DEFAULT_EXTENSIONS : DEFAULT_EXTENSIONS.filter((extension) => extension.name !== "history");
|
|
48
50
|
const ed = new Editor({
|
|
49
51
|
element,
|
|
50
|
-
extensions: [...
|
|
52
|
+
extensions: [...defaults, ...extensions],
|
|
51
53
|
content: initialContent,
|
|
52
54
|
editable,
|
|
53
55
|
autofocus: focus
|