@kerebron/editor 0.2.1 → 0.3.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.
Files changed (59) hide show
  1. package/assets/gapcursor.css +4 -11
  2. package/assets/index.css +1 -0
  3. package/assets/search.css +6 -0
  4. package/esm/CoreEditor.d.ts +11 -5
  5. package/esm/CoreEditor.d.ts.map +1 -1
  6. package/esm/CoreEditor.js +62 -61
  7. package/esm/DummyEditorView.d.ts +60 -0
  8. package/esm/DummyEditorView.d.ts.map +1 -0
  9. package/esm/DummyEditorView.js +277 -0
  10. package/esm/Extension.d.ts +9 -9
  11. package/esm/Extension.d.ts.map +1 -1
  12. package/esm/Extension.js +2 -2
  13. package/esm/ExtensionManager.d.ts +8 -7
  14. package/esm/ExtensionManager.d.ts.map +1 -1
  15. package/esm/ExtensionManager.js +58 -39
  16. package/esm/Mark.d.ts +8 -6
  17. package/esm/Mark.d.ts.map +1 -1
  18. package/esm/Mark.js +8 -2
  19. package/esm/Node.d.ts +14 -12
  20. package/esm/Node.d.ts.map +1 -1
  21. package/esm/Node.js +10 -4
  22. package/esm/commands/CommandManager.d.ts +5 -9
  23. package/esm/commands/CommandManager.d.ts.map +1 -1
  24. package/esm/commands/CommandManager.js +7 -6
  25. package/esm/commands/mod.d.ts +12 -6
  26. package/esm/commands/mod.d.ts.map +1 -1
  27. package/esm/commands/mod.js +0 -45
  28. package/esm/mod.d.ts +1 -0
  29. package/esm/mod.d.ts.map +1 -1
  30. package/esm/mod.js +1 -0
  31. package/esm/nodeToTreeString.d.ts.map +1 -1
  32. package/esm/nodeToTreeString.js +23 -21
  33. package/esm/plugins/input-rules/InputRulesPlugin.js +2 -2
  34. package/esm/plugins/keymap/keymap.d.ts +11 -0
  35. package/esm/plugins/keymap/keymap.d.ts.map +1 -0
  36. package/esm/plugins/keymap/keymap.js +125 -0
  37. package/esm/plugins/keymap/mod.d.ts +2 -0
  38. package/esm/plugins/keymap/mod.d.ts.map +1 -0
  39. package/esm/plugins/keymap/mod.js +1 -0
  40. package/esm/plugins/keymap/w3c-keyname.d.ts +4 -0
  41. package/esm/plugins/keymap/w3c-keyname.d.ts.map +1 -0
  42. package/esm/plugins/keymap/w3c-keyname.js +124 -0
  43. package/esm/search/mod.d.ts +3 -0
  44. package/esm/search/mod.d.ts.map +1 -0
  45. package/esm/search/mod.js +2 -0
  46. package/esm/search/query.d.ts +45 -0
  47. package/esm/search/query.d.ts.map +1 -0
  48. package/esm/search/query.js +390 -0
  49. package/esm/search/search.d.ts +32 -0
  50. package/esm/search/search.d.ts.map +1 -0
  51. package/esm/search/search.js +212 -0
  52. package/esm/types.d.ts +10 -5
  53. package/esm/types.d.ts.map +1 -1
  54. package/esm/utilities/createNodeFromContent.d.ts +4 -3
  55. package/esm/utilities/createNodeFromContent.d.ts.map +1 -1
  56. package/esm/utilities/createNodeFromContent.js +4 -5
  57. package/esm/utilities/getHtmlAttributes.d.ts +8 -3
  58. package/esm/utilities/getHtmlAttributes.d.ts.map +1 -1
  59. package/package.json +8 -3
@@ -1,8 +1,9 @@
1
1
  import { Fragment, Node as ProseMirrorNode, Schema } from 'prosemirror-model';
2
- import type { Content } from '../types.js';
2
+ import type { JSONContent } from '../types.js';
3
3
  export type CreateNodeFromContentOptions = {
4
4
  errorOnInvalidContent?: boolean;
5
5
  };
6
- export declare function createNodeFromObject(content: Content | ProseMirrorNode | Fragment, schema: Schema, options?: CreateNodeFromContentOptions): ProseMirrorNode | Fragment;
7
- export declare function createNodeFromContent(content: Content | ProseMirrorNode | Fragment, schema: Schema, options?: CreateNodeFromContentOptions): ProseMirrorNode | Fragment;
6
+ export declare function createNodeFromObject(content: JSONContent | ProseMirrorNode | Fragment, schema: Schema, options?: CreateNodeFromContentOptions): ProseMirrorNode;
7
+ export declare function createNodeFromArray(content: JSONContent[], schema: Schema): Fragment;
8
+ export declare function createNodeFromContent(content: JSONContent | ProseMirrorNode | Fragment, schema: Schema, options?: CreateNodeFromContentOptions): ProseMirrorNode | Fragment;
8
9
  //# sourceMappingURL=createNodeFromContent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createNodeFromContent.d.ts","sourceRoot":"","sources":["../../src/utilities/createNodeFromContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,4BAA4B,GAAG;IACzC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,QAAQ,EAC7C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,eAAe,GAAG,QAAQ,CAiC5B;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,GAAG,eAAe,GAAG,QAAQ,EAC7C,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,eAAe,GAAG,QAAQ,CAY5B"}
