@ctzhian/tiptap 0.5.6 → 1.0.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.
- package/dist/Editor/demo.js +1 -1
- package/dist/EditorDiff/demo.d.ts +4 -0
- package/dist/EditorDiff/demo.js +12 -0
- package/dist/EditorDiff/index.d.ts +7 -0
- package/dist/EditorDiff/index.js +24 -0
- package/dist/extension/component/Attachment/Readonly.js +0 -1
- package/dist/extension/component/Image/Readonly.js +0 -1
- package/dist/extension/component/Link/Readonly.js +2 -2
- package/dist/extension/component/Mathematics/block/Readonly.js +0 -1
- package/dist/extension/component/Mathematics/inline/Readonly.js +0 -1
- package/dist/extension/component/Video/Readonly.js +0 -1
- package/dist/extension/extension/StructuredDiff.d.ts +18 -0
- package/dist/extension/extension/StructuredDiff.js +131 -0
- package/dist/extension/extension/index.d.ts +1 -0
- package/dist/extension/extension/index.js +2 -1
- package/dist/extension/index.js +38 -82
- package/dist/extension/node/Table.js +7 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/util/decorations.d.ts +22 -0
- package/dist/util/decorations.js +302 -0
- package/dist/util/structuredDiff.d.ts +59 -0
- package/dist/util/structuredDiff.js +550 -0
- package/package.json +3 -1
package/dist/Editor/demo.js
CHANGED
|
@@ -81,7 +81,7 @@ var Reader = function Reader() {
|
|
|
81
81
|
}
|
|
82
82
|
return onUpload;
|
|
83
83
|
}(),
|
|
84
|
-
content: "<
|
|
84
|
+
content: "\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\"><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 <hr/>\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 "
|
|
85
85
|
}),
|
|
86
86
|
editor = _useTiptap.editor;
|
|
87
87
|
return /*#__PURE__*/React.createElement(EditorThemeProvider, {
|
|
@@ -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\"><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,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;
|
|
@@ -27,7 +27,6 @@ var ReadonlyAttachment = function ReadonlyAttachment(_ref) {
|
|
|
27
27
|
borderColor: attrs.url === 'error' ? 'error.main' : 'divider',
|
|
28
28
|
cursor: 'pointer',
|
|
29
29
|
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
30
|
-
bgcolor: 'background.paper',
|
|
31
30
|
p: 2,
|
|
32
31
|
':hover': {
|
|
33
32
|
borderColor: attrs.url === 'error' ? 'error.main' : 'primary.main',
|
|
@@ -34,7 +34,6 @@ var ReadonlyLink = function ReadonlyLink(_ref) {
|
|
|
34
34
|
color: 'text.primary',
|
|
35
35
|
cursor: 'pointer',
|
|
36
36
|
borderRadius: 'var(--mui-shape-borderRadius)',
|
|
37
|
-
bgcolor: 'background.paper',
|
|
38
37
|
p: 2,
|
|
39
38
|
':hover': {
|
|
40
39
|
borderColor: 'primary.main',
|
|
@@ -86,7 +85,8 @@ var ReadonlyLink = function ReadonlyLink(_ref) {
|
|
|
86
85
|
alignItems: 'baseline',
|
|
87
86
|
gap: '2px',
|
|
88
87
|
color: 'primary.main',
|
|
89
|
-
fontWeight: 500
|
|
88
|
+
fontWeight: 500,
|
|
89
|
+
lineHeight: 1.625
|
|
90
90
|
}
|
|
91
91
|
}, attrs.type === 'icon' && /*#__PURE__*/React.createElement(Avatar, {
|
|
92
92
|
sx: {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Editor, Extension } from '@tiptap/core';
|
|
2
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
3
|
+
declare const diffPluginKey: PluginKey<any>;
|
|
4
|
+
declare module '@tiptap/core' {
|
|
5
|
+
interface Commands<ReturnType> {
|
|
6
|
+
structuredDiff: {
|
|
7
|
+
showStructuredDiff: (oldHtml: string, newHtml: string) => ReturnType;
|
|
8
|
+
hideStructuredDiff: () => ReturnType;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare const StructuredDiffExtension: Extension<any, any>;
|
|
13
|
+
export { diffPluginKey };
|
|
14
|
+
export declare function getDiffState(editor: Editor): {
|
|
15
|
+
isActive: any;
|
|
16
|
+
diffs: any;
|
|
17
|
+
diffCount: any;
|
|
18
|
+
} | null;
|
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
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; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import { Extension } from '@tiptap/core';
|
|
9
|
+
import { Plugin, PluginKey } from '@tiptap/pm/state';
|
|
10
|
+
import { createDecorationsFromDiffs, createEmptyDecorationSet } from "../../util/decorations";
|
|
11
|
+
import { compareDocuments } from "../../util/structuredDiff";
|
|
12
|
+
var diffPluginKey = new PluginKey('structuredDiff');
|
|
13
|
+
var DiffPluginState = /*#__PURE__*/function () {
|
|
14
|
+
function DiffPluginState(decorations) {
|
|
15
|
+
var diffs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
16
|
+
var isActive = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
17
|
+
_classCallCheck(this, DiffPluginState);
|
|
18
|
+
_defineProperty(this, "decorations", void 0);
|
|
19
|
+
_defineProperty(this, "diffs", void 0);
|
|
20
|
+
_defineProperty(this, "isActive", void 0);
|
|
21
|
+
this.decorations = decorations;
|
|
22
|
+
this.diffs = diffs;
|
|
23
|
+
this.isActive = isActive;
|
|
24
|
+
}
|
|
25
|
+
_createClass(DiffPluginState, [{
|
|
26
|
+
key: "apply",
|
|
27
|
+
value: function apply(tr, value, oldState, newState) {
|
|
28
|
+
if (tr.docChanged && value.isActive) {
|
|
29
|
+
var mappedDecorations = value.decorations.map(tr.mapping, tr.doc);
|
|
30
|
+
return new DiffPluginState(mappedDecorations, value.diffs, value.isActive);
|
|
31
|
+
}
|
|
32
|
+
var diffMeta = tr.getMeta(diffPluginKey);
|
|
33
|
+
if (diffMeta) {
|
|
34
|
+
switch (diffMeta.type) {
|
|
35
|
+
case 'showDiff':
|
|
36
|
+
return new DiffPluginState(diffMeta.decorations, diffMeta.diffs, true);
|
|
37
|
+
case 'hideDiff':
|
|
38
|
+
return new DiffPluginState(createEmptyDecorationSet(newState.doc), [], false);
|
|
39
|
+
default:
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}], [{
|
|
46
|
+
key: "init",
|
|
47
|
+
value: function init(config, state) {
|
|
48
|
+
return new DiffPluginState(createEmptyDecorationSet(state.doc), [], false);
|
|
49
|
+
}
|
|
50
|
+
}]);
|
|
51
|
+
return DiffPluginState;
|
|
52
|
+
}();
|
|
53
|
+
export var StructuredDiffExtension = Extension.create({
|
|
54
|
+
name: 'structuredDiff',
|
|
55
|
+
addProseMirrorPlugins: function addProseMirrorPlugins() {
|
|
56
|
+
return [new Plugin({
|
|
57
|
+
key: diffPluginKey,
|
|
58
|
+
state: {
|
|
59
|
+
init: DiffPluginState.init,
|
|
60
|
+
apply: DiffPluginState.prototype.apply
|
|
61
|
+
},
|
|
62
|
+
props: {
|
|
63
|
+
decorations: function decorations(state) {
|
|
64
|
+
var pluginState = diffPluginKey.getState(state);
|
|
65
|
+
return pluginState ? pluginState.decorations : null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
})];
|
|
69
|
+
},
|
|
70
|
+
addCommands: function addCommands() {
|
|
71
|
+
return {
|
|
72
|
+
showStructuredDiff: function showStructuredDiff(oldHtml, newHtml) {
|
|
73
|
+
return function (_ref) {
|
|
74
|
+
var tr = _ref.tr,
|
|
75
|
+
state = _ref.state,
|
|
76
|
+
dispatch = _ref.dispatch,
|
|
77
|
+
editor = _ref.editor;
|
|
78
|
+
try {
|
|
79
|
+
var extensions = editor.extensionManager.extensions;
|
|
80
|
+
var comparison = compareDocuments(oldHtml, newHtml, extensions);
|
|
81
|
+
if (!comparison.hasChanges) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
var decorations = createDecorationsFromDiffs(comparison.diffs, state.doc);
|
|
85
|
+
var newTr = tr.setMeta(diffPluginKey, {
|
|
86
|
+
type: 'showDiff',
|
|
87
|
+
decorations: decorations,
|
|
88
|
+
diffs: comparison.diffs
|
|
89
|
+
});
|
|
90
|
+
if (dispatch) {
|
|
91
|
+
dispatch(newTr);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
console.error('显示结构化diff时出错:', error);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
hideStructuredDiff: function hideStructuredDiff() {
|
|
101
|
+
return function (_ref2) {
|
|
102
|
+
var tr = _ref2.tr,
|
|
103
|
+
state = _ref2.state,
|
|
104
|
+
dispatch = _ref2.dispatch;
|
|
105
|
+
try {
|
|
106
|
+
var newTr = tr.setMeta(diffPluginKey, {
|
|
107
|
+
type: 'hideDiff'
|
|
108
|
+
});
|
|
109
|
+
if (dispatch) dispatch(newTr);
|
|
110
|
+
return true;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
console.error('隐藏结构化diff时出错:', error);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
export { diffPluginKey };
|
|
121
|
+
export function getDiffState(editor) {
|
|
122
|
+
if (!editor || !editor.state) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
var pluginState = diffPluginKey.getState(editor.state);
|
|
126
|
+
return pluginState ? {
|
|
127
|
+
isActive: pluginState.isActive,
|
|
128
|
+
diffs: pluginState.diffs,
|
|
129
|
+
diffCount: pluginState.diffs.length
|
|
130
|
+
} : null;
|
|
131
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from "./SlashCommands";
|
|
1
|
+
export * from "./SlashCommands";
|
|
2
|
+
export * from "./StructuredDiff";
|
package/dist/extension/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { TextStyleKit } from '@tiptap/extension-text-style';
|
|
|
13
13
|
import { CharacterCount, Placeholder } from '@tiptap/extensions';
|
|
14
14
|
import StarterKit from '@tiptap/starter-kit';
|
|
15
15
|
import { PLACEHOLDER } from "../contants/placeholder";
|
|
16
|
-
import { SlashCommands } from "./extension";
|
|
16
|
+
import { SlashCommands, StructuredDiffExtension } from "./extension";
|
|
17
17
|
import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomInlineMathExtension, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, ImageExtension, InlineAttachmentExtension, InlineLinkExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YoutubeExtension } from "./node";
|
|
18
18
|
export var getExtensions = function getExtensions(_ref) {
|
|
19
19
|
var limit = _ref.limit,
|
|
@@ -38,7 +38,7 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
38
38
|
color: 'var(--mui-palette-primary-main)',
|
|
39
39
|
width: 2
|
|
40
40
|
}
|
|
41
|
-
}), TextAlign.configure({
|
|
41
|
+
}), ListExtension, TextAlign.configure({
|
|
42
42
|
types: ['heading', 'paragraph']
|
|
43
43
|
}), VerticalAlign.configure({
|
|
44
44
|
types: ['textStyle'],
|
|
@@ -66,7 +66,30 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
66
66
|
}
|
|
67
67
|
return '';
|
|
68
68
|
}
|
|
69
|
-
})]
|
|
69
|
+
}), InlineLinkExtension, BlockLinkExtension, DetailsExtension, DetailsContentExtension, DetailsSummaryExtension].concat(_toConsumableArray(TableExtension({
|
|
70
|
+
editable: editable
|
|
71
|
+
})), [TableOfContents({
|
|
72
|
+
onTocUpdate: onTocUpdate
|
|
73
|
+
}), CustomInlineMathExtension({
|
|
74
|
+
onError: onError
|
|
75
|
+
}), CustomBlockMathExtension({
|
|
76
|
+
onError: onError
|
|
77
|
+
}), VideoExtension({
|
|
78
|
+
onUpload: onUpload,
|
|
79
|
+
onError: onError
|
|
80
|
+
}), AudioExtension({
|
|
81
|
+
onUpload: onUpload,
|
|
82
|
+
onError: onError
|
|
83
|
+
}), ImageExtension({
|
|
84
|
+
onUpload: onUpload,
|
|
85
|
+
onError: onError
|
|
86
|
+
}), InlineAttachmentExtension({
|
|
87
|
+
onUpload: onUpload,
|
|
88
|
+
onError: onError
|
|
89
|
+
}), BlockAttachmentExtension({
|
|
90
|
+
onUpload: onUpload,
|
|
91
|
+
onError: onError
|
|
92
|
+
})]);
|
|
70
93
|
if (!(exclude !== null && exclude !== void 0 && exclude.includes('emoji'))) {
|
|
71
94
|
var Emoji = EmojiExtension;
|
|
72
95
|
defaultExtensions.push(Emoji);
|
|
@@ -78,96 +101,29 @@ export var getExtensions = function getExtensions(_ref) {
|
|
|
78
101
|
});
|
|
79
102
|
defaultExtensions.push(Mention);
|
|
80
103
|
}
|
|
81
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('details'))) {
|
|
82
|
-
var Details = DetailsExtension;
|
|
83
|
-
var DetailsContent = DetailsContentExtension;
|
|
84
|
-
var DetailsSummary = DetailsSummaryExtension;
|
|
85
|
-
defaultExtensions.push(Details);
|
|
86
|
-
defaultExtensions.push(DetailsContent);
|
|
87
|
-
defaultExtensions.push(DetailsSummary);
|
|
88
|
-
}
|
|
89
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('mathematics'))) {
|
|
90
|
-
var CustomInlineMath = CustomInlineMathExtension({
|
|
91
|
-
onError: onError
|
|
92
|
-
});
|
|
93
|
-
var CustomBlockMath = CustomBlockMathExtension({
|
|
94
|
-
onError: onError
|
|
95
|
-
});
|
|
96
|
-
defaultExtensions.push(CustomInlineMath);
|
|
97
|
-
defaultExtensions.push(CustomBlockMath);
|
|
98
|
-
}
|
|
99
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('table'))) {
|
|
100
|
-
var Table = TableExtension({
|
|
101
|
-
editable: editable
|
|
102
|
-
});
|
|
103
|
-
defaultExtensions.push.apply(defaultExtensions, _toConsumableArray(Table));
|
|
104
|
-
}
|
|
105
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('list'))) {
|
|
106
|
-
var List = ListExtension;
|
|
107
|
-
defaultExtensions.push(List);
|
|
108
|
-
}
|
|
109
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('video'))) {
|
|
110
|
-
var Video = VideoExtension({
|
|
111
|
-
onUpload: onUpload,
|
|
112
|
-
onError: onError
|
|
113
|
-
});
|
|
114
|
-
defaultExtensions.push(Video);
|
|
115
|
-
}
|
|
116
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('audio'))) {
|
|
117
|
-
var Audio = AudioExtension({
|
|
118
|
-
onUpload: onUpload,
|
|
119
|
-
onError: onError
|
|
120
|
-
});
|
|
121
|
-
defaultExtensions.push(Audio);
|
|
122
|
-
}
|
|
123
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('image'))) {
|
|
124
|
-
var Image = ImageExtension({
|
|
125
|
-
onUpload: onUpload,
|
|
126
|
-
onError: onError
|
|
127
|
-
});
|
|
128
|
-
defaultExtensions.push(Image);
|
|
129
|
-
}
|
|
130
104
|
if (!(exclude !== null && exclude !== void 0 && exclude.includes('youtube'))) {
|
|
131
105
|
var Youtube = YoutubeExtension(youtube);
|
|
132
106
|
defaultExtensions.push(Youtube);
|
|
133
107
|
}
|
|
134
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('fileHandler'))) {
|
|
135
|
-
var FileHandler = FileHandlerExtension({
|
|
136
|
-
onUpload: onUpload
|
|
137
|
-
});
|
|
138
|
-
defaultExtensions.push(FileHandler);
|
|
139
|
-
var UploadProgress = UploadProgressExtension;
|
|
140
|
-
defaultExtensions.push(UploadProgress);
|
|
141
|
-
}
|
|
142
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('link'))) {
|
|
143
|
-
defaultExtensions.push(InlineLinkExtension);
|
|
144
|
-
defaultExtensions.push(BlockLinkExtension);
|
|
145
|
-
}
|
|
146
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('attachment'))) {
|
|
147
|
-
var InlineAttachment = InlineAttachmentExtension({
|
|
148
|
-
onUpload: onUpload,
|
|
149
|
-
onError: onError
|
|
150
|
-
});
|
|
151
|
-
var BlockAttachment = BlockAttachmentExtension({
|
|
152
|
-
onUpload: onUpload,
|
|
153
|
-
onError: onError
|
|
154
|
-
});
|
|
155
|
-
defaultExtensions.push(InlineAttachment);
|
|
156
|
-
defaultExtensions.push(BlockAttachment);
|
|
157
|
-
}
|
|
158
|
-
if (!(exclude !== null && exclude !== void 0 && exclude.includes('tableOfContents'))) {
|
|
159
|
-
var CustomTableOfContents = TableOfContents({
|
|
160
|
-
onTocUpdate: onTocUpdate
|
|
161
|
-
});
|
|
162
|
-
defaultExtensions.push(CustomTableOfContents);
|
|
163
|
-
}
|
|
164
108
|
if (editable) {
|
|
109
|
+
if (!(exclude !== null && exclude !== void 0 && exclude.includes('fileHandler'))) {
|
|
110
|
+
var FileHandler = FileHandlerExtension({
|
|
111
|
+
onUpload: onUpload
|
|
112
|
+
});
|
|
113
|
+
defaultExtensions.push(FileHandler);
|
|
114
|
+
var UploadProgress = UploadProgressExtension;
|
|
115
|
+
defaultExtensions.push(UploadProgress);
|
|
116
|
+
}
|
|
165
117
|
if (!(exclude !== null && exclude !== void 0 && exclude.includes('slashCommands'))) {
|
|
166
118
|
defaultExtensions.push(SlashCommands);
|
|
167
119
|
}
|
|
168
120
|
if (!(exclude !== null && exclude !== void 0 && exclude.includes('invisibleCharacters'))) {
|
|
169
121
|
defaultExtensions.push(InvisibleCharacters);
|
|
170
122
|
}
|
|
123
|
+
} else {
|
|
124
|
+
if (!(exclude !== null && exclude !== void 0 && exclude.includes('structuredDiff'))) {
|
|
125
|
+
defaultExtensions.push(StructuredDiffExtension);
|
|
126
|
+
}
|
|
171
127
|
}
|
|
172
128
|
if (extensionsProps && extensionsProps.length > 0) {
|
|
173
129
|
defaultExtensions.push.apply(defaultExtensions, _toConsumableArray(extensionsProps));
|
|
@@ -12,13 +12,7 @@ import { TextSelection } from '@tiptap/pm/state';
|
|
|
12
12
|
import { createTableContextMenuPlugin } from "../component/Table";
|
|
13
13
|
export var TableExtension = function TableExtension(_ref) {
|
|
14
14
|
var editable = _ref.editable;
|
|
15
|
-
return [Table.
|
|
16
|
-
handleWidth: 5,
|
|
17
|
-
cellMinWidth: 100,
|
|
18
|
-
resizable: editable,
|
|
19
|
-
lastColumnResizable: editable,
|
|
20
|
-
allowTableNodeSelection: editable
|
|
21
|
-
}).extend({
|
|
15
|
+
return [Table.extend({
|
|
22
16
|
addCommands: function addCommands() {
|
|
23
17
|
var _this$parent;
|
|
24
18
|
return _objectSpread(_objectSpread({}, (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.call(this)), {}, {
|
|
@@ -80,6 +74,12 @@ export var TableExtension = function TableExtension(_ref) {
|
|
|
80
74
|
}, originalRender];
|
|
81
75
|
return wrapper;
|
|
82
76
|
}
|
|
77
|
+
}).configure({
|
|
78
|
+
handleWidth: 5,
|
|
79
|
+
cellMinWidth: 100,
|
|
80
|
+
resizable: editable,
|
|
81
|
+
lastColumnResizable: editable,
|
|
82
|
+
allowTableNodeSelection: editable
|
|
83
83
|
}), TableHeader.configure({
|
|
84
84
|
HTMLAttributes: {
|
|
85
85
|
class: 'table-header'
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from './component/Icons';
|
|
2
2
|
export { default as Editor } from './Editor';
|
|
3
|
+
export { default as EditorDiff } from './EditorDiff';
|
|
3
4
|
export { default as EditorThemeProvider } from './EditorThemeProvider';
|
|
4
5
|
export { default as EditorToolbar } from './EditorToolbar';
|
|
5
6
|
export { default as useTiptap } from './hook';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./component/Icons";
|
|
2
2
|
export { default as Editor } from "./Editor";
|
|
3
|
+
export { default as EditorDiff } from "./EditorDiff";
|
|
3
4
|
export { default as EditorThemeProvider } from "./EditorThemeProvider";
|
|
4
5
|
export { default as EditorToolbar } from "./EditorToolbar";
|
|
5
6
|
export { default as useTiptap } from "./hook";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Node as PMNode } from '@tiptap/pm/model';
|
|
2
|
+
import { DecorationSet } from '@tiptap/pm/view';
|
|
3
|
+
import { DiffItem, ProseMirrorNode } from './structuredDiff';
|
|
4
|
+
/**
|
|
5
|
+
* 根据差异数组创建装饰集合
|
|
6
|
+
* @param {Array} diffs - 差异数组
|
|
7
|
+
* @param {Object} doc - ProseMirror文档
|
|
8
|
+
* @returns {DecorationSet} 装饰集合
|
|
9
|
+
*/
|
|
10
|
+
export declare function createDecorationsFromDiffs(diffs: DiffItem[], doc: PMNode): DecorationSet;
|
|
11
|
+
/**
|
|
12
|
+
* 创建空的装饰集合
|
|
13
|
+
* @param {Object} doc - ProseMirror文档
|
|
14
|
+
* @returns {DecorationSet} 空装饰集合
|
|
15
|
+
*/
|
|
16
|
+
export declare function createEmptyDecorationSet(doc: PMNode): DecorationSet;
|
|
17
|
+
/**
|
|
18
|
+
* 获取节点大小(包含子节点)
|
|
19
|
+
* @param {Object} node - ProseMirror节点
|
|
20
|
+
* @returns {number} 节点大小
|
|
21
|
+
*/
|
|
22
|
+
export declare function getNodeSize(node: ProseMirrorNode): number;
|