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
a9a68883
Commit
a9a68883
authored
4 years ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
replace all
parent
8b9811ae
No related branches found
No related tags found
1 merge request
!190
Find and replace
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wax-prosemirror-components/src/components/findAndReplace/ExandedFindAndReplaceComponent.js
+18
-3
18 additions, 3 deletions
...mponents/findAndReplace/ExandedFindAndReplaceComponent.js
with
18 additions
and
3 deletions
wax-prosemirror-components/src/components/findAndReplace/ExandedFindAndReplaceComponent.js
+
18
−
3
View file @
a9a68883
...
...
@@ -6,7 +6,7 @@ import React, {
useCallback
,
useEffect
,
}
from
'
react
'
;
import
{
each
,
debounce
}
from
'
lodash
'
;
import
{
each
,
eachRight
,
debounce
}
from
'
lodash
'
;
import
{
WaxContext
}
from
'
wax-prosemirror-core
'
;
import
styled
from
'
styled-components
'
;
import
{
grid
,
th
}
from
'
@pubsweet/ui-toolkit
'
;
...
...
@@ -138,6 +138,7 @@ const ExandedFindAndReplaceComponent = ({ close, nonExpandedText }) => {
const
searchRef
=
useRef
(
null
);
const
replaceRef
=
useRef
(
null
);
const
[
searchValue
,
setSearchValue
]
=
useState
(
nonExpandedText
);
const
[
replaceValue
,
setReplaceValue
]
=
useState
(
''
);
const
[
counterText
,
setCounterText
]
=
useState
(
'
0 of 0
'
);
const
findAndReplacePlugin
=
app
.
PmPlugins
.
get
(
'
findAndReplacePlugin
'
);
...
...
@@ -175,13 +176,27 @@ const ExandedFindAndReplaceComponent = ({ close, nonExpandedText }) => {
}
};
const
onChangeReplaceInput
=
()
=>
{};
const
onChangeReplaceInput
=
()
=>
{
setReplaceValue
(
replaceRef
.
current
.
value
);
};
const
replace
=
()
=>
{
// const { from, to } = results[0];
// dispatch(state.tr.insertText(replace, from, to));
};
const
replaceAll
=
()
=>
{};
const
replaceAll
=
()
=>
{
each
(
view
,
(
singleView
,
viewId
)
=>
{
const
results
=
helpers
.
findMatches
(
singleView
.
state
.
doc
,
searchValue
);
const
{
state
:
{
tr
},
}
=
singleView
;
eachRight
(
results
,
result
=>
{
tr
.
insertText
(
replaceValue
,
result
.
from
,
result
.
to
);
});
singleView
.
dispatch
(
tr
);
});
};
const
closeFind
=
()
=>
{
findAndReplacePlugin
.
props
.
setSearchText
(
''
);
...
...
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