@paged-media/plugin-sdk 0.2.32-canary.0 → 0.2.33-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +36 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -624,6 +624,42 @@ function createBundleHost(getEditor, manifest, options) {
|
|
|
624
624
|
);
|
|
625
625
|
return store.add(getEditor().registries.keybindings.register(c));
|
|
626
626
|
},
|
|
627
|
+
menu(c) {
|
|
628
|
+
assertNamespaced(c.command, "menu");
|
|
629
|
+
requireDeclared(
|
|
630
|
+
lists(declared?.commands, c.command),
|
|
631
|
+
"contribute.menu",
|
|
632
|
+
`contributes.commands[] must include "${c.command}" before a menu entry can invoke it`
|
|
633
|
+
);
|
|
634
|
+
const scope = c.scope ?? "document";
|
|
635
|
+
const editContext = typeof scope === "object" ? scope.editContext : null;
|
|
636
|
+
const menus = getEditor().registries.menus;
|
|
637
|
+
if (!menus) {
|
|
638
|
+
return { dispose() {
|
|
639
|
+
} };
|
|
640
|
+
}
|
|
641
|
+
return store.add(
|
|
642
|
+
menus.register({
|
|
643
|
+
path: c.path,
|
|
644
|
+
command: c.command,
|
|
645
|
+
order: c.order,
|
|
646
|
+
group: c.group,
|
|
647
|
+
// The scope becomes a `when` predicate, which is the host's
|
|
648
|
+
// existing vocabulary for "does this apply where you are
|
|
649
|
+
// standing" — the same field the Insert items and the Window
|
|
650
|
+
// menu already use. A context-scoped entry is simply one whose
|
|
651
|
+
// predicate asks what context is active.
|
|
652
|
+
when: (state2) => {
|
|
653
|
+
const st = state2;
|
|
654
|
+
if (!st?.document?.handle || (st.document.handle.pageCount ?? 0) === 0) {
|
|
655
|
+
return false;
|
|
656
|
+
}
|
|
657
|
+
if (editContext === null) return true;
|
|
658
|
+
return st.editContext?.type === editContext;
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
);
|
|
662
|
+
},
|
|
627
663
|
overlay(c) {
|
|
628
664
|
assertNamespaced(c.id, "overlay");
|
|
629
665
|
requireDeclared(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paged-media/plugin-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.33-canary.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@paged-media/plugin-api": "0.2.
|
|
14
|
+
"@paged-media/plugin-api": "0.2.33-canary.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": "^18.3.0"
|