@ctzhian/tiptap 1.13.4 → 1.13.6
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/Editor/demo.js +2 -1
- package/dist/EditorToolbar/index.d.ts +8 -1
- package/dist/EditorToolbar/index.js +70 -15
- package/dist/component/Icons/collapse-horizontal-line.d.ts +6 -0
- package/dist/component/Icons/collapse-horizontal-line.js +13 -0
- package/dist/component/Icons/expand-horizontal-line.d.ts +6 -0
- package/dist/component/Icons/expand-horizontal-line.js +13 -0
- package/dist/component/Icons/index.d.ts +2 -0
- package/dist/component/Icons/index.js +3 -1
- package/dist/extension/component/UploadProgress/index.d.ts +1 -1
- package/dist/extension/index.d.ts +1 -1
- package/dist/extension/index.js +3 -2
- package/dist/hook/index.d.ts +1 -1
- package/dist/hook/index.js +4 -2
- package/dist/type/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/Editor/demo.js
CHANGED
|
@@ -173,7 +173,8 @@ var Reader = function Reader() {
|
|
|
173
173
|
marginBottom: '30px'
|
|
174
174
|
}
|
|
175
175
|
}, /*#__PURE__*/React.createElement(EditorToolbar, {
|
|
176
|
-
editor: editor
|
|
176
|
+
editor: editor,
|
|
177
|
+
mode: "advanced"
|
|
177
178
|
})), /*#__PURE__*/React.createElement(Box, {
|
|
178
179
|
sx: {
|
|
179
180
|
'.tiptap': {
|
|
@@ -4,6 +4,13 @@ import { ToolbarItemType } from '../type';
|
|
|
4
4
|
interface EditorToolbarProps {
|
|
5
5
|
editor: Editor;
|
|
6
6
|
menuInToolbarMore?: ToolbarItemType[];
|
|
7
|
+
/**
|
|
8
|
+
* Toolbar 模式
|
|
9
|
+
* - advanced:展示全部工具
|
|
10
|
+
* - simple:只展示常用工具,并尽量保持单行
|
|
11
|
+
*/
|
|
12
|
+
mode?: 'simple' | 'advanced';
|
|
13
|
+
onModeChange?: (mode: 'simple' | 'advanced') => void;
|
|
7
14
|
}
|
|
8
|
-
declare const EditorToolbar: ({ editor, menuInToolbarMore }: EditorToolbarProps) => React.JSX.Element;
|
|
15
|
+
declare const EditorToolbar: ({ editor, menuInToolbarMore, mode, onModeChange, }: EditorToolbarProps) => React.JSX.Element;
|
|
9
16
|
export default EditorToolbar;
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _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; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
7
|
import { Box, Divider, Stack } from '@mui/material';
|
|
2
8
|
import { useEditorState } from '@tiptap/react';
|
|
3
9
|
import React from 'react';
|
|
4
|
-
import { AiGenerate2Icon, ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, EraserLineIcon, ItalicIcon, LinkIcon, MarkPenLineIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, UnderlineIcon } from "../component/Icons";
|
|
10
|
+
import { AiGenerate2Icon, ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, CodeBoxLineIcon, CollapseHorizontalLine, EraserLineIcon, ExpandHorizontalLineIcon, ItalicIcon, LinkIcon, MarkPenLineIcon, StrikethroughIcon, SubscriptIcon, SuperscriptIcon, UnderlineIcon } from "../component/Icons";
|
|
5
11
|
import { EditorAlignSelect, EditorFontBgColor, EditorFontColor, EditorFontSize, EditorHeading, EditorInsert, EditorListSelect, EditorMore, EditorVerticalAlignSelect, ToolbarItem } from "../component/Toolbar";
|
|
6
12
|
import { hasMarksInSelection } from "../util";
|
|
7
13
|
var EditorToolbar = function EditorToolbar(_ref) {
|
|
8
14
|
var editor = _ref.editor,
|
|
9
|
-
menuInToolbarMore = _ref.menuInToolbarMore
|
|
15
|
+
menuInToolbarMore = _ref.menuInToolbarMore,
|
|
16
|
+
mode = _ref.mode,
|
|
17
|
+
onModeChange = _ref.onModeChange;
|
|
18
|
+
var _React$useState = React.useState(function () {
|
|
19
|
+
return mode !== null && mode !== void 0 ? mode : 'advanced';
|
|
20
|
+
}),
|
|
21
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
22
|
+
toolbarMode = _React$useState2[0],
|
|
23
|
+
setToolbarMode = _React$useState2[1];
|
|
24
|
+
React.useEffect(function () {
|
|
25
|
+
if (typeof mode !== 'undefined') {
|
|
26
|
+
setToolbarMode(mode);
|
|
27
|
+
}
|
|
28
|
+
}, [mode]);
|
|
29
|
+
var isSimpleMode = toolbarMode === 'simple';
|
|
30
|
+
var handleToggleMode = React.useCallback(function () {
|
|
31
|
+
var nextMode = isSimpleMode ? 'advanced' : 'simple';
|
|
32
|
+
setToolbarMode(nextMode);
|
|
33
|
+
onModeChange === null || onModeChange === void 0 || onModeChange(nextMode);
|
|
34
|
+
}, [isSimpleMode, onModeChange]);
|
|
10
35
|
var _useEditorState = useEditorState({
|
|
11
36
|
editor: editor,
|
|
12
37
|
selector: function selector(ctx) {
|
|
@@ -23,7 +48,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
23
48
|
isSubscript: ctx.editor.isActive('subscript'),
|
|
24
49
|
isLink: ctx.editor.isActive('link'),
|
|
25
50
|
isHighlight: ctx.editor.isActive('highlight'),
|
|
26
|
-
isAiWriting: !!((_ctx$editor$storage = ctx.editor.storage) !== null && _ctx$editor$storage !== void 0 && (_ctx$editor$storage = _ctx$editor$storage.aiWriting) !== null && _ctx$editor$storage !== void 0 && _ctx$editor$storage.enabled)
|
|
51
|
+
isAiWriting: !!((_ctx$editor$storage = ctx.editor.storage) !== null && _ctx$editor$storage !== void 0 && (_ctx$editor$storage = _ctx$editor$storage.aiWriting) !== null && _ctx$editor$storage !== void 0 && _ctx$editor$storage.enabled),
|
|
52
|
+
isCodeBlock: ctx.editor.isActive('codeBlock')
|
|
27
53
|
};
|
|
28
54
|
}
|
|
29
55
|
}),
|
|
@@ -38,16 +64,19 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
38
64
|
isSubscript = _useEditorState.isSubscript,
|
|
39
65
|
isLink = _useEditorState.isLink,
|
|
40
66
|
isAiWriting = _useEditorState.isAiWriting,
|
|
41
|
-
isHighlight = _useEditorState.isHighlight
|
|
67
|
+
isHighlight = _useEditorState.isHighlight,
|
|
68
|
+
isCodeBlock = _useEditorState.isCodeBlock;
|
|
42
69
|
return /*#__PURE__*/React.createElement(Box, {
|
|
43
70
|
className: "editor-toolbar"
|
|
44
71
|
}, /*#__PURE__*/React.createElement(Stack, {
|
|
45
72
|
direction: "row",
|
|
46
73
|
alignItems: "center",
|
|
47
|
-
justifyContent:
|
|
48
|
-
flexWrap: 'wrap',
|
|
74
|
+
justifyContent: isSimpleMode ? 'flex-start' : 'center',
|
|
75
|
+
flexWrap: isSimpleMode ? 'nowrap' : 'wrap',
|
|
49
76
|
sx: {
|
|
50
77
|
minHeight: '44px',
|
|
78
|
+
overflowX: isSimpleMode ? 'auto' : 'visible',
|
|
79
|
+
columnGap: 0.5,
|
|
51
80
|
'.MuiSelect-root': {
|
|
52
81
|
minWidth: '36px',
|
|
53
82
|
bgcolor: 'background.paper',
|
|
@@ -72,7 +101,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
72
101
|
}
|
|
73
102
|
}
|
|
74
103
|
}
|
|
75
|
-
}, editor.options.extensions.find(function (it) {
|
|
104
|
+
}, !isSimpleMode && editor.options.extensions.find(function (it) {
|
|
76
105
|
return it.name === 'aiWriting';
|
|
77
106
|
}) && /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
78
107
|
text: 'AI 伴写',
|
|
@@ -86,7 +115,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
86
115
|
return editor.chain().focus().setAiWriting(!isAiWriting).run();
|
|
87
116
|
},
|
|
88
117
|
className: isAiWriting ? 'tool-active' : ''
|
|
89
|
-
}), /*#__PURE__*/React.createElement(EditorInsert, {
|
|
118
|
+
}), !isSimpleMode && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorInsert, {
|
|
90
119
|
editor: editor
|
|
91
120
|
}), /*#__PURE__*/React.createElement(Divider, {
|
|
92
121
|
orientation: "vertical",
|
|
@@ -96,7 +125,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
96
125
|
height: 20,
|
|
97
126
|
alignSelf: 'center'
|
|
98
127
|
}
|
|
99
|
-
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
128
|
+
})), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
100
129
|
tip: '撤销',
|
|
101
130
|
shortcutKey: ['ctrl', 'Z'],
|
|
102
131
|
icon: /*#__PURE__*/React.createElement(ArrowGoBackLineIcon, {
|
|
@@ -141,7 +170,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
141
170
|
}
|
|
142
171
|
}), /*#__PURE__*/React.createElement(EditorHeading, {
|
|
143
172
|
editor: editor
|
|
144
|
-
}), /*#__PURE__*/React.createElement(EditorFontSize, {
|
|
173
|
+
}), !isSimpleMode && /*#__PURE__*/React.createElement(EditorFontSize, {
|
|
145
174
|
editor: editor
|
|
146
175
|
}), /*#__PURE__*/React.createElement(Divider, {
|
|
147
176
|
orientation: "vertical",
|
|
@@ -175,7 +204,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
175
204
|
return editor.chain().focus().toggleItalic().run();
|
|
176
205
|
},
|
|
177
206
|
className: isItalic ? 'tool-active' : ''
|
|
178
|
-
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
207
|
+
}), !isSimpleMode && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
179
208
|
tip: '删除线',
|
|
180
209
|
shortcutKey: ['ctrl', 'shift', 'S'],
|
|
181
210
|
icon: /*#__PURE__*/React.createElement(StrikethroughIcon, {
|
|
@@ -199,7 +228,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
199
228
|
return editor.chain().focus().toggleUnderline().run();
|
|
200
229
|
},
|
|
201
230
|
className: isUnderline ? 'tool-active' : ''
|
|
202
|
-
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
231
|
+
})), !isSimpleMode && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
203
232
|
tip: '高亮',
|
|
204
233
|
shortcutKey: ['ctrl', 'shift', 'H'],
|
|
205
234
|
icon: /*#__PURE__*/React.createElement(MarkPenLineIcon, {
|
|
@@ -247,9 +276,21 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
247
276
|
height: 20,
|
|
248
277
|
alignSelf: 'center'
|
|
249
278
|
}
|
|
250
|
-
}), /*#__PURE__*/React.createElement(EditorListSelect, {
|
|
279
|
+
})), /*#__PURE__*/React.createElement(EditorListSelect, {
|
|
251
280
|
editor: editor
|
|
252
|
-
}), /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
281
|
+
}), isSimpleMode ? /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
282
|
+
tip: '代码块',
|
|
283
|
+
shortcutKey: ['ctrl', 'alt', 'C'],
|
|
284
|
+
icon: /*#__PURE__*/React.createElement(CodeBoxLineIcon, {
|
|
285
|
+
sx: {
|
|
286
|
+
fontSize: '1rem'
|
|
287
|
+
}
|
|
288
|
+
}),
|
|
289
|
+
onClick: function onClick() {
|
|
290
|
+
return editor.chain().focus().toggleCodeBlock().run();
|
|
291
|
+
},
|
|
292
|
+
className: isCodeBlock ? 'tool-active' : ''
|
|
293
|
+
}) : /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
253
294
|
tip: '链接',
|
|
254
295
|
shortcutKey: ['ctrl', '1'],
|
|
255
296
|
icon: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
@@ -268,7 +309,7 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
268
309
|
}).run();
|
|
269
310
|
},
|
|
270
311
|
className: isLink ? 'tool-active' : ''
|
|
271
|
-
}), /*#__PURE__*/React.createElement(EditorAlignSelect, {
|
|
312
|
+
}), !isSimpleMode && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(EditorAlignSelect, {
|
|
272
313
|
editor: editor
|
|
273
314
|
}), /*#__PURE__*/React.createElement(EditorVerticalAlignSelect, {
|
|
274
315
|
editor: editor
|
|
@@ -282,6 +323,20 @@ var EditorToolbar = function EditorToolbar(_ref) {
|
|
|
282
323
|
}
|
|
283
324
|
}), /*#__PURE__*/React.createElement(EditorMore, {
|
|
284
325
|
more: menuInToolbarMore
|
|
326
|
+
})), isSimpleMode && menuInToolbarMore !== null && menuInToolbarMore !== void 0 && menuInToolbarMore.length ? /*#__PURE__*/React.createElement(EditorMore, {
|
|
327
|
+
more: menuInToolbarMore
|
|
328
|
+
}) : null, mode === 'simple' && /*#__PURE__*/React.createElement(ToolbarItem, {
|
|
329
|
+
tip: isSimpleMode ? '切换为复杂模式' : '切换为简单模式',
|
|
330
|
+
icon: isSimpleMode ? /*#__PURE__*/React.createElement(ExpandHorizontalLineIcon, {
|
|
331
|
+
sx: {
|
|
332
|
+
fontSize: '1rem'
|
|
333
|
+
}
|
|
334
|
+
}) : /*#__PURE__*/React.createElement(CollapseHorizontalLine, {
|
|
335
|
+
sx: {
|
|
336
|
+
fontSize: '1rem'
|
|
337
|
+
}
|
|
338
|
+
}),
|
|
339
|
+
onClick: handleToggleMode
|
|
285
340
|
})));
|
|
286
341
|
};
|
|
287
342
|
export default EditorToolbar;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import { SvgIcon } from "@mui/material";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export var CollapseHorizontalLine = function CollapseHorizontalLine(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(SvgIcon, _extends({
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
version: "1.1",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M13.5 12 18.4497 7.05029 19.864 8.46451 17.3284 11H23V13H17.3284L19.8615 15.5331 18.4473 16.9473 13.5 12ZM1 13H6.67084L4.13584 15.535 5.55005 16.9493 10.5 11.9996 5.55025 7.0498 4.13604 8.46402 6.67206 11H1V13Z"
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
CollapseHorizontalLine.displayName = 'collapse-horizontal-line';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import { SvgIcon } from '@mui/material';
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
export var ExpandHorizontalLineIcon = function ExpandHorizontalLineIcon(props) {
|
|
5
|
+
return /*#__PURE__*/React.createElement(SvgIcon, _extends({
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
version: "1.1",
|
|
8
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
9
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
10
|
+
d: "M0.5 12L5.44975 7.05029L6.86396 8.46451L4.32843 11H10V13H4.32843L6.86148 15.5331L5.44727 16.9473L0.5 12ZM14 13H19.6708L17.1358 15.535L18.55 16.9493L23.5 11.9996L18.5503 7.0498L17.136 8.46402L19.6721 11H14V13Z"
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
ExpandHorizontalLineIcon.displayName = 'expand-horizontal-line';
|
|
@@ -134,3 +134,5 @@ export { UserSmileFillIcon } from './user-smile-fill-icon';
|
|
|
134
134
|
export { VolumeMuteLineIcon } from './volume-mute-line-icon';
|
|
135
135
|
export { VolumeUpLineIcon } from './volume-up-line-icon';
|
|
136
136
|
export { WindowFillIcon } from './window-fill-icon';
|
|
137
|
+
export { CollapseHorizontalLine } from './collapse-horizontal-line';
|
|
138
|
+
export { ExpandHorizontalLineIcon } from './expand-horizontal-line';
|
|
@@ -136,4 +136,6 @@ export { UploadIcon } from "./upload-icon";
|
|
|
136
136
|
export { UserSmileFillIcon } from "./user-smile-fill-icon";
|
|
137
137
|
export { VolumeMuteLineIcon } from "./volume-mute-line-icon";
|
|
138
138
|
export { VolumeUpLineIcon } from "./volume-up-line-icon";
|
|
139
|
-
export { WindowFillIcon } from "./window-fill-icon";
|
|
139
|
+
export { WindowFillIcon } from "./window-fill-icon";
|
|
140
|
+
export { CollapseHorizontalLine } from "./collapse-horizontal-line";
|
|
141
|
+
export { ExpandHorizontalLineIcon } from "./expand-horizontal-line";
|
|
@@ -7,6 +7,6 @@ export interface UploadProgressAttributes {
|
|
|
7
7
|
tempId: string;
|
|
8
8
|
}
|
|
9
9
|
export declare const getFileIcon: (fileType: string) => React.JSX.Element;
|
|
10
|
-
export declare const getFileTypeText: (fileType: string) => "
|
|
10
|
+
export declare const getFileTypeText: (fileType: string) => "音频" | "图片" | "视频" | "文件";
|
|
11
11
|
declare const UploadProgressView: React.FC<NodeViewProps>;
|
|
12
12
|
export default UploadProgressView;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { GetExtensionsProps } from '../type';
|
|
2
|
-
export declare const getExtensions: ({ contentType, limit, exclude, extensions: extensionsProps, youtube, editable, mentionItems, onMentionFilter, onUpload, onError, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, }: GetExtensionsProps) => any;
|
|
2
|
+
export declare const getExtensions: ({ contentType, limit, exclude, extensions: extensionsProps, youtube, editable, mentionItems, onMentionFilter, onUpload, onError, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, placeholder, }: GetExtensionsProps) => any;
|
package/dist/extension/index.js
CHANGED
|
@@ -28,7 +28,8 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
28
28
|
onError = _ref.onError,
|
|
29
29
|
onTocUpdate = _ref.onTocUpdate,
|
|
30
30
|
onAiWritingGetSuggestion = _ref.onAiWritingGetSuggestion,
|
|
31
|
-
onValidateUrl = _ref.onValidateUrl
|
|
31
|
+
onValidateUrl = _ref.onValidateUrl,
|
|
32
|
+
_placeholder = _ref.placeholder;
|
|
32
33
|
var defaultExtensions = [StarterKit.configure({
|
|
33
34
|
link: false,
|
|
34
35
|
code: false,
|
|
@@ -94,7 +95,7 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
94
95
|
var type = node.type,
|
|
95
96
|
attrs = node.attrs;
|
|
96
97
|
if (pos === 0 && editor.isEmpty) {
|
|
97
|
-
return PLACEHOLDER.default;
|
|
98
|
+
return _placeholder || PLACEHOLDER.default;
|
|
98
99
|
}
|
|
99
100
|
var aiWritingEnabled = !!(editor !== null && editor !== void 0 && (_storage = editor.storage) !== null && _storage !== void 0 && (_storage = _storage.aiWriting) !== null && _storage !== void 0 && _storage.enabled);
|
|
100
101
|
if (!aiWritingEnabled) {
|
package/dist/hook/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UseTiptapProps, UseTiptapReturn } from "../type";
|
|
2
2
|
import { UseEditorOptions } from '@tiptap/react';
|
|
3
|
-
declare const useTiptap: ({ exclude, extensions: extensionsProps, mentionItems, onMentionFilter, onSave, onError, onUpload, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, editable, contentType, ...options }: UseTiptapProps & UseEditorOptions) => UseTiptapReturn;
|
|
3
|
+
declare const useTiptap: ({ exclude, extensions: extensionsProps, mentionItems, onMentionFilter, onSave, onError, onUpload, onTocUpdate, onAiWritingGetSuggestion, onValidateUrl, editable, contentType, placeholder, ...options }: UseTiptapProps & UseEditorOptions) => UseTiptapReturn;
|
|
4
4
|
export default useTiptap;
|
package/dist/hook/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["exclude", "extensions", "mentionItems", "onMentionFilter", "onSave", "onError", "onUpload", "onTocUpdate", "onAiWritingGetSuggestion", "onValidateUrl", "editable", "contentType"];
|
|
2
|
+
var _excluded = ["exclude", "extensions", "mentionItems", "onMentionFilter", "onSave", "onError", "onUpload", "onTocUpdate", "onAiWritingGetSuggestion", "onValidateUrl", "editable", "contentType", "placeholder"];
|
|
3
3
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
4
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
5
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -25,6 +25,7 @@ var useTiptap = function useTiptap(_ref) {
|
|
|
25
25
|
_ref$editable = _ref.editable,
|
|
26
26
|
editable = _ref$editable === void 0 ? true : _ref$editable,
|
|
27
27
|
contentType = _ref.contentType,
|
|
28
|
+
placeholder = _ref.placeholder,
|
|
28
29
|
options = _objectWithoutProperties(_ref, _excluded);
|
|
29
30
|
var extensions = getExtensions({
|
|
30
31
|
contentType: contentType,
|
|
@@ -37,7 +38,8 @@ var useTiptap = function useTiptap(_ref) {
|
|
|
37
38
|
onError: onError,
|
|
38
39
|
onTocUpdate: onTocUpdate,
|
|
39
40
|
onAiWritingGetSuggestion: onAiWritingGetSuggestion,
|
|
40
|
-
onValidateUrl: onValidateUrl
|
|
41
|
+
onValidateUrl: onValidateUrl,
|
|
42
|
+
placeholder: placeholder
|
|
41
43
|
});
|
|
42
44
|
var editor = useEditor(_objectSpread(_objectSpread(_objectSpread({
|
|
43
45
|
editable: editable,
|
package/dist/type/index.d.ts
CHANGED
|
@@ -96,6 +96,7 @@ export type ExtensionRelativeProps = MentionExtensionProps & EditorFnProps & {
|
|
|
96
96
|
editable: boolean;
|
|
97
97
|
youtube?: Partial<YoutubeOptions>;
|
|
98
98
|
contentType?: UseEditorOptions['contentType'];
|
|
99
|
+
placeholder?: string;
|
|
99
100
|
};
|
|
100
101
|
export type UseTiptapProps = {
|
|
101
102
|
onSave?: (editor: Editor) => void;
|