@ctzhian/tiptap 0.5.6 → 1.1.0

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.
Files changed (52) hide show
  1. package/dist/Editor/demo.js +1 -1
  2. package/dist/EditorDiff/demo.d.ts +4 -0
  3. package/dist/EditorDiff/demo.js +12 -0
  4. package/dist/EditorDiff/index.d.ts +7 -0
  5. package/dist/EditorDiff/index.js +24 -0
  6. package/dist/EditorToolbar/index.js +19 -3
  7. package/dist/component/CustomBubbleMenu/SelectionText.js +1 -1
  8. package/dist/component/CustomDragHandle/index.js +237 -191
  9. package/dist/component/Icons/index.d.ts +1 -0
  10. package/dist/component/Icons/index.js +1 -0
  11. package/dist/component/Icons/information-2-line-icon.d.ts +6 -0
  12. package/dist/component/Icons/information-2-line-icon.js +13 -0
  13. package/dist/component/Menu/NestedList.d.ts +14 -0
  14. package/dist/component/Menu/NestedList.js +149 -0
  15. package/dist/component/Menu/index.js +12 -117
  16. package/dist/component/Toolbar/EditorCode.js +1 -1
  17. package/dist/component/Toolbar/EditorMore/NotificationDialog.js +2 -1
  18. package/dist/component/index.d.ts +2 -0
  19. package/dist/component/index.js +3 -1
  20. package/dist/contants/enums.d.ts +1 -0
  21. package/dist/contants/enums.js +10 -3
  22. package/dist/contants/shortcut-key.js +1 -1
  23. package/dist/contants/slash-commands.d.ts +2 -1
  24. package/dist/contants/slash-commands.js +98 -42
  25. package/dist/extension/component/Alert/index.d.ts +7 -9
  26. package/dist/extension/component/Alert/index.js +186 -109
  27. package/dist/extension/component/Attachment/Readonly.js +0 -1
  28. package/dist/extension/component/Image/Readonly.js +0 -1
  29. package/dist/extension/component/Link/Readonly.js +2 -2
  30. package/dist/extension/component/Mathematics/block/Readonly.js +0 -1
  31. package/dist/extension/component/Mathematics/inline/Readonly.js +0 -1
  32. package/dist/extension/component/SlashCommandsList/index.js +235 -100
  33. package/dist/extension/component/Video/Readonly.js +0 -1
  34. package/dist/extension/extension/StructuredDiff.d.ts +18 -0
  35. package/dist/extension/extension/StructuredDiff.js +131 -0
  36. package/dist/extension/extension/index.d.ts +1 -0
  37. package/dist/extension/extension/index.js +2 -1
  38. package/dist/extension/index.js +38 -82
  39. package/dist/extension/node/Alert.d.ts +19 -8
  40. package/dist/extension/node/Alert.js +210 -131
  41. package/dist/extension/node/Table.js +7 -7
  42. package/dist/extension/suggestion/slash.d.ts +2 -1
  43. package/dist/extension/suggestion/slash.js +3 -1
  44. package/dist/index.css +14 -26
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.js +1 -0
  47. package/dist/type/index.d.ts +11 -2
  48. package/dist/util/decorations.d.ts +22 -0
  49. package/dist/util/decorations.js +302 -0
  50. package/dist/util/structuredDiff.d.ts +59 -0
  51. package/dist/util/structuredDiff.js +550 -0
  52. package/package.json +3 -1
@@ -81,7 +81,7 @@ var Reader = function Reader() {
81
81
  }
82
82
  return onUpload;
83
83
  }(),
84
- content: "<ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u5F17\u8428\u5361\u91CC\u6253\u98DE\u673A\u4E86</p></li><li><p>\u53D1\u5723\u8BDE\u8282\u4E86\u798F\u514B\u65AF\u7684\u6D6A\u8D39\u6492</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u98DE\u673A\u554A\u7684\u6570\u91CF\u5496\u5561\u5C31</p></li><li><p>\u53D1\u51E0\u5723\u8BDE\u5FEB\u4E50\u98DE\u673A\u4E0A\u5927\u6D6A\u8D39</p></li><li><p>\u5927\u5E45\u6492\u89E3\u653E\u770B\u62C9\u4E0A\u98DE\u673A\u554A</p><ul class=\"bullet-list\" data-type=\"bulletList\"><li><p>\u53D1\u6492\u7684\u8DEF\u53E3\u9644\u8FD1\u5FEB\u6492\u4E86\u53D1\u751F</p></li><li><p>\u53D1\u5723\u8BDE\u8282\u53D1\u62C9\u4E0A\u5927\u5206\u4E86\u5361\u4E0A</p></li><li><p>\u53D1\u5927\u6C34\u5FEB\u4E50\u98DE\u673A\u6492\u8DEF\u53E3\u7B49</p></li></ul></li></ul></li></ul><p></p>"
84
+ content: "<blockquote><p>\u98DE\u673A\u554A\u6B7B\u4E86\u6253\u98DE\u673A\u554A\u6536\u5230\u4E86</p></blockquote><p></p>"
85
85
  }),
86
86
  editor = _useTiptap.editor;
87
87
  return /*#__PURE__*/React.createElement(EditorThemeProvider, {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import '../index.css';
3
+ declare const EditorDiffDemo: () => React.JSX.Element;
4
+ export default EditorDiffDemo;
@@ -0,0 +1,12 @@
1
+ import { EditorDiff, EditorThemeProvider } from "./..";
2
+ import React from 'react';
3
+ import "../index.css";
4
+ var EditorDiffDemo = function EditorDiffDemo() {
5
+ return /*#__PURE__*/React.createElement(EditorThemeProvider, {
6
+ mode: "light"
7
+ }, /*#__PURE__*/React.createElement(EditorDiff, {
8
+ oldHtml: "\n <p>\u53D1\u751F\u5927\u89E3\u653E\u4E86\u5361\u4E0A\u6253\u98DE\u673A\uFF0C\u53D1\u751F\u7B80<a target=\"_blank\" type=\"text\" href=\"\u4E8B\u5B9E\u4E0A\" title=\"\u5355\u5FEB\u4E50\u98DE\u673A\">\u5355\u5FEB\u4E50\u98DE\u673A</a>\u963F\u65AF\u5229\u5EB7\u53D1\u7684\u3002</p><p><img src=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" width=\"212\"></p><p><span data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"images.jpeg\" data-size=\"6.81 KB\"></span></p><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"monkeycode-1.20.0.vsix\" data-size=\"27.94 MB\"></div><video class=\"video-wrapper\" src=\"http://vjs.zencdn.net/v/oceans.mp4\" controls=\"true\" width=\"760\"></video><audio class=\"audio-wrapper\" src=\"http://vjs.zencdn.net/v/oceans.mp4\" controls=\"true\"></audio><details class=\"cq-details\" open=\"\"><summary>\u98DE\u673A\u963F\u91CC\u65AF\u987F\u770B\u98CE\u666F</summary><div data-type=\"detailsContent\"><p>\u8FD9\u662F<strong>\u4E00\u6BB5\u5F88\u957F\u7684\u6587</strong>\u672C\uFF0C\u96F7\u6C60 <s>WAF</s> \u662F\u4E00\u6B3E\u7B80\u5355\u9AD8<span style=\"color: rgb(216, 164, 127);\">\u6548\u7684 Web \u5E94</span>\u7528\u9632<span style=\"background-color: rgb(179, 229, 252);\">\u706B\u5899\uFF0C\u80FD</span>\u6709\u6548\u9632\u5FA1 S<sup>L</sup> \u6CE8\u5165\u3001X<sub>SS</sub> \u7B49\u5404\u7C7B Web \u653B\u51FB\uFF0C\u63D0\u4F9B\u8BBF\u95EE\u9891\u7387\u9650\u5236\u3001\u4EBA\u673A\u9A8C\u8BC1\u3001\u52A8<code>\u6001\u9632\u62A4\u7B49</code>\u529F\u80FD\u3002<em>\u5168</em><a target=\"_blank\" type=\"icon\" href=\"https://www.baidu.com\" title=\"\u7403\u88C5\u673A\u91CF\">\u7403\u88C5\u673A\u91CF</a><em>\u8D85 30 \u4E07\u53F0</em>\uFF0C<u>\u65E5\u5747\u5904\u7406 300 \u4EBF\u6B21\u8BF7</u>\u6C42\u3002<span data-latex=\"x + y = 1\" data-type=\"inline-math\"></span></p><div class=\"tableWrapper\"><table style=\"min-width: 400px;\"><colgroup><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"></colgroup><tbody><tr class=\"table-row\"><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>1</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>2</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>3</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>4</p></th></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>5</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>6</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>7</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>8</p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>9</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>10</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>11</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>12</p></td></tr></tbody></table></div><div data-latex=\"x + y + z = 1\" data-type=\"block-math\"></div><pre><code>export const DetailsExtension = CustomDetails.configure({\n persist: true,\n openClassName: 'is-open',\n HTMLAttributes: {\n class: 'cq-details',\n },\n});\n\nexport const DetailsSummaryExtension = DetailsSummary.configure({\n});\n\nexport const DetailsContentExtension = DetailsContent.configure({\n});</code></pre><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F\u5217\u8868</p></li><li><p>\u793A\u4F8B\u793A\u4F8B\u8DEF\u4E0A\u4E86</p></li></ol><blockquote><p>\u6570\u636E\u554A\u514B\u5229\u592B\u5170\u6492\u98DE\u673A\u62C9\u5361\u4E0A\u6253\u98DE\u673A\u554A\u770B\u5230\u4E86\u5730\u65B9\u3002</p></blockquote></div></details><p></p>\n ",
9
+ newHtml: "\n <p style=\"text-align: center;\">\u53D1\u751F\u5927\u89E3\u653E\u4E86\u5361<a target=\"_blank\" type=\"text\" href=\"https://www.baidu.com\" title=\"\u4E0A\u6253\u98DE\u673A\">\u4E0A\u6253\u98DE\u673A</a>\uFF0C\u53D1\u751F\u7B80<a target=\"_blank\" type=\"icon\" href=\"\u4E8B\u5B9E\u4E0A\" title=\"\u5355\u5FEB\u4E50\u98DE\u673A\">\u5355\u5FEB\u4E50\u98DE\u673A</a>\u963F\u65AF\u5229\u5EB7\u53D1\u7684\u3002</p><p><img src=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" width=\"540\"></p><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"images.jpeg\" data-size=\"6.81 KB\"></div><div data-tag=\"attachment\" url=\"\" title=\"\" size=\"0\" data-url=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" data-title=\"monkeycode-1.20.vsix\" data-size=\"27.94 MB\"></div><video class=\"video-wrapper\" src=\"http://vjs.zencdn.net/v/oceans.mp4\" controls=\"true\" width=\"1017\"></video><audio class=\"audio-wrapper\" src=\"http://vjs.zencdn.net/v/oceans.mp4\" title=\"\u6536\u62FE\u6536\u62FE\" poster=\"https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg\" controls=\"true\"></audio><details class=\"cq-details\" open=\"\"><summary>\u5C31\u53D1\u751F\u7684\u5FEB\u4E50\u98DE\u673A\u963F\u91CC\u65AF\u987F</summary><div data-type=\"detailsContent\"><p>\u6C60 <s>W1111F</s> \u662F\u4E00\u6B3E\u7B80\u5355\u9AD8<span style=\"color: rgb(216, 164, 127);\">\u6548\u7684 </span><span style=\"color: rgb(254, 69, 69);\">Web</span><span style=\"color: rgb(216, 164, 127);\"> \u5E94</span>\u7528\u9632<span style=\"background-color: rgb(179, 229, 252);\">\u706B\uFF0C\u80FD</span>\u6709\u6548\u9632\u5FA1 S<sup>QL</sup> \u6CE8\u5165\u3001X<sub>SS</sub> \u7B49\u5404\u7C7B Web \u653B\u51FB\uFF0C\u63D0\u4F9B\u8BBF\u95EE\u9891\u7387\u9650\u5236\u3001\u4EBA\u673A\u9A8C\u8BC1\u3001\u52A8<code>\u6001\u9632\u6536\u62FE\u6536\u62FE\u7B49</code>\u529F\u80FD\u3002<em>\u5168</em><a target=\"_blank\" type=\"icon\" href=\"https://www.baidu.com\" title=\"\u7403\u88C5\u673A\">\u7403\u88C5\u673A</a><em>\u8D85 30 \u4E07\u53F0</em>\uFF0C<u>\u65E5\u5747</u>\u5904\u7406 300 \u4EBF\u6B21<u>\u8BF7</u>\u6C42\u3002<span data-latex=\"x ^ 2 + y ^ 2=1\" data-type=\"inline-math\"></span></p><div class=\"tableWrapper\"><table style=\"min-width: 537px;\"><colgroup><col style=\"min-width: 100px;\"><col style=\"width: 237px;\"><col style=\"min-width: 100px;\"><col style=\"min-width: 100px;\"></colgroup><tbody><tr class=\"table-row\"><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>1</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\" colwidth=\"237\"><p>2</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>3</p></th><th class=\"table-header\" colspan=\"1\" rowspan=\"1\"><p>4</p></th></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>5</p></td><td colspan=\"1\" rowspan=\"1\" colwidth=\"237\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>6</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>7sfadfsaf</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p></p></td></tr><tr class=\"table-row\"><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>9</p></td><td colspan=\"1\" rowspan=\"1\" colwidth=\"237\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>10</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p>11</p></td><td colspan=\"1\" rowspan=\"1\" data-background-color=\"transparent\" style=\"background-color: transparent;\"><p><strong>12</strong></p></td></tr></tbody></table></div><a target=\"_blank\" type=\"block\" href=\"http://localhost:8000/components/editor\" title=\"\u89E3\u653E\u6492\u7684\u8DEF\u53E3\">\u89E3\u653E\u6492\u7684\u8DEF\u53E3</a><div data-latex=\"x ^ 2 + y ^ 2 + z^2=1\" data-type=\"block-math\"></div><pre><code>export const DetailsExtension = CustomDetails.configure({\n persist: true,\n openClassName: 'is-open',\n HTMLAttributes: {\n class: 'cq-details',\n },\n});\n\nexport const SummaryExtension = DetailsSummary.configure({\n HTMLAttributes: {\n class: 'cq-details',\n },\n});\n\nconst persist = true;\n\nexport const ContentExtension = DetailsContent.configure({\n persist,\n});</code></pre><ol class=\"ordered-list\" data-type=\"orderedList\"><li><p>\u8FD9\u662F<s>\u5217\u8868</s></p></li><li><p>\u793A<span style=\"color: rgb(254, 69, 69);\">\u4F8B\u793A\u4F8B\u8DEF</span>\u4E0A\u4E86</p></li><li><p>\u6CD5\u7532\u8054\u8D5B\u80AF\u5FB7\u57FA</p></li></ol><blockquote><p>\u6570\u636E\u554A\u514B<strong>\u5229\u592B\u5170\u6492\u98DE\u673A\u62C9\u5361\u4E0A</strong>\u6253\u98DE\u673A\u554A\u770B\u5230\u4E86\u5730\u65B9</p></blockquote></div></details><p></p>\n "
10
+ }));
11
+ };
12
+ export default EditorDiffDemo;
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ interface EditorDiffProps {
3
+ oldHtml: string;
4
+ newHtml: string;
5
+ }
6
+ declare const EditorDiff: ({ oldHtml, newHtml }: EditorDiffProps) => React.JSX.Element;
7
+ export default EditorDiff;
@@ -0,0 +1,24 @@
1
+ import { EditorContent } from "@tiptap/react";
2
+ import React, { useEffect } from "react";
3
+ import useTiptap from "../hook";
4
+ var EditorDiff = function EditorDiff(_ref) {
5
+ var oldHtml = _ref.oldHtml,
6
+ newHtml = _ref.newHtml;
7
+ var editorRef = useTiptap({
8
+ editable: false,
9
+ content: newHtml,
10
+ exclude: ['youtube', 'mention']
11
+ });
12
+ useEffect(function () {
13
+ if (!editorRef.editor) return;
14
+ editorRef.editor.commands.showStructuredDiff(oldHtml, newHtml);
15
+ return function () {
16
+ var _editorRef$editor, _editorRef$editor$com, _editorRef$editor$com2;
17
+ (_editorRef$editor = editorRef.editor) === null || _editorRef$editor === void 0 || (_editorRef$editor$com = (_editorRef$editor$com2 = _editorRef$editor.commands).hideStructuredDiff) === null || _editorRef$editor$com === void 0 || _editorRef$editor$com.call(_editorRef$editor$com2);
18
+ };
19
+ }, [oldHtml, newHtml, editorRef.editor]);
20
+ return /*#__PURE__*/React.createElement(EditorContent, {
21
+ editor: editorRef.editor
22
+ });
23
+ };
24
+ export default EditorDiff;
@@ -6,7 +6,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { Box, Divider, Stack } from '@mui/material';
8
8
  import React, { useEffect, useState } from 'react';
9
- import { ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, DoubleQuotesLIcon, ItalicIcon, LinkIcon, MenuFold2FillIcon, StrikethroughIcon, Table2Icon, UnderlineIcon } from "../component/Icons";
9
+ import { ArrowGoBackLineIcon, ArrowGoForwardLineIcon, BoldIcon, DoubleQuotesLIcon, Information2LineIcon, ItalicIcon, LinkIcon, MenuFold2FillIcon, StrikethroughIcon, Table2Icon, UnderlineIcon } from "../component/Icons";
10
10
  import { EditorAlignSelect, EditorCode, EditorFontBgColor, EditorFontColor, EditorFontSize, EditorHeading, EditorInsert, EditorListSelect, EditorMath, EditorMore, EditorScript, EditorVerticalAlignSelect, ToolbarItem } from "../component/Toolbar";
11
11
  var EditorToolbar = function EditorToolbar(_ref) {
12
12
  var editor = _ref.editor,
@@ -23,7 +23,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
23
23
  subscript: false,
24
24
  details: false,
25
25
  table: false,
26
- link: false
26
+ link: false,
27
+ alert: false
27
28
  }),
28
29
  _useState2 = _slicedToArray(_useState, 2),
29
30
  active = _useState2[0],
@@ -41,7 +42,8 @@ var EditorToolbar = function EditorToolbar(_ref) {
41
42
  subscript: editor.isActive('subscript'),
42
43
  details: editor.isActive('details'),
43
44
  table: editor.isActive('table'),
44
- link: editor.isActive('link')
45
+ link: editor.isActive('link'),
46
+ alert: editor.isActive('alert')
45
47
  });