1
+ {"version":3,"file":"createNodeFromContent.d.ts","sourceRoot":"","sources":["../../src/utilities/createNodeFromContent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,KAAK,EAAW,WAAW,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,4BAA4B,GAAG;IACzC,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,WAAW,GAAG,eAAe,GAAG,QAAQ,EACjD,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,eAAe,CA0BjB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,WAAW,EAAE,EACtB,MAAM,EAAE,MAAM,GACb,QAAQ,CAIV;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,WAAW,GAAG,eAAe,GAAG,QAAQ,EACjD,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,4BAA4B,GACrC,eAAe,GAAG,QAAQ,CAY5B"}
@@ -1,10 +1,6 @@
1
1
  import { Fragment, Node as ProseMirrorNode } from 'prosemirror-model';
2
2
  export function createNodeFromObject(content, schema, options) {
3
3
  try {
4
- // if the JSON Content is an array of nodes, create a fragment for each node
5
- if (Array.isArray(content) && content.length > 0) {
6
- return Fragment.fromArray(content.map((item) => schema.nodeFromJSON(item)));
7
- }
8
4
  const node = schema.nodeFromJSON(content);
9
5
  if (options?.errorOnInvalidContent) {
10
6
  node.check();
@@ -21,13 +17,16 @@ export function createNodeFromObject(content, schema, options) {
21
17
  return schema.topNodeType.createAndFill(null, []);
22
18
  }
23
19
  }
20
+ export function createNodeFromArray(content, schema) {
21
+ return Fragment.fromArray(content.map((item) => schema.nodeFromJSON(item)));
22
+ }
24
23
  export function createNodeFromContent(content, schema, options) {
25
24
  if (content instanceof ProseMirrorNode || content instanceof Fragment) {
26
25
  return content;
27
26
  }
28
27
  const isJSONContent = typeof content === 'object' && content !== null;
29
28
  if (isJSONContent) {
30
- createNodeFromObject(content, schema, options);
29
+ return createNodeFromObject(content, schema, options);
31
30
  }
32
31
  return schema.topNodeType.createAndFill(null, []);
33
32
  }
@@ -1,4 +1,9 @@
1
- export declare function getHtmlAttributes(extension: any, node: any): {};
2
- export declare function setHtmlAttributes(extension: any, element: any): {};
3
- export declare function addAttributesToSchema(spec: any, extension: any): void;
1
+ import type { MarkSpec, Node as ProseMirrorNode, NodeSpec } from 'prosemirror-model';
2
+ import type { Mark } from '../Mark.js';
3
+ import type { Node } from '../Node.js';
4
+ type MarkOfNode = Mark | Node;
5
+ export declare function getHtmlAttributes(extension: MarkOfNode, node: ProseMirrorNode): Record<string, any>;
6
+ export declare function setHtmlAttributes(extension: MarkOfNode, element: HTMLElement): Record<string, any>;
7
+ export declare function addAttributesToSchema(spec: MarkSpec | NodeSpec, extension: MarkOfNode): void;
8
+ export {};
4
9
  //# sourceMappingURL=getHtmlAttributes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getHtmlAttributes.d.ts","sourceRoot":"","sources":["../../src/utilities/getHtmlAttributes.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,SAAS,KAAA,EAAE,IAAI,KAAA,MAkBhD;AAED,wBAAgB,iBAAiB,CAAC,SAAS,KAAA,EAAE,OAAO,KAAA,MAcnD;AAED,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,QAcpD"}
1
+ {"version":3,"file":"getHtmlAttributes.d.ts","sourceRoot":"","sources":["../../src/utilities/getHtmlAttributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,IAAI,IAAI,eAAe,EACvB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,CAAC;AAE9B,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,UAAU,EACrB,IAAI,EAAE,eAAe,uBAmBtB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,uBAc5E;AAED,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EACzB,SAAS,EAAE,UAAU,QAetB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/editor",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "license": "MIT",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -13,14 +13,19 @@
13
13
  "./plugins/input-rules": {
14
14
  "import": "./esm/plugins/input-rules/mod.js"
15
15
  },
16
+ "./plugins/keymap": {
17
+ "import": "./esm/plugins/keymap/mod.js"
18
+ },
19
+ "./search": {
20
+ "import": "./esm/search/mod.js"
21
+ },
16
22
  "./utilities": {
17
23
  "import": "./esm/utilities/mod.js"
18
24
  }
19
25
  },
20
26
  "scripts": {},
21
27
  "dependencies": {
22
- "prosemirror-keymap": "1.2.2",
23
- "prosemirror-model": "1.25.1",
28
+ "prosemirror-model": "1.25.2",
24
29
  "prosemirror-state": "1.4.3",
25
30
  "prosemirror-transform": "1.10.4",
26
31
  "prosemirror-view": "1.40.0"