@kerebron/extension-codemirror 0.3.0 → 0.3.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"CoreEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/src/CoreEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAc3C,qBAAa,UAAW,SAAQ,WAAW;IACzC,SAAgB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAG7C;IACF,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAiB;IAChC,IAAI,EAAG,UAAU,GAAG,eAAe,CAAC;IACpC,KAAK,EAAG,WAAW,CAAC;gBAEf,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM;IA4BhD,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI9D,IAAW,MAAM,qBAEhB;IAEM,KAAK,IAAI,eAAe;IAIxB,GAAG,IAAI,eAAe;IAI7B,OAAO,CAAC,UAAU;IAqBX,mBAAmB,CAAC,WAAW,EAAE,WAAW;IAcnD,OAAO,CAAC,YAAY;IAcb,aAAa;IASb,WAAW,CAAC,OAAO,EAAE,GAAG;IAuBxB,WAAW;IAIL,YAAY,CAAC,S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WAAW,EAAE,WAAW;IAcnD,OAAO,CAAC,YAAY;IAcb,aAAa;IASb,WAAW,CAAC,OAAO,EAAE,GAAG;IAyBxB,WAAW;IAIL,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IA0BnD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAY1D,OAAO,IAAI,WAAW;IAItB,KAAK,CAAC,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GAAG,UAAU;IAOvD,KAAK,CAAC,GAAG,CAAC,EAAE,eAAe;CAMnC"}
@@ -128,7 +128,9 @@ export class CoreEditor extends EventTarget {
128
128
  this.setDocument(content);
129
129
  }
