Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
9beefd7d
Unverified
Commit
9beefd7d
authored
Mar 09, 2024
by
zxhlyh
Committed by
GitHub
Mar 09, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: auto prompt (#2768)
parent
88145efa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
simple-prompt-input.tsx
...s/app/configuration/config-prompt/simple-prompt-input.tsx
+5
-0
index.tsx
web/app/components/base/prompt-editor/index.tsx
+2
-0
update-block.tsx
...pp/components/base/prompt-editor/plugins/update-block.tsx
+21
-0
No files found.
web/app/components/app/configuration/config-prompt/simple-prompt-input.tsx
View file @
9beefd7d
...
...
@@ -26,6 +26,7 @@ import { ArrowNarrowRight } from '@/app/components/base/icons/src/vender/line/ar
import
{
useEventEmitterContextContext
}
from
'@/context/event-emitter'
import
{
ADD_EXTERNAL_DATA_TOOL
}
from
'@/app/components/app/configuration/config-var'
import
{
INSERT_VARIABLE_VALUE_BLOCK_COMMAND
}
from
'@/app/components/base/prompt-editor/plugins/variable-block'
import
{
PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER
}
from
'@/app/components/base/prompt-editor/plugins/update-block'
export
type
ISimplePromptInput
=
{
mode
:
AppType
...
...
@@ -125,6 +126,10 @@ const Prompt: FC<ISimplePromptInput> = ({
if
(
mode
===
AppType
.
chat
)
setIntroduction
(
res
.
opening_statement
)
showAutomaticFalse
()
eventEmitter
?.
emit
({
type
:
PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER
,
payload
:
res
.
prompt
,
}
as
any
)
}
const
minHeight
=
228
const
[
editorHeight
,
setEditorHeight
]
=
useState
(
minHeight
)
...
...
web/app/components/base/prompt-editor/index.tsx
View file @
9beefd7d
...
...
@@ -32,6 +32,7 @@ import VariableValueBlock from './plugins/variable-value-block'
import
{
VariableValueBlockNode
}
from
'./plugins/variable-value-block/node'
import
{
CustomTextNode
}
from
'./plugins/custom-text/node'
import
OnBlurBlock
from
'./plugins/on-blur-block'
import
UpdateBlock
from
'./plugins/update-block'
import
{
textToEditorState
}
from
'./utils'
import
type
{
Dataset
}
from
'./plugins/context-block'
import
type
{
RoleName
}
from
'./plugins/history-block'
...
...
@@ -222,6 +223,7 @@ const PromptEditor: FC<PromptEditorProps> = ({
<
VariableValueBlock
/>
<
OnChangePlugin
onChange=
{
handleEditorChange
}
/>
<
OnBlurBlock
onBlur=
{
onBlur
}
/>
<
UpdateBlock
/>
{
/* <TreeView /> */
}
</
div
>
</
LexicalComposer
>
...
...
web/app/components/base/prompt-editor/plugins/update-block.tsx
0 → 100644
View file @
9beefd7d
import
{
useLexicalComposerContext
}
from
'@lexical/react/LexicalComposerContext'
import
{
textToEditorState
}
from
'../utils'
import
{
useEventEmitterContextContext
}
from
'@/context/event-emitter'
export
const
PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER
=
'PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER'
const
UpdateBlock
=
()
=>
{
const
{
eventEmitter
}
=
useEventEmitterContextContext
()
const
[
editor
]
=
useLexicalComposerContext
()
eventEmitter
?.
useSubscription
((
v
:
any
)
=>
{
if
(
v
.
type
===
PROMPT_EDITOR_UPDATE_VALUE_BY_EVENT_EMITTER
)
{
const
editorState
=
editor
.
parseEditorState
(
textToEditorState
(
v
.
payload
))
editor
.
setEditorState
(
editorState
)
}
})
return
null
}
export
default
UpdateBlock
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment