@ctzhian/tiptap 1.10.3 → 1.11.1

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.
@@ -3,7 +3,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
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
- import { Box, Button } from '@mui/material';
6
+ import { Box } from '@mui/material';
7
7
  import React from 'react';
8
8
  import "../index.css";
9
9
  var Reader = function Reader() {
@@ -158,22 +158,12 @@ var Reader = function Reader() {
158
158
  }
159
159
  return onUpload;
160
160
  }(),
161
- content: "---\nissue_key: gitlab://git.in.chaitin.net/dev/board/ai-ready?issue=1\ncode_repo: https://git.in.chaitin.net/dev/board/ai-ready.git\npriority: high\ndesigned_by: jinzhao.liu\ndev_env: n/a\nstart_from: main\nmerge_to: main\nestimated_loc: 500\ndifficulty_level: medium\n---\n\n\u53D1\u5565\u4E86\u89C1\u98CE\u4F7F\u8235\u4F60\u770B**fjsldk**\u653E\u5047 sd \u5361\u90A3\n\n# \u6807\u98981\n"
161
+ content: ":::alert\n# \u798F\u5EFA\u5E08\u5927\u4F60\u770B\n\u526F\u4E66\u8BB0\u770B\u5230\u4E86\u53D1\u9001\n:::\n\n:::alert {variant=\"warning\", type=\"text\"}\nThis is a warning message with **bold** text.\n:::"
162
162
  }),
163
163
  editor = _useTiptap.editor;
164
164
  return /*#__PURE__*/React.createElement(EditorThemeProvider, {
165
165
  mode: "light"
166
- }, /*#__PURE__*/React.createElement(Button, {
167
- variant: "contained",
168
- onClick: function onClick() {
169
- editor.commands.insertContent('# 标题1\n\n<a target="_blank" type="icon" href="http://localhost:8000/components/editor" title="发生的发">发生的发</a>\n\n## 标题2\n标题*斜体*\n标题**加粗**\n标题~~删除线~~\n标题`代码`\n标题^上标^,标题~下标~\n标题==高亮==', {
170
- contentType: 'markdown'
171
- });
172
- // editor.commands.setContent('# 标题1\n## 标题2\n标题*斜体*\n标题**加粗**\n标题~~删除线~~\n标题`代码`\n标题^上标^,标题~下标~\n标题==高亮==', {
173
- // contentType: 'markdown'
174
- // })
175
- }
176
- }, "\u6D4B\u8BD5\u4E00\u4E0B"), /*#__PURE__*/React.createElement(Box, {
166
+ }, /*#__PURE__*/React.createElement(Box, {
177
167
  sx: {
178
168
  border: '1px solid #eee',
179
169
  borderRadius: '10px',
@@ -223,7 +223,7 @@ var EditorInsert = function EditorInsert(_ref) {
223
223
  onClick: function onClick() {
224
224
  return editor.chain().focus().setDetails().run();
225
225
  }
226
- }], _toConsumableArray(!isMarkdown ? [{
226
+ }], _toConsumableArray(isMarkdown ? [{
227
227
  label: '警告提示',
228
228
  key: 'highlight',
229
229
  icon: /*#__PURE__*/React.createElement(Information2LineIcon, {
@@ -6,8 +6,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
6
6
  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; }
7
7
  import Highlight from '@tiptap/extension-highlight';
8
8
  import InvisibleCharacters from '@tiptap/extension-invisible-characters';
9
- import Subscript from '@tiptap/extension-subscript';
10
- import Superscript from '@tiptap/extension-superscript';
11
9
  import TextAlign from '@tiptap/extension-text-align';
12
10
  import { TextStyleKit } from '@tiptap/extension-text-style';
13
11
  import { CharacterCount, Placeholder } from '@tiptap/extensions';
@@ -16,7 +14,7 @@ import StarterKit from '@tiptap/starter-kit';
16
14
  import { PLACEHOLDER } from "../contants/placeholder";
17
15
  import { AiWritingExtension, SlashCommands, StructuredDiffExtension } from "./extension";
18
16
  import { CodeExtension } from "./mark/Code";
19
- import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomHorizontalRule, CustomInlineMathExtension, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, InlineUploadProgressExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YamlFormat, YoutubeExtension } from "./node";
17
+ import { AlertExtension, AudioExtension, BlockAttachmentExtension, BlockLinkExtension, CodeBlockLowlightExtension, CustomBlockMathExtension, CustomHorizontalRule, CustomInlineMathExtension, CustomSubscript, CustomSuperscript, DetailsContentExtension, DetailsExtension, DetailsSummaryExtension, EmojiExtension, FileHandlerExtension, IframeExtension, ImageExtension, Indent, InlineAttachmentExtension, InlineLinkExtension, InlineUploadProgressExtension, ListExtension, MentionExtension, TableExtension, TableOfContents, UploadProgressExtension, VerticalAlign, VideoExtension, YamlFormat, YoutubeExtension } from "./node";
20
18
  export var getExtensions = function getExtensions(_ref) {
21
19
  var contentType = _ref.contentType,
22
20
  limit = _ref.limit,
@@ -45,7 +43,7 @@ export var getExtensions = function getExtensions(_ref) {
45
43
  color: 'var(--mui-palette-primary-main)',
46
44
  width: 2
47
45
  }
48
- }), Subscript, Superscript, TextStyleKit, CodeExtension, ListExtension, EmojiExtension, DetailsExtension, InlineLinkExtension, DetailsContentExtension, DetailsSummaryExtension, CodeBlockLowlightExtension, InlineUploadProgressExtension, YamlFormat, CustomHorizontalRule].concat(_toConsumableArray(TableExtension({
46
+ }), TextStyleKit, CodeExtension, ListExtension, EmojiExtension, AlertExtension, CustomSubscript, DetailsExtension, CustomSuperscript, InlineLinkExtension, DetailsContentExtension, DetailsSummaryExtension, CodeBlockLowlightExtension, InlineUploadProgressExtension, YamlFormat, CustomHorizontalRule].concat(_toConsumableArray(TableExtension({
49
47
  editable: editable
50
48
  })), [TableOfContents({
51
49
  onTocUpdate: onTocUpdate
@@ -1,7 +1,13 @@
1
- import { mergeAttributes, Node } from '@tiptap/core';
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ import { createBlockMarkdownSpec, mergeAttributes, Node } from '@tiptap/core';
2
8
  import { ReactNodeViewRenderer } from '@tiptap/react';
3
9
  import AlertView from "../component/Alert";
4
- export var AlertExtension = Node.create({
10
+ export var AlertExtension = Node.create(_objectSpread(_objectSpread({
5
11
  name: 'alert',
6
12
  group: 'block',
7
13
  content: 'block+',
@@ -26,14 +32,14 @@ export var AlertExtension = Node.create({
26
32
  }
27
33
  },
28
34
  variant: {
29
- default: 'info',
35
+ default: 'default',
30
36
  renderHTML: function renderHTML(attributes) {
31
37
  return {
32
38
  'data-variant': attributes.variant
33
39
  };
34
40
  },
35
41
  parseHTML: function parseHTML(element) {
36
- return element.getAttribute('data-variant') || 'info';
42
+ return element.getAttribute('data-variant') || 'default';
37
43
  }
38
44
  },
39
45
  type: {
@@ -59,7 +65,10 @@ export var AlertExtension = Node.create({
59
65
  return ['div', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
60
66
  'data-node': 'alert'
61
67
  }), 0];
62
- },
68
+ }
69
+ }, createBlockMarkdownSpec({
70
+ nodeName: 'alert'
71
+ })), {}, {
63
72
  addCommands: function addCommands() {
64
73
  var _this = this;
65
74
  return {
@@ -68,7 +77,7 @@ export var AlertExtension = Node.create({
68
77
  return function (_ref2) {
69
78
  var commands = _ref2.commands;
70
79
  var id = "alert_".concat(Math.random().toString(36).slice(2));
71
- var variant = attrs.variant || 'info';
80
+ var variant = attrs.variant || 'default';
72
81
  var type = attrs.type || 'icon';
73
82
  return commands.wrapIn(_this.name, {
74
83
  id: id,
@@ -98,7 +107,7 @@ export var AlertExtension = Node.create({
98
107
  return function (_ref5) {
99
108
  var commands = _ref5.commands;
100
109
  var id = "alert_".concat(Math.random().toString(36).slice(2));
101
- var variant = attrs.variant || 'info';
110
+ var variant = attrs.variant || 'default';
102
111
  var type = attrs.type || 'icon';
103
112
  return commands.toggleWrap(_this.name, {
104
113
  id: id,
@@ -112,5 +121,5 @@ export var AlertExtension = Node.create({
112
121
  addNodeView: function addNodeView() {
113
122
  return ReactNodeViewRenderer(AlertView);
114
123
  }
115
- });
124
+ }));
116
125
  export default AlertExtension;
@@ -0,0 +1,2 @@
1
+ export declare const CustomSubscript: import("@tiptap/core").Mark<import("@tiptap/extension-subscript").SubscriptExtensionOptions, any>;
2
+ export declare const CustomSuperscript: import("@tiptap/core").Mark<import("@tiptap/extension-superscript").SuperscriptExtensionOptions, any>;
@@ -0,0 +1,70 @@
1
+ import Subscript from '@tiptap/extension-subscript';
2
+ import Superscript from '@tiptap/extension-superscript';
3
+ export var CustomSubscript = Subscript.extend({
4
+ markdownTokenName: 'sub',
5
+ renderMarkdown: function renderMarkdown(node, helpers) {
6
+ var content = helpers.renderChildren(node);
7
+ return "~".concat(content, "~");
8
+ },
9
+ parseMarkdown: function parseMarkdown(token, helpers) {
10
+ var content = helpers.parseInline(token.tokens || []);
11
+ if (!content.length && token.text) {
12
+ content.push(helpers.createTextNode(token.text));
13
+ }
14
+ return helpers.applyMark('subscript', content);
15
+ },
16
+ markdownTokenizer: {
17
+ name: 'sub',
18
+ level: 'inline',
19
+ start: function start(src) {
20
+ return src.indexOf('~');
21
+ },
22
+ tokenize: function tokenize(src, _tokens, helpers) {
23
+ var match = /^~(?!~)([\s\S]+?)~(?!~)/.exec(src);
24
+ if (!match) {
25
+ return;
26
+ }
27
+ var innerContent = match[1];
28
+ return {
29
+ type: 'sub',
30
+ raw: match[0],
31
+ text: innerContent,
32
+ tokens: helpers.inlineTokens(innerContent)
33
+ };
34
+ }
35
+ }
36
+ });
37
+ export var CustomSuperscript = Superscript.extend({
38
+ markdownTokenName: 'sup',
39
+ renderMarkdown: function renderMarkdown(node, helpers) {
40
+ var content = helpers.renderChildren(node);
41
+ return "^".concat(content, "^");
42
+ },
43
+ parseMarkdown: function parseMarkdown(token, helpers) {
44
+ var content = helpers.parseInline(token.tokens || []);
45
+ if (!content.length && token.text) {
46
+ content.push(helpers.createTextNode(token.text));
47
+ }
48
+ return helpers.applyMark('superscript', content);
49
+ },
50
+ markdownTokenizer: {
51
+ name: 'sup',
52
+ level: 'inline',
53
+ start: function start(src) {
54
+ return src.indexOf('^');
55
+ },
56
+ tokenize: function tokenize(src, _tokens, helpers) {
57
+ var match = /^\^(?!\^)([\s\S]+?)\^(?!\^)/.exec(src);
58
+ if (!match) {
59
+ return;
60
+ }
61
+ var innerContent = match[1];
62
+ return {
63
+ type: 'sup',
64
+ raw: match[0],
65
+ text: innerContent,
66
+ tokens: helpers.inlineTokens(innerContent)
67
+ };
68
+ }
69
+ }
70
+ });
@@ -14,6 +14,7 @@ export * from './Link';
14
14
  export * from './ListKit';
15
15
  export * from './Mathematics';
16
16
  export * from './Mention';
17
+ export * from './Script';
17
18
  export * from './Table';
18
19
  export * from './TableOfContents';
19
20
  export * from './UploadProgress';
@@ -14,6 +14,7 @@ export * from "./Link";
14
14
  export * from "./ListKit";
15
15
  export * from "./Mathematics";
16
16
  export * from "./Mention";
17
+ export * from "./Script";
17
18
  export * from "./Table";
18
19
  export * from "./TableOfContents";
19
20
  export * from "./UploadProgress";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzhian/tiptap",
3
- "version": "1.10.3",
3
+ "version": "1.11.1",
4
4
  "description": "基于 Tiptap 二次开发的编辑器组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",