@lobehub/editor 1.16.0 → 1.16.2
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.
|
@@ -82,6 +82,7 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
82
82
|
// Parse markdown options
|
|
83
83
|
var markdownOption = (_this$config$markdown = (_this$config = this.config) === null || _this$config === void 0 ? void 0 : _this$config.markdownOption) !== null && _this$config$markdown !== void 0 ? _this$config$markdown : true;
|
|
84
84
|
var isMarkdownEnabled = markdownOption !== false;
|
|
85
|
+
var softBreak = isMarkdownEnabled ? '\n\n' : '\n';
|
|
85
86
|
|
|
86
87
|
// Determine which formats are enabled
|
|
87
88
|
var formats = {
|
|
@@ -100,9 +101,6 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
100
101
|
formats.quote = (_markdownOption$quote = markdownOption.quote) !== null && _markdownOption$quote !== void 0 ? _markdownOption$quote : true;
|
|
101
102
|
formats.strikethrough = (_markdownOption$strik = markdownOption.strikethrough) !== null && _markdownOption$strik !== void 0 ? _markdownOption$strik : true;
|
|
102
103
|
}
|
|
103
|
-
if (!isMarkdownEnabled) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
104
|
|
|
107
105
|
// Register quote shortcut if enabled
|
|
108
106
|
if (formats.quote) {
|
|
@@ -191,11 +189,11 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
191
189
|
markdownService.registerMarkdownShortCuts(textFormatShortcuts);
|
|
192
190
|
}
|
|
193
191
|
markdownService.registerMarkdownWriter('paragraph', function (ctx) {
|
|
194
|
-
ctx.wrap('',
|
|
192
|
+
ctx.wrap('', softBreak);
|
|
195
193
|
});
|
|
196
194
|
markdownService.registerMarkdownWriter('quote', function (ctx, node) {
|
|
197
195
|
if ($isQuoteNode(node)) {
|
|
198
|
-
ctx.wrap('> ',
|
|
196
|
+
ctx.wrap('> ', softBreak);
|
|
199
197
|
}
|
|
200
198
|
});
|
|
201
199
|
markdownService.registerMarkdownWriter('heading', function (ctx, node) {
|
|
@@ -233,7 +231,7 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
233
231
|
}
|
|
234
232
|
default:
|
|
235
233
|
{
|
|
236
|
-
ctx.wrap('',
|
|
234
|
+
ctx.wrap('', softBreak);
|
|
237
235
|
break;
|
|
238
236
|
}
|
|
239
237
|
}
|
|
@@ -166,7 +166,7 @@ var ReactPlainText = /*#__PURE__*/memo(function (_ref) {
|
|
|
166
166
|
});
|
|
167
167
|
};
|
|
168
168
|
return /*#__PURE__*/_jsxs("div", {
|
|
169
|
-
className: cx(styles.root, markdownOption === true && styles.variant, markdownOption === false && styles.noHeader, _typeof(markdownOption) === 'object' && markdownOption.header === true && styles.header, _typeof(markdownOption) === 'object' && markdownOption.header === false && styles.noHeader, _typeof(markdownOption) === 'object' && markdownOption.code === true && styles.code, _typeof(markdownOption) === 'object' && markdownOption.quote === true && styles.blockquote, className),
|
|
169
|
+
className: cx(styles.root, markdownOption === true && styles.variant, markdownOption === false && styles.noStyle, markdownOption === false && styles.noHeader, _typeof(markdownOption) === 'object' && markdownOption.header === true && styles.header, _typeof(markdownOption) === 'object' && markdownOption.header === false && styles.noHeader, _typeof(markdownOption) === 'object' && markdownOption.code === true && styles.code, _typeof(markdownOption) === 'object' && markdownOption.quote === true && styles.blockquote, className),
|
|
170
170
|
style: style,
|
|
171
171
|
children: [/*#__PURE__*/_jsx("div", {
|
|
172
172
|
contentEditable: true,
|
|
@@ -26,6 +26,7 @@ export declare const useStyles: (props?: {
|
|
|
26
26
|
code: import("antd-style").SerializedStyles;
|
|
27
27
|
header: import("antd-style").SerializedStyles;
|
|
28
28
|
noHeader: import("antd-style").SerializedStyles;
|
|
29
|
+
noStyle: import("antd-style").SerializedStyles;
|
|
29
30
|
p: import("antd-style").SerializedStyles;
|
|
30
31
|
root: import("antd-style").SerializedStyles;
|
|
31
32
|
variant: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
|
|
1
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
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); }
|
|
4
4
|
import { createStyles } from 'antd-style';
|
|
@@ -30,7 +30,7 @@ export var useStyles = createStyles(function (_ref2, _ref3) {
|
|
|
30
30
|
lineHeight = _ref3$lineHeight === void 0 ? 1.8 : _ref3$lineHeight;
|
|
31
31
|
var __root = css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n --lobe-markdown-font-size: ", "px;\n --lobe-markdown-header-multiple: ", ";\n --lobe-markdown-margin-multiple: ", ";\n --lobe-markdown-line-height: ", ";\n --lobe-markdown-border-radius: ", ";\n --lobe-markdown-border-color: ", ";\n\n position: relative;\n\n display: flex;\n flex-direction: column;\n\n width: 100%;\n max-width: 100%;\n height: 100%;\n\n font-size: var(--lobe-markdown-font-size);\n line-height: var(--lobe-markdown-line-height);\n word-break: break-word;\n\n @keyframes cursor-blink {\n to {\n visibility: hidden;\n }\n }\n\n [data-lexical-cursor='true'] {\n pointer-events: none;\n position: absolute;\n display: block;\n\n &::after {\n content: '';\n\n position: absolute;\n inset-block-start: -2px;\n\n display: block;\n\n width: 20px;\n border-block-start: 1px solid ", ";\n\n animation: cursor-blink 1.1s steps(2, start) infinite;\n }\n }\n "])), fontSize, headerMultiple, marginMultiple, lineHeight, token.borderRadiusLG, token.colorFillQuaternary, token.colorText);
|
|
32
32
|
var header = css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: max(\n calc(var(--lobe-markdown-header-multiple) * var(--lobe-markdown-margin-multiple) * 0.4em),\n var(--lobe-markdown-font-size)\n );\n font-weight: bold;\n line-height: 1.25;\n }\n\n h1 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 1.5 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h2 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + var(--lobe-markdown-header-multiple))\n );\n }\n\n h3 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 0.5 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h4 {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 0.25 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h5,\n h6 {\n font-size: calc(var(--lobe-markdown-font-size) * 1);\n }\n "])));
|
|
33
|
-
var p = css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n p {\n margin-block:
|
|
33
|
+
var p = css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n p {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n line-height: var(--lobe-markdown-line-height);\n letter-spacing: 0.02em;\n\n &:not(:first-child) {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n\n &:not(:last-child) {\n margin-block-end: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n }\n "])));
|
|
34
34
|
var blockquote = css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n .editor_quote {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n margin-inline: 0;\n padding-block: 0;\n padding-inline: 1em;\n border-inline-start: solid 4px ", ";\n\n color: ", ";\n }\n "])), token.colorBorder, token.colorTextSecondary);
|
|
35
35
|
var code = css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n .editor_code {\n display: inline;\n\n margin-inline: 0.25em;\n padding-block: 0.2em;\n padding-inline: 0.4em;\n border: 1px solid var(--lobe-markdown-border-color);\n border-radius: 0.25em;\n\n font-family: ", ";\n font-size: 0.875em;\n line-height: 1;\n word-break: break-word;\n white-space: break-spaces;\n\n background: ", ";\n }\n "])), token.fontFamilyCode, token.colorFillSecondary);
|
|
36
36
|
return {
|
|
@@ -38,6 +38,7 @@ export var useStyles = createStyles(function (_ref2, _ref3) {
|
|
|
38
38
|
code: code,
|
|
39
39
|
header: header,
|
|
40
40
|
noHeader: css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-block: 4px;\n font-size: var(--lobe-markdown-font-size);\n line-height: var(--lobe-markdown-line-height);\n letter-spacing: 0.02em;\n\n &:not(:first-child) {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n\n &:not(:last-child) {\n margin-block-end: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n }\n "]))),
|
|
41
|
+
noStyle: css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n --lobe-markdown-header-multiple: 0;\n --lobe-markdown-margin-multiple: 0;\n --lobe-markdown-line-height: 1.5;\n\n p {\n margin-block: 0;\n }\n "]))),
|
|
41
42
|
p: p,
|
|
42
43
|
root: __root,
|
|
43
44
|
variant: cx(header, p, blockquote, code)
|
package/package.json
CHANGED