Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wax-prosemirror
Manage
Activity
Members
Labels
Plan
Issues
34
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wax
wax-prosemirror
Commits
684fe329
Commit
684fe329
authored
11 months ago
by
victor mutai
Browse files
Options
Downloads
Patches
Plain Diff
feat: add list of prompts to popup
parent
3e8b6577
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!549
Allow book owner to add customised AI writing prompts
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
editors/demo/src/Editoria/config/config.js
+2
-0
2 additions, 0 deletions
editors/demo/src/Editoria/config/config.js
wax-prosemirror-services/src/AiService/components/AskAIOverlay.js
+36
-2
36 additions, 2 deletions
...emirror-services/src/AiService/components/AskAIOverlay.js
with
38 additions
and
2 deletions
editors/demo/src/Editoria/config/config.js
+
2
−
0
View file @
684fe329
...
@@ -180,6 +180,8 @@ export default {
...
@@ -180,6 +180,8 @@ export default {
AskAiContentService
:
{
AskAiContentService
:
{
AskAiContentTransformation
:
DummyPromise
,
AskAiContentTransformation
:
DummyPromise
,
AiOn
:
true
,
AiOn
:
true
,
customPromptsOn
:
true
,
freeTextPrompts
:
[],
},
},
services
:
[
services
:
[
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-services/src/AiService/components/AskAIOverlay.js
+
36
−
2
View file @
684fe329
...
@@ -96,14 +96,25 @@ const ResultText = styled.div`
...
@@ -96,14 +96,25 @@ const ResultText = styled.div`
const
SubmitButton
=
styled
.
button
`
const
SubmitButton
=
styled
.
button
`
background: none;
background: none;
border: none;
border: none;
cursor: pointer;
cursor:
${
props
=>
(
props
.
disabled
?
'
not-allowed
'
:
'
pointer
'
)}
;
outline: none;
outline: none;
padding: 0 8px; /* Adjust padding as needed */
padding: 0 8px; /* Adjust padding as needed */
`
;
`
;
const
PromptDiv
=
styled
.
div
`
background: white;
border: 0.5px #dcdcdc solid;
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.08);
display: inline-flex;
justify-content: space-between;
padding: 8px 12px;
width: 458px;
`
;
const
AskAIOverlay
=
({
setPosition
,
position
,
config
})
=>
{
const
AskAIOverlay
=
({
setPosition
,
position
,
config
})
=>
{
const
{
t
,
i18n
}
=
useTranslation
();
const
{
t
,
i18n
}
=
useTranslation
();
const
{
const
{
app
,
pmViews
:
{
main
},
pmViews
:
{
main
},
options
,
options
,
}
=
useContext
(
WaxContext
);
}
=
useContext
(
WaxContext
);
...
@@ -113,6 +124,9 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
...
@@ -113,6 +124,9 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
const
{
AskAiContentTransformation
}
=
config
;
const
{
AskAiContentTransformation
}
=
config
;
const
inputRef
=
useRef
(
null
);
const
inputRef
=
useRef
(
null
);
const
aiService
=
app
.
config
.
get
(
'
config.AskAiContentService
'
);
const
prompts
=
aiService
.
freeTextPrompts
;
useLayoutEffect
(()
=>
{
useLayoutEffect
(()
=>
{
const
WaxSurface
=
main
.
dom
.
getBoundingClientRect
();
const
WaxSurface
=
main
.
dom
.
getBoundingClientRect
();
const
{
selection
}
=
main
.
state
;
const
{
selection
}
=
main
.
state
;
...
@@ -198,10 +212,16 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
...
@@ -198,10 +212,16 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
}
}
};
};
const
handleSubmitPrompt
=
idx
=>
{
inputRef
.
current
.
value
=
prompts
[
idx
];
handleSubmit
();
};
return
options
?.
AiOn
?
(
return
options
?.
AiOn
?
(
<
Wrapper
id
=
"
ai-overlay
"
>
<
Wrapper
id
=
"
ai-overlay
"
>
<
AskAIForm
>
<
AskAIForm
>
<
AskAIFormInput
<
AskAIFormInput
disabled
=
{
!
aiService
.
customPromptsOn
}
id
=
"
askAiInput
"
id
=
"
askAiInput
"
onKeyPress
=
{
handleKeyDown
}
onKeyPress
=
{
handleKeyDown
}
placeholder
=
{
placeholder
=
{
...
@@ -212,10 +232,24 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
...
@@ -212,10 +232,24 @@ const AskAIOverlay = ({ setPosition, position, config }) => {
ref
=
{
inputRef
}
ref
=
{
inputRef
}
type
=
"
text
"
type
=
"
text
"
/>
/>
<
SubmitButton
onClick
=
{
handleSubmit
}
>
<
SubmitButton
disabled
=
{
!
aiService
.
customPromptsOn
}
onClick
=
{
handleSubmit
}
>
{
isLoading
?
<
icons
.
loaderIco
/>
:
<
icons
.
submitIco
/>
}
{
isLoading
?
<
icons
.
loaderIco
/>
:
<
icons
.
submitIco
/>
}
<
/SubmitButton
>
<
/SubmitButton
>
<
/AskAIForm
>
<
/AskAIForm
>
{
prompts
.
map
((
prompt
,
idx
)
=>
(
<
PromptDiv
key
=
{
prompt
}
>
<
ResultText
>
{
prompt
}
<
/ResultText
>
<
SubmitButton
disabled
=
{
isLoading
}
onClick
=
{()
=>
handleSubmitPrompt
(
idx
)}
>
<
icons
.
submitIco
/>
<
/SubmitButton
>
<
/PromptDiv
>
))}
{
isSubmitted
&&
(
{
isSubmitted
&&
(
<>
<>
<
ResultDiv
>
<
ResultDiv
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment