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
61680f9e
Commit
61680f9e
authored
9 months ago
by
chris
Browse files
Options
Downloads
Patches
Plain Diff
fix useEffect
parent
9d68f328
No related branches found
No related tags found
1 merge request
!590
Build wax view
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wax-prosemirror-core/src/Wax.js
+5
-1
5 additions, 1 deletion
wax-prosemirror-core/src/Wax.js
wax-prosemirror-core/src/WaxView.js
+70
-80
70 additions, 80 deletions
wax-prosemirror-core/src/WaxView.js
with
75 additions
and
81 deletions
wax-prosemirror-core/src/Wax.js
+
5
−
1
View file @
61680f9e
...
...
@@ -58,7 +58,11 @@ const Wax = forwardRef((props, ref) => {
const
[
application
,
setApplication
]
=
useState
();
const
configHash
=
createConfigWithHash
(
config
);
// useEffect(() => () => application && application.resetApp(), []);
// useEffect(() => {
// const newApplication = createApplication(props);
// setApplication(newApplication);
// return () => newApplication.resetApp();
// }, []);
useEffect
(()
=>
{
console
.
log
(
'
updated application
'
,
configHash
);
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-core/src/WaxView.js
+
70
−
80
View file @
61680f9e
...
...
@@ -4,7 +4,6 @@ import React, {
useContext
,
useCallback
,
useMemo
,
useRef
,
useEffect
,
forwardRef
,
useImperativeHandle
,
...
...
@@ -55,55 +54,53 @@ const WaxView = forwardRef((props, ref) => {
context
.
app
.
setContext
({
...
context
,
createPortal
});
const
schema
=
context
.
app
.
getSchema
();
console
.
log
(
context
.
app
.
id
);
const
setEditorRef
=
useCallback
(
node
=>
{
//
if (node) {
console
.
log
(
'
load editor view
'
);
// if (!mounted) {
context
.
app
.
bootService
s
();
context
.
app
.
get
ShortCut
s
();
context
.
app
.
getRules
();
// }
const
options
=
WaxOptions
({
...
props
,
schema
,
plugins
:
context
.
app
.
getPlugins
(),
});
view
=
new
EditorView
(
{
mount
:
node
},
{
editable
:
()
=>
!
readonly
,
customValues
,
state
:
EditorState
.
create
(
op
tion
s
)
,
dis
patchTransaction
,
disallowedTools
:
[]
,
user
,
scroll
Margin
:
scrollMargin
||
200
,
scrollThreshold
:
scrollThreshold
||
200
,
attributes
:
{
spellcheck
:
browserSpellCheck
?
'
true
'
:
'
false
'
,
if
(
node
)
{
// if (!mounted) {
context
.
app
.
bootServices
();
context
.
app
.
getShortCut
s
();
context
.
app
.
get
Rule
s
();
// }
const
options
=
WaxOptions
({
...
props
,
schema
,
plugins
:
context
.
app
.
getPlugins
()
,
});
view
=
new
EditorView
(
{
mount
:
node
},
{
editable
:
()
=>
!
readonly
,
customValues
,
state
:
EditorState
.
create
(
options
)
,
dispatchTransac
tion
,
dis
allowedTools
:
[]
,
user
,
scrollMargin
:
scrollMargin
||
200
,
scroll
Threshold
:
scrollThreshold
||
200
,
attributes
:
{
spellcheck
:
browserSpellCheck
?
'
true
'
:
'
false
'
,
}
,
},
},
);
);
// setMounted(true);
// setMounted(true);
context
.
updateView
(
{
main
:
view
,
},
'
main
'
,
);
setTimeout
(()
=>
{
if
(
autoFocus
&&
view
)
{
view
.
state
.
tr
.
insertText
(
''
,
0
);
view
.
dispatch
(
view
.
state
.
tr
.
scrollIntoView
());
view
.
focus
();
}
},
500
);
//
}
context
.
updateView
(
{
main
:
view
,
},
'
main
'
,
);
setTimeout
(()
=>
{
if
(
autoFocus
&&
view
)
{
view
.
state
.
tr
.
insertText
(
''
,
0
);
view
.
dispatch
(
view
.
state
.
tr
.
scrollIntoView
());
view
.
focus
();
}
},
500
);
}
return
node
;
},
[
readonly
,
customValues
,
context
.
app
.
id
],
...
...
@@ -114,41 +111,34 @@ const WaxView = forwardRef((props, ref) => {
},
[]);
useEffect
(()
=>
{
// const currentConfigHash = context.app.config.get('config.hash');
// if (
// prevConfigHashRef.current &&
// prevConfigHashRef.current !== currentConfigHash
// ) {
// eslint-disable-next-line no-console
console
.
log
(
'
Creating new state from config ...
'
);
// const parse = parser(schema);
let
finalPlugins
=
[];
if
(
context
.
app
.
config
.
get
(
'
config.PmPlugins
'
).
length
===
0
)
{
console
.
log
(
'
reconfigure>
'
);
let
finalPlugins
=
[];
const
createPlaceholder
=
()
=>
{
return
Placeholder
({
content
:
placeholder
});
};
const
createPlaceholder
=
()
=>
{
return
Placeholder
({
content
:
placeholder
});
};
finalPlugins
=
defaultPlugins
.
concat
([
createPlaceholder
(
placeholder
),
...
context
.
app
.
getPlugins
(),
]);
finalPlugins
=
defaultPlugins
.
concat
([
createPlaceholder
(
placeholder
),
...
context
.
app
.
getPlugins
(),
]);
const
reconfigureOptions
=
{
// doc: parse(value),
schema
,
plugins
:
finalPlugins
,
};
const
reconfigureOptions
=
{
// doc: parse(value),
schema
,
plugins
:
finalPlugins
,
};
context
.
pmViews
.
main
.
updateState
(
EditorState
.
create
(
reconfigureOptions
));
context
.
pmViews
.
main
.
updateState
(
EditorState
.
create
(
reconfigureOptions
));
if
(
context
.
pmViews
.
main
.
dispatch
)
{
context
.
pmViews
.
main
.
dispatch
(
context
.
pmViews
?.
main
.
state
.
tr
.
setMeta
(
'
addToHistory
'
,
false
),
);
if
(
context
.
pmViews
.
main
.
dispatch
)
{
context
.
pmViews
.
main
.
dispatch
(
context
.
pmViews
?.
main
.
state
.
tr
.
setMeta
(
'
addToHistory
'
,
false
),
);
}
}
// }
// prevConfigHashRef.current = currentConfigHash;
return
true
;
},
[
context
.
app
.
id
]);
...
...
@@ -176,15 +166,15 @@ const WaxView = forwardRef((props, ref) => {
main don't keep updating the view ,as this is
the central point of each transaction
*/
//
context.setTransaction(transaction);
context
.
setTransaction
(
transaction
);
if
(
!
transaction
.
getMeta
(
'
outsideView
'
))
{
//
context.updateView(
//
{
//
main: view,
//
},
//
'main',
//
);
context
.
updateView
(
{
main
:
view
,
},
'
main
'
,
);
}
const
docContent
=
...
...
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