@ctzhian/tiptap 1.12.24 → 1.13.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/component/CustomBubbleMenu/index.js +1 -1
- package/dist/component/Toolbar/EditorInsert/index.js +12 -1
- package/dist/contants/slash-commands.js +34 -31
- package/dist/extension/component/Flow/Edit.d.ts +10 -0
- package/dist/extension/component/Flow/Edit.js +97 -0
- package/dist/extension/component/Flow/Insert.d.ts +7 -0
- package/dist/extension/component/Flow/Insert.js +108 -0
- package/dist/extension/component/Flow/Readonly.d.ts +8 -0
- package/dist/extension/component/Flow/Readonly.js +65 -0
- package/dist/extension/component/Flow/index.d.ts +9 -0
- package/dist/extension/component/Flow/index.js +354 -0
- package/dist/extension/component/Flow/useMermaidRender.d.ts +16 -0
- package/dist/extension/component/Flow/useMermaidRender.js +138 -0
- package/dist/extension/component/Flow/utils.d.ts +9 -0
- package/dist/extension/component/Flow/utils.js +32 -0
- package/dist/extension/component/SlashCommandsList/index.js +1 -1
- package/dist/extension/component/UploadProgress/index.d.ts +1 -1
- package/dist/extension/index.js +7 -2
- package/dist/extension/node/CodeBlockLowlight.js +15 -0
- package/dist/extension/node/FileHandler.d.ts +1 -1
- package/dist/extension/node/Flow/index.d.ts +18 -0
- package/dist/extension/node/Flow/index.js +103 -0
- package/dist/extension/node/index.d.ts +1 -0
- package/dist/extension/node/index.js +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,103 @@
|
|
|
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 { mergeAttributes, Node } from '@tiptap/core';
|
|
8
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
9
|
+
import FlowViewWrapper from "../../component/Flow";
|
|
10
|
+
export var FlowExtension = function FlowExtension(props) {
|
|
11
|
+
return Node.create({
|
|
12
|
+
name: 'flow',
|
|
13
|
+
group: 'block',
|
|
14
|
+
atom: true,
|
|
15
|
+
selectable: true,
|
|
16
|
+
draggable: true,
|
|
17
|
+
addAttributes: function addAttributes() {
|
|
18
|
+
return {
|
|
19
|
+
code: {
|
|
20
|
+
default: '',
|
|
21
|
+
parseHTML: function parseHTML(element) {
|
|
22
|
+
return element.getAttribute('data-code') || '';
|
|
23
|
+
},
|
|
24
|
+
renderHTML: function renderHTML(attributes) {
|
|
25
|
+
if (!attributes.code) return {};
|
|
26
|
+
return {
|
|
27
|
+
'data-code': attributes.code
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
width: {
|
|
32
|
+
default: '100%',
|
|
33
|
+
parseHTML: function parseHTML(element) {
|
|
34
|
+
return element.getAttribute('data-width') || '100%';
|
|
35
|
+
},
|
|
36
|
+
renderHTML: function renderHTML(attributes) {
|
|
37
|
+
if (!attributes.width) return {};
|
|
38
|
+
return {
|
|
39
|
+
'data-width': String(attributes.width)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
parseHTML: function parseHTML() {
|
|
46
|
+
return [{
|
|
47
|
+
tag: 'div[data-type="flow"]',
|
|
48
|
+
getAttrs: function getAttrs(dom) {
|
|
49
|
+
if (!(dom instanceof HTMLElement)) return false;
|
|
50
|
+
var code = dom.getAttribute('data-code') || '';
|
|
51
|
+
var width = dom.getAttribute('data-width') || '100%';
|
|
52
|
+
return {
|
|
53
|
+
code: code,
|
|
54
|
+
width: width
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}];
|
|
58
|
+
},
|
|
59
|
+
renderHTML: function renderHTML(_ref) {
|
|
60
|
+
var HTMLAttributes = _ref.HTMLAttributes,
|
|
61
|
+
node = _ref.node;
|
|
62
|
+
var attrs = node.attrs;
|
|
63
|
+
return ['div', mergeAttributes({
|
|
64
|
+
'data-type': 'flow'
|
|
65
|
+
}, attrs.code ? {
|
|
66
|
+
'data-code': attrs.code
|
|
67
|
+
} : {}, attrs.width ? {
|
|
68
|
+
'data-width': String(attrs.width)
|
|
69
|
+
} : {}, this.options.HTMLAttributes, HTMLAttributes)];
|
|
70
|
+
},
|
|
71
|
+
renderMarkdown: function renderMarkdown(node) {
|
|
72
|
+
var _ref2 = node.attrs,
|
|
73
|
+
code = _ref2.code;
|
|
74
|
+
if (!code) return '';
|
|
75
|
+
return "```mermaid\n".concat(code, "\n```");
|
|
76
|
+
},
|
|
77
|
+
addCommands: function addCommands() {
|
|
78
|
+
var _this = this;
|
|
79
|
+
return {
|
|
80
|
+
setFlow: function setFlow(options) {
|
|
81
|
+
return function (_ref3) {
|
|
82
|
+
var commands = _ref3.commands;
|
|
83
|
+
return commands.insertContent({
|
|
84
|
+
type: _this.name,
|
|
85
|
+
attrs: {
|
|
86
|
+
code: options.code || '',
|
|
87
|
+
width: options.width || '100%'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
},
|
|
94
|
+
addNodeView: function addNodeView() {
|
|
95
|
+
return ReactNodeViewRenderer(function (renderProps) {
|
|
96
|
+
return FlowViewWrapper(_objectSpread(_objectSpread({}, renderProps), {}, {
|
|
97
|
+
onError: props.onError
|
|
98
|
+
}));
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
export default FlowExtension;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctzhian/tiptap",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "基于 Tiptap 二次开发的编辑器组件",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -121,6 +121,7 @@
|
|
|
121
121
|
"katex": "^0.16.22",
|
|
122
122
|
"linkifyjs": "^4.3.2",
|
|
123
123
|
"lowlight": "^3.3.0",
|
|
124
|
+
"mermaid": "^10.9.5",
|
|
124
125
|
"react-ace": "^14.0.1",
|
|
125
126
|
"react-colorful": "^5.6.1",
|
|
126
127
|
"react-image-crop": "^11.0.10",
|