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
68414e06
Commit
68414e06
authored
3 years ago
by
Giannis Kopanas
Committed by
chris
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix(core): fix portal views editor
parent
bfe9b806
No related branches found
No related tags found
1 merge request
!289
Pm node views portals
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
wax-prosemirror-core/src/Wax.js
+33
-32
33 additions, 32 deletions
wax-prosemirror-core/src/Wax.js
wax-prosemirror-core/src/WaxOptions.js
+3
-6
3 additions, 6 deletions
wax-prosemirror-core/src/WaxOptions.js
wax-prosemirror-core/src/WaxView.js
+22
-5
22 additions, 5 deletions
wax-prosemirror-core/src/WaxView.js
with
58 additions
and
43 deletions
wax-prosemirror-core/src/Wax.js
+
33
−
32
View file @
68414e06
...
@@ -22,7 +22,7 @@ const serializer = schema => {
...
@@ -22,7 +22,7 @@ const serializer = schema => {
let
schema
;
let
schema
;
const
createApplication
=
props
=>
{
const
createApplication
=
props
=>
{
const
application
=
Application
.
create
(
props
);
const
application
=
Application
.
create
(
props
);
schema
=
application
.
getSchema
();
//
schema = application.getSchema();
// application.bootServices();
// application.bootServices();
return
application
;
return
application
;
};
};
...
@@ -54,39 +54,40 @@ const Wax = props => {
...
@@ -54,39 +54,40 @@ const Wax = props => {
if
(
!
application
)
return
null
;
if
(
!
application
)
return
null
;
const
WaxOnchange
=
onChange
||
(
v
=>
true
);
const
WaxOnchange
=
onChange
||
(
v
=>
true
);
const
finalOnChange
=
debounce
(
const
finalOnChange
=
()
=>
{};
// eslint-disable-next-line no-shadow
// const finalOnChange = debounce(
value
=>
{
// // eslint-disable-next-line no-shadow
/* HACK alter toDOM of footnote, because of how PM treats inline nodes
// value => {
with content */
// /* HACK alter toDOM of footnote, because of how PM treats inline nodes
if
(
schema
.
nodes
.
footnote
)
{
// with content */
const
old
=
schema
.
nodes
.
footnote
.
spec
.
toDOM
;
// if (schema.nodes.footnote) {
schema
.
nodes
.
footnote
.
spec
.
toDOM
=
node
=>
{
// const old = schema.nodes.footnote.spec.toDOM;
// eslint-disable-next-line prefer-rest-params
// schema.nodes.footnote.spec.toDOM = node => {
old
.
apply
(
this
);
// // eslint-disable-next-line prefer-rest-params
return
[
'
footnote
'
,
node
.
attrs
,
0
];
// old.apply(this);
};
// return ['footnote', node.attrs, 0];
}
// };
// }
if
(
targetFormat
===
'
JSON
'
)
{
//
if (targetFormat === 'JSON') {
WaxOnchange
(
value
);
//
WaxOnchange(value);
}
else
{
//
} else {
const
serialize
=
serializer
(
schema
);
//
const serialize = serializer(schema);
WaxOnchange
(
serialize
(
value
));
//
WaxOnchange(serialize(value));
}
//
}
if
(
schema
.
nodes
.
footnote
)
{
//
if (schema.nodes.footnote) {
const
old
=
schema
.
nodes
.
footnote
.
spec
.
toDOM
;
//
const old = schema.nodes.footnote.spec.toDOM;
schema
.
nodes
.
footnote
.
spec
.
toDOM
=
node
=>
{
//
schema.nodes.footnote.spec.toDOM = node => {
// eslint-disable-next-line prefer-rest-params
//
// eslint-disable-next-line prefer-rest-params
old
.
apply
(
this
);
//
old.apply(this);
return
[
'
footnote
'
,
node
.
attrs
];
//
return ['footnote', node.attrs];
};
//
};
}
//
}
},
//
},
1000
,
//
1000,
{
maxWait
:
5000
},
//
{ maxWait: 5000 },
);
//
);
const
TrackChange
=
application
.
config
.
get
(
'
config.EnableTrackChangeService
'
);
const
TrackChange
=
application
.
config
.
get
(
'
config.EnableTrackChangeService
'
);
const
Layout
=
application
.
container
.
get
(
'
Layout
'
);
const
Layout
=
application
.
container
.
get
(
'
Layout
'
);
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-core/src/
use
WaxOptions.js
→
wax-prosemirror-core/src/WaxOptions.js
+
3
−
6
View file @
68414e06
...
@@ -15,9 +15,7 @@ const parser = schema => {
...
@@ -15,9 +15,7 @@ const parser = schema => {
};
};
};
};
export
default
({
placeholder
,
targetFormat
,
value
})
=>
{
export
default
({
placeholder
,
targetFormat
,
value
,
schema
,
plugins
})
=>
{
const
context
=
useContext
(
WaxContext
);
let
finalPlugins
=
[];
let
finalPlugins
=
[];
// eslint-disable-next-line no-shadow
// eslint-disable-next-line no-shadow
...
@@ -25,13 +23,12 @@ export default ({ placeholder, targetFormat, value }) => {
...
@@ -25,13 +23,12 @@ export default ({ placeholder, targetFormat, value }) => {
return
Placeholder
({
content
:
placeholder
});
return
Placeholder
({
content
:
placeholder
});
};
};
console
.
log
(
plugins
);
finalPlugins
=
defaultPlugins
.
concat
([
finalPlugins
=
defaultPlugins
.
concat
([
createPlaceholder
(
placeholder
),
createPlaceholder
(
placeholder
),
...
context
.
app
.
getP
lugins
()
,
...
p
lugins
,
]);
]);
const
schema
=
context
.
app
.
getSchema
();
const
WaxOptions
=
{
const
WaxOptions
=
{
schema
,
schema
,
plugins
:
finalPlugins
,
plugins
:
finalPlugins
,
...
...
This diff is collapsed.
Click to expand it.
wax-prosemirror-core/src/WaxView.js
+
22
−
5
View file @
68414e06
import
React
,
{
useRef
,
useContext
,
useCallback
,
useMemo
}
from
'
react
'
;
import
React
,
{
useRef
,
useContext
,
useCallback
,
useMemo
,
useEffect
,
}
from
'
react
'
;
import
applyDevTools
from
'
prosemirror-dev-tools
'
;
import
applyDevTools
from
'
prosemirror-dev-tools
'
;
import
{
EditorState
}
from
'
prosemirror-state
'
;
import
{
EditorState
}
from
'
prosemirror-state
'
;
...
@@ -10,7 +16,7 @@ import ComponentPlugin from './ComponentPlugin';
...
@@ -10,7 +16,7 @@ import ComponentPlugin from './ComponentPlugin';
import
{
WaxContext
}
from
'
./WaxContext
'
;
import
{
WaxContext
}
from
'
./WaxContext
'
;
import
{
PortalContext
}
from
'
./PortalContext
'
;
import
{
PortalContext
}
from
'
./PortalContext
'
;
import
transformPasted
from
'
./helpers/TransformPasted
'
;
import
transformPasted
from
'
./helpers/TransformPasted
'
;
import
use
WaxOptions
from
'
./
use
WaxOptions
'
;
import
WaxOptions
from
'
./WaxOptions
'
;
let
previousDoc
;
let
previousDoc
;
...
@@ -29,14 +35,17 @@ export default props => {
...
@@ -29,14 +35,17 @@ export default props => {
export
default
props
=>
{
export
default
props
=>
{
const
{
readonly
,
onBlur
,
debug
,
autoFocus
,
user
,
targetFormat
}
=
props
;
const
{
readonly
,
onBlur
,
debug
,
autoFocus
,
user
,
targetFormat
}
=
props
;
const
editorRef
=
useRef
();
const
editorRef
=
useRef
();
let
view
;
const
context
=
useContext
(
WaxContext
);
const
context
=
useContext
(
WaxContext
);
const
{
createPortal
}
=
useContext
(
PortalContext
);
const
{
createPortal
}
=
useContext
(
PortalContext
);
context
.
app
.
setContext
({
...
context
,
createPortal
});
context
.
app
.
setContext
({
...
context
,
createPortal
});
context
.
app
.
bootServices
();
const
schema
=
context
.
app
.
getSchema
();
const
options
=
useWaxOptions
(
props
);
if
(
!
view
)
{
context
.
app
.
bootServices
();
}
const
setEditorRef
=
useCallback
(
const
setEditorRef
=
useCallback
(
// eslint-disable-next-line consistent-return
// eslint-disable-next-line consistent-return
...
@@ -47,6 +56,14 @@ export default props => {
...
@@ -47,6 +56,14 @@ export default props => {
// clean up the unmount if you need to.
// clean up the unmount if you need to.
}
}
if
(
node
)
{
if
(
node
)
{
const
options
=
WaxOptions
({
...
props
,
schema
,
plugins
:
context
.
app
.
getPlugins
(),
});
console
.
log
(
options
);
// debugger;
view
=
new
EditorView
(
view
=
new
EditorView
(
{
mount
:
node
},
{
mount
:
node
},
{
{
...
...
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