@ant-design/agentic-ui 2.29.28 → 2.29.30
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/MarkdownEditor/BaseMarkdownEditor.js +29 -4
- package/dist/MarkdownEditor/editor/Editor.d.ts +2 -1
- package/dist/MarkdownEditor/editor/Editor.js +4 -4
- package/dist/MarkdownEditor/editor/elements/LinkCard/ReadonlyLinkCard.js +10 -9
- package/dist/MarkdownEditor/editor/elements/LinkCard/index.js +10 -9
- package/dist/MarkdownEditor/editor/elements/index.js +9 -0
- package/dist/MarkdownEditor/editor/plugins/useHighlight.d.ts +1 -1
- package/dist/MarkdownEditor/editor/plugins/useHighlight.js +25 -1
- package/dist/MarkdownEditor/editor/plugins/useKeyboard.js +30 -2
- package/dist/MarkdownEditor/editor/store.d.ts +12 -0
- package/dist/MarkdownEditor/editor/store.js +7 -1
- package/dist/MarkdownEditor/editor/style.js +10 -0
- package/dist/MarkdownEditor/editor/tools/InsertAutocomplete.js +1 -1
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/index.d.ts +2 -0
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/index.js +327 -0
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/style.d.ts +9 -0
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/style.js +131 -0
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/templates.d.ts +5 -0
- package/dist/MarkdownEditor/editor/tools/JinjaTemplatePanel/templates.js +28 -0
- package/dist/MarkdownEditor/editor/tools/ToolBar/FloatBar.js +1 -1
- package/dist/MarkdownEditor/el.d.ts +3 -0
- package/dist/MarkdownEditor/plugin.d.ts +5 -0
- package/dist/MarkdownEditor/plugins/jinja.d.ts +21 -0
- package/dist/MarkdownEditor/plugins/jinja.js +70 -0
- package/dist/MarkdownEditor/style.js +54 -60
- package/dist/MarkdownEditor/types.d.ts +38 -1
- package/dist/Plugins/chart/ChartRender.js +12 -1
- package/dist/Plugins/code/components/AceEditor.js +0 -1
- package/dist/TaskList/index.d.ts +1 -1
- package/dist/index.d.ts +16 -15
- package/dist/index.js +16 -15
- package/package.json +2 -1
|
@@ -136,6 +136,10 @@ function _sliced_to_array(arr, i) {
|
|
|
136
136
|
function _to_consumable_array(arr) {
|
|
137
137
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
138
138
|
}
|
|
139
|
+
function _type_of(obj) {
|
|
140
|
+
"@swc/helpers - typeof";
|
|
141
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
142
|
+
}
|
|
139
143
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
140
144
|
if (!o) return;
|
|
141
145
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -161,6 +165,7 @@ import { withErrorReporting } from "./editor/plugins/catchError";
|
|
|
161
165
|
import { EditorStore, EditorStoreContext } from "./editor/store";
|
|
162
166
|
import { InsertAutocomplete } from "./editor/tools/InsertAutocomplete";
|
|
163
167
|
import { InsertLink } from "./editor/tools/InsertLink";
|
|
168
|
+
import { JinjaTemplatePanel } from "./editor/tools/JinjaTemplatePanel";
|
|
164
169
|
import { TocHeading } from "./editor/tools/Leading";
|
|
165
170
|
import { FloatBar } from "./editor/tools/ToolBar/FloatBar";
|
|
166
171
|
import ToolBar from "./editor/tools/ToolBar/ToolBar";
|
|
@@ -244,7 +249,7 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
244
249
|
* - 提供Markdown解析和渲染
|
|
245
250
|
*/ export var BaseMarkdownEditor = function BaseMarkdownEditor(props) {
|
|
246
251
|
var _props_typewriter, _props_readonly;
|
|
247
|
-
var _props_floatBar, _props_floatBar1, _props_textAreaProps;
|
|
252
|
+
var _props_jinja, _effectiveJinja_templatePanel, _props_floatBar, _props_floatBar1, _props_textAreaProps;
|
|
248
253
|
var initValue = props.initValue, width = props.width, _props_toolBar = props.toolBar, toolBar = _props_toolBar === void 0 ? {} : _props_toolBar, editorRef = props.editorRef, _props_toc = props.toc, toc = _props_toc === void 0 ? false : _props_toc, readonly = props.readonly, lazy = props.lazy, style = props.style, _props_contentStyle = props.contentStyle, contentStyle = _props_contentStyle === void 0 ? {
|
|
249
254
|
height: '100%'
|
|
250
255
|
} : _props_contentStyle, editorStyle = props.editorStyle, height = props.height, children = props.children, rest = _object_without_properties(props, [
|
|
@@ -395,6 +400,18 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
395
400
|
return new Subject();
|
|
396
401
|
}, []);
|
|
397
402
|
var _useState6 = _sliced_to_array(useState(null), 2), domRect = _useState6[0], setDomRect = _useState6[1];
|
|
403
|
+
var jinjaEnabled = ((_props_jinja = props.jinja) === null || _props_jinja === void 0 ? void 0 : _props_jinja.enable) === true || Array.isArray(props.plugins) && props.plugins.some(function(p) {
|
|
404
|
+
return p.jinja === true;
|
|
405
|
+
});
|
|
406
|
+
var pluginWithJinja = Array.isArray(props.plugins) ? props.plugins.find(function(p) {
|
|
407
|
+
return p.jinja === true;
|
|
408
|
+
}) : undefined;
|
|
409
|
+
var effectiveJinja = props.jinja ? props.jinja : (pluginWithJinja === null || pluginWithJinja === void 0 ? void 0 : pluginWithJinja.jinjaConfig) ? pluginWithJinja.jinjaConfig : pluginWithJinja ? {
|
|
410
|
+
enable: true
|
|
411
|
+
} : undefined;
|
|
412
|
+
var jinjaTemplatePanelEnabled = jinjaEnabled && effectiveJinja !== undefined && effectiveJinja !== null && effectiveJinja.templatePanel !== false && (_type_of(effectiveJinja.templatePanel) !== 'object' || ((_effectiveJinja_templatePanel = effectiveJinja.templatePanel) === null || _effectiveJinja_templatePanel === void 0 ? void 0 : _effectiveJinja_templatePanel.enable) !== false);
|
|
413
|
+
var _useState7 = _sliced_to_array(useState(false), 2), openJinjaTemplate = _useState7[0], setOpenJinjaTemplate = _useState7[1];
|
|
414
|
+
var _useState8 = _sliced_to_array(useState(null), 2), jinjaAnchorPath = _useState8[0], setJinjaAnchorPath = _useState8[1];
|
|
398
415
|
var _obj;
|
|
399
416
|
return wrapSSR(/*#__PURE__*/ React.createElement(I18nBoundary, null, /*#__PURE__*/ React.createElement(PluginContext.Provider, {
|
|
400
417
|
value: props.plugins || []
|
|
@@ -414,9 +431,17 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
414
431
|
setDomRect: setDomRect,
|
|
415
432
|
typewriter: (_props_typewriter = props.typewriter) !== null && _props_typewriter !== void 0 ? _props_typewriter : false,
|
|
416
433
|
readonly: (_props_readonly = props.readonly) !== null && _props_readonly !== void 0 ? _props_readonly : false,
|
|
417
|
-
editorProps:
|
|
434
|
+
editorProps: effectiveJinja !== undefined ? _object_spread_props(_object_spread({}, props), {
|
|
435
|
+
jinja: effectiveJinja
|
|
436
|
+
}) : props || {},
|
|
418
437
|
markdownEditorRef: markdownEditorRef,
|
|
419
|
-
markdownContainerRef: markdownContainerRef
|
|
438
|
+
markdownContainerRef: markdownContainerRef,
|
|
439
|
+
openJinjaTemplate: openJinjaTemplate,
|
|
440
|
+
setOpenJinjaTemplate: setOpenJinjaTemplate,
|
|
441
|
+
jinjaAnchorPath: jinjaAnchorPath,
|
|
442
|
+
setJinjaAnchorPath: setJinjaAnchorPath,
|
|
443
|
+
jinjaEnabled: jinjaEnabled,
|
|
444
|
+
jinjaTemplatePanelEnabled: jinjaTemplatePanelEnabled
|
|
420
445
|
}
|
|
421
446
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
422
447
|
id: props.id ? String(props.id) || undefined : undefined,
|
|
@@ -473,5 +498,5 @@ var I18nBoundary = function I18nBoundary(param) {
|
|
|
473
498
|
comment: props.comment
|
|
474
499
|
}) : null), readonly || (props === null || props === void 0 ? void 0 : (_props_textAreaProps = props.textAreaProps) === null || _props_textAreaProps === void 0 ? void 0 : _props_textAreaProps.enable) || (props === null || props === void 0 ? void 0 : props.reportMode) ? null : /*#__PURE__*/ React.createElement("div", {
|
|
475
500
|
className: classNames("".concat(baseClassName, "-focus"))
|
|
476
|
-
}), readonly ? /*#__PURE__*/ React.createElement(React.Fragment, null) : /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(InsertLink, null), /*#__PURE__*/ React.createElement(InsertAutocomplete, (props === null || props === void 0 ? void 0 : props.insertAutocompleteProps) || {})), children)))));
|
|
501
|
+
}), readonly ? /*#__PURE__*/ React.createElement(React.Fragment, null) : /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(InsertLink, null), /*#__PURE__*/ React.createElement(InsertAutocomplete, (props === null || props === void 0 ? void 0 : props.insertAutocompleteProps) || {}), jinjaTemplatePanelEnabled ? /*#__PURE__*/ React.createElement(JinjaTemplatePanel, null) : null), children)))));
|
|
477
502
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { MarkdownEditorInstance, MarkdownEditorProps } from '../types';
|
|
2
3
|
/**
|
|
3
4
|
* Markdown 编辑器组件的属性接口
|
|
@@ -66,4 +67,4 @@ export type MEditorProps = {
|
|
|
66
67
|
* - 支持错误边界
|
|
67
68
|
* - 响应式布局
|
|
68
69
|
*/
|
|
69
|
-
export declare const SlateMarkdownEditor: (props: MEditorProps) => any
|
|
70
|
+
export declare const SlateMarkdownEditor: React.MemoExoticComponent<(props: MEditorProps) => any>;
|
|
@@ -322,10 +322,10 @@ var defaultAllowedTypes = [
|
|
|
322
322
|
* - 提供粘贴处理
|
|
323
323
|
* - 支持错误边界
|
|
324
324
|
* - 响应式布局
|
|
325
|
-
*/ export var SlateMarkdownEditor =
|
|
325
|
+
*/ export var SlateMarkdownEditor = /*#__PURE__*/ React.memo(function(props) {
|
|
326
326
|
var _markdownEditorRef_current, _props_textAreaProps, _props_comment, _markdownEditorRef_current1;
|
|
327
327
|
// 所有hooks必须在组件顶部按固定顺序调用
|
|
328
|
-
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, setDomRect = _useEditorStore.setDomRect;
|
|
328
|
+
var _useEditorStore = useEditorStore(), store = _useEditorStore.store, markdownEditorRef = _useEditorStore.markdownEditorRef, markdownContainerRef = _useEditorStore.markdownContainerRef, readonly = _useEditorStore.readonly, setDomRect = _useEditorStore.setDomRect, jinjaEnabled = _useEditorStore.jinjaEnabled;
|
|
329
329
|
// 懒加载元素索引计数器
|
|
330
330
|
var lazyElementIndexRef = useRef(0);
|
|
331
331
|
// 用于标记是否已在当前渲染周期重置过索引
|
|
@@ -357,7 +357,7 @@ var defaultAllowedTypes = [
|
|
|
357
357
|
var plugins = useContext(PluginContext);
|
|
358
358
|
var onKeyDown = useKeyboard(store, markdownEditorRef, props);
|
|
359
359
|
var onChange = useOnchange(markdownEditorRef.current, props.onChange);
|
|
360
|
-
var high = useHighlight(store);
|
|
360
|
+
var high = useHighlight(store, jinjaEnabled);
|
|
361
361
|
var childrenIsEmpty = useMemo(function() {
|
|
362
362
|
var _markdownEditorRef_current;
|
|
363
363
|
if (!((_markdownEditorRef_current = markdownEditorRef.current) === null || _markdownEditorRef_current === void 0 ? void 0 : _markdownEditorRef_current.children)) return false;
|
|
@@ -1229,4 +1229,4 @@ var defaultAllowedTypes = [
|
|
|
1229
1229
|
renderLeaf: renderMarkdownLeaf,
|
|
1230
1230
|
onKeyDown: handleKeyDown
|
|
1231
1231
|
}))));
|
|
1232
|
-
};
|
|
1232
|
+
});
|
|
@@ -82,7 +82,8 @@ import { AvatarList } from "../../components/ContributorAvatar";
|
|
|
82
82
|
var element = param.element, attributes = param.attributes, children = param.children;
|
|
83
83
|
var _element_otherProps, _element_otherProps_collaborators, _element_otherProps1, _element_otherProps2;
|
|
84
84
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
85
|
-
var
|
|
85
|
+
var contentCls = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-content');
|
|
86
|
+
var blockCls = contentCls ? "".concat(contentCls, "-link-card") : '';
|
|
86
87
|
var _useState = _sliced_to_array(useState(false), 2), showAsText = _useState[0], setShowAsText = _useState[1];
|
|
87
88
|
// 如果 finished 为 false,设置 5 秒超时,超时后显示为文本
|
|
88
89
|
useEffect(function() {
|
|
@@ -123,7 +124,7 @@ import { AvatarList } from "../../components/ContributorAvatar";
|
|
|
123
124
|
}), children);
|
|
124
125
|
}
|
|
125
126
|
return /*#__PURE__*/ React.createElement("div", attributes, /*#__PURE__*/ React.createElement("div", {
|
|
126
|
-
className: classNames(
|
|
127
|
+
className: classNames(blockCls),
|
|
127
128
|
"data-be": "link-card",
|
|
128
129
|
draggable: false,
|
|
129
130
|
style: {
|
|
@@ -146,12 +147,12 @@ import { AvatarList } from "../../components/ContributorAvatar";
|
|
|
146
147
|
if (typeof window === 'undefined') return;
|
|
147
148
|
window.open(element === null || element === void 0 ? void 0 : element.url);
|
|
148
149
|
},
|
|
149
|
-
className: classNames("".concat(
|
|
150
|
+
className: classNames("".concat(blockCls, "__container"))
|
|
150
151
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
151
|
-
className: classNames("".concat(
|
|
152
|
+
className: classNames("".concat(blockCls, "__content")),
|
|
152
153
|
contentEditable: false
|
|
153
154
|
}, element.icon ? /*#__PURE__*/ React.createElement("img", {
|
|
154
|
-
className: classNames("".concat(
|
|
155
|
+
className: classNames("".concat(blockCls, "__icon")),
|
|
155
156
|
src: element.icon,
|
|
156
157
|
width: 56
|
|
157
158
|
}) : null, /*#__PURE__*/ React.createElement("div", {
|
|
@@ -161,7 +162,7 @@ import { AvatarList } from "../../components/ContributorAvatar";
|
|
|
161
162
|
}
|
|
162
163
|
}, /*#__PURE__*/ React.createElement("a", {
|
|
163
164
|
href: element === null || element === void 0 ? void 0 : element.url,
|
|
164
|
-
className: classNames("".concat(
|
|
165
|
+
className: classNames("".concat(blockCls, "__title")),
|
|
165
166
|
onClick: function onClick(e) {
|
|
166
167
|
e.stopPropagation();
|
|
167
168
|
e.preventDefault();
|
|
@@ -170,9 +171,9 @@ import { AvatarList } from "../../components/ContributorAvatar";
|
|
|
170
171
|
},
|
|
171
172
|
download: element.title || element.name || 'no title'
|
|
172
173
|
}, element.title || element.name || 'no title'), /*#__PURE__*/ React.createElement("div", {
|
|
173
|
-
className: classNames("".concat(
|
|
174
|
+
className: classNames("".concat(blockCls, "__description"))
|
|
174
175
|
}, element.description ? element.description : element === null || element === void 0 ? void 0 : element.url), /*#__PURE__*/ React.createElement("div", {
|
|
175
|
-
className: classNames("".concat(
|
|
176
|
+
className: classNames("".concat(blockCls, "__collaborators"))
|
|
176
177
|
}, ((_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.collaborators) ? /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(AvatarList, {
|
|
177
178
|
displayList: ((_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : (_element_otherProps_collaborators = _element_otherProps1.collaborators) === null || _element_otherProps_collaborators === void 0 ? void 0 : _element_otherProps_collaborators.map(function(item) {
|
|
178
179
|
var _Object_keys, _Object_values;
|
|
@@ -182,7 +183,7 @@ import { AvatarList } from "../../components/ContributorAvatar";
|
|
|
182
183
|
};
|
|
183
184
|
}).slice(0, 5)) || []
|
|
184
185
|
})) : /*#__PURE__*/ React.createElement("div", null), ((_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.updateTime) ? /*#__PURE__*/ React.createElement("div", {
|
|
185
|
-
className: classNames("".concat(
|
|
186
|
+
className: classNames("".concat(blockCls, "__update-time")),
|
|
186
187
|
style: {
|
|
187
188
|
color: 'rgba(0,0,0,0.45)',
|
|
188
189
|
fontSize: 12
|
|
@@ -53,7 +53,8 @@ export function LinkCard(param) {
|
|
|
53
53
|
var element = param.element, attributes = param.attributes, children = param.children;
|
|
54
54
|
var _element_otherProps, _element_otherProps_collaborators, _element_otherProps1, _element_otherProps2;
|
|
55
55
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
56
|
-
var
|
|
56
|
+
var contentCls = context === null || context === void 0 ? void 0 : context.getPrefixCls('agentic-md-editor-content');
|
|
57
|
+
var blockCls = contentCls ? "".concat(contentCls, "-link-card") : '';
|
|
57
58
|
var htmlRef = React.useRef(null);
|
|
58
59
|
var _useState = _sliced_to_array(useState(false), 2), showAsText = _useState[0], setShowAsText = _useState[1];
|
|
59
60
|
// 如果 finished 为 false,设置 5 秒超时,超时后显示为文本
|
|
@@ -95,7 +96,7 @@ export function LinkCard(param) {
|
|
|
95
96
|
}), children);
|
|
96
97
|
}
|
|
97
98
|
return /*#__PURE__*/ React.createElement("div", attributes, /*#__PURE__*/ React.createElement("div", {
|
|
98
|
-
className: classNames(
|
|
99
|
+
className: classNames(blockCls),
|
|
99
100
|
"data-be": "link-card",
|
|
100
101
|
"data-drag-el": true,
|
|
101
102
|
draggable: false,
|
|
@@ -126,12 +127,12 @@ export function LinkCard(param) {
|
|
|
126
127
|
if (typeof window === 'undefined') return;
|
|
127
128
|
window.open(element === null || element === void 0 ? void 0 : element.url);
|
|
128
129
|
},
|
|
129
|
-
className: classNames("".concat(
|
|
130
|
+
className: classNames("".concat(blockCls, "__container"))
|
|
130
131
|
}, /*#__PURE__*/ React.createElement("div", {
|
|
131
|
-
className: classNames("".concat(
|
|
132
|
+
className: classNames("".concat(blockCls, "__content")),
|
|
132
133
|
contentEditable: false
|
|
133
134
|
}, element.icon ? /*#__PURE__*/ React.createElement("img", {
|
|
134
|
-
className: classNames("".concat(
|
|
135
|
+
className: classNames("".concat(blockCls, "__icon")),
|
|
135
136
|
src: element.icon,
|
|
136
137
|
width: 56
|
|
137
138
|
}) : null, /*#__PURE__*/ React.createElement("div", {
|
|
@@ -141,7 +142,7 @@ export function LinkCard(param) {
|
|
|
141
142
|
}
|
|
142
143
|
}, /*#__PURE__*/ React.createElement("a", {
|
|
143
144
|
href: element === null || element === void 0 ? void 0 : element.url,
|
|
144
|
-
className: classNames("".concat(
|
|
145
|
+
className: classNames("".concat(blockCls, "__title")),
|
|
145
146
|
onClick: function onClick(e) {
|
|
146
147
|
e.stopPropagation();
|
|
147
148
|
e.preventDefault();
|
|
@@ -150,9 +151,9 @@ export function LinkCard(param) {
|
|
|
150
151
|
},
|
|
151
152
|
download: element.title || element.name || 'no title'
|
|
152
153
|
}, element.title || element.name || 'no title'), /*#__PURE__*/ React.createElement("div", {
|
|
153
|
-
className: classNames("".concat(
|
|
154
|
+
className: classNames("".concat(blockCls, "__description"))
|
|
154
155
|
}, element.description ? element.description : element === null || element === void 0 ? void 0 : element.url), /*#__PURE__*/ React.createElement("div", {
|
|
155
|
-
className: classNames("".concat(
|
|
156
|
+
className: classNames("".concat(blockCls, "__collaborators"))
|
|
156
157
|
}, ((_element_otherProps = element.otherProps) === null || _element_otherProps === void 0 ? void 0 : _element_otherProps.collaborators) ? /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(AvatarList, {
|
|
157
158
|
displayList: ((_element_otherProps1 = element.otherProps) === null || _element_otherProps1 === void 0 ? void 0 : (_element_otherProps_collaborators = _element_otherProps1.collaborators) === null || _element_otherProps_collaborators === void 0 ? void 0 : _element_otherProps_collaborators.map(function(item) {
|
|
158
159
|
var _Object_keys, _Object_values;
|
|
@@ -162,7 +163,7 @@ export function LinkCard(param) {
|
|
|
162
163
|
};
|
|
163
164
|
}).slice(0, 5)) || []
|
|
164
165
|
})) : /*#__PURE__*/ React.createElement("div", null), ((_element_otherProps2 = element.otherProps) === null || _element_otherProps2 === void 0 ? void 0 : _element_otherProps2.updateTime) ? /*#__PURE__*/ React.createElement("div", {
|
|
165
|
-
className: classNames("".concat(
|
|
166
|
+
className: classNames("".concat(blockCls, "__update-time")),
|
|
166
167
|
style: {
|
|
167
168
|
color: 'rgba(0,0,0,0.45)',
|
|
168
169
|
fontSize: 12
|
|
@@ -410,6 +410,15 @@ var MLeafComponent = function MLeafComponent(props) {
|
|
|
410
410
|
if (leaf.html) {
|
|
411
411
|
prefixClassName = classNames(mdEditorBaseClass + '-m-html');
|
|
412
412
|
}
|
|
413
|
+
if (leaf.jinjaVariable) {
|
|
414
|
+
prefixClassName = classNames(prefixClassName, "".concat(mdEditorBaseClass, "-jinja-variable"));
|
|
415
|
+
}
|
|
416
|
+
if (leaf.jinjaTag) {
|
|
417
|
+
prefixClassName = classNames(prefixClassName, "".concat(mdEditorBaseClass, "-jinja-tag"));
|
|
418
|
+
}
|
|
419
|
+
if (leaf.jinjaComment) {
|
|
420
|
+
prefixClassName = classNames(prefixClassName, "".concat(mdEditorBaseClass, "-jinja-comment"));
|
|
421
|
+
}
|
|
413
422
|
if (leaf.current) {
|
|
414
423
|
style.background = '#f59e0b';
|
|
415
424
|
}
|
|
@@ -5,4 +5,4 @@ export declare const cacheTextNode: WeakMap<object, {
|
|
|
5
5
|
range: Range[];
|
|
6
6
|
}>;
|
|
7
7
|
export declare const clearInlineKatex: (editor: Editor) => void;
|
|
8
|
-
export declare function useHighlight(store?: EditorStore): ([node, path]: NodeEntry) => Range[];
|
|
8
|
+
export declare function useHighlight(store?: EditorStore, jinjaEnabled?: boolean): ([node, path]: NodeEntry) => Range[];
|
|
@@ -91,6 +91,9 @@ var HTML_REG = /<[a-z]+[\s"'=:;()\w\-[\]/.]*\/?>(.*<\/[a-z]+>:?)?/g;
|
|
|
91
91
|
var LINK_REG = /(https?|ftp):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/gi;
|
|
92
92
|
var FOOTNOTE_REG = /\[\^[^\]]+\]/g;
|
|
93
93
|
var TABLE_ROW_REG = /^\|([^|]+\|)+$/;
|
|
94
|
+
/** 至少一个非 } 字符,避免匹配 {{}}、{{ 等不完整表达式 */ var JINJA_VARIABLE_REG = /\{\{[^}]+\}\}/g;
|
|
95
|
+
/** 至少一个非 % 字符,避免匹配 {%%} */ var JINJA_TAG_REG = /\{%[^%]+%\}/g;
|
|
96
|
+
/** 单行内注释,避免跨多行高亮造成大段误匹配(编辑器场景) */ var JINJA_COMMENT_REG = /\{#[^\n]*?#\}/g;
|
|
94
97
|
export var cacheTextNode = new WeakMap();
|
|
95
98
|
export var clearInlineKatex = function clearInlineKatex(editor) {
|
|
96
99
|
var inlineMath = Array.from(Editor.nodes(editor, {
|
|
@@ -172,7 +175,24 @@ var processLinkMatches = function processLinkMatches(text, path, childIndex) {
|
|
|
172
175
|
}
|
|
173
176
|
return ranges;
|
|
174
177
|
};
|
|
175
|
-
|
|
178
|
+
var processJinjaMatches = function processJinjaMatches(text, path, childIndex) {
|
|
179
|
+
var ranges = [];
|
|
180
|
+
var collect = function collect(reg, prop) {
|
|
181
|
+
reg.lastIndex = 0;
|
|
182
|
+
var match;
|
|
183
|
+
while((match = reg.exec(text)) !== null){
|
|
184
|
+
var index = match.index;
|
|
185
|
+
if (typeof index === 'number') {
|
|
186
|
+
ranges.push(createRange(path, childIndex, index, match[0].length, _define_property({}, prop, true)));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
collect(JINJA_VARIABLE_REG, 'jinjaVariable');
|
|
191
|
+
collect(JINJA_TAG_REG, 'jinjaTag');
|
|
192
|
+
collect(JINJA_COMMENT_REG, 'jinjaComment');
|
|
193
|
+
return ranges;
|
|
194
|
+
};
|
|
195
|
+
export function useHighlight(store, jinjaEnabled) {
|
|
176
196
|
return function(param) {
|
|
177
197
|
var _param = _sliced_to_array(param, 2), node = _param[0], path = _param[1];
|
|
178
198
|
// 快速路径:非元素节点或不在高亮节点列表中
|
|
@@ -204,6 +224,10 @@ export function useHighlight(store) {
|
|
|
204
224
|
var _allTextRanges1;
|
|
205
225
|
(_allTextRanges1 = allTextRanges).push.apply(_allTextRanges1, _to_consumable_array(processLinkMatches(child.text, path, i)));
|
|
206
226
|
}
|
|
227
|
+
if (jinjaEnabled && child.text && !EditorUtils.isDirtLeaf(child)) {
|
|
228
|
+
var _allTextRanges2;
|
|
229
|
+
(_allTextRanges2 = allTextRanges).push.apply(_allTextRanges2, _to_consumable_array(processJinjaMatches(child.text, path, i)));
|
|
230
|
+
}
|
|
207
231
|
}
|
|
208
232
|
// 统一缓存
|
|
209
233
|
cacheTextNode.set(node, {
|
|
@@ -36,6 +36,10 @@ function _non_iterable_rest() {
|
|
|
36
36
|
function _sliced_to_array(arr, i) {
|
|
37
37
|
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
38
38
|
}
|
|
39
|
+
function _type_of(obj) {
|
|
40
|
+
"@swc/helpers - typeof";
|
|
41
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
42
|
+
}
|
|
39
43
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
40
44
|
if (!o) return;
|
|
41
45
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -94,7 +98,10 @@ import { useEditorStore } from "../store";
|
|
|
94
98
|
* - 与编辑器状态深度集成,实现上下文相关的行为
|
|
95
99
|
* - 提供良好的用户体验和 Markdown 编辑效率
|
|
96
100
|
*/ export var useKeyboard = function useKeyboard(store, markdownEditorRef, props) {
|
|
97
|
-
var _useEditorStore = useEditorStore(), openInsertCompletion = _useEditorStore.openInsertCompletion, insertCompletionText$ = _useEditorStore.insertCompletionText$, setOpenInsertCompletion = _useEditorStore.setOpenInsertCompletion;
|
|
101
|
+
var _useEditorStore = useEditorStore(), openInsertCompletion = _useEditorStore.openInsertCompletion, insertCompletionText$ = _useEditorStore.insertCompletionText$, setOpenInsertCompletion = _useEditorStore.setOpenInsertCompletion, openJinjaTemplate = _useEditorStore.openJinjaTemplate, setOpenJinjaTemplate = _useEditorStore.setOpenJinjaTemplate, setJinjaAnchorPath = _useEditorStore.setJinjaAnchorPath, jinjaTemplatePanelEnabled = _useEditorStore.jinjaTemplatePanelEnabled, editorProps = _useEditorStore.editorProps;
|
|
102
|
+
// 从 editorProps.jinja 读取(BaseMarkdownEditor 已写入 effectiveJinja),支持插件配置的 trigger
|
|
103
|
+
var effectiveJinja = editorProps === null || editorProps === void 0 ? void 0 : editorProps.jinja;
|
|
104
|
+
var jinjaTrigger = (effectiveJinja === null || effectiveJinja === void 0 ? void 0 : effectiveJinja.templatePanel) && _type_of(effectiveJinja.templatePanel) === 'object' && effectiveJinja.templatePanel.trigger || '{}';
|
|
98
105
|
return useMemo(function() {
|
|
99
106
|
var tab = new TabKey(markdownEditorRef.current);
|
|
100
107
|
var backspace = new BackspaceKey(markdownEditorRef.current);
|
|
@@ -114,6 +121,10 @@ import { useEditorStore } from "../store";
|
|
|
114
121
|
e.preventDefault();
|
|
115
122
|
return;
|
|
116
123
|
}
|
|
124
|
+
if (openJinjaTemplate && (isHotkey('up', e) || isHotkey('down', e))) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
117
128
|
if (isHotkey('mod+ArrowDown', e)) {
|
|
118
129
|
e.preventDefault();
|
|
119
130
|
Transforms.select(markdownEditorRef.current, Editor.end(markdownEditorRef.current, []));
|
|
@@ -239,6 +250,15 @@ import { useEditorStore } from "../store";
|
|
|
239
250
|
var str = Node.string(node3[0]) || '';
|
|
240
251
|
var codeMatch = str.match(/^```([\w+\-#]+)$/i);
|
|
241
252
|
if (codeMatch) {} else {
|
|
253
|
+
var strAfterKey = str + (e.key.length === 1 ? e.key : '');
|
|
254
|
+
// 仅在实际输入一个字符且刚好补全 trigger 时打开面板,避免 Backspace 等导致误打开
|
|
255
|
+
if (jinjaTemplatePanelEnabled && e.key.length === 1 && strAfterKey === jinjaTrigger && setOpenJinjaTemplate && setJinjaAnchorPath) {
|
|
256
|
+
setJinjaAnchorPath(node3[1]);
|
|
257
|
+
setTimeout(function() {
|
|
258
|
+
return setOpenJinjaTemplate(true);
|
|
259
|
+
});
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
242
262
|
var insertMatch = str.match(/^\/([^\n]+)?$/i);
|
|
243
263
|
if (insertMatch && !(!Path.hasPrevious(node3[1]) && Node.parent(markdownEditorRef.current, node3[1]).type === 'list-item')) {
|
|
244
264
|
setOpenInsertCompletion === null || setOpenInsertCompletion === void 0 ? void 0 : setOpenInsertCompletion(true);
|
|
@@ -252,6 +272,14 @@ import { useEditorStore } from "../store";
|
|
|
252
272
|
};
|
|
253
273
|
}, [
|
|
254
274
|
markdownEditorRef.current,
|
|
255
|
-
props === null || props === void 0 ? void 0 : props.readonly
|
|
275
|
+
props === null || props === void 0 ? void 0 : props.readonly,
|
|
276
|
+
openInsertCompletion,
|
|
277
|
+
insertCompletionText$,
|
|
278
|
+
setOpenInsertCompletion,
|
|
279
|
+
openJinjaTemplate,
|
|
280
|
+
setOpenJinjaTemplate,
|
|
281
|
+
setJinjaAnchorPath,
|
|
282
|
+
jinjaTemplatePanelEnabled,
|
|
283
|
+
jinjaTrigger
|
|
256
284
|
]);
|
|
257
285
|
};
|
|
@@ -46,6 +46,18 @@ export interface EditorStoreContextType {
|
|
|
46
46
|
openInsertCompletion?: boolean;
|
|
47
47
|
/** 设置打开插入自动完成状态 */
|
|
48
48
|
setOpenInsertCompletion?: (open: boolean) => void;
|
|
49
|
+
/** 是否打开 Jinja 模板面板 */
|
|
50
|
+
openJinjaTemplate?: boolean;
|
|
51
|
+
/** 设置打开 Jinja 模板面板状态 */
|
|
52
|
+
setOpenJinjaTemplate?: (open: boolean) => void;
|
|
53
|
+
/** Jinja 弹层插入锚点 path(当前段落节点 path) */
|
|
54
|
+
jinjaAnchorPath?: number[] | null;
|
|
55
|
+
/** 设置 Jinja 弹层锚点 path */
|
|
56
|
+
setJinjaAnchorPath?: (path: number[] | null) => void;
|
|
57
|
+
/** 是否启用 Jinja(总开关,用于语法高亮等) */
|
|
58
|
+
jinjaEnabled?: boolean;
|
|
59
|
+
/** 是否启用 Jinja 模板面板(用于触发与弹层) */
|
|
60
|
+
jinjaTemplatePanelEnabled?: boolean;
|
|
49
61
|
/** 编辑器属性配置 */
|
|
50
62
|
editorProps: MarkdownEditorProps;
|
|
51
63
|
/** Markdown编辑器引用 */
|
|
@@ -163,7 +163,13 @@ export var EditorStoreContext = createContext(null);
|
|
|
163
163
|
readonly: true,
|
|
164
164
|
typewriter: false,
|
|
165
165
|
editorProps: {},
|
|
166
|
-
markdownEditorRef: {}
|
|
166
|
+
markdownEditorRef: {},
|
|
167
|
+
openJinjaTemplate: false,
|
|
168
|
+
setOpenJinjaTemplate: undefined,
|
|
169
|
+
jinjaAnchorPath: null,
|
|
170
|
+
setJinjaAnchorPath: undefined,
|
|
171
|
+
jinjaEnabled: false,
|
|
172
|
+
jinjaTemplatePanelEnabled: false
|
|
167
173
|
};
|
|
168
174
|
};
|
|
169
175
|
/** 支持键入操作的标签类型列表 */ var SUPPORT_TYPING_TAG = [
|
|
@@ -529,6 +529,16 @@ var genStyle = function genStyle(token) {
|
|
|
529
529
|
'& &-m-html': {
|
|
530
530
|
color: 'rgba(0,0,0,0.45)'
|
|
531
531
|
},
|
|
532
|
+
'& &-jinja-variable': {
|
|
533
|
+
color: 'var(--color-primary-control-fill-primary, #1677ff)'
|
|
534
|
+
},
|
|
535
|
+
'& &-jinja-tag': {
|
|
536
|
+
color: 'var(--color-orange-6, #d46b08)'
|
|
537
|
+
},
|
|
538
|
+
'& &-jinja-comment': {
|
|
539
|
+
color: 'var(--color-text-tertiary, rgba(0,0,0,0.25))',
|
|
540
|
+
fontStyle: 'italic'
|
|
541
|
+
},
|
|
532
542
|
'&:not(:last-child)': {
|
|
533
543
|
marginBottom: '0.5em'
|
|
534
544
|
},
|
|
@@ -969,7 +969,7 @@ export var InsertAutocomplete = function InsertAutocomplete(props) {
|
|
|
969
969
|
openInsertCompletion
|
|
970
970
|
]);
|
|
971
971
|
var context = useContext(ConfigProvider.ConfigContext);
|
|
972
|
-
var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls("md-editor-insert-autocomplete");
|
|
972
|
+
var baseClassName = context === null || context === void 0 ? void 0 : context.getPrefixCls("agentic-md-editor-insert-autocomplete");
|
|
973
973
|
var _useStyle = useStyle(baseClassName), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
|
|
974
974
|
return /*#__PURE__*/ ReactDOM.createPortal(wrapSSR(/*#__PURE__*/ React.createElement("div", {
|
|
975
975
|
ref: dom,
|