@handlewithcare/react-prosemirror 3.1.0-tiptap.42 → 3.1.0-tiptap.43
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 +26 -0
- package/dist/cjs/ReactEditorView.js +74 -70
- package/dist/cjs/StaticEditorView.js +21 -18
- package/dist/cjs/browser.js +3 -1
- package/dist/cjs/commands/reorderSiblings.js +13 -9
- package/dist/cjs/components/ChildNodeViews.js +71 -68
- package/dist/cjs/components/CursorWrapper.js +17 -26
- package/dist/cjs/components/LayoutGroup.js +16 -12
- package/dist/cjs/components/NativeWidgetView.js +19 -15
- package/dist/cjs/components/OutputSpec.js +13 -9
- package/dist/cjs/components/ProseMirror.js +27 -37
- package/dist/cjs/components/ProseMirrorDoc.js +18 -25
- package/dist/cjs/components/SeparatorHackView.js +20 -17
- package/dist/cjs/components/TextNodeView.js +20 -22
- package/dist/cjs/components/TrailingHackView.js +17 -13
- package/dist/cjs/components/WidgetView.js +18 -14
- package/dist/cjs/components/marks/DefaultMarkView.js +15 -27
- package/dist/cjs/components/marks/MarkView.js +23 -32
- package/dist/cjs/components/marks/MarkViewConstructorView.js +22 -38
- package/dist/cjs/components/marks/ReactMarkView.js +16 -27
- package/dist/cjs/components/nodes/DefaultNodeView.js +15 -27
- package/dist/cjs/components/nodes/DocNodeView.js +16 -12
- package/dist/cjs/components/nodes/NodeView.js +26 -33
- package/dist/cjs/components/nodes/NodeViewConstructorView.js +29 -45
- package/dist/cjs/components/nodes/ReactNodeView.js +27 -39
- package/dist/cjs/constants.js +10 -6
- package/dist/cjs/contexts/ChildDescriptionsContext.js +3 -1
- package/dist/cjs/contexts/EditorContext.js +3 -1
- package/dist/cjs/contexts/EditorStateContext.js +3 -1
- package/dist/cjs/contexts/IgnoreMutationContext.js +3 -1
- package/dist/cjs/contexts/LayoutGroupContext.js +3 -1
- package/dist/cjs/contexts/NodeViewContext.js +3 -1
- package/dist/cjs/contexts/SelectNodeContext.js +3 -1
- package/dist/cjs/contexts/StopEventContext.js +3 -1
- package/dist/cjs/decorations/ReactWidgetType.js +19 -13
- package/dist/cjs/decorations/computeDocDeco.js +5 -3
- package/dist/cjs/decorations/iterDeco.js +19 -17
- package/dist/cjs/decorations/viewDecorations.js +15 -12
- package/dist/cjs/dom.js +34 -13
- package/dist/cjs/findDOMNode.js +9 -5
- package/dist/cjs/hooks/useClientLayoutEffect.js +3 -1
- package/dist/cjs/hooks/useComponentEventListeners.js +7 -6
- package/dist/cjs/hooks/useEditor.js +28 -30
- package/dist/cjs/hooks/useEditorEffect.js +9 -7
- package/dist/cjs/hooks/useEditorEventCallback.js +9 -7
- package/dist/cjs/hooks/useEditorEventListener.js +8 -6
- package/dist/cjs/hooks/useEditorState.js +5 -3
- package/dist/cjs/hooks/useEffectEvent.js +3 -1
- package/dist/cjs/hooks/useForceUpdate.js +3 -1
- package/dist/cjs/hooks/useIgnoreMutation.js +9 -7
- package/dist/cjs/hooks/useIsEditorStatic.js +5 -5
- package/dist/cjs/hooks/useIsNodeSelected.js +5 -3
- package/dist/cjs/hooks/useLayoutGroupEffect.js +7 -5
- package/dist/cjs/hooks/useMarkViewDescription.js +31 -25
- package/dist/cjs/hooks/useNodePos.js +7 -5
- package/dist/cjs/hooks/useNodeViewDescription.js +32 -28
- package/dist/cjs/hooks/useReactKeys.js +7 -5
- package/dist/cjs/hooks/useSelectNode.js +10 -8
- package/dist/cjs/hooks/useStopEvent.js +9 -7
- package/dist/cjs/index.js +66 -34
- package/dist/cjs/plugins/beforeInputPlugin.js +20 -23
- package/dist/cjs/plugins/componentEventListeners.js +8 -6
- package/dist/cjs/plugins/componentEventListenersPlugin.js +8 -6
- package/dist/cjs/plugins/reactKeys.js +15 -10
- package/dist/cjs/props.js +23 -19
- package/dist/cjs/refs.js +3 -1
- package/dist/cjs/testing/editorViewTestHelpers.js +40 -47
- package/dist/cjs/testing/setupProseMirrorView.js +7 -4
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +10 -6
- package/dist/cjs/tiptap/TiptapEditor.js +15 -14
- package/dist/cjs/tiptap/TiptapEditorContent.js +18 -28
- package/dist/cjs/tiptap/TiptapEditorView.js +23 -34
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +3 -1
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +8 -6
- package/dist/cjs/tiptap/extensions/ReactProseMirrorCommands.js +5 -3
- package/dist/cjs/tiptap/extensions/commands/updateAttributes.js +4 -2
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +5 -3
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +12 -14
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +12 -10
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +6 -4
- package/dist/cjs/tiptap/index.js +36 -18
- package/dist/cjs/tiptap/tiptapNodeView.js +48 -62
- package/dist/cjs/viewdesc.js +119 -89
- package/dist/esm/ReactEditorView.js +68 -66
- package/dist/esm/StaticEditorView.js +18 -17
- package/dist/esm/commands/reorderSiblings.js +5 -5
- package/dist/esm/components/ChildNodeViews.js +33 -36
- package/dist/esm/components/CursorWrapper.js +5 -18
- package/dist/esm/components/LayoutGroup.js +1 -1
- package/dist/esm/components/NativeWidgetView.js +2 -2
- package/dist/esm/components/OutputSpec.js +1 -1
- package/dist/esm/components/ProseMirror.js +3 -17
- package/dist/esm/components/ProseMirrorDoc.js +6 -19
- package/dist/esm/components/SeparatorHackView.js +3 -4
- package/dist/esm/components/TextNodeView.js +6 -10
- package/dist/esm/components/TrailingHackView.js +2 -2
- package/dist/esm/components/WidgetView.js +3 -3
- package/dist/esm/components/marks/DefaultMarkView.js +6 -22
- package/dist/esm/components/marks/MarkView.js +11 -24
- package/dist/esm/components/marks/MarkViewConstructorView.js +7 -27
- package/dist/esm/components/marks/ReactMarkView.js +3 -18
- package/dist/esm/components/nodes/DefaultNodeView.js +6 -22
- package/dist/esm/components/nodes/DocNodeView.js +2 -2
- package/dist/esm/components/nodes/NodeView.js +11 -24
- package/dist/esm/components/nodes/NodeViewConstructorView.js +11 -31
- package/dist/esm/components/nodes/ReactNodeView.js +6 -22
- package/dist/esm/decorations/ReactWidgetType.js +10 -8
- package/dist/esm/decorations/iterDeco.js +13 -13
- package/dist/esm/decorations/viewDecorations.js +7 -6
- package/dist/esm/dom.js +1 -2
- package/dist/esm/findDOMNode.js +1 -1
- package/dist/esm/hooks/useComponentEventListeners.js +2 -3
- package/dist/esm/hooks/useEditor.js +5 -9
- package/dist/esm/hooks/useEditorEffect.js +1 -1
- package/dist/esm/hooks/useEditorEventCallback.js +1 -1
- package/dist/esm/hooks/useEditorEventListener.js +1 -1
- package/dist/esm/hooks/useIsEditorStatic.js +1 -3
- package/dist/esm/hooks/useMarkViewDescription.js +14 -10
- package/dist/esm/hooks/useNodeViewDescription.js +10 -8
- package/dist/esm/hooks/useReactKeys.js +1 -1
- package/dist/esm/plugins/beforeInputPlugin.js +12 -17
- package/dist/esm/plugins/reactKeys.js +3 -4
- package/dist/esm/props.js +15 -15
- package/dist/esm/testing/editorViewTestHelpers.js +20 -31
- package/dist/esm/testing/setupProseMirrorView.js +1 -2
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +7 -5
- package/dist/esm/tiptap/TiptapEditor.js +9 -10
- package/dist/esm/tiptap/TiptapEditorContent.js +4 -18
- package/dist/esm/tiptap/TiptapEditorView.js +8 -23
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +1 -1
- package/dist/esm/tiptap/extensions/commands/updateAttributes.js +1 -1
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +4 -8
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +4 -4
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +1 -1
- package/dist/esm/tiptap/tiptapNodeView.js +20 -38
- package/dist/esm/viewdesc.js +74 -66
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/props.d.ts +8 -8
- package/package.json +1 -2
|
@@ -4,22 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "beforeInputPlugin", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return beforeInputPlugin;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
11
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
12
|
+
const _CursorWrapper = require("../components/CursorWrapper.js");
|
|
13
|
+
const _ReactWidgetType = require("../decorations/ReactWidgetType.js");
|
|
12
14
|
function insertText(view, eventData) {
|
|
13
15
|
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
14
16
|
if (eventData === null) return false;
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
var _to;
|
|
18
|
-
const to = (_to = options.to) !== null && _to !== void 0 ? _to : view.state.selection.to;
|
|
17
|
+
const from = options.from ?? view.state.selection.from;
|
|
18
|
+
const to = options.to ?? view.state.selection.to;
|
|
19
19
|
if (view.someProp("handleTextInput", (f)=>f(view, from, to, eventData, ()=>view.state.tr.insertText(eventData, from, to)))) {
|
|
20
20
|
return true;
|
|
21
21
|
}
|
|
22
|
-
const { tr
|
|
22
|
+
const { tr } = view.state;
|
|
23
23
|
if (options.marks) tr.ensureMarks(options.marks);
|
|
24
24
|
tr.insertText(eventData, from, to);
|
|
25
25
|
view.dispatch(tr);
|
|
@@ -28,17 +28,16 @@ function insertText(view, eventData) {
|
|
|
28
28
|
function beforeInputPlugin(setCursorWrapper) {
|
|
29
29
|
let compositionMarks = null;
|
|
30
30
|
let precompositionSnapshot = null;
|
|
31
|
-
return new
|
|
31
|
+
return new _prosemirrorstate.Plugin({
|
|
32
32
|
props: {
|
|
33
33
|
handleDOMEvents: {
|
|
34
34
|
compositionstart (view) {
|
|
35
|
-
const { state
|
|
35
|
+
const { state } = view;
|
|
36
36
|
view.dispatch(state.tr.deleteSelection());
|
|
37
37
|
const $pos = state.selection.$from;
|
|
38
|
-
|
|
39
|
-
compositionMarks = (_storedMarks = state.storedMarks) !== null && _storedMarks !== void 0 ? _storedMarks : $pos.marks();
|
|
38
|
+
compositionMarks = state.storedMarks ?? $pos.marks();
|
|
40
39
|
if (compositionMarks) {
|
|
41
|
-
setCursorWrapper((0,
|
|
40
|
+
setCursorWrapper((0, _ReactWidgetType.widget)(state.selection.from, _CursorWrapper.CursorWrapper, {
|
|
42
41
|
key: "cursor-wrapper",
|
|
43
42
|
marks: compositionMarks
|
|
44
43
|
}));
|
|
@@ -46,7 +45,7 @@ function beforeInputPlugin(setCursorWrapper) {
|
|
|
46
45
|
// Snapshot the siblings of the node that contains the
|
|
47
46
|
// current cursor. We'll restore this later, so that React
|
|
48
47
|
// doesn't panic about unknown DOM nodes.
|
|
49
|
-
const { node: parent
|
|
48
|
+
const { node: parent } = view.domAtPos($pos.pos);
|
|
50
49
|
precompositionSnapshot = [];
|
|
51
50
|
for (const node of parent.childNodes){
|
|
52
51
|
precompositionSnapshot.push(node);
|
|
@@ -61,8 +60,8 @@ function beforeInputPlugin(setCursorWrapper) {
|
|
|
61
60
|
compositionend (view, event) {
|
|
62
61
|
// @ts-expect-error Internal property - input
|
|
63
62
|
view.input.composing = false;
|
|
64
|
-
const { state
|
|
65
|
-
const { node: parent
|
|
63
|
+
const { state } = view;
|
|
64
|
+
const { node: parent } = view.domAtPos(state.selection.from);
|
|
66
65
|
if (precompositionSnapshot) {
|
|
67
66
|
// Restore the snapshot of the parent node's children
|
|
68
67
|
// from before the composition started. This gives us a
|
|
@@ -114,15 +113,13 @@ function beforeInputPlugin(setCursorWrapper) {
|
|
|
114
113
|
keyCode: 13,
|
|
115
114
|
shiftKey: event.inputType === "insertLineBreak"
|
|
116
115
|
});
|
|
117
|
-
var ref;
|
|
118
116
|
// Use someProp to directly call ProseMirror handlers
|
|
119
|
-
return
|
|
117
|
+
return view.someProp("handleKeyDown", (f)=>f(view, keyEvent)) ?? false;
|
|
120
118
|
}
|
|
121
119
|
case "insertReplacementText":
|
|
122
120
|
{
|
|
123
|
-
var ref1, ref2;
|
|
124
121
|
const ranges = event.getTargetRanges();
|
|
125
|
-
|
|
122
|
+
event.dataTransfer?.items[0]?.getAsString((data)=>{
|
|
126
123
|
for (const range of ranges){
|
|
127
124
|
const from = view.posAtDOM(range.startContainer, range.startOffset, 1);
|
|
128
125
|
const to = view.posAtDOM(range.endContainer, range.endOffset, 1);
|
|
@@ -150,11 +147,11 @@ function beforeInputPlugin(setCursorWrapper) {
|
|
|
150
147
|
case "deleteContent":
|
|
151
148
|
{
|
|
152
149
|
const targetRanges = event.getTargetRanges();
|
|
153
|
-
const { tr
|
|
150
|
+
const { tr } = view.state;
|
|
154
151
|
for (const range of targetRanges){
|
|
155
152
|
const start = view.posAtDOM(range.startContainer, range.startOffset);
|
|
156
153
|
const end = view.posAtDOM(range.endContainer, range.endOffset);
|
|
157
|
-
const { doc
|
|
154
|
+
const { doc } = view.state;
|
|
158
155
|
const storedMarks = doc.resolve(start).marksAcross(doc.resolve(end));
|
|
159
156
|
tr.delete(start, end).setStoredMarks(storedMarks);
|
|
160
157
|
}
|
|
@@ -4,17 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "componentEventListeners", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return componentEventListeners;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
12
|
+
const _reactdom = require("react-dom");
|
|
11
13
|
function componentEventListeners(eventHandlerRegistry) {
|
|
12
14
|
const domEventHandlers = {};
|
|
13
15
|
for (const [eventType, handlers] of eventHandlerRegistry.entries()){
|
|
14
16
|
function handleEvent(view, event) {
|
|
15
17
|
for (const handler of handlers){
|
|
16
18
|
let handled = false;
|
|
17
|
-
(0,
|
|
19
|
+
(0, _reactdom.unstable_batchedUpdates)(()=>{
|
|
18
20
|
handled = !!handler.call(this, view, event);
|
|
19
21
|
});
|
|
20
22
|
if (handled || event.defaultPrevented) return true;
|
|
@@ -23,8 +25,8 @@ function componentEventListeners(eventHandlerRegistry) {
|
|
|
23
25
|
}
|
|
24
26
|
domEventHandlers[eventType] = handleEvent;
|
|
25
27
|
}
|
|
26
|
-
const plugin = new
|
|
27
|
-
key: new
|
|
28
|
+
const plugin = new _prosemirrorstate.Plugin({
|
|
29
|
+
key: new _prosemirrorstate.PluginKey("@handlewithcare/react-prosemirror/componentEventListeners"),
|
|
28
30
|
props: {
|
|
29
31
|
handleDOMEvents: domEventHandlers
|
|
30
32
|
}
|
|
@@ -4,17 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "createComponentEventListenersPlugin", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return createComponentEventListenersPlugin;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
12
|
+
const _reactdom = require("react-dom");
|
|
11
13
|
function createComponentEventListenersPlugin(eventHandlerRegistry) {
|
|
12
14
|
const domEventHandlers = {};
|
|
13
15
|
for (const [eventType, handlers] of eventHandlerRegistry.entries()){
|
|
14
16
|
function handleEvent(view, event) {
|
|
15
17
|
for (const handler of handlers){
|
|
16
18
|
let handled = false;
|
|
17
|
-
(0,
|
|
19
|
+
(0, _reactdom.unstable_batchedUpdates)(()=>{
|
|
18
20
|
handled = !!handler.call(this, view, event);
|
|
19
21
|
});
|
|
20
22
|
if (handled || event.defaultPrevented) return true;
|
|
@@ -23,8 +25,8 @@ function createComponentEventListenersPlugin(eventHandlerRegistry) {
|
|
|
23
25
|
}
|
|
24
26
|
domEventHandlers[eventType] = handleEvent;
|
|
25
27
|
}
|
|
26
|
-
const plugin = new
|
|
27
|
-
key: new
|
|
28
|
+
const plugin = new _prosemirrorstate.Plugin({
|
|
29
|
+
key: new _prosemirrorstate.PluginKey("componentEventListeners"),
|
|
28
30
|
props: {
|
|
29
31
|
handleDOMEvents: domEventHandlers
|
|
30
32
|
}
|
|
@@ -9,19 +9,25 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
createNodeKey: ()
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
createNodeKey: function() {
|
|
13
|
+
return createNodeKey;
|
|
14
|
+
},
|
|
15
|
+
reactKeys: function() {
|
|
16
|
+
return reactKeys;
|
|
17
|
+
},
|
|
18
|
+
reactKeysPluginKey: function() {
|
|
19
|
+
return reactKeysPluginKey;
|
|
20
|
+
}
|
|
15
21
|
});
|
|
16
|
-
const
|
|
22
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
17
23
|
function createNodeKey() {
|
|
18
24
|
const key = Math.floor(Math.random() * 0xffffffffffff).toString(16);
|
|
19
25
|
return key;
|
|
20
26
|
}
|
|
21
|
-
const reactKeysPluginKey = new
|
|
27
|
+
const reactKeysPluginKey = new _prosemirrorstate.PluginKey("@handlewithcare/react-prosemirror/reactKeys");
|
|
22
28
|
function reactKeys() {
|
|
23
29
|
let composing = false;
|
|
24
|
-
return new
|
|
30
|
+
return new _prosemirrorstate.Plugin({
|
|
25
31
|
key: reactKeysPluginKey,
|
|
26
32
|
state: {
|
|
27
33
|
init (_, state) {
|
|
@@ -45,11 +51,10 @@ function reactKeys() {
|
|
|
45
51
|
* and assign its key to that new position, dropping it if the
|
|
46
52
|
* node was deleted.
|
|
47
53
|
*/ apply (tr, value, _, newState) {
|
|
48
|
-
var ref;
|
|
49
54
|
if (!tr.docChanged || composing) {
|
|
50
55
|
return value;
|
|
51
56
|
}
|
|
52
|
-
const overrides =
|
|
57
|
+
const overrides = tr.getMeta(reactKeysPluginKey)?.overrides;
|
|
53
58
|
const next = {
|
|
54
59
|
posToKey: new Map(),
|
|
55
60
|
keyToPos: new Map()
|
|
@@ -59,8 +64,8 @@ function reactKeys() {
|
|
|
59
64
|
return a - b;
|
|
60
65
|
});
|
|
61
66
|
for (const [pos, key] of posToKeyEntries){
|
|
62
|
-
const override = overrides
|
|
63
|
-
const { pos: newPos
|
|
67
|
+
const override = overrides?.[pos];
|
|
68
|
+
const { pos: newPos, deleted } = override === undefined ? tr.mapping.mapResult(pos) : {
|
|
64
69
|
pos: override,
|
|
65
70
|
deleted: false
|
|
66
71
|
};
|
package/dist/cjs/props.js
CHANGED
|
@@ -9,11 +9,15 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
htmlAttrsToReactProps: function() {
|
|
13
|
+
return htmlAttrsToReactProps;
|
|
14
|
+
},
|
|
15
|
+
mergeReactProps: function() {
|
|
16
|
+
return mergeReactProps;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
|
-
const _classnames = /*#__PURE__*/
|
|
16
|
-
function
|
|
19
|
+
const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
|
|
20
|
+
function _interop_require_default(obj) {
|
|
17
21
|
return obj && obj.__esModule ? obj : {
|
|
18
22
|
default: obj
|
|
19
23
|
};
|
|
@@ -44,7 +48,7 @@ function mergeStyleProps(a, b) {
|
|
|
44
48
|
if (!("STYLE" in b) || typeof b.STYLE !== "string") {
|
|
45
49
|
return a.STYLE;
|
|
46
50
|
}
|
|
47
|
-
return
|
|
51
|
+
return `${a.STYLE.match(/;\s*$/) ? a.STYLE : `${a.STYLE};`} ${b.STYLE}`;
|
|
48
52
|
}
|
|
49
53
|
function mergeReactProps(a, b) {
|
|
50
54
|
return {
|
|
@@ -190,32 +194,32 @@ function htmlAttrsToReactProps(attrs) {
|
|
|
190
194
|
}
|
|
191
195
|
case "maxlength":
|
|
192
196
|
{
|
|
193
|
-
const
|
|
194
|
-
if (!Number.isNaN(
|
|
197
|
+
const numValue = parseInt(attrValue, 10);
|
|
198
|
+
if (!Number.isNaN(numValue)) {
|
|
195
199
|
props.maxLength = attrValue;
|
|
196
200
|
}
|
|
197
201
|
break;
|
|
198
202
|
}
|
|
199
203
|
case "minlength":
|
|
200
204
|
{
|
|
201
|
-
const
|
|
202
|
-
if (!Number.isNaN(
|
|
205
|
+
const numValue = parseInt(attrValue, 10);
|
|
206
|
+
if (!Number.isNaN(numValue)) {
|
|
203
207
|
props.minLength = attrValue;
|
|
204
208
|
}
|
|
205
209
|
break;
|
|
206
210
|
}
|
|
207
211
|
case "max":
|
|
208
212
|
{
|
|
209
|
-
const
|
|
210
|
-
if (!Number.isNaN(
|
|
213
|
+
const numValue = parseInt(attrValue, 10);
|
|
214
|
+
if (!Number.isNaN(numValue)) {
|
|
211
215
|
props.max = attrValue;
|
|
212
216
|
}
|
|
213
217
|
break;
|
|
214
218
|
}
|
|
215
219
|
case "min":
|
|
216
220
|
{
|
|
217
|
-
const
|
|
218
|
-
if (!Number.isNaN(
|
|
221
|
+
const numValue = parseInt(attrValue, 10);
|
|
222
|
+
if (!Number.isNaN(numValue)) {
|
|
219
223
|
props.min = attrValue;
|
|
220
224
|
}
|
|
221
225
|
break;
|
|
@@ -237,8 +241,8 @@ function htmlAttrsToReactProps(attrs) {
|
|
|
237
241
|
}
|
|
238
242
|
case "size":
|
|
239
243
|
{
|
|
240
|
-
const
|
|
241
|
-
if (!Number.isNaN(
|
|
244
|
+
const numValue = parseInt(attrValue, 10);
|
|
245
|
+
if (!Number.isNaN(numValue)) {
|
|
242
246
|
props.size = attrValue;
|
|
243
247
|
}
|
|
244
248
|
break;
|
|
@@ -249,8 +253,8 @@ function htmlAttrsToReactProps(attrs) {
|
|
|
249
253
|
props.step = attrValue;
|
|
250
254
|
break;
|
|
251
255
|
}
|
|
252
|
-
const
|
|
253
|
-
if (!Number.isNaN(
|
|
256
|
+
const numValue = parseInt(attrValue, 10);
|
|
257
|
+
if (!Number.isNaN(numValue) && numValue > 0) {
|
|
254
258
|
props.step = attrValue;
|
|
255
259
|
}
|
|
256
260
|
break;
|
|
@@ -262,8 +266,8 @@ function htmlAttrsToReactProps(attrs) {
|
|
|
262
266
|
}
|
|
263
267
|
case "rows":
|
|
264
268
|
{
|
|
265
|
-
const
|
|
266
|
-
if (!Number.isNaN(
|
|
269
|
+
const numValue = parseInt(attrValue, 10);
|
|
270
|
+
if (!Number.isNaN(numValue)) {
|
|
267
271
|
props.rows = attrValue;
|
|
268
272
|
}
|
|
269
273
|
break;
|
package/dist/cjs/refs.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "useMergedDOMRefs", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return useMergedDOMRefs;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _react = require("react");
|
|
10
12
|
function useMergedDOMRefs() {
|
|
@@ -9,46 +9,36 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
findTextNode: function() {
|
|
13
|
+
return findTextNode;
|
|
14
|
+
},
|
|
15
|
+
tempEditor: function() {
|
|
16
|
+
return tempEditor;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
19
|
const _react = require("@testing-library/react");
|
|
16
20
|
const _expect = require("expect");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const _react1 = /*#__PURE__*/
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
function
|
|
26
|
-
_extends = Object.assign || function(target) {
|
|
27
|
-
for(var i = 1; i < arguments.length; i++){
|
|
28
|
-
var source = arguments[i];
|
|
29
|
-
for(var key in source){
|
|
30
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
31
|
-
target[key] = source[key];
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return target;
|
|
36
|
-
};
|
|
37
|
-
return _extends.apply(this, arguments);
|
|
38
|
-
}
|
|
39
|
-
function _interopRequireDefault(obj) {
|
|
21
|
+
const _prosemirrormodel = require("prosemirror-model");
|
|
22
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
23
|
+
const _prosemirrortestbuilder = require("prosemirror-test-builder");
|
|
24
|
+
const _react1 = /*#__PURE__*/ _interop_require_default(require("react"));
|
|
25
|
+
const _ProseMirror = require("../components/ProseMirror.js");
|
|
26
|
+
const _ProseMirrorDoc = require("../components/ProseMirrorDoc.js");
|
|
27
|
+
const _useEditorEffect = require("../hooks/useEditorEffect.js");
|
|
28
|
+
const _reactKeys = require("../plugins/reactKeys.js");
|
|
29
|
+
function _interop_require_default(obj) {
|
|
40
30
|
return obj && obj.__esModule ? obj : {
|
|
41
31
|
default: obj
|
|
42
32
|
};
|
|
43
33
|
}
|
|
44
34
|
const toEqualNode = function(actual, expected) {
|
|
45
|
-
if (!(actual instanceof
|
|
35
|
+
if (!(actual instanceof _prosemirrormodel.Node && expected instanceof _prosemirrormodel.Node)) {
|
|
46
36
|
throw new Error("Must be comparing nodes");
|
|
47
37
|
}
|
|
48
|
-
const pass = (0,
|
|
38
|
+
const pass = (0, _prosemirrortestbuilder.eq)(actual, expected);
|
|
49
39
|
return {
|
|
50
40
|
message: ()=>// `this` context will have correct typings
|
|
51
|
-
|
|
41
|
+
`expected ${this.utils.printReceived(actual)} ${pass ? "not " : ""}to equal ${this.utils.printExpected(expected)}`,
|
|
52
42
|
pass
|
|
53
43
|
};
|
|
54
44
|
};
|
|
@@ -56,40 +46,43 @@ _expect.expect.extend({
|
|
|
56
46
|
toEqualNode
|
|
57
47
|
});
|
|
58
48
|
function tempEditor(param) {
|
|
59
|
-
let { doc: startDoc
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const state = _prosemirrorState.EditorState.create({
|
|
49
|
+
let { doc: startDoc, selection, controlled, plugins, ...props } = param;
|
|
50
|
+
startDoc = startDoc ?? (0, _prosemirrortestbuilder.doc)((0, _prosemirrortestbuilder.p)());
|
|
51
|
+
const state = _prosemirrorstate.EditorState.create({
|
|
63
52
|
doc: startDoc,
|
|
64
|
-
schema:
|
|
65
|
-
selection:
|
|
53
|
+
schema: _prosemirrortestbuilder.schema,
|
|
54
|
+
selection: selection ?? startDoc.tag?.a ? _prosemirrorstate.TextSelection.create(startDoc, startDoc.tag.a, startDoc.tag?.b) : undefined,
|
|
66
55
|
plugins: [
|
|
67
|
-
...plugins
|
|
68
|
-
(0,
|
|
56
|
+
...plugins ?? [],
|
|
57
|
+
(0, _reactKeys.reactKeys)()
|
|
69
58
|
]
|
|
70
59
|
});
|
|
71
60
|
let view = null;
|
|
72
61
|
function Test() {
|
|
73
|
-
(0,
|
|
62
|
+
(0, _useEditorEffect.useEditorEffect)((v)=>{
|
|
74
63
|
view = v;
|
|
75
64
|
});
|
|
76
65
|
return null;
|
|
77
66
|
}
|
|
78
|
-
const { rerender
|
|
79
|
-
|
|
80
|
-
} : {
|
|
81
|
-
defaultState: state
|
|
82
|
-
}, props), /*#__PURE__*/ _react1.default.createElement(Test, null), /*#__PURE__*/ _react1.default.createElement(_proseMirrorDocJs.ProseMirrorDoc, null)));
|
|
83
|
-
function rerenderEditor() {
|
|
84
|
-
let { ...newProps } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
85
|
-
rerender(/*#__PURE__*/ _react1.default.createElement(_proseMirrorJs.ProseMirror, _extends({}, controlled ? {
|
|
67
|
+
const { rerender, unmount } = (0, _react.render)(/*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
|
|
68
|
+
...controlled ? {
|
|
86
69
|
state
|
|
87
70
|
} : {
|
|
88
71
|
defaultState: state
|
|
89
|
-
},
|
|
72
|
+
},
|
|
73
|
+
...props
|
|
74
|
+
}, /*#__PURE__*/ _react1.default.createElement(Test, null), /*#__PURE__*/ _react1.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, null)));
|
|
75
|
+
function rerenderEditor() {
|
|
76
|
+
let { ...newProps } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
77
|
+
rerender(/*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
|
|
78
|
+
...controlled ? {
|
|
79
|
+
state
|
|
80
|
+
} : {
|
|
81
|
+
defaultState: state
|
|
82
|
+
},
|
|
90
83
|
...props,
|
|
91
84
|
...newProps
|
|
92
|
-
}
|
|
85
|
+
}, /*#__PURE__*/ _react1.default.createElement(Test, null), /*#__PURE__*/ _react1.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, null)));
|
|
93
86
|
return view;
|
|
94
87
|
}
|
|
95
88
|
return {
|
|
@@ -9,8 +9,12 @@ function _export(target, all) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
_export(exports, {
|
|
12
|
-
setupProseMirrorView: ()
|
|
13
|
-
|
|
12
|
+
setupProseMirrorView: function() {
|
|
13
|
+
return setupProseMirrorView;
|
|
14
|
+
},
|
|
15
|
+
teardownProseMirrorView: function() {
|
|
16
|
+
return teardownProseMirrorView;
|
|
17
|
+
}
|
|
14
18
|
});
|
|
15
19
|
let oldElementFromPoint;
|
|
16
20
|
let oldGetClientRects;
|
|
@@ -67,8 +71,7 @@ const mockGetClientRects = ()=>{
|
|
|
67
71
|
];
|
|
68
72
|
const domRectList = Object.assign(list, {
|
|
69
73
|
item (index) {
|
|
70
|
-
|
|
71
|
-
return (_index = list[index]) !== null && _index !== void 0 ? _index : null;
|
|
74
|
+
return list[index] ?? null;
|
|
72
75
|
}
|
|
73
76
|
});
|
|
74
77
|
return domRectList;
|
|
@@ -4,19 +4,23 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "ReactProseMirrorNodeView", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return ReactProseMirrorNodeView;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@tiptap/core");
|
|
10
12
|
let ReactProseMirrorNodeView = class ReactProseMirrorNodeView extends _core.NodeView {
|
|
13
|
+
_dom;
|
|
14
|
+
_contentDOM;
|
|
15
|
+
constructor(component, props, dom, contentDOM, options){
|
|
16
|
+
super(component, props, options);
|
|
17
|
+
this._dom = dom;
|
|
18
|
+
this._contentDOM = contentDOM;
|
|
19
|
+
}
|
|
11
20
|
get dom() {
|
|
12
21
|
return this._dom;
|
|
13
22
|
}
|
|
14
23
|
get contentDOM() {
|
|
15
24
|
return this._contentDOM;
|
|
16
25
|
}
|
|
17
|
-
constructor(component, props, dom, contentDOM, options){
|
|
18
|
-
super(component, props, options);
|
|
19
|
-
this._dom = dom;
|
|
20
|
-
this._contentDOM = contentDOM;
|
|
21
|
-
}
|
|
22
26
|
};
|
|
@@ -4,17 +4,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "TiptapEditor", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return TiptapEditor;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _core = require("@tiptap/core");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
+
const _prosemirrorstate = require("prosemirror-state");
|
|
13
|
+
const _StaticEditorView = require("../StaticEditorView.js");
|
|
12
14
|
let TiptapEditor = class TiptapEditor extends _core.Editor {
|
|
15
|
+
constructor(options = {}){
|
|
16
|
+
super({
|
|
17
|
+
...options,
|
|
18
|
+
element: null
|
|
19
|
+
});
|
|
20
|
+
}
|
|
13
21
|
get view() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
state: _prosemirrorState.EditorState.create({
|
|
22
|
+
return(// @ts-expect-error private property
|
|
23
|
+
this.editorView ?? new _StaticEditorView.StaticEditorView({
|
|
24
|
+
state: _prosemirrorstate.EditorState.create({
|
|
18
25
|
schema: this.extensionManager.schema
|
|
19
26
|
}),
|
|
20
27
|
...this.options.editorProps,
|
|
@@ -22,12 +29,6 @@ let TiptapEditor = class TiptapEditor extends _core.Editor {
|
|
|
22
29
|
role: "textbox",
|
|
23
30
|
...this.options.editorProps.attributes
|
|
24
31
|
}
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
constructor(options = {}){
|
|
28
|
-
super({
|
|
29
|
-
...options,
|
|
30
|
-
element: null
|
|
31
|
-
});
|
|
32
|
+
}));
|
|
32
33
|
}
|
|
33
34
|
};
|