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