@ctzhian/tiptap 1.13.5 → 1.13.7

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.
@@ -6,6 +6,7 @@ import { Editor, EditorThemeProvider, EditorToolbar, useTiptap } from "./..";
6
6
  import { Box } from '@mui/material';
7
7
  import React from 'react';
8
8
  import "../index.css";
9
+ var defaultContent = "";
9
10
  var Reader = function Reader() {
10
11
  var handleTocUpdate = function handleTocUpdate(toc) {
11
12
  console.log('toc', toc);
@@ -155,7 +156,7 @@ var Reader = function Reader() {
155
156
  }
156
157
  return onUpload;
157
158
  }(),
158
- content: "<pre><code>$$ sflsa $$\n\n$fsjadl$</code></pre><p></p><p><span data-latex=\"x+y=1\" data-type=\"inline-math\"></span></p><div data-latex=\"ssss\" data-type=\"block-math\"></div><p></p><p>fadsjlfkas</p><div data-type=\"flow\" data-code=\"C4Context\n title System Context diagram for Internet Banking System\n Enterprise_Boundary(b0, &quot;BankBoundary0&quot;) {\n Person(customerA, &quot;Banking Customer A&quot;, &quot;A customer of the bank, with personal bank accounts.&quot;)\n Person(customerB, &quot;Banking Customer B&quot;)\n Person_Ext(customerC, &quot;Banking Customer C&quot;, &quot;desc&quot;)\n\n Person(customerD, &quot;Banking Customer D&quot;, &quot;A customer of the bank, &lt;br/&gt; with personal bank accounts.&quot;)\n\n System(SystemAA, &quot;Internet Banking System&quot;, &quot;Allows customers to view information about their bank accounts, and make payments.&quot;)\n\n Enterprise_Boundary(b1, &quot;BankBoundary&quot;) {\n SystemDb_Ext(SystemE, &quot;Mainframe Banking System&quot;, &quot;Stores all of the core banking information about customers, accounts, transactions, etc.&quot;)\n\n System_Boundary(b2, &quot;BankBoundary2&quot;) {\n System(SystemA, &quot;Banking System A&quot;)\n System(SystemB, &quot;Banking System B&quot;, &quot;A system of the bank, with personal bank accounts. next line.&quot;)\n }\n\n System_Ext(SystemC, &quot;E-mail system&quot;, &quot;The internal Microsoft Exchange e-mail system.&quot;)\n SystemDb(SystemD, &quot;Banking System D Database&quot;, &quot;A system of the bank, with personal bank accounts.&quot;)\n\n Boundary(b3, &quot;BankBoundary3&quot;, &quot;boundary&quot;) {\n SystemQueue(SystemF, &quot;Banking System F Queue&quot;, &quot;A system of the bank.&quot;)\n SystemQueue_Ext(SystemG, &quot;Banking System G Queue&quot;, &quot;A system of the bank, with personal bank accounts.&quot;)\n }\n }\n }\n\n BiRel(customerA, SystemAA, &quot;Uses&quot;)\n BiRel(SystemAA, SystemE, &quot;Uses&quot;)\n Rel(SystemAA, SystemC, &quot;Sends e-mails&quot;, &quot;SMTP&quot;)\n Rel(SystemC, customerA, &quot;Sends e-mails to&quot;)\" data-width=\"100%\" data-height=\"auto\"></div><p>fsajdlkfjadsl</p>"
159
+ content: defaultContent
159
160
  }),
160
161
  editor = _useTiptap.editor;
161
162
  return /*#__PURE__*/React.createElement(EditorThemeProvider, {
@@ -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;
@@ -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) {
@@ -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, "key" | "editor">, any>;
4
+ }) => import("@tiptap/core").Extension<Omit<import("@tiptap/extension-file-handler").FileHandlePluginOptions, "editor" | "key">, any>;
@@ -15,6 +15,9 @@ import { clickHandler } from "./helpers/clickHandler";
15
15
  import { pasteHandler } from "./helpers/pasteHandler";
16
16
  import { UNICODE_WHITESPACE_REGEX_GLOBAL } from "./helpers/whitespace";
17
17
 
18
+ // export const pasteRegex =
19
+ // /https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z]{2,}\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi
20
+
18
21
  /**
19
22
  * @deprecated The default behavior is now to open links when the editor is not editable.
20
23
  */
@@ -365,6 +368,20 @@ export var InlineLinkExtension = Node.create({
365
368
  }
366
369
  };
367
370
  },
371
+ markdownTokenName: 'link',
372
+ parseMarkdown: function parseMarkdown(token, helpers) {
373
+ return helpers.createNode('inlineLink', {
374
+ href: token.href || '',
375
+ title: token.title || null,
376
+ type: 'icon'
377
+ }, [helpers.createTextNode(token.text || '')]);
378
+ },
379
+ renderMarkdown: function renderMarkdown(node, h) {
380
+ var _node$attrs;
381
+ var href = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.href) || '';
382
+ var text = h.renderChildren(node);
383
+ return "[".concat(text, "](").concat(href, ")");
384
+ },
368
385
  addNodeView: function addNodeView() {
369
386
  return ReactNodeViewRenderer(LinkViewWrapper);
370
387
  }
@@ -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;
@@ -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,
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.13.5",
3
+ "version": "1.13.7",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",