46
48
  };
47
49
  useEffect(function () {
@@ -136,6 +138,20 @@ var EditorToolbar = function EditorToolbar(_ref) {
136
138
  return editor.chain().focus().toggleBlockquote().run();
137
139
  },
138
140
  className: active.quote ? 'tool-active' : ''
141
+ }), /*#__PURE__*/React.createElement(ToolbarItem, {
142
+ tip: '警告提示',
143
+ icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
144
+ sx: {
145
+ fontSize: '1rem'
146
+ }
147
+ }),
148
+ onClick: function onClick() {
149
+ return editor.chain().focus().toggleAlert({
150
+ type: 'icon',
151
+ variant: 'info'
152
+ }).run();
153
+ },
154
+ className: active.alert ? 'tool-active' : ''
139
155
  }), /*#__PURE__*/React.createElement(Divider, {
140
156
  orientation: "vertical",
141
157
  flexItem: true,
@@ -150,7 +150,7 @@ var SelectionText = function SelectionText(_ref) {
150
150
  },
151
151
  className: active.subscript ? "tool-active" : ""
152
152
  }), /*#__PURE__*/React.createElement(ToolbarItem, {
153
- tip: "\u4EE3\u7801",
153
+ tip: "\u884C\u5185\u4EE3\u7801",
154
154
  icon: /*#__PURE__*/React.createElement(CodeLineIcon, {
155
155
  sx: {
156
156
  fontSize: '1rem'