@handlewithcare/react-prosemirror 2.9.0-tiptap.24 → 3.0.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 +140 -75
- package/dist/cjs/StaticEditorView.js +0 -3
- package/dist/cjs/components/ChildNodeViews.js +4 -4
- package/dist/cjs/components/NativeWidgetView.js +2 -2
- package/dist/cjs/components/OutputSpec.js +10 -3
- package/dist/cjs/components/ProseMirror.js +11 -17
- package/dist/cjs/components/SeparatorHackView.js +2 -2
- package/dist/cjs/components/TrailingHackView.js +2 -2
- package/dist/cjs/components/WidgetView.js +2 -2
- package/dist/cjs/components/marks/DefaultMarkView.js +2 -1
- package/dist/cjs/components/marks/MarkView.js +2 -2
- package/dist/cjs/components/marks/{CustomMarkView.js → MarkViewConstructorView.js} +16 -7
- package/dist/cjs/components/marks/ReactMarkView.js +26 -6
- package/dist/cjs/components/nodes/DefaultNodeView.js +3 -2
- package/dist/cjs/components/nodes/DocNodeView.js +7 -6
- package/dist/cjs/components/nodes/NodeView.js +17 -6
- package/dist/cjs/components/nodes/{CustomNodeView.js → NodeViewConstructorView.js} +22 -9
- package/dist/cjs/components/nodes/ReactNodeView.js +59 -17
- package/dist/cjs/contexts/{ChildDescriptorsContext.js → ChildDescriptionsContext.js} +3 -3
- package/dist/cjs/hooks/useEditor.js +0 -4
- package/dist/cjs/hooks/useEditorEventCallback.js +1 -1
- package/dist/cjs/hooks/useMarkViewDescription.js +24 -21
- package/dist/cjs/hooks/useNodePos.js +18 -0
- package/dist/cjs/hooks/{useNodeViewDescriptor.js → useNodeViewDescription.js} +30 -25
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/refs.js +28 -0
- package/dist/cjs/viewdesc.js +18 -5
- package/dist/esm/StaticEditorView.js +0 -3
- package/dist/esm/components/ChildNodeViews.js +4 -4
- package/dist/esm/components/NativeWidgetView.js +2 -2
- package/dist/esm/components/OutputSpec.js +10 -3
- package/dist/esm/components/ProseMirror.js +11 -17
- package/dist/esm/components/SeparatorHackView.js +2 -2
- package/dist/esm/components/TrailingHackView.js +2 -2
- package/dist/esm/components/WidgetView.js +2 -2
- package/dist/esm/components/marks/DefaultMarkView.js +2 -1
- package/dist/esm/components/marks/MarkView.js +2 -2
- package/dist/esm/components/marks/{CustomMarkView.js → MarkViewConstructorView.js} +14 -5
- package/dist/esm/components/marks/ReactMarkView.js +26 -6
- package/dist/esm/components/nodes/DefaultNodeView.js +3 -2
- package/dist/esm/components/nodes/DocNodeView.js +8 -7
- package/dist/esm/components/nodes/NodeView.js +7 -4
- package/dist/esm/components/nodes/{CustomNodeView.js → NodeViewConstructorView.js} +20 -7
- package/dist/esm/components/nodes/ReactNodeView.js +59 -17
- package/dist/esm/contexts/{ChildDescriptorsContext.js → ChildDescriptionsContext.js} +1 -1
- package/dist/esm/hooks/useEditor.js +0 -4
- package/dist/esm/hooks/useEditorEffect.js +0 -4
- package/dist/esm/hooks/useEditorEventCallback.js +6 -4
- package/dist/esm/hooks/useMarkViewDescription.js +26 -23
- package/dist/esm/hooks/useNodePos.js +15 -0
- package/dist/esm/hooks/{useNodeViewDescriptor.js → useNodeViewDescription.js} +29 -24
- package/dist/esm/index.js +2 -0
- package/dist/esm/refs.js +18 -0
- package/dist/esm/viewdesc.js +13 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/AbstractEditorView.d.ts +0 -1
- package/dist/types/StaticEditorView.d.ts +0 -1
- package/dist/types/components/OutputSpec.d.ts +2 -1
- package/dist/types/components/ProseMirror.d.ts +3 -11
- package/dist/types/components/ProseMirrorDoc.d.ts +2 -2
- package/dist/types/components/marks/DefaultMarkView.d.ts +1 -1
- package/dist/types/components/marks/MarkViewComponentProps.d.ts +4 -3
- package/dist/types/components/marks/{CustomMarkView.d.ts → MarkViewConstructorView.d.ts} +1 -1
- package/dist/types/components/nodes/DefaultNodeView.d.ts +1 -1
- package/dist/types/components/nodes/DocNodeView.d.ts +2 -2
- package/dist/types/components/nodes/NodeView.d.ts +1 -0
- package/dist/types/components/nodes/NodeViewComponentProps.d.ts +4 -3
- package/dist/types/components/{CustomNodeView.d.ts → nodes/NodeViewConstructorView.d.ts} +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/contexts/{ChildDescriptorsContext.d.ts → ChildDescriptionsContext.d.ts} +1 -1
- package/dist/types/hooks/useEditorEffect.d.ts +0 -4
- package/dist/types/hooks/useEditorEventCallback.d.ts +6 -4
- package/dist/types/hooks/useMarkViewDescription.d.ts +6 -9
- package/dist/types/hooks/useNodePos.d.ts +9 -0
- package/dist/types/hooks/{useNodeViewDescriptor.d.ts → useNodeViewDescription.d.ts} +5 -9
- package/dist/types/index.d.ts +2 -0
- package/dist/types/props.d.ts +26 -26
- package/dist/types/refs.d.ts +2 -0
- package/dist/types/viewdesc.d.ts +4 -0
- package/package.json +12 -20
- package/dist/cjs/components/CustomNodeView.js +0 -132
- package/dist/cjs/components/DefaultNodeView.js +0 -67
- package/dist/cjs/components/DocNodeView.js +0 -96
- package/dist/cjs/components/MarkView.js +0 -119
- package/dist/cjs/components/NodeView.js +0 -86
- package/dist/cjs/components/NodeViewComponentProps.js +0 -4
- package/dist/cjs/components/ReactNodeView.js +0 -174
- package/dist/cjs/components/marks/OldMarkView.js +0 -120
- package/dist/cjs/tiptap/ReactProseMirrorNodeView.js +0 -26
- package/dist/cjs/tiptap/TiptapEditor.js +0 -34
- package/dist/cjs/tiptap/TiptapEditorContent.js +0 -142
- package/dist/cjs/tiptap/TiptapEditorView.js +0 -118
- package/dist/cjs/tiptap/TiptapNodeView.js +0 -26
- package/dist/cjs/tiptap/contexts/TiptapEditorContext.js +0 -12
- package/dist/cjs/tiptap/extensions/ReactProseMirror.js +0 -40
- package/dist/cjs/tiptap/hooks/useIsInReactProseMirror.js +0 -15
- package/dist/cjs/tiptap/hooks/useTiptapEditor.js +0 -43
- package/dist/cjs/tiptap/hooks/useTiptapEditorEffect.js +0 -35
- package/dist/cjs/tiptap/hooks/useTiptapEditorEventCallback.js +0 -35
- package/dist/cjs/tiptap/index.js +0 -48
- package/dist/cjs/tiptap/tiptapNodeView.js +0 -237
- package/dist/esm/components/CustomNodeView.js +0 -81
- package/dist/esm/components/DefaultNodeView.js +0 -16
- package/dist/esm/components/DocNodeView.js +0 -45
- package/dist/esm/components/MarkView.js +0 -68
- package/dist/esm/components/NodeView.js +0 -35
- package/dist/esm/components/NodeViewComponentProps.js +0 -1
- package/dist/esm/components/ReactNodeView.js +0 -123
- package/dist/esm/components/marks/OldMarkView.js +0 -69
- package/dist/esm/tiptap/ReactProseMirrorNodeView.js +0 -22
- package/dist/esm/tiptap/TiptapEditor.js +0 -24
- package/dist/esm/tiptap/TiptapEditorContent.js +0 -91
- package/dist/esm/tiptap/TiptapEditorView.js +0 -69
- package/dist/esm/tiptap/TiptapNodeView.js +0 -22
- package/dist/esm/tiptap/contexts/TiptapEditorContext.js +0 -2
- package/dist/esm/tiptap/extensions/ReactProseMirror.js +0 -30
- package/dist/esm/tiptap/hooks/useIsInReactProseMirror.js +0 -5
- package/dist/esm/tiptap/hooks/useTiptapEditor.js +0 -33
- package/dist/esm/tiptap/hooks/useTiptapEditorEffect.js +0 -42
- package/dist/esm/tiptap/hooks/useTiptapEditorEventCallback.js +0 -35
- package/dist/esm/tiptap/index.js +0 -9
- package/dist/esm/tiptap/tiptapNodeView.js +0 -205
- package/dist/types/components/DefaultNodeView.d.ts +0 -3
- package/dist/types/components/DocNodeView.d.ts +0 -12
- package/dist/types/components/MarkView.d.ts +0 -9
- package/dist/types/components/NodeView.d.ts +0 -11
- package/dist/types/components/NodeViewComponentProps.d.ts +0 -12
- package/dist/types/components/ReactNodeView.d.ts +0 -13
- package/dist/types/components/marks/OldMarkView.d.ts +0 -10
- package/dist/types/components/nodes/CustomNodeView.d.ts +0 -12
- package/dist/types/tiptap/ReactProseMirrorNodeView.d.ts +0 -15
- package/dist/types/tiptap/TiptapEditor.d.ts +0 -6
- package/dist/types/tiptap/TiptapEditorContent.d.ts +0 -19
- package/dist/types/tiptap/TiptapEditorView.d.ts +0 -16
- package/dist/types/tiptap/TiptapNodeView.d.ts +0 -15
- package/dist/types/tiptap/contexts/TiptapEditorContext.d.ts +0 -6
- package/dist/types/tiptap/extensions/ReactProseMirror.d.ts +0 -9
- package/dist/types/tiptap/hooks/useIsInReactProseMirror.d.ts +0 -1
- package/dist/types/tiptap/hooks/useTiptapEditor.d.ts +0 -4
- package/dist/types/tiptap/hooks/useTiptapEditorEffect.d.ts +0 -21
- package/dist/types/tiptap/hooks/useTiptapEditorEventCallback.d.ts +0 -13
- package/dist/types/tiptap/index.d.ts +0 -9
- package/dist/types/tiptap/tiptapNodeView.d.ts +0 -50
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ReactProseMirrorNodeView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ReactProseMirrorNodeView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _core = require("@tiptap/core");
|
|
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
|
-
}
|
|
20
|
-
get dom() {
|
|
21
|
-
return this._dom;
|
|
22
|
-
}
|
|
23
|
-
get contentDOM() {
|
|
24
|
-
return this._contentDOM;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditor", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditor;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _core = require("@tiptap/core");
|
|
12
|
-
const _prosemirrorstate = require("prosemirror-state");
|
|
13
|
-
const _StaticEditorView = require("../StaticEditorView.js");
|
|
14
|
-
let TiptapEditor = class TiptapEditor extends _core.Editor {
|
|
15
|
-
constructor(options = {}){
|
|
16
|
-
super({
|
|
17
|
-
...options,
|
|
18
|
-
element: null
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
get view() {
|
|
22
|
-
return(// @ts-expect-error private property
|
|
23
|
-
this.editorView ?? new _StaticEditorView.StaticEditorView({
|
|
24
|
-
state: _prosemirrorstate.EditorState.create({
|
|
25
|
-
schema: this.extensionManager.schema
|
|
26
|
-
}),
|
|
27
|
-
...this.options.editorProps,
|
|
28
|
-
attributes: {
|
|
29
|
-
role: "textbox",
|
|
30
|
-
...this.options.editorProps.attributes
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditorContent", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditorContent;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
12
|
-
const _reactdom = require("react-dom");
|
|
13
|
-
const _ProseMirrorDoc = require("../components/ProseMirrorDoc.js");
|
|
14
|
-
const _useEditorEffect = require("../hooks/useEditorEffect.js");
|
|
15
|
-
const _TiptapEditorContext = require("./contexts/TiptapEditorContext.js");
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
-
if (typeof WeakMap !== "function") return null;
|
|
18
|
-
var cacheBabelInterop = new WeakMap();
|
|
19
|
-
var cacheNodeInterop = new WeakMap();
|
|
20
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
-
})(nodeInterop);
|
|
23
|
-
}
|
|
24
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
-
return {
|
|
30
|
-
default: obj
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
-
if (cache && cache.has(obj)) {
|
|
35
|
-
return cache.get(obj);
|
|
36
|
-
}
|
|
37
|
-
var newObj = {
|
|
38
|
-
__proto__: null
|
|
39
|
-
};
|
|
40
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
-
for(var key in obj){
|
|
42
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
-
if (desc && (desc.get || desc.set)) {
|
|
45
|
-
Object.defineProperty(newObj, key, desc);
|
|
46
|
-
} else {
|
|
47
|
-
newObj[key] = obj[key];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
newObj.default = obj;
|
|
52
|
-
if (cache) {
|
|
53
|
-
cache.set(obj, newObj);
|
|
54
|
-
}
|
|
55
|
-
return newObj;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* This component renders all of the editor's registered "React renderers".
|
|
59
|
-
*/ const Portals = (param)=>{
|
|
60
|
-
let { contentComponent } = param;
|
|
61
|
-
const renderers = (0, _react.useSyncExternalStore)(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);
|
|
62
|
-
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, Object.values(renderers));
|
|
63
|
-
};
|
|
64
|
-
function getInstance() {
|
|
65
|
-
const subscribers = new Set();
|
|
66
|
-
let renderers = {};
|
|
67
|
-
return {
|
|
68
|
-
/**
|
|
69
|
-
* Subscribe to the editor instance's changes.
|
|
70
|
-
*/ subscribe (callback) {
|
|
71
|
-
subscribers.add(callback);
|
|
72
|
-
return ()=>{
|
|
73
|
-
subscribers.delete(callback);
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
getSnapshot () {
|
|
77
|
-
return renderers;
|
|
78
|
-
},
|
|
79
|
-
getServerSnapshot () {
|
|
80
|
-
return renderers;
|
|
81
|
-
},
|
|
82
|
-
/**
|
|
83
|
-
* Adds a new React Renderer to the editor.
|
|
84
|
-
*/ setRenderer (id, renderer) {
|
|
85
|
-
renderers = {
|
|
86
|
-
...renderers,
|
|
87
|
-
[id]: /*#__PURE__*/ (0, _reactdom.createPortal)(renderer.reactElement, renderer.element, id)
|
|
88
|
-
};
|
|
89
|
-
subscribers.forEach((subscriber)=>subscriber());
|
|
90
|
-
},
|
|
91
|
-
/**
|
|
92
|
-
* Removes a React Renderer from the editor.
|
|
93
|
-
*/ removeRenderer (id) {
|
|
94
|
-
const nextRenderers = {
|
|
95
|
-
...renderers
|
|
96
|
-
};
|
|
97
|
-
delete nextRenderers[id];
|
|
98
|
-
renderers = nextRenderers;
|
|
99
|
-
subscribers.forEach((subscriber)=>subscriber());
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
function TiptapEditorContent(param) {
|
|
104
|
-
let { editor: editorProp, ...props } = param;
|
|
105
|
-
const editor = editorProp;
|
|
106
|
-
const { onEditorInitialize, onEditorDeinitialize } = (0, _react.useContext)(_TiptapEditorContext.TiptapEditorContext);
|
|
107
|
-
(0, _useEditorEffect.useEditorEffect)((view)=>{
|
|
108
|
-
if (editor.view === view) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
// @ts-expect-error private property
|
|
112
|
-
editor.editorView = view;
|
|
113
|
-
editor.contentComponent = getInstance();
|
|
114
|
-
// @ts-expect-error private method
|
|
115
|
-
editor.injectCSS();
|
|
116
|
-
const dom = view.dom;
|
|
117
|
-
dom.editor = editor;
|
|
118
|
-
setTimeout(()=>{
|
|
119
|
-
if (editor.isDestroyed) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
editor.commands.focus(editor.options.autofocus);
|
|
123
|
-
editor.emit("create", {
|
|
124
|
-
editor
|
|
125
|
-
});
|
|
126
|
-
editor.isInitialized = true;
|
|
127
|
-
onEditorInitialize();
|
|
128
|
-
});
|
|
129
|
-
return ()=>{
|
|
130
|
-
editor.isInitialized = false;
|
|
131
|
-
editor.contentComponent = null;
|
|
132
|
-
onEditorDeinitialize();
|
|
133
|
-
};
|
|
134
|
-
}, [
|
|
135
|
-
editor,
|
|
136
|
-
onEditorDeinitialize,
|
|
137
|
-
onEditorInitialize
|
|
138
|
-
]);
|
|
139
|
-
return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_ProseMirrorDoc.ProseMirrorDoc, props), editor?.contentComponent && /*#__PURE__*/ _react.default.createElement(Portals, {
|
|
140
|
-
contentComponent: editor.contentComponent
|
|
141
|
-
}));
|
|
142
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditorView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditorView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _react1 = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
13
|
-
const _ProseMirror = require("../components/ProseMirror.js");
|
|
14
|
-
const _useForceUpdate = require("../hooks/useForceUpdate.js");
|
|
15
|
-
const _TiptapEditorContext = require("./contexts/TiptapEditorContext.js");
|
|
16
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
17
|
-
if (typeof WeakMap !== "function") return null;
|
|
18
|
-
var cacheBabelInterop = new WeakMap();
|
|
19
|
-
var cacheNodeInterop = new WeakMap();
|
|
20
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
21
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
22
|
-
})(nodeInterop);
|
|
23
|
-
}
|
|
24
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
25
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
|
-
return obj;
|
|
27
|
-
}
|
|
28
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
29
|
-
return {
|
|
30
|
-
default: obj
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
|
-
if (cache && cache.has(obj)) {
|
|
35
|
-
return cache.get(obj);
|
|
36
|
-
}
|
|
37
|
-
var newObj = {
|
|
38
|
-
__proto__: null
|
|
39
|
-
};
|
|
40
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
41
|
-
for(var key in obj){
|
|
42
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
44
|
-
if (desc && (desc.get || desc.set)) {
|
|
45
|
-
Object.defineProperty(newObj, key, desc);
|
|
46
|
-
} else {
|
|
47
|
-
newObj[key] = obj[key];
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
newObj.default = obj;
|
|
52
|
-
if (cache) {
|
|
53
|
-
cache.set(obj, newObj);
|
|
54
|
-
}
|
|
55
|
-
return newObj;
|
|
56
|
-
}
|
|
57
|
-
function TiptapEditorView(param) {
|
|
58
|
-
let { editor, nodeViews, markViews, children, static: isStatic = false } = param;
|
|
59
|
-
const [isEditorInitialized, setIsEditorInitialized] = (0, _react1.useState)(editor.isInitialized);
|
|
60
|
-
const forceUpdate = (0, _useForceUpdate.useForceUpdate)();
|
|
61
|
-
const dispatchTransaction = (0, _react1.useCallback)((tr)=>{
|
|
62
|
-
// @ts-expect-error calling private method
|
|
63
|
-
editor.dispatchTransaction(tr);
|
|
64
|
-
// Tiptap's dispatchTransaction doesn't trigger
|
|
65
|
-
// a re-render, so we need to manually force
|
|
66
|
-
// one to ensure that React stays in sync.
|
|
67
|
-
forceUpdate();
|
|
68
|
-
}, [
|
|
69
|
-
editor,
|
|
70
|
-
forceUpdate
|
|
71
|
-
]);
|
|
72
|
-
const initialEditorProps = {
|
|
73
|
-
...editor.options.editorProps,
|
|
74
|
-
attributes: {
|
|
75
|
-
role: "textbox",
|
|
76
|
-
...editor.options.editorProps?.attributes
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const { nodeViews: customNodeViews, markViews: customMarkViews } = editor.isDestroyed ? {
|
|
80
|
-
nodeViews: undefined,
|
|
81
|
-
markViews: undefined
|
|
82
|
-
} : editor.view.props;
|
|
83
|
-
const contextValue = (0, _react1.useMemo)(()=>({
|
|
84
|
-
editor
|
|
85
|
-
}), [
|
|
86
|
-
editor
|
|
87
|
-
]);
|
|
88
|
-
const onEditorInitialize = (0, _react1.useCallback)(()=>{
|
|
89
|
-
setIsEditorInitialized(true);
|
|
90
|
-
}, []);
|
|
91
|
-
const onEditorDeinitialize = (0, _react1.useCallback)(()=>{
|
|
92
|
-
setIsEditorInitialized(false);
|
|
93
|
-
}, []);
|
|
94
|
-
const tiptapEditorContextValue = (0, _react1.useMemo)(()=>({
|
|
95
|
-
isEditorInitialized,
|
|
96
|
-
onEditorInitialize,
|
|
97
|
-
onEditorDeinitialize
|
|
98
|
-
}), [
|
|
99
|
-
isEditorInitialized,
|
|
100
|
-
onEditorDeinitialize,
|
|
101
|
-
onEditorInitialize
|
|
102
|
-
]);
|
|
103
|
-
return /*#__PURE__*/ _react1.default.createElement(_ProseMirror.ProseMirror, {
|
|
104
|
-
static: isStatic,
|
|
105
|
-
className: "tiptap",
|
|
106
|
-
...initialEditorProps,
|
|
107
|
-
markViews: markViews,
|
|
108
|
-
customMarkViews: customMarkViews,
|
|
109
|
-
nodeViews: nodeViews,
|
|
110
|
-
customNodeViews: customNodeViews,
|
|
111
|
-
state: editor.state,
|
|
112
|
-
dispatchTransaction: dispatchTransaction
|
|
113
|
-
}, /*#__PURE__*/ _react1.default.createElement(_react.EditorContext.Provider, {
|
|
114
|
-
value: contextValue
|
|
115
|
-
}, /*#__PURE__*/ _react1.default.createElement(_TiptapEditorContext.TiptapEditorContext.Provider, {
|
|
116
|
-
value: tiptapEditorContextValue
|
|
117
|
-
}, children)));
|
|
118
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ReactProseMirrorNodeView", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ReactProseMirrorNodeView;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _core = require("@tiptap/core");
|
|
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
|
-
}
|
|
20
|
-
get dom() {
|
|
21
|
-
return this._dom;
|
|
22
|
-
}
|
|
23
|
-
get contentDOM() {
|
|
24
|
-
return this._contentDOM;
|
|
25
|
-
}
|
|
26
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "TiptapEditorContext", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return TiptapEditorContext;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("react");
|
|
12
|
-
const TiptapEditorContext = (0, _react.createContext)(null);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ReactProseMirror", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ReactProseMirror;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _core = require("@tiptap/core");
|
|
12
|
-
const _reorderSiblings = require("../../commands/reorderSiblings.js");
|
|
13
|
-
const _reactKeys = require("../../plugins/reactKeys.js");
|
|
14
|
-
const ReactProseMirror = _core.Extension.create({
|
|
15
|
-
name: "@handlewithcare/react-prosemirror/reactKeys",
|
|
16
|
-
addProseMirrorPlugins () {
|
|
17
|
-
return [
|
|
18
|
-
(0, _reactKeys.reactKeys)()
|
|
19
|
-
];
|
|
20
|
-
},
|
|
21
|
-
addCommands () {
|
|
22
|
-
return {
|
|
23
|
-
/**
|
|
24
|
-
* Command that reorders the adjacent nodes starting
|
|
25
|
-
* at the provided position.
|
|
26
|
-
*
|
|
27
|
-
* @param pos - The `start` position of the parent of the nodes being reordered
|
|
28
|
-
* @param order - The new order for the nodes, expressed as an array of indices. For
|
|
29
|
-
* example, to swap the first two nodes in a set of three, `order`
|
|
30
|
-
* would be set to `[1, 0, 2]`. To move the first node to the end,
|
|
31
|
-
* and keep the other two in relative order, set `order` to `[1, 2, 0]`.
|
|
32
|
-
*/ reorderSiblings (initialPos, order) {
|
|
33
|
-
return function reorderSiblingsCommand(param) {
|
|
34
|
-
let { tr, state, dispatch } = param;
|
|
35
|
-
return (0, _reorderSiblings.reorderSiblingsOnTransaction)(initialPos, order, tr, state, dispatch);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useIsInReactProseMirror", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useIsInReactProseMirror;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("react");
|
|
12
|
-
const _EditorContext = require("../../contexts/EditorContext.js");
|
|
13
|
-
function useIsInReactProseMirror() {
|
|
14
|
-
return (0, _react.useContext)(_EditorContext.EditorContext) !== null;
|
|
15
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useTiptapEditor", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useTiptapEditor;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _StaticEditorView = require("../../StaticEditorView.js");
|
|
13
|
-
function useTiptapEditor(options, deps) {
|
|
14
|
-
const editor = (0, _react.useEditor)({
|
|
15
|
-
...options,
|
|
16
|
-
element: null
|
|
17
|
-
}, deps);
|
|
18
|
-
// @ts-expect-error private property
|
|
19
|
-
editor.editorView ??= new _StaticEditorView.StaticEditorView({
|
|
20
|
-
// @ts-expect-error private property
|
|
21
|
-
state: editor.editorState,
|
|
22
|
-
...editor.options.editorProps,
|
|
23
|
-
attributes: {
|
|
24
|
-
role: "textbox",
|
|
25
|
-
...editor.options.editorProps.attributes
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
// @ts-expect-error private property
|
|
29
|
-
const stateHasPlugins = !!editor.editorState.plugins.length;
|
|
30
|
-
const stateNeedsReconfigure = !stateHasPlugins && !editor.isDestroyed;
|
|
31
|
-
if (stateNeedsReconfigure) {
|
|
32
|
-
const managerPlugins = editor.extensionManager.plugins;
|
|
33
|
-
if (managerPlugins.length) {
|
|
34
|
-
// @ts-expect-error private property
|
|
35
|
-
editor.editorState = editor.editorState.reconfigure({
|
|
36
|
-
plugins: editor.extensionManager.plugins
|
|
37
|
-
});
|
|
38
|
-
// @ts-expect-error private property
|
|
39
|
-
editor.editorView.updateState(editor.editorState);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return editor;
|
|
43
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useTiptapEditorEffect", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useTiptapEditorEffect;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _react1 = require("react");
|
|
13
|
-
const _ReactEditorView = require("../../ReactEditorView.js");
|
|
14
|
-
const _EditorContext = require("../../contexts/EditorContext.js");
|
|
15
|
-
const _useEditorEffect = require("../../hooks/useEditorEffect.js");
|
|
16
|
-
const _TiptapEditorContext = require("../contexts/TiptapEditorContext.js");
|
|
17
|
-
function useTiptapEditorEffect(effect, dependencies) {
|
|
18
|
-
const { view } = (0, _react1.useContext)(_EditorContext.EditorContext);
|
|
19
|
-
const { editor } = (0, _react.useCurrentEditor)();
|
|
20
|
-
const { isEditorInitialized } = (0, _react1.useContext)(_TiptapEditorContext.TiptapEditorContext);
|
|
21
|
-
(0, _useEditorEffect.useEditorEffect)(()=>{
|
|
22
|
-
if (editor?.view instanceof _ReactEditorView.ReactEditorView && view instanceof _ReactEditorView.ReactEditorView && isEditorInitialized) {
|
|
23
|
-
return effect(editor);
|
|
24
|
-
}
|
|
25
|
-
// The rules of hooks want to be able to statically
|
|
26
|
-
// verify the dependencies for the effect, but this will
|
|
27
|
-
// have already happened at the call-site.
|
|
28
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
|
-
}, dependencies && [
|
|
30
|
-
editor,
|
|
31
|
-
view,
|
|
32
|
-
isEditorInitialized,
|
|
33
|
-
...dependencies
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "useTiptapEditorEventCallback", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return useTiptapEditorEventCallback;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _react = require("@tiptap/react");
|
|
12
|
-
const _react1 = require("react");
|
|
13
|
-
const _useEditorEffect = require("../../hooks/useEditorEffect.js");
|
|
14
|
-
function assertEditor(editor) {
|
|
15
|
-
if (editor) return;
|
|
16
|
-
throw new DOMException("Tiptap Editor is not initialized", "InvalidStateError");
|
|
17
|
-
}
|
|
18
|
-
function useTiptapEditorEventCallback(callback) {
|
|
19
|
-
const ref = (0, _react1.useRef)(callback);
|
|
20
|
-
const { editor } = (0, _react.useCurrentEditor)();
|
|
21
|
-
(0, _useEditorEffect.useEditorEffect)(()=>{
|
|
22
|
-
ref.current = callback;
|
|
23
|
-
}, [
|
|
24
|
-
callback
|
|
25
|
-
]);
|
|
26
|
-
return (0, _react1.useCallback)(function() {
|
|
27
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
28
|
-
args[_key] = arguments[_key];
|
|
29
|
-
}
|
|
30
|
-
assertEditor(editor);
|
|
31
|
-
return ref.current(editor, ...args);
|
|
32
|
-
}, [
|
|
33
|
-
editor
|
|
34
|
-
]);
|
|
35
|
-
}
|
package/dist/cjs/tiptap/index.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: all[name]
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
ReactProseMirror: function() {
|
|
13
|
-
return _ReactProseMirror.ReactProseMirror;
|
|
14
|
-
},
|
|
15
|
-
TiptapEditor: function() {
|
|
16
|
-
return _TiptapEditor.TiptapEditor;
|
|
17
|
-
},
|
|
18
|
-
TiptapEditorContent: function() {
|
|
19
|
-
return _TiptapEditorContent.TiptapEditorContent;
|
|
20
|
-
},
|
|
21
|
-
TiptapEditorView: function() {
|
|
22
|
-
return _TiptapEditorView.TiptapEditorView;
|
|
23
|
-
},
|
|
24
|
-
tiptapNodeView: function() {
|
|
25
|
-
return _tiptapNodeView.tiptapNodeView;
|
|
26
|
-
},
|
|
27
|
-
useIsInReactProseMirror: function() {
|
|
28
|
-
return _useIsInReactProseMirror.useIsInReactProseMirror;
|
|
29
|
-
},
|
|
30
|
-
useTiptapEditor: function() {
|
|
31
|
-
return _useTiptapEditor.useTiptapEditor;
|
|
32
|
-
},
|
|
33
|
-
useTiptapEditorEffect: function() {
|
|
34
|
-
return _useTiptapEditorEffect.useTiptapEditorEffect;
|
|
35
|
-
},
|
|
36
|
-
useTiptapEditorEventCallback: function() {
|
|
37
|
-
return _useTiptapEditorEventCallback.useTiptapEditorEventCallback;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
const _tiptapNodeView = require("./tiptapNodeView.js");
|
|
41
|
-
const _TiptapEditorView = require("./TiptapEditorView.js");
|
|
42
|
-
const _TiptapEditorContent = require("./TiptapEditorContent.js");
|
|
43
|
-
const _useTiptapEditorEffect = require("./hooks/useTiptapEditorEffect.js");
|
|
44
|
-
const _useIsInReactProseMirror = require("./hooks/useIsInReactProseMirror.js");
|
|
45
|
-
const _useTiptapEditorEventCallback = require("./hooks/useTiptapEditorEventCallback.js");
|
|
46
|
-
const _TiptapEditor = require("./TiptapEditor.js");
|
|
47
|
-
const _useTiptapEditor = require("./hooks/useTiptapEditor.js");
|
|
48
|
-
const _ReactProseMirror = require("./extensions/ReactProseMirror.js");
|