@ctzhian/tiptap 2.1.1 → 2.1.2
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.
|
@@ -25,7 +25,7 @@ var Reader = function Reader() {
|
|
|
25
25
|
return _context.abrupt("return", new Promise(function (resolve) {
|
|
26
26
|
var progress = 0;
|
|
27
27
|
var interval = setInterval(function () {
|
|
28
|
-
progress += Math.random() *
|
|
28
|
+
progress += Math.random() * 5;
|
|
29
29
|
if (progress >= 100) {
|
|
30
30
|
progress = 100;
|
|
31
31
|
onProgress === null || onProgress === void 0 || onProgress({
|
|
@@ -119,14 +119,8 @@ var Reader = function Reader() {
|
|
|
119
119
|
onSave: function onSave(editor) {
|
|
120
120
|
var value = editor.getMarkdown();
|
|
121
121
|
console.log(value);
|
|
122
|
-
// editor.chain().focus().setContent(value, {
|
|
123
|
-
// contentType: 'markdown'
|
|
124
|
-
// }).run()
|
|
125
122
|
},
|
|
126
|
-
|
|
127
|
-
// console.log('toc', toc)
|
|
128
|
-
// },
|
|
129
|
-
content: mdContent
|
|
123
|
+
content: ''
|
|
130
124
|
}),
|
|
131
125
|
editor = _useTiptap.editor;
|
|
132
126
|
var handleGlobalSave = useCallback(function (event) {
|
|
@@ -142,6 +136,11 @@ var Reader = function Reader() {
|
|
|
142
136
|
document.removeEventListener('keydown', handleGlobalSave);
|
|
143
137
|
};
|
|
144
138
|
}, [handleGlobalSave]);
|
|
139
|
+
useEffect(function () {
|
|
140
|
+
editor.commands.setContent(mdContent, {
|
|
141
|
+
contentType: 'markdown'
|
|
142
|
+
});
|
|
143
|
+
}, [mdContent, editor]);
|
|
145
144
|
return /*#__PURE__*/React.createElement(EditorThemeProvider, {
|
|
146
145
|
mode: "light"
|
|
147
146
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -139,18 +139,34 @@ var ImageViewWrapper = function ImageViewWrapper(_ref) {
|
|
|
139
139
|
useEffect(function () {
|
|
140
140
|
if (attrs.src && (!attrs.width || attrs.width <= 0)) {
|
|
141
141
|
getImageDimensions(attrs.src).then(function (dimensions) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
142
|
+
try {
|
|
143
|
+
var pos = typeof getPos === 'function' ? getPos() : null;
|
|
144
|
+
if (pos === null || pos === undefined) return;
|
|
145
|
+
var currentNode = editor.state.doc.nodeAt(pos);
|
|
146
|
+
if (!currentNode || currentNode.type.name !== 'image') return;
|
|
147
|
+
updateAttributes({
|
|
148
|
+
src: attrs.src,
|
|
149
|
+
width: dimensions.width
|
|
150
|
+
});
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.warn('Failed to update image dimensions:', error);
|
|
153
|
+
}
|
|
146
154
|
}).catch(function (error) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
try {
|
|
156
|
+
var pos = typeof getPos === 'function' ? getPos() : null;
|
|
157
|
+
if (pos === null || pos === undefined) return;
|
|
158
|
+
var currentNode = editor.state.doc.nodeAt(pos);
|
|
159
|
+
if (!currentNode || currentNode.type.name !== 'image') return;
|
|
160
|
+
updateAttributes({
|
|
161
|
+
src: attrs.src,
|
|
162
|
+
width: 400
|
|
163
|
+
});
|
|
164
|
+
} catch (updateError) {
|
|
165
|
+
console.warn('Failed to update image attributes with fallback width:', updateError);
|
|
166
|
+
}
|
|
151
167
|
});
|
|
152
168
|
}
|
|
153
|
-
}, [attrs.src, attrs.width, updateAttributes]);
|
|
169
|
+
}, [attrs.src, attrs.width, updateAttributes, getPos, editor]);
|
|
154
170
|
var handleMouseDown = function handleMouseDown(e, corner) {
|
|
155
171
|
e.preventDefault();
|
|
156
172
|
e.stopPropagation();
|
|
@@ -386,10 +386,9 @@ export var TableSelectionOverlay = function TableSelectionOverlay(_ref2) {
|
|
|
386
386
|
var c = tableDom === null || tableDom === void 0 ? void 0 : tableDom.querySelector('.table-selection-overlay-container');
|
|
387
387
|
containerRef.current = c !== null && c !== void 0 ? c : null;
|
|
388
388
|
}, [tableDom]);
|
|
389
|
-
if (!isVisible || !selectionRect) {
|
|
389
|
+
if (!isVisible || !selectionRect || !editor || !editor.isEditable) {
|
|
390
390
|
return null;
|
|
391
391
|
}
|
|
392
|
-
if (!editor) return null;
|
|
393
392
|
var renderCellMenu = function renderCellMenu() {
|
|
394
393
|
if (!CellMenu) return null;
|
|
395
394
|
return /*#__PURE__*/React.createElement("span", {
|