Page Menu
Home
Musing Studio
Search
Configure Global Search
Log In
Files
F12142942
menu.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
843 B
Subscribers
None
menu.js
View Options
import
{
MenuItem
}
from
"prosemirror-menu"
;
import
{
buildMenuItems
}
from
"prosemirror-example-setup"
;
import
{
writeFreelySchema
}
from
"./schema"
;
function
canInsert
(
state
,
nodeType
,
attrs
)
{
let
$from
=
state
.
selection
.
$from
;
for
(
let
d
=
$from
.
depth
;
d
>=
0
;
d
--
)
{
let
index
=
$from
.
index
(
d
);
if
(
$from
.
node
(
d
).
canReplaceWith
(
index
,
index
,
nodeType
,
attrs
))
return
true
;
}
return
false
;
}
const
ReadMoreItem
=
new
MenuItem
({
label
:
"Read more"
,
select
:
(
state
)
=>
canInsert
(
state
,
writeFreelySchema
.
nodes
.
readmore
),
run
(
state
,
dispatch
)
{
dispatch
(
state
.
tr
.
replaceSelectionWith
(
writeFreelySchema
.
nodes
.
readmore
.
create
())
);
},
});
export
const
getMenu
=
()
=>
{
const
menuContent
=
[
...
buildMenuItems
(
writeFreelySchema
).
fullMenu
,
[
ReadMoreItem
],
];
return
menuContent
;
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Oct 10, 3:23 AM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3440316
Attached To
rWF WriteFreely
Event Timeline
Log In to Comment