@ctzhian/tiptap 1.12.15 → 1.12.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EditorToolbar/index.js +1 -3
- package/dist/component/CustomDragHandle/index.js +0 -1
- package/dist/component/Toolbar/EditorInsert/index.d.ts +1 -2
- package/dist/component/Toolbar/EditorInsert/index.js +5 -12
- package/dist/extension/index.js +6 -6
- package/dist/extension/node/Attachment.js +13 -6
- package/dist/extension/node/Audio.js +11 -3
- package/dist/extension/node/Iframe.js +10 -2
- package/dist/extension/node/Video.js +11 -3
- package/package.json +1 -1
|
@@ -7,7 +7,6 @@ import { hasMarksInSelection } from "../util";
|
|
|
7
7
|
var EditorToolbar = function EditorToolbar(_ref) {
|
|
8
8
|
var editor = _ref.editor,
|
|
9
9
|
menuInToolbarMore = _ref.menuInToolbarMore;
|
|
10
|
-
var isMarkdown = editor.options.contentType === 'markdown';
|
|
11
10
|
var _useEditorState = useEditorState({
|
|
12
11
|
editor: editor,
|
|
13
12
|
selector: function selector(ctx) {
|
|
@@ -88,8 +87,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
88
87
|
},
|
|
89
88
|
className: isAiWriting ? 'tool-active' : ''
|
|
90
89
|
}), /*#__PURE__*/React.createElement(EditorInsert, {
|
|
91
|
-
editor: editor
|
|
92
|
-
isMarkdown: isMarkdown
|
|
90
|
+
editor: editor
|
|
93
91
|
}), /*#__PURE__*/React.createElement(Divider, {
|
|
94
92
|
orientation: "vertical",
|
|
95
93
|
flexItem: true,
|
|
@@ -98,7 +98,6 @@ var CustomDragHandle = function CustomDragHandle(_ref3) {
|
|
|
98
98
|
more = _ref3.more,
|
|
99
99
|
onTip = _ref3.onTip;
|
|
100
100
|
var theme = useTheme();
|
|
101
|
-
var isMarkdown = editor.options.contentType === 'markdown';
|
|
102
101
|
var _useState = useState({
|
|
103
102
|
editor: editor,
|
|
104
103
|
node: null,
|
|
@@ -2,7 +2,6 @@ import { Editor } from '@tiptap/react';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
interface EditorInsertProps {
|
|
4
4
|
editor: Editor;
|
|
5
|
-
isMarkdown: boolean;
|
|
6
5
|
}
|
|
7
|
-
declare const EditorInsert: ({ editor
|
|
6
|
+
declare const EditorInsert: ({ editor }: EditorInsertProps) => React.JSX.Element;
|
|
8
7
|
export default EditorInsert;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
1
|
import { getShortcutKeyText } from "../../../util";
|
|
8
2
|
import { Typography } from '@mui/material';
|
|
9
3
|
import React from 'react';
|
|
@@ -12,8 +6,7 @@ import Menu from "../../Menu";
|
|
|
12
6
|
import ToolbarItem from "../Item";
|
|
13
7
|
import TableSizePicker from "../TableSizePicker";
|
|
14
8
|
var EditorInsert = function EditorInsert(_ref) {
|
|
15
|
-
var editor = _ref.editor
|
|
16
|
-
isMarkdown = _ref.isMarkdown;
|
|
9
|
+
var editor = _ref.editor;
|
|
17
10
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
18
11
|
width: 224,
|
|
19
12
|
context: /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
@@ -95,7 +88,7 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
95
88
|
}
|
|
96
89
|
})
|
|
97
90
|
}]
|
|
98
|
-
}
|
|
91
|
+
}, {
|
|
99
92
|
label: '文件',
|
|
100
93
|
key: 'file',
|
|
101
94
|
icon: /*#__PURE__*/React.createElement(Folder2LineIcon, {
|
|
@@ -168,7 +161,7 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
168
161
|
});
|
|
169
162
|
}
|
|
170
163
|
}]
|
|
171
|
-
}
|
|
164
|
+
}, {
|
|
172
165
|
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
173
166
|
sx: {
|
|
174
167
|
px: 1,
|
|
@@ -407,7 +400,7 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
407
400
|
});
|
|
408
401
|
}
|
|
409
402
|
}]
|
|
410
|
-
}
|
|
403
|
+
}, {
|
|
411
404
|
customLabel: /*#__PURE__*/React.createElement(Typography, {
|
|
412
405
|
sx: {
|
|
413
406
|
px: 1,
|
|
@@ -432,7 +425,7 @@ var EditorInsert = function EditorInsert(_ref) {
|
|
|
432
425
|
height: 400
|
|
433
426
|
});
|
|
434
427
|
}
|
|
435
|
-
}]
|
|
428
|
+
}]
|
|
436
429
|
});
|
|
437
430
|
};
|
|
438
431
|
export default EditorInsert;
|
package/dist/extension/index.js
CHANGED
|
@@ -44,7 +44,10 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
44
44
|
color: 'var(--mui-palette-primary-main)',
|
|
45
45
|
width: 2
|
|
46
46
|
}
|
|
47
|
-
}), TextStyleKit, CodeExtension, ListExtension, EmojiExtension, AlertExtension, CustomSubscript, DetailsExtension, CustomSuperscript, DetailsContentExtension, DetailsSummaryExtension, CodeBlockLowlightExtension, InlineUploadProgressExtension, YamlFormat, CustomHorizontalRule,
|
|
47
|
+
}), TextStyleKit, CodeExtension, ListExtension, EmojiExtension, AlertExtension, CustomSubscript, DetailsExtension, CustomSuperscript, DetailsContentExtension, DetailsSummaryExtension, CodeBlockLowlightExtension, InlineUploadProgressExtension, YamlFormat, CustomHorizontalRule, IframeExtension({
|
|
48
|
+
onError: onError,
|
|
49
|
+
onValidateUrl: onValidateUrl
|
|
50
|
+
}), VideoExtension({
|
|
48
51
|
onUpload: onUpload,
|
|
49
52
|
onError: onError,
|
|
50
53
|
onValidateUrl: onValidateUrl
|
|
@@ -113,13 +116,10 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
113
116
|
}
|
|
114
117
|
}));
|
|
115
118
|
} else {
|
|
116
|
-
defaultExtensions.push.apply(defaultExtensions, [InlineLinkExtension, BlockLinkExtension,
|
|
117
|
-
onError: onError,
|
|
118
|
-
onValidateUrl: onValidateUrl
|
|
119
|
-
}), BlockAttachmentExtension({
|
|
119
|
+
defaultExtensions.push.apply(defaultExtensions, [InlineLinkExtension, BlockLinkExtension, InlineAttachmentExtension({
|
|
120
120
|
onUpload: onUpload,
|
|
121
121
|
onError: onError
|
|
122
|
-
}),
|
|
122
|
+
}), BlockAttachmentExtension({
|
|
123
123
|
onUpload: onUpload,
|
|
124
124
|
onError: onError
|
|
125
125
|
})]);
|
|
@@ -81,6 +81,13 @@ export var InlineAttachmentExtension = function InlineAttachmentExtension(props)
|
|
|
81
81
|
'data-tag': 'attachment'
|
|
82
82
|
}, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes))];
|
|
83
83
|
},
|
|
84
|
+
renderMarkdown: function renderMarkdown(node) {
|
|
85
|
+
var _ref2 = node.attrs,
|
|
86
|
+
url = _ref2.url,
|
|
87
|
+
title = _ref2.title;
|
|
88
|
+
if (!url) return '';
|
|
89
|
+
return "<a href=\"".concat(url, "\" target=\"_blank\" download=\"").concat(title, "\">").concat(title, "</a>");
|
|
90
|
+
},
|
|
84
91
|
addKeyboardShortcuts: function addKeyboardShortcuts() {
|
|
85
92
|
var _this = this;
|
|
86
93
|
return {
|
|
@@ -97,8 +104,8 @@ export var InlineAttachmentExtension = function InlineAttachmentExtension(props)
|
|
|
97
104
|
var _this2 = this;
|
|
98
105
|
return {
|
|
99
106
|
setInlineAttachment: function setInlineAttachment(options) {
|
|
100
|
-
return function (
|
|
101
|
-
var commands =
|
|
107
|
+
return function (_ref3) {
|
|
108
|
+
var commands = _ref3.commands;
|
|
102
109
|
return commands.insertContent({
|
|
103
110
|
type: _this2.name,
|
|
104
111
|
attrs: {
|
|
@@ -190,8 +197,8 @@ export var BlockAttachmentExtension = function BlockAttachmentExtension(props) {
|
|
|
190
197
|
}
|
|
191
198
|
}];
|
|
192
199
|
},
|
|
193
|
-
renderHTML: function renderHTML(
|
|
194
|
-
var HTMLAttributes =
|
|
200
|
+
renderHTML: function renderHTML(_ref4) {
|
|
201
|
+
var HTMLAttributes = _ref4.HTMLAttributes;
|
|
195
202
|
return ['div', _objectSpread({
|
|
196
203
|
'data-tag': 'attachment'
|
|
197
204
|
}, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes))];
|
|
@@ -200,8 +207,8 @@ export var BlockAttachmentExtension = function BlockAttachmentExtension(props) {
|
|
|
200
207
|
var _this3 = this;
|
|
201
208
|
return {
|
|
202
209
|
setBlockAttachment: function setBlockAttachment(options) {
|
|
203
|
-
return function (
|
|
204
|
-
var commands =
|
|
210
|
+
return function (_ref5) {
|
|
211
|
+
var commands = _ref5.commands;
|
|
205
212
|
return commands.insertContent({
|
|
206
213
|
type: _this3.name,
|
|
207
214
|
attrs: {
|
|
@@ -137,9 +137,17 @@ export var AudioExtension = function AudioExtension(props) {
|
|
|
137
137
|
var HTMLAttributes = _ref.HTMLAttributes;
|
|
138
138
|
return ['audio', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
139
139
|
},
|
|
140
|
-
renderMarkdown: function renderMarkdown(
|
|
141
|
-
var
|
|
142
|
-
|
|
140
|
+
renderMarkdown: function renderMarkdown(node) {
|
|
141
|
+
var _ref2 = node.attrs,
|
|
142
|
+
src = _ref2.src,
|
|
143
|
+
title = _ref2.title,
|
|
144
|
+
poster = _ref2.poster,
|
|
145
|
+
controls = _ref2.controls,
|
|
146
|
+
autoplay = _ref2.autoplay,
|
|
147
|
+
loop = _ref2.loop,
|
|
148
|
+
muted = _ref2.muted;
|
|
149
|
+
if (!src) return '';
|
|
150
|
+
return "<audio src=\"".concat(src, "\" ").concat(title ? "title=\"".concat(title, "\"") : '', " ").concat(poster ? "poster=\"".concat(poster, "\"") : '', " ").concat(controls ? 'controls' : '', " ").concat(autoplay ? 'autoplay' : '', " ").concat(loop ? 'loop' : '', " ").concat(muted ? 'muted' : '', "></audio>");
|
|
143
151
|
},
|
|
144
152
|
addCommands: function addCommands() {
|
|
145
153
|
var _this2 = this;
|
|
@@ -90,12 +90,20 @@ export var IframeExtension = function IframeExtension(props) {
|
|
|
90
90
|
loop: '0'
|
|
91
91
|
}))];
|
|
92
92
|
},
|
|
93
|
+
renderMarkdown: function renderMarkdown(node) {
|
|
94
|
+
var _ref3 = node.attrs,
|
|
95
|
+
src = _ref3.src,
|
|
96
|
+
width = _ref3.width,
|
|
97
|
+
height = _ref3.height;
|
|
98
|
+
if (!src || src.trim() === '') return '';
|
|
99
|
+
return "<iframe src=\"".concat(src, "\" ").concat(width ? "width=\"".concat(width, "\"") : '', " ").concat(height ? "height=\"".concat(height, "\"") : '', " frameborder=\"0\" allowfullscreen=\"true\" autoplay=\"0\" loop=\"0\"></iframe>");
|
|
100
|
+
},
|
|
93
101
|
addCommands: function addCommands() {
|
|
94
102
|
var _this = this;
|
|
95
103
|
return {
|
|
96
104
|
setIframe: function setIframe(options) {
|
|
97
|
-
return function (
|
|
98
|
-
var commands =
|
|
105
|
+
return function (_ref4) {
|
|
106
|
+
var commands = _ref4.commands;
|
|
99
107
|
return commands.insertContent({
|
|
100
108
|
type: _this.name,
|
|
101
109
|
attrs: {
|
|
@@ -143,9 +143,17 @@ export var VideoExtension = function VideoExtension(props) {
|
|
|
143
143
|
var HTMLAttributes = _ref.HTMLAttributes;
|
|
144
144
|
return ['video', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
145
145
|
},
|
|
146
|
-
renderMarkdown: function renderMarkdown(
|
|
147
|
-
var
|
|
148
|
-
|
|
146
|
+
renderMarkdown: function renderMarkdown(node) {
|
|
147
|
+
var _ref2 = node.attrs,
|
|
148
|
+
src = _ref2.src,
|
|
149
|
+
width = _ref2.width,
|
|
150
|
+
controls = _ref2.controls,
|
|
151
|
+
autoplay = _ref2.autoplay,
|
|
152
|
+
loop = _ref2.loop,
|
|
153
|
+
muted = _ref2.muted,
|
|
154
|
+
poster = _ref2.poster;
|
|
155
|
+
if (!src) return '';
|
|
156
|
+
return "<video src=\"".concat(src, "\" ").concat(width ? "width=\"".concat(width, "\"") : '', " ").concat(controls ? 'controls' : '', " ").concat(autoplay ? 'autoplay' : '', " ").concat(loop ? 'loop' : '', " ").concat(muted ? 'muted' : '', " ").concat(poster ? "poster=\"".concat(poster, "\"") : '', "></video>");
|
|
149
157
|
},
|
|
150
158
|
addCommands: function addCommands() {
|
|
151
159
|
var _this2 = this;
|