@ctzhian/tiptap 1.6.1 → 1.6.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.
package/dist/Editor/demo.js
CHANGED
|
@@ -4,7 +4,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
4
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
5
|
import { Editor, EditorThemeProvider, EditorToolbar, useTiptap } from "./..";
|
|
6
6
|
import { Box } from '@mui/material';
|
|
7
|
-
import React
|
|
7
|
+
import React from 'react';
|
|
8
8
|
import { AiGenerate2Icon } from "../component/Icons";
|
|
9
9
|
import "../index.css";
|
|
10
10
|
var Reader = function Reader() {
|
|
@@ -15,13 +15,17 @@ var Reader = function Reader() {
|
|
|
15
15
|
console.log(editor.getHTML());
|
|
16
16
|
editor.commands.setContent(editor.getHTML());
|
|
17
17
|
},
|
|
18
|
+
onCreate: function onCreate(_ref) {
|
|
19
|
+
var currentEditor = _ref.editor;
|
|
20
|
+
currentEditor.commands.setAiWriting(true);
|
|
21
|
+
},
|
|
18
22
|
onAiWritingGetSuggestion: function () {
|
|
19
|
-
var _onAiWritingGetSuggestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(
|
|
23
|
+
var _onAiWritingGetSuggestion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref2) {
|
|
20
24
|
var prefix, suffix;
|
|
21
25
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
22
26
|
while (1) switch (_context.prev = _context.next) {
|
|
23
27
|
case 0:
|
|
24
|
-
prefix =
|
|
28
|
+
prefix = _ref2.prefix, suffix = _ref2.suffix;
|
|
25
29
|
console.log('onAiWritingGetSuggestion', prefix, suffix);
|
|
26
30
|
return _context.abrupt("return", new Promise(function (resolve) {
|
|
27
31
|
resolve(['this is a default suggestion.', 'we are good.', 'what is your name?', 'how are you?', 'what is your favorite color?', 'what is your favorite food?', 'what is your favorite animal?', 'what is your favorite book?', 'what is your favorite movie?', 'what is your favorite song?', 'what is your favorite artist?', 'what is your favorite band?', 'what is your favorite city?', 'what is your favorite country?', 'what is your favorite sport?'][Math.floor(Math.random() * 10)]);
|
|
@@ -39,12 +43,12 @@ var Reader = function Reader() {
|
|
|
39
43
|
}(),
|
|
40
44
|
// onTocUpdate: handleTocUpdate,
|
|
41
45
|
onMentionFilter: function () {
|
|
42
|
-
var _onMentionFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(
|
|
46
|
+
var _onMentionFilter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
|
|
43
47
|
var query;
|
|
44
48
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
45
49
|
while (1) switch (_context2.prev = _context2.next) {
|
|
46
50
|
case 0:
|
|
47
|
-
query =
|
|
51
|
+
query = _ref3.query;
|
|
48
52
|
return _context2.abrupt("return", new Promise(function (resolve) {
|
|
49
53
|
resolve(['Winona Ryder', 'Molly Ringwald', 'Ally Sheedy', 'Debbie Harry', 'Olivia Newton-John', 'Elton John', 'Michael J. Fox', 'Axl Rose', 'Emilio Estevez', 'Ralph Macchio', 'Rob Lowe', 'Jennifer Grey'].filter(function (item) {
|
|
50
54
|
return item.toLowerCase().startsWith(query.toLowerCase());
|
|
@@ -106,11 +110,6 @@ var Reader = function Reader() {
|
|
|
106
110
|
content: ""
|
|
107
111
|
}),
|
|
108
112
|
editor = _useTiptap.editor;
|
|
109
|
-
useEffect(function () {
|
|
110
|
-
if (editor) {
|
|
111
|
-
editor.commands.setAiWriting(true);
|
|
112
|
-
}
|
|
113
|
-
}, [editor]);
|
|
114
113
|
return /*#__PURE__*/React.createElement(EditorThemeProvider, {
|
|
115
114
|
mode: "light"
|
|
116
115
|
}, /*#__PURE__*/React.createElement(Box, {
|
|
@@ -66,16 +66,13 @@ export var AiWritingExtension = function AiWritingExtension(props) {
|
|
|
66
66
|
setAiWriting: function setAiWriting(enabled) {
|
|
67
67
|
return function (_ref) {
|
|
68
68
|
var tr = _ref.tr,
|
|
69
|
-
state = _ref.state,
|
|
70
69
|
dispatch = _ref.dispatch;
|
|
71
70
|
if (dispatch) {
|
|
72
71
|
var meta = {
|
|
73
72
|
type: 'setEnabled',
|
|
74
73
|
enabled: enabled
|
|
75
74
|
};
|
|
76
|
-
dispatch(tr.setMeta(aiWritingPluginKey, meta))
|
|
77
|
-
// 同步到 storage,便于外部判断
|
|
78
|
-
;
|
|
75
|
+
dispatch(tr.setMeta(aiWritingPluginKey, meta));
|
|
79
76
|
_this.storage.enabled = !!enabled;
|
|
80
77
|
}
|
|
81
78
|
return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { UploadFunction } from "../../type";
|
|
2
2
|
export declare const FileHandlerExtension: (props: {
|
|
3
3
|
onUpload?: UploadFunction;
|
|
4
|
-
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "
|
|
4
|
+
}) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "key" | "editor">, any>;
|