130
130
  setDocument(content) {
131
- let doc = createNodeFromObject(content, this.schema);
131
+ let doc = createNodeFromObject(content, this.schema, {
132
+ errorOnInvalidContent: true,
133
+ });
132
134
  doc = ensureDocSchema(doc, this.schema);
133
135
  this.state = EditorState.create({
134
136
  doc,
@@ -1 +1 @@
1
- {"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../../src/editor/src/Extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,eAAe;IAE9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAEnB,QAAQ,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,O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AAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7C,KAAK,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED,8BAAsB,SAAS;IAIV,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC;IAH7D,QAAQ,CAAC,IAAI,eAAe;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEO,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM;IAGlE,aAAa,IAAI,SAAS,EAAE;IAI5B,qBAAqB,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE;IAInE,mBAAmB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIlE,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAInE,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAI5E,SAAS,CAAC,IAAI,EAAE,UAAU;CAE3B"}
@@ -25,7 +25,7 @@ export declare class ExtensionManager {
25
25
  converters: Record<string, Converter>;
26
26
  private debug;
27
27
  constructor(extensions: AnyExtensionOrReq[], editor: CoreEditor);
28
- getExtension(name: string): Extension | undefined;
28
+ getExtension<T extends Extension>(name: string): T | undefined;
29
29
  private getPlugins;
30
30
  private setupExtensions;
31
31
  getSchemaByResolvedExtensions(editor: CoreEditor): Schema;
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionManager.d.ts","sourceRoot":"","sources":["../../../src/editor/src/ExtensionManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,m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,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAY9D,OAAO,CAAC,UAAU;IAoJlB,OAAO,CAAC,eAAe;IAoEvB,6BAA6B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;CAuC1D"}
@@ -1,4 +1,10 @@
1
- import { Node } from 'prosemirror-model';
2
- export declare function nodeToTreeString(node: Node | Node[] | readonly Node[], level?: number, currentPos?: number): string;
1
+ import type { Node } from 'prosemirror-model';
2
+ import { SmartOutput } from './utilities/SmartOutput.js';
3
+ export interface NodeAndPos {
4
+ node: Node;
5
+ pos: number;
6
+ }
7
+ export declare function nodeToTreeStringOutput(output: SmartOutput<NodeAndPos>, node: Node | Node[] | readonly Node[], level?: number, currentPos?: number): SmartOutput<NodeAndPos> | undefined;
8
+ export declare function nodeToTreeString(node: Node | Node[] | readonly Node[]): string;
3
9
  export declare function debugNode(node: Node | Node[]): void;
4
10
  //# sourceMappingURL=nodeToTreeString.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAYzC,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,UA4Df;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
1
+ {"version":3,"file":"nodeToTreeString.d.ts","sourceRoot":"","sources":["../../../src/editor/src/nodeToTreeString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAYzD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,WAAW,CAAC,UAAU,CAAC,EAC/B,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,EACrC,KAAK,SAAI,EACT,UAAU,SAAI,uCAmEf;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,SAAS,IAAI,EAAE,UAIrE;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,QAE5C"}
@@ -1,3 +1,4 @@
1
+ import { SmartOutput } from './utilities/SmartOutput.js';
1
2
  function trimText(str, maxLen = 20) {
2
3
  str = str.replaceAll('\n', '\\n');
3
4
  if (str.length <= maxLen) {
@@ -5,19 +6,19 @@ function trimText(str, maxLen = 20) {
5
6
  }
6
7
  return str.slice(0, maxLen) + '...';
7
8
  }
8
- export function nodeToTreeString(node, level = 0, currentPos = 0) {
9
+ export function nodeToTreeStringOutput(output, node, level = 0, currentPos = 0) {
9
10
  let delim = '';
10
11
  for (let i = 0; i < level; i++) {
11
12
  delim += ' ';
12
13
  }
13
- let output = '';
14
14
  if (Array.isArray(node)) {
15
15
  for (const child of node) {
16
- output += delim +
17
- nodeToTreeString(child, level + 1, currentPos).replace(/\s+$/gm, '') +
18
- '\n';
16
+ output.log(delim, { node: child, pos: currentPos });
17
+ nodeToTreeStringOutput(output, child, level + 1, currentPos);
18
+ // .replace(/\s+$/gm, '') +
19
+ // '\n'
19
20
  }
20
- return output;
21
+ return;
21
22
  }
22
23
  // https://prosemirror.net/docs/guide/#doc.indexing
23
24
  let line = '';
@@ -33,7 +34,7 @@ export function nodeToTreeString(node, level = 0, currentPos = 0) {
33
34
  if (node.content) {
34
35
  line += `fragment.size: ${node.content.size}, `;
35
36
  }
36
- output += (delim + line) + '\n';
37
+ output.log((delim + line) + '\n', { node, pos: currentPos });
37
38
  let marksLine = '';
38
39
  if (node.marks) {
39
40
  for (const mark of node.marks) {
@@ -41,18 +42,33 @@ export function nodeToTreeString(node, level = 0, currentPos = 0) {
41
42
  }
42
43
  }
43
44
  if (marksLine) {
44
- output += (delim + ' ' + marksLine) + '\n';
45
+ output.log((delim + ' ' + marksLine) + '\n', {
46
+ node,
47
+ pos: currentPos,
48
+ });
45
49
  }
46
50
  if (node.text) {
47
- output += (delim + ' "' + trimText(node.text) + '"') + '\n';
51
+ output.log((delim + ' "' + trimText(node.text) + '"') + '\n', {
52
+ node,
53
+ pos: currentPos,
54
+ });
48
55
  }
49
56
  }
50
57
  node.forEach((child, offset) => {
51
- output +=
52
- nodeToTreeString(child, level + 1, currentPos + offset + 1).replace(/\s+$/gm, '') + '\n'; // + (node.isLeaf ? 1 : 2)
58
+ // output +=
59
+ nodeToTreeStringOutput(output, child, level + 1, currentPos + offset + 1);
60
+ // .replace(
61
+ // /\s+$/gm,
62
+ // '',
63
+ // ) + '\n'; // + (node.isLeaf ? 1 : 2)
53
64
  });
54
65
  return output;
55
66
  }
67
+ export function nodeToTreeString(node) {
68
+ const output = new SmartOutput();
69
+ nodeToTreeStringOutput(output, node);
70
+ return output.toString();
71
+ }
56
72
  export function debugNode(node) {
57
73
  console.debug(nodeToTreeString(node));
58
74
  }
@@ -8,7 +8,7 @@ export type AnyExtensionOrReq = AnyExtension | {
8
8
  };
9
9
  export type Content = JSONContent | JSONContent[] | null;
10
10
  export interface EditorOptions {
11
- element: Element;
11
+ element: HTMLElement;
12
12
  content: Content;
13
13
  parseOptions: ParseOptions;
14
14
  extensions: AnyExtensionOrReq[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/editor/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,EAAE,M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AC,CAAC,IAAI;IACzB,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,CAAC,CAAC;IACtC,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,CAAC,CAAC;CACtC,CAAC"}
@@ -0,0 +1,39 @@
1
+ export interface OutputMeta<K> {
2
+ rowPos: number;
3
+ colPos: number;
4
+ item: K;
5
+ }
6
+ interface Mapping {
7
+ sourceNo: number;
8
+ sourceRowPos: number;
9
+ sourceColPos: number;
10
+ }
11
+ export interface SourceMap {
12
+ 'version': 3;
13
+ 'file': string;
14
+ 'sourceRoot': string;
15
+ 'sources': Array<string>;
16
+ 'sourcesContent': Array<string>;
17
+ 'names': Array<string>;
18
+ 'mappings': string;
19
+ }
20
+ export declare class SmartOutput<K> {
21
+ private _rowPos;
22
+ private _colPos;
23
+ private chunks;
24
+ private metas;
25
+ log(text: string, item: K): void;
26
+ get chunkPos(): number;
27
+ rollback(pos: number): void;
28
+ get rowPos(): number;
29
+ get colPos(): number;
30
+ endsWith(text: string): boolean;
31
+ toString(): string;
32
+ getSourceMap(mapper: (item: K, rowPos: number, colPos: number) => Mapping | void): SourceMap;
33
+ }
34
+ /** @param {string} string */
35
+ export declare function decode(string: any): number[];
36
+ /** @param {number | number[]} value */
37
+ export declare function encode(value: any): string;
38
+ export {};
39
+ //# sourceMappingURL=SmartOutput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SmartOutput.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/SmartOutput.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,CAAC,CAAC;CACT;AAED,UAAU,OAAO;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,CAAC,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,gBAAgB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW,CAAC,CAAC;IACxB,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,OAAO,CAAK;IAEpB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,KAAK,CAA4B;IAEzC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAiBzB,IAAI,QAAQ,WAEX;IAED,QAAQ,CAAC,GAAG,EAAE,MAAM;IAKpB,IAAI,MAAM,WAET;IAED,IAAI,MAAM,WAET;IAED,QAAQ,CAAC,IAAI,EAAE,MAAM;IAIrB,QAAQ;IAIR,YAAY,CACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAClE,SAAS;CAuDb;AA0DD,6BAA6B;AAC7B,wBAAgB,MAAM,CAAC,MAAM,KAAA,YAqC5B;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CAAC,KAAK,KAAA,UAW3B"}
@@ -0,0 +1,213 @@
1
+ export class SmartOutput {
2
+ constructor() {
3
+ Object.defineProperty(this, "_rowPos", {
4
+ enumerable: true,
5
+ configurable: true,
6
+ writable: true,
7
+ value: 0
8
+ });
9
+ Object.defineProperty(this, "_colPos", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: 0
14
+ });
15
+ Object.defineProperty(this, "chunks", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: []
20
+ });
21
+ Object.defineProperty(this, "metas", {
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true,
25
+ value: []
26
+ });
27
+ }
28
+ log(text, item) {
29
+ this.chunks.push(text);
30
+ this.metas.push({
31
+ colPos: this._colPos,
32
+ rowPos: this._rowPos,
33
+ item,
34
+ });
35
+ const lines = text.split('\n');
36
+ if (lines.length === 1) {
37
+ this._colPos += lines[lines.length - 1].length;
38
+ }
39
+ else {
40
+ this._rowPos += lines.length - 1;
41
+ this._colPos = lines[lines.length - 1].length;
42
+ }
43
+ }
44
+ get chunkPos() {
45
+ return this.chunks.length;
46
+ }
47
+ rollback(pos) {
48
+ this.chunks.splice(pos);
49
+ this.metas.splice(pos);
50
+ }
51
+ get rowPos() {
52
+ return this._rowPos;
53
+ }
54
+ get colPos() {
55
+ return this._colPos;
56
+ }
57
+ endsWith(text) {
58
+ return this.chunks.join('').endsWith(text);
59
+ }
60
+ toString() {
61
+ return this.chunks.join('');
62
+ }
63
+ getSourceMap(mapper) {
64
+ const mappingRows = [];
65
+ let lastRow = -1;
66
+ let lastCol = -1;
67
+ for (const meta of this.metas) {
68
+ while (meta.rowPos >= mappingRows.length) {
69
+ mappingRows.push([]);
70
+ }
71
+ if (lastRow != meta.rowPos || lastCol != meta.colPos) {
72
+ const currentRow = mappingRows[meta.rowPos];
73
+ const mapping = mapper(meta.item, meta.rowPos, meta.colPos);
74
+ if (mapping) {
75
+ currentRow.push([
76
+ meta.colPos,
77
+ mapping.sourceNo,
78
+ mapping.sourceRowPos,
79
+ mapping.sourceColPos,
80
+ ]);
81
+ }
82
+ }
83
+ lastRow = meta.rowPos;
84
+ lastCol = meta.colPos;
85
+ }
86
+ const mappings = mappingRows
87
+ .map((row) => row.map((group) => encode(group))
88
+ .join(','))
89
+ .join(';');
90
+ mappingRows.forEach((row, rowNo) => {
91
+ // console.log('g', rowNo, row);
92
+ row.forEach((group) => {
93
+ const enc = encode(group);
94
+ // console.log('g', rowNo, group, enc, decode(enc));
95
+ });
96
+ });
97
+ return {
98
+ version: 3,
99
+ file: '',
100
+ sourceRoot: '',
101
+ sources: [],
102
+ sourcesContent: [],
103
+ names: [],
104
+ mappings,
105
+ };
106
+ }
107
+ }
108
+ const BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
109
+ function toVLQ(value) {
110
+ const vlq = [];
111
+ const isNegative = value < 0;
112
+ value = Math.abs(value);
113
+ if (value === 0) {
114
+ vlq.push(0);
115
+ return vlq;
116
+ }
117
+ while (value > 0) {
118
+ let digit = value & 0x1F;
119
+ value >>= 5;
120
+ if (value > 0) {
121
+ digit |= 0x20;
122
+ }
123
+ vlq.push(digit);
124
+ if (vlq.length === 1) {
125
+ digit = isNegative ? (digit | 0x1) : (digit & ~0x1);
126
+ vlq[0] = digit;
127
+ }
128
+ }
129
+ return vlq;
130
+ }
131
+ function encodeVLQ(input) {
132
+ const numbers = Array.isArray(input) ? input : [input];
133
+ let result = '';
134
+ for (const num of numbers) {
135
+ const vlq = toVLQ(num);
136
+ for (const digit of vlq) {
137
+ result += BASE64_CHARS[digit];
138
+ }
139
+ }
140
+ return result;
141
+ }
142
+ /** @type {Record<string, number>} */
143
+ let char_to_integer = {};
144
+ /** @type {Record<number, string>} */
145
+ let integer_to_char = {};
146
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
147
+ .split('')
148
+ .forEach(function (char, i) {
149
+ char_to_integer[char] = i;
150
+ integer_to_char[i] = char;
151
+ });
152
+ /** @param {string} string */
153
+ export function decode(string) {
154
+ /** @type {number[]} */
155
+ let result = [];
156
+ let shift = 0;
157
+ let value = 0;
158
+ for (let i = 0; i < string.length; i += 1) {
159
+ let integer = char_to_integer[string[i]];
160
+ if (integer === undefined) {
161
+ throw new Error('Invalid character (' + string[i] + ')');
162
+ }
163
+ const has_continuation_bit = integer & 32;
164
+ integer &= 31;
165
+ value += integer << shift;
166
+ if (has_continuation_bit) {
167
+ shift += 5;
168
+ }
169
+ else {
170
+ const should_negate = value & 1;
171
+ value >>>= 1;
172
+ if (should_negate) {
173
+ result.push(value === 0 ? -0x80000000 : -value);
174
+ }
175
+ else {
176
+ result.push(value);
177
+ }
178
+ // reset
179
+ value = shift = 0;
180
+ }
181
+ }
182
+ return result;
183
+ }
184
+ /** @param {number | number[]} value */
185
+ export function encode(value) {
186
+ if (typeof value === 'number') {
187
+ return encode_integer(value);
188
+ }
189
+ let result = '';
190
+ for (let i = 0; i < value.length; i += 1) {
191
+ result += encode_integer(value[i]);
192
+ }
193
+ return result;
194
+ }
195
+ /** @param {number} num */
196
+ function encode_integer(num) {
197
+ let result = '';
198
+ if (num < 0) {
199
+ num = (-num << 1) | 1;
200
+ }
201
+ else {
202
+ num <<= 1;
203
+ }
204
+ do {
205
+ let clamped = num & 31;
206
+ num >>>= 5;
207
+ if (num > 0) {
208
+ clamped |= 32;
209
+ }
210
+ result += integer_to_char[clamped];
211
+ } while (num > 0);
212
+ return result;
213
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './getHtmlAttributes.js';
2
2
  export * from './createNodeFromContent.js';
3
+ export * from './SmartOutput.js';
3
4
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/mod.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/editor/src/utilities/mod.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,kBAAkB,CAAC"}
@@ -1,2 +1,3 @@
1
1
  export * from './getHtmlAttributes.js';
2
2
  export * from './createNodeFromContent.js';
3
+ export * from './SmartOutput.js';
@@ -1 +1 @@
1
- {"version":3,"file":"NodeCodeMirror.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/NodeCodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAEtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,6CAA6C,CAAC;AAOrD,eAAO,MAAM,kBAAkB,gBAAoC,CAAC;AAyCpE,qBAAa,cAAe,SAAQ,IAAI;IAC7B,IAAI,SAAgB;IAGpB,aAAa,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAgDnB,WAAW,IAAI,QAAQ;IA0CvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAQ1C,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAUnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAUjD,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE;CA8B7D"}
1
+ {"version":3,"file":"NodeCodeMirror.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/NodeCodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAC;AAC9E,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpE,OAAO,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC3E,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EAEtB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,6CAA6C,CAAC;AAOrD,eAAO,MAAM,kBAAkB,gBAAoC,CAAC;AAyCpE,qBAAa,cAAe,SAAQ,IAAI;IAC7B,IAAI,SAAgB;IAGpB,aAAa,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAiDnB,WAAW,IAAI,QAAQ;IA0CvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAQ1C,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAUnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAUjD,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE;CA8B7D"}
@@ -66,9 +66,10 @@ export class NodeCodeMirror extends Node {
66
66
  }
67
67
  }
68
68
  }
69
- return retVal.join('');
69
+ return new TextEncoder().encode(retVal.join(''));
70
70
  },
71
71
  toDoc: async (buffer) => {
72
+ const code = new TextDecoder().decode(buffer);
72
73
  const content = {
73
74
  'type': 'doc_code',
74
75
  'content': [
@@ -160,7 +161,7 @@ export class NodeCodeMirror extends Node {
160
161
  key: codeMirrorBlockKey,
161
162
  props: {
162
163
  nodeViews: {
163
- [this.name]: codeMirrorBlockNodeView(settings),
164
+ [this.name]: codeMirrorBlockNodeView(settings, editor),
164
165
  },
165
166
  },
166
167
  });
@@ -1,6 +1,7 @@
1
1
  import { Node } from 'prosemirror-model';
2
2
  import { EditorView as PMEditorView, NodeView } from 'prosemirror-view';
3
3
  import { CodeBlockSettings } from './types.js';
4
+ import { CoreEditor } from '../../editor/src/mod.js';
4
5
  export declare const themeCallbacks: Array<(theme: string) => void>;
5
- export declare const codeMirrorBlockNodeView: (settings: CodeBlockSettings) => (pmNode: Node, view: PMEditorView, getPos: (() => number) | boolean) => NodeView;
6
+ export declare const codeMirrorBlockNodeView: (settings: CodeBlockSettings, editor: CoreEditor) => (pmNode: Node, view: PMEditorView, getPos: (() => number) | boolean) => NodeView;
6
7
  //# sourceMappingURL=codeMirrorBlockNodeView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codeMirrorBlockNodeView.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/codeMirrorBlockNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAEL,UAAU,IAAI,YAAY,EAC1B,QAAQ,EACT,MAAM,kBAAkB,CAAC;AA0C1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAO/C,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAM,CAAC;AA0QjE,eAAO,MAAM,uBAAuB,EAAE,CACpC,QAAQ,EAAE,iBAAiB,KACxB,CACH,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,OAAO,KAC7B,QAQJ,CAAC"}
1
+ {"version":3,"file":"codeMirrorBlockNodeView.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/codeMirrorBlockNodeView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAEL,UAAU,IAAI,YAAY,EAC1B,QAAQ,EACT,MAAM,kBAAkB,CAAC;AA0C1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAM/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAM,CAAC;AAkRjE,eAAO,MAAM,uBAAuB,EAAE,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,UAAU,KACf,CACH,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,CAAC,MAAM,MAAM,CAAC,GAAG,OAAO,KAC7B,QAQJ,CAAC"}
@@ -10,7 +10,7 @@ import { YSyncConfig, ySyncFacet } from './y-sync.js';
10
10
  import { yRemoteSelections, yRemoteSelectionsTheme, } from './y-remote-selections.js';
11
11
  export const themeCallbacks = [];
12
12
  class CodeMirrorBlockNodeView {
13
- constructor(node, view, getPos, settings) {
13
+ constructor(node, view, getPos, settings, editor) {
14
14
  Object.defineProperty(this, "node", {
15
15
  enumerable: true,
16
16
  configurable: true,
@@ -35,6 +35,12 @@ class CodeMirrorBlockNodeView {
35
35
  writable: true,
36
36
  value: settings
37
37
  });
38
+ Object.defineProperty(this, "editor", {
39
+ enumerable: true,
40
+ configurable: true,
41
+ writable: true,
42
+ value: editor
43
+ });
38
44
  Object.defineProperty(this, "dom", {
39
45
  enumerable: true,
40
46
  configurable: true,
@@ -172,6 +178,13 @@ class CodeMirrorBlockNodeView {
172
178
  ...closeBracketsKeymap,
173
179
  ...completionKeymap,
174
180
  indentWithTab,
181
+ {
182
+ key: 'Ctrl-`',
183
+ run: () => {
184
+ editor.chain().toggleDevToolkit().run();
185
+ return true;
186
+ },
187
+ },
175
188
  ]),
176
189
  ...(settings.theme ? settings.theme : []),
177
190
  themeConfig.of([]),
@@ -260,8 +273,8 @@ class CodeMirrorBlockNodeView {
260
273
  themeCallbacks.splice(themeCallbacks.indexOf(this.updateTheme), 1);
261
274
  }
262
275
  }
263
- export const codeMirrorBlockNodeView = (settings) => {
276
+ export const codeMirrorBlockNodeView = (settings, editor) => {
264
277
  return (pmNode, view, getPos) => {
265
- return new CodeMirrorBlockNodeView(pmNode, view, getPos, settings);
278
+ return new CodeMirrorBlockNodeView(pmNode, view, getPos, settings, editor);
266
279
  };
267
280
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kerebron/extension-codemirror",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "license": "MIT",
5
5
  "module": "./esm/extension-codemirror/src/ExtensionCodeMirror.js",
6
6
  "exports": {
@@ -33,7 +33,7 @@
33
33
  "@codemirror/search": "6.5.10",
34
34
  "@codemirror/state": "6.5.2",
35
35
  "@codemirror/view": "6.38.1",
36
- "prosemirror-model": "1.25.2",
36
+ "prosemirror-model": "1.25.3",
37
37
  "prosemirror-state": "1.4.3",
38
38
  "prosemirror-transform": "1.10.4",
39
39
  "prosemirror-view": "1.40.0"