Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(typography): 添加 onSave 回调支持编辑完成时触发#8385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
274153705 wants to merge1 commit intovueComponent:main
base:main
Choose a base branch
Loading
from274153705:main
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletionscomponents/typography/Base.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,6 +49,7 @@ export interface EditConfig {
tooltip?: boolean;
onStart?: () => void;
onChange?: (value: string) => void;
onSave?: (value: string) => void;
onCancel?: () => void;
onEnd?: () => void;
maxlength?: number;
Expand DownExpand Up@@ -219,6 +220,11 @@ const Base = defineComponent({
}

function onEditChange(value: string) {
const { onSave } = editable.value;
if (value !== props.content) {
emit('save', value);
onSave?.(value);
}
onContentChange(value);
triggerEdit(false);
}
Expand Down
6 changes: 4 additions & 2 deletionscomponents/typography/demo/interactive.vue
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,7 +15,7 @@ title:
Provide additional interactive capacity of editable and copyable.
</docs>
<template>
<a-typography-paragraph v-model:content="editableStr" editable />
<a-typography-paragraph v-model:content="editableStr":editable="{ onSave: saveText }" />
<a-typography-paragraph v-model:content="customIconStr" editable>
<template #editableIcon><HighlightOutlined /></template>
<template #editableTooltip>click to edit text</template>
Expand DownExpand Up@@ -85,7 +85,9 @@ watch(editableStr, () => {
console.log('editableStr', editableStr.value);
});
const chooseTrigger = ref<('icon' | 'text')[]>(['icon']);

const saveText = (value: string) => {
console.log('saveText', value);
};
const radioToState = (input: string): ('icon' | 'text')[] => {
switch (input) {
case 'text':
Expand Down
2 changes: 2 additions & 0 deletionscomponents/typography/index.en-US.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -103,6 +103,7 @@ Basic text writing, including headings, body text, lists, and more.
autoSize: boolean | { minRows: number, maxRows: number },
onStart: function,
onChange: function(string),
onSave: function(string),
onCancel: function,
onEnd: function,
triggerType: ('icon' | 'text')[],
Expand All@@ -118,6 +119,7 @@ Basic text writing, including headings, body text, lists, and more.
| triggerType | Edit mode trigger - icon, text or both (not specifying icon as trigger hides it) | Array&lt;`icon`\|`text`> | \[`icon`] | |
| onCancel | Called when type ESC to exit editable state | function | - | |
| onChange | Called when input at textarea | function(event) | - | |
| onSave | Called when exit editable state,Contains text fields that are converted back to text | function(event) | - | |
| onEnd | Called when type ENTER to exit editable state | function | - | |
| onStart | Called when enter editable state | function | - | |

Expand Down
2 changes: 2 additions & 0 deletionscomponents/typography/index.zh-CN.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,6 +104,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*LT2jR41Uj2EAAA
autoSize: boolean | { minRows: number, maxRows: number },
onStart: function,
onChange: function(string),
onSave: function(string),
onCancel: function,
onEnd: function,
triggerType: ('icon' | 'text')[],
Expand All@@ -119,6 +120,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*LT2jR41Uj2EAAA
| triggerType | 编辑模式触发器类型,图标、文本或者两者都设置(不设置图标作为触发器时它会隐藏) | Array&lt;`icon`\|`text`> | \[`icon`] | |
| onCancel | 按 ESC 退出编辑状态时触发 | function | - | |
| onChange | 文本域编辑时触发 | function(event) | - | |
| onSave | 文本域编辑结束时触发,包含文本域变回文字 | function(event) | - | |
| onEnd | 按 ENTER 结束编辑状态时触发 | function | - | |
| onStart | 进入编辑中状态时触发 | function | - | |

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp