Skip to content

Commit 0f8bb19

Browse files
authored
feat(EditorMd): 增加beforeShowHint参数 (#1809)
1 parent 56c37fc commit 0f8bb19

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

packages/devui-vue/devui/editor-md/src/composables/use-editor-md.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function useEditorMd(props: EditorMdProps, ctx: SetupContext) {
2020
hintConfig,
2121
disableChangeEvent,
2222
modelValue,
23+
beforeShowHint,
2324
} = toRefs(props);
2425

2526
const toolbars = reactive(cloneDeep(DEFAULT_TOOLBARS));
@@ -202,6 +203,13 @@ export function useEditorMd(props: EditorMdProps, ctx: SetupContext) {
202203
const cursor = editorIns.getCursor();
203204
let i = prefixes.value.length;
204205
const value = editorIns.getLine(cursor.line).replace(/\t/g, ' ');
206+
let result = false;
207+
if (beforeShowHint?.value) {
208+
result = beforeShowHint.value(value);
209+
}
210+
if (result) {
211+
return;
212+
}
205213
const selection = editorIns.getSelection();
206214
const isImgRegx = /^\!\[\S+/;
207215
if (selection) {

packages/devui-vue/devui/editor-md/src/editor-md-types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ export const editorMdProps = {
125125
customHintReplaceFn: {
126126
type: Function as PropType<(prefix: string, row: any) => string>,
127127
},
128+
beforeShowHint: {
129+
type: Function as PropType<(value: string) => boolean>,
130+
},
128131
};
129132

130133
export type EditorMdProps = ExtractPropTypes<typeof editorMdProps>;

packages/devui-vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-devui",
3-
"version": "1.6.4-markdown.0",
3+
"version": "1.6.4-markdown.1",
44
"license": "MIT",
55
"description": "DevUI components based on Vite and Vue3",
66
"keywords": [

0 commit comments

Comments
 (0)