@kerebron/extension-dev-toolkit 0.4.28 → 0.4.30

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/esm/mod.js CHANGED
@@ -34,3 +34,4 @@ export class ExtensionDevToolkit extends Extension {
34
34
  return shortcuts;
35
35
  }
36
36
  }
37
+ //# sourceMappingURL=mod.js.map
package/esm/mod.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAAqC,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,MAAM,OAAO,mBAAoB,SAAQ,SAAS;IAKjB;IAJ/B,IAAI,GAAG,aAAa,CAAC;IAEb,OAAO,GAAG,KAAK,CAAC;IAExB,YAA+B,SAA2B,EAAE;QAC1D,KAAK,CAAC,MAAM,CAAC,CAAC;QADe,WAAM,GAAN,MAAM,CAAuB;IAE5D,CAAC;IAEQ,mBAAmB,CAAC,MAAkB;QAC7C,MAAM,QAAQ,GAAqB;YACjC,gBAAgB,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE;gBAC3B,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,cAAc,EAAE,CAAC;oBACjB,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;gBAC/B,CAAC;qBAAM,CAAC;oBACN,IAAI,MAAM,CAAC,IAAI,YAAY,UAAU,EAAE,CAAC;wBACtC,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;wBACvD,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;oBAC/B,CAAC;gBACH,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC;QACF,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEQ,oBAAoB;QAC3B,MAAM,SAAS,GAAqB;YAClC,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/extension-dev-toolkit",
3
- "version": "0.4.28",
3
+ "version": "0.4.30",
4
4
  "license": "MIT",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -9,8 +9,12 @@
9
9
  }
10
10
  },
11
11
  "scripts": {},
12
+ "files": [
13
+ "esm",
14
+ "src"
15
+ ],
12
16
  "dependencies": {
13
- "@kerebron/editor": "0.4.28",
17
+ "@kerebron/editor": "0.4.30",
14
18
  "prosemirror-dev-toolkit": "1.1.8",
15
19
  "prosemirror-view": "1.40.0"
16
20
  },
package/src/mod.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { applyDevTools, removeDevTools } from 'prosemirror-dev-toolkit';
2
+
3
+ import { CommandFactories, type CoreEditor, Extension } from '@kerebron/editor';
4
+ import { CommandShortcuts } from '@kerebron/editor/commands';
5
+ import { EditorView } from 'prosemirror-view';
6
+
7
+ export interface DevToolkitConfig {
8
+ }
9
+
10
+ export class ExtensionDevToolkit extends Extension {
11
+ name = 'dev_toolkit';
12
+
13
+ private visible = false;
14
+
15
+ constructor(protected override config: DevToolkitConfig = {}) {
16
+ super(config);
17
+ }
18
+
19
+ override getCommandFactories(editor: CoreEditor): Partial<CommandFactories> {
20
+ const commands: CommandFactories = {
21
+ toggleDevToolkit: () => () => {
22
+ if (this.visible) {
23
+ removeDevTools();
24
+ this.visible = !this.visible;
25
+ } else {
26
+ if (editor.view instanceof EditorView) {
27
+ applyDevTools(editor.view, { devToolsExpanded: true });
28
+ this.visible = !this.visible;
29
+ }
30
+ }
31
+ return true;
32
+ },
33
+ };
34
+ return commands;
35
+ }
36
+
37
+ override getKeyboardShortcuts(): Partial<CommandShortcuts> {
38
+ const shortcuts: CommandShortcuts = {
39
+ 'Ctrl-`': 'toggleDevToolkit',
40
+ };
41
+ return shortcuts;
42
+ }
43
+ }