mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-15 13:55:19 +00:00
refac
This commit is contained in:
parent
3af2938efc
commit
c94ce71ca3
2 changed files with 14 additions and 11 deletions
|
|
@ -1193,23 +1193,27 @@ Provide the enhanced notes in markdown format. Use markdown syntax for headings,
|
||||||
bind:value={note.data.content.json}
|
bind:value={note.data.content.json}
|
||||||
html={note.data?.content?.html}
|
html={note.data?.content?.html}
|
||||||
documentId={`note:${note.id}`}
|
documentId={`note:${note.id}`}
|
||||||
{files}
|
|
||||||
collaboration={true}
|
collaboration={true}
|
||||||
socket={$socket}
|
socket={$socket}
|
||||||
user={$user}
|
user={$user}
|
||||||
link={true}
|
link={true}
|
||||||
image={true}
|
image={true}
|
||||||
|
{files}
|
||||||
placeholder={$i18n.t('Write something...')}
|
placeholder={$i18n.t('Write something...')}
|
||||||
editable={versionIdx === null && !editing}
|
editable={versionIdx === null && !editing}
|
||||||
onSelectionUpdate={({ editor }) => {
|
onSelectionUpdate={({ editor }) => {
|
||||||
const { from, to } = editor.state.selection;
|
const { from, to } = editor.state.selection;
|
||||||
const selectedText = editor.state.doc.textBetween(from, to, ' ');
|
const selectedText = editor.state.doc.textBetween(from, to, ' ');
|
||||||
|
|
||||||
selectedContent = {
|
if (selectedText.length === 0) {
|
||||||
text: selectedText,
|
selectedContent = null;
|
||||||
from: from,
|
} else {
|
||||||
to: to
|
selectedContent = {
|
||||||
};
|
text: selectedText,
|
||||||
|
from: from,
|
||||||
|
to: to
|
||||||
|
};
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onChange={(content) => {
|
onChange={(content) => {
|
||||||
note.data.content.html = content.html;
|
note.data.content.html = content.html;
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ Based on the user's instruction, update and enhance the existing notes or select
|
||||||
if (editEnabled) {
|
if (editEnabled) {
|
||||||
responseMessage.content = `<status title="${$i18n.t('Edited')}" done="true" />`;
|
responseMessage.content = `<status title="${$i18n.t('Edited')}" done="true" />`;
|
||||||
|
|
||||||
if (selectedContent && editor) {
|
if (selectedContent && selectedContent?.text && editor) {
|
||||||
editor.commands.insertContentAt(
|
editor.commands.insertContentAt(
|
||||||
{
|
{
|
||||||
from: selectedContent.from,
|
from: selectedContent.from,
|
||||||
|
|
@ -262,16 +262,15 @@ Based on the user's instruction, update and enhance the existing notes or select
|
||||||
enhancedContent.md += deltaContent;
|
enhancedContent.md += deltaContent;
|
||||||
enhancedContent.html = marked.parse(enhancedContent.md);
|
enhancedContent.html = marked.parse(enhancedContent.md);
|
||||||
|
|
||||||
if (!selectedContent) {
|
if (!selectedContent || !selectedContent?.text) {
|
||||||
note.data.content.md = enhancedContent.md;
|
note.data.content.md = enhancedContent.md;
|
||||||
note.data.content.html = enhancedContent.html;
|
note.data.content.html = enhancedContent.html;
|
||||||
note.data.content.json = null;
|
note.data.content.json = null;
|
||||||
|
|
||||||
scrollToBottomHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
responseMessage.content = `<status title="${$i18n.t('Editing')}" done="false" />`;
|
scrollToBottomHandler();
|
||||||
|
|
||||||
|
responseMessage.content = `<status title="${$i18n.t('Editing')}" done="false" />`;
|
||||||
messages = messages;
|
messages = messages;
|
||||||
} else {
|
} else {
|
||||||
messageContent += deltaContent;
|
messageContent += deltaContent;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue