@kerebron/extension-codemirror 0.3.2 → 0.4.1

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 (242) hide show
  1. package/README.md +3 -3
  2. package/esm/_dnt.polyfills.d.ts +101 -0
  3. package/esm/_dnt.polyfills.d.ts.map +1 -0
  4. package/esm/_dnt.polyfills.js +127 -0
  5. package/esm/_dnt.shims.d.ts +6 -0
  6. package/esm/_dnt.shims.d.ts.map +1 -0
  7. package/esm/_dnt.shims.js +61 -0
  8. package/esm/editor/src/CoreEditor.d.ts +13 -4
  9. package/esm/editor/src/CoreEditor.d.ts.map +1 -1
  10. package/esm/editor/src/CoreEditor.js +64 -12
  11. package/esm/editor/src/Extension.d.ts +6 -1
  12. package/esm/editor/src/Extension.d.ts.map +1 -1
  13. package/esm/editor/src/Extension.js +21 -1
  14. package/esm/editor/src/ExtensionManager.d.ts +5 -6
  15. package/esm/editor/src/ExtensionManager.d.ts.map +1 -1
  16. package/esm/editor/src/ExtensionManager.js +43 -55
  17. package/esm/editor/src/Mark.d.ts +3 -0
  18. package/esm/editor/src/Mark.d.ts.map +1 -1
  19. package/esm/editor/src/Mark.js +11 -0
  20. package/esm/editor/src/Node.d.ts +5 -2
  21. package/esm/editor/src/Node.d.ts.map +1 -1
  22. package/esm/editor/src/Node.js +13 -2
  23. package/esm/editor/src/commands/CommandManager.d.ts +13 -6
  24. package/esm/editor/src/commands/CommandManager.d.ts.map +1 -1
  25. package/esm/editor/src/commands/CommandManager.js +59 -2
  26. package/esm/editor/src/commands/baseCommandFactories.d.ts +3 -0
  27. package/esm/editor/src/commands/baseCommandFactories.d.ts.map +1 -0
  28. package/esm/editor/src/commands/baseCommandFactories.js +836 -0
  29. package/esm/editor/src/commands/keyCommandFactories.d.ts +3 -0
  30. package/esm/editor/src/commands/keyCommandFactories.d.ts.map +1 -0
  31. package/esm/editor/src/commands/keyCommandFactories.js +10 -0
  32. package/esm/editor/src/commands/mod.d.ts +5 -53
  33. package/esm/editor/src/commands/mod.d.ts.map +1 -1
  34. package/esm/editor/src/commands/mod.js +14 -821
  35. package/esm/editor/src/commands/replaceCommandFactories.d.ts +3 -0
  36. package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +1 -0
  37. package/esm/editor/src/commands/replaceCommandFactories.js +94 -0
  38. package/esm/editor/src/commands/types.d.ts +18 -0
  39. package/esm/editor/src/commands/types.d.ts.map +1 -0
  40. package/esm/editor/src/commands/types.js +1 -0
  41. package/esm/editor/src/mod.d.ts +2 -0
  42. package/esm/editor/src/mod.d.ts.map +1 -1
  43. package/esm/editor/src/mod.js +2 -0
  44. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +6 -0
  45. package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +1 -0
  46. package/esm/editor/src/plugins/TrackSelecionPlugin.js +24 -0
  47. package/esm/editor/src/types.d.ts +19 -1
  48. package/esm/editor/src/types.d.ts.map +1 -1
  49. package/esm/editor/src/ui.d.ts +15 -0
  50. package/esm/editor/src/ui.d.ts.map +1 -0
  51. package/esm/editor/src/ui.js +16 -0
  52. package/esm/editor/src/utilities/SmartOutput.d.ts +9 -7
  53. package/esm/editor/src/utilities/SmartOutput.d.ts.map +1 -1
  54. package/esm/editor/src/utilities/SmartOutput.js +35 -20
  55. package/esm/editor/src/utilities/getShadowRoot.d.ts +2 -0
  56. package/esm/editor/src/utilities/getShadowRoot.d.ts.map +1 -0
  57. package/esm/editor/src/utilities/getShadowRoot.js +16 -0
  58. package/esm/editor/src/utilities/mod.d.ts +2 -0
  59. package/esm/editor/src/utilities/mod.d.ts.map +1 -1
  60. package/esm/editor/src/utilities/mod.js +2 -0
  61. package/esm/editor/src/utilities/toRawTextResult.d.ts +3 -0
  62. package/esm/editor/src/utilities/toRawTextResult.d.ts.map +1 -0
  63. package/esm/editor/src/utilities/toRawTextResult.js +21 -0
  64. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts +8 -0
  65. package/esm/extension-autocomplete/src/AutocompletePlugin.d.ts.map +1 -0
  66. package/esm/extension-autocomplete/src/AutocompletePlugin.js +232 -0
  67. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts +17 -0
  68. package/esm/extension-autocomplete/src/DefaultRenderer.d.ts.map +1 -0
  69. package/esm/extension-autocomplete/src/DefaultRenderer.js +137 -0
  70. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts +26 -0
  71. package/esm/extension-autocomplete/src/ExtensionAutocomplete.d.ts.map +1 -0
  72. package/esm/extension-autocomplete/src/ExtensionAutocomplete.js +30 -0
  73. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts +11 -0
  74. package/esm/extension-autocomplete/src/createDefaultMatcher.d.ts.map +1 -0
  75. package/esm/extension-autocomplete/src/createDefaultMatcher.js +58 -0
  76. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts +4 -0
  77. package/esm/extension-autocomplete/src/createRegexMatcher.d.ts.map +1 -0
  78. package/esm/extension-autocomplete/src/createRegexMatcher.js +50 -0
  79. package/esm/extension-autocomplete/src/mod.d.ts +3 -0
  80. package/esm/extension-autocomplete/src/mod.d.ts.map +1 -0
  81. package/esm/extension-autocomplete/src/mod.js +2 -0
  82. package/esm/extension-autocomplete/src/types.d.ts +60 -0
  83. package/esm/extension-autocomplete/src/types.d.ts.map +1 -0
  84. package/esm/extension-autocomplete/src/types.js +1 -0
  85. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts +15 -0
  86. package/esm/extension-basic-editor/src/ExtensionHtml.d.ts.map +1 -0
  87. package/esm/extension-basic-editor/src/ExtensionHtml.js +108 -0
  88. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts +9 -0
  89. package/esm/extension-basic-editor/src/NodeCodeBlock.d.ts.map +1 -0
  90. package/esm/extension-basic-editor/src/NodeCodeBlock.js +58 -0
  91. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts +24 -0
  92. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.d.ts.map +1 -0
  93. package/esm/extension-basic-editor/src/remote-selection/ExtensionRemoteSelection.js +35 -0
  94. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts +25 -0
  95. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.d.ts.map +1 -0
  96. package/esm/extension-basic-editor/src/remote-selection/remoteSelectionPlugin.js +96 -0
  97. package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts +15 -2
  98. package/esm/extension-codemirror/src/ExtensionCodeMirror.d.ts.map +1 -1
  99. package/esm/extension-codemirror/src/ExtensionCodeMirror.js +74 -2
  100. package/esm/extension-codemirror/src/NodeCodeMirror.d.ts +13 -9
  101. package/esm/extension-codemirror/src/NodeCodeMirror.d.ts.map +1 -1
  102. package/esm/extension-codemirror/src/NodeCodeMirror.js +34 -122
  103. package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts +3 -3
  104. package/esm/extension-codemirror/src/codeMirrorBlockNodeView.d.ts.map +1 -1
  105. package/esm/extension-codemirror/src/codeMirrorBlockNodeView.js +155 -107
  106. package/esm/extension-codemirror/src/defaults.d.ts +1 -1
  107. package/esm/extension-codemirror/src/defaults.d.ts.map +1 -1
  108. package/esm/extension-codemirror/src/defaults.js +4 -3
  109. package/esm/extension-codemirror/src/languageLoaders.d.ts.map +1 -1
  110. package/esm/extension-codemirror/src/languageLoaders.js +1 -2
  111. package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts +14 -0
  112. package/esm/extension-codemirror/src/lsp/LSPExtension.d.ts.map +1 -0
  113. package/esm/extension-codemirror/src/lsp/LSPExtension.js +38 -0
  114. package/esm/extension-codemirror/src/lsp/completion.d.ts +8 -0
  115. package/esm/extension-codemirror/src/lsp/completion.d.ts.map +1 -0
  116. package/esm/extension-codemirror/src/lsp/completion.js +179 -0
  117. package/esm/extension-codemirror/src/lsp/hover.d.ts +5 -0
  118. package/esm/extension-codemirror/src/lsp/hover.d.ts.map +1 -0
  119. package/esm/extension-codemirror/src/lsp/hover.js +81 -0
  120. package/esm/extension-codemirror/src/lsp/index.d.ts +7 -0
  121. package/esm/extension-codemirror/src/lsp/index.d.ts.map +1 -0
  122. package/esm/extension-codemirror/src/lsp/index.js +49 -0
  123. package/esm/extension-codemirror/src/lsp/plugin.d.ts +37 -0
  124. package/esm/extension-codemirror/src/lsp/plugin.d.ts.map +1 -0
  125. package/esm/extension-codemirror/src/lsp/plugin.js +125 -0
  126. package/esm/extension-codemirror/src/lsp/pos.d.ts +5 -0
  127. package/esm/extension-codemirror/src/lsp/pos.d.ts.map +1 -0
  128. package/esm/extension-codemirror/src/lsp/pos.js +8 -0
  129. package/esm/extension-codemirror/src/lsp/text.d.ts +2 -0
  130. package/esm/extension-codemirror/src/lsp/text.d.ts.map +1 -0
  131. package/esm/extension-codemirror/src/lsp/text.js +47 -0
  132. package/esm/extension-codemirror/src/lsp/theme.d.ts +2 -0
  133. package/esm/extension-codemirror/src/lsp/theme.d.ts.map +1 -0
  134. package/esm/extension-codemirror/src/lsp/theme.js +76 -0
  135. package/esm/extension-codemirror/src/{y-remote-selections.d.ts → remote-selections.d.ts} +5 -5
  136. package/esm/extension-codemirror/src/remote-selections.d.ts.map +1 -0
  137. package/esm/extension-codemirror/src/{y-remote-selections.js → remote-selections.js} +49 -69
  138. package/esm/extension-codemirror/src/remote-sync.d.ts +11 -0
  139. package/esm/extension-codemirror/src/remote-sync.d.ts.map +1 -0
  140. package/esm/extension-codemirror/src/{y-sync.js → remote-sync.js} +6 -6
  141. package/esm/extension-codemirror/src/types.d.ts +10 -10
  142. package/esm/extension-codemirror/src/types.d.ts.map +1 -1
  143. package/esm/extension-codemirror/src/utils.d.ts +7 -6
  144. package/esm/extension-codemirror/src/utils.d.ts.map +1 -1
  145. package/esm/extension-codemirror/src/utils.js +21 -10
  146. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts +32 -0
  147. package/esm/extension-lsp/src/DiagnosticPlugin.d.ts.map +1 -0
  148. package/esm/extension-lsp/src/DiagnosticPlugin.js +131 -0
  149. package/esm/extension-lsp/src/ExtensionLsp.d.ts +25 -0
  150. package/esm/extension-lsp/src/ExtensionLsp.d.ts.map +1 -0
  151. package/esm/extension-lsp/src/ExtensionLsp.js +126 -0
  152. package/esm/extension-lsp/src/LSPClient.d.ts +56 -0
  153. package/esm/extension-lsp/src/LSPClient.d.ts.map +1 -0
  154. package/esm/extension-lsp/src/LSPClient.js +449 -0
  155. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts +8 -0
  156. package/esm/extension-lsp/src/computeIncrementalChanges.d.ts.map +1 -0
  157. package/esm/extension-lsp/src/computeIncrementalChanges.js +82 -0
  158. package/esm/extension-lsp/src/createLspAutocomplete.d.ts +23 -0
  159. package/esm/extension-lsp/src/createLspAutocomplete.d.ts.map +1 -0
  160. package/esm/extension-lsp/src/createLspAutocomplete.js +68 -0
  161. package/esm/extension-lsp/src/mod.d.ts +4 -0
  162. package/esm/extension-lsp/src/mod.d.ts.map +1 -0
  163. package/esm/extension-lsp/src/mod.js +3 -0
  164. package/esm/extension-lsp/src/workspace.d.ts +62 -0
  165. package/esm/extension-lsp/src/workspace.d.ts.map +1 -0
  166. package/esm/extension-lsp/src/workspace.js +168 -0
  167. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts +36 -0
  168. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.d.ts.map +1 -0
  169. package/esm/extension-markdown/src/DocumentMarkdownInlineTokenizer.js +240 -0
  170. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts +26 -0
  171. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.d.ts.map +1 -0
  172. package/esm/extension-markdown/src/DocumentMarkdownTokenizer.js +115 -0
  173. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts +22 -0
  174. package/esm/extension-markdown/src/ExtensionMarkdown.d.ts.map +1 -0
  175. package/esm/extension-markdown/src/ExtensionMarkdown.js +48 -0
  176. package/esm/extension-markdown/src/MarkdownParser.d.ts +61 -0
  177. package/esm/extension-markdown/src/MarkdownParser.d.ts.map +1 -0
  178. package/esm/extension-markdown/src/MarkdownParser.js +249 -0
  179. package/esm/extension-markdown/src/MarkdownSerializer.d.ts +42 -0
  180. package/esm/extension-markdown/src/MarkdownSerializer.d.ts.map +1 -0
  181. package/esm/extension-markdown/src/MarkdownSerializer.js +325 -0
  182. package/esm/extension-markdown/src/PositionMapper.d.ts +15 -0
  183. package/esm/extension-markdown/src/PositionMapper.d.ts.map +1 -0
  184. package/esm/extension-markdown/src/PositionMapper.js +100 -0
  185. package/esm/extension-markdown/src/TokenSource.d.ts +11 -0
  186. package/esm/extension-markdown/src/TokenSource.d.ts.map +1 -0
  187. package/esm/extension-markdown/src/TokenSource.js +39 -0
  188. package/esm/extension-markdown/src/mdToPmConverter.d.ts +5 -0
  189. package/esm/extension-markdown/src/mdToPmConverter.d.ts.map +1 -0
  190. package/esm/extension-markdown/src/mdToPmConverter.js +111 -0
  191. package/esm/extension-markdown/src/pmToMdConverter.d.ts +16 -0
  192. package/esm/extension-markdown/src/pmToMdConverter.d.ts.map +1 -0
  193. package/esm/extension-markdown/src/pmToMdConverter.js +433 -0
  194. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts +4 -0
  195. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.d.ts.map +1 -0
  196. package/esm/extension-markdown/src/token_handlers/basic_token_handlers.js +151 -0
  197. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts +3 -0
  198. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.d.ts.map +1 -0
  199. package/esm/extension-markdown/src/token_handlers/footnote_token_handlers.js +34 -0
  200. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts +6 -0
  201. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.d.ts.map +1 -0
  202. package/esm/extension-markdown/src/token_handlers/inline_token_handlers.js +380 -0
  203. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts +3 -0
  204. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.d.ts.map +1 -0
  205. package/esm/extension-markdown/src/token_handlers/lists_token_handlers.js +323 -0
  206. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts +9 -0
  207. package/esm/extension-markdown/src/token_handlers/table_token_handlers.d.ts.map +1 -0
  208. package/esm/extension-markdown/src/token_handlers/table_token_handlers.js +308 -0
  209. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts +5 -0
  210. package/esm/extension-markdown/src/treeSitterTokenizer.d.ts.map +1 -0
  211. package/esm/extension-markdown/src/treeSitterTokenizer.js +769 -0
  212. package/esm/extension-markdown/src/types.d.ts +28 -0
  213. package/esm/extension-markdown/src/types.d.ts.map +1 -0
  214. package/esm/extension-markdown/src/types.js +131 -0
  215. package/esm/extension-markdown/src/utils.d.ts +8 -0
  216. package/esm/extension-markdown/src/utils.d.ts.map +1 -0
  217. package/esm/extension-markdown/src/utils.js +86 -0
  218. package/esm/tree-sitter-shim/src/main.d.ts +15 -0
  219. package/esm/tree-sitter-shim/src/main.d.ts.map +1 -0
  220. package/esm/tree-sitter-shim/src/main.js +25 -0
  221. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts +6 -0
  222. package/esm/tree-sitter-shim/src/tree_sitter/node.d.ts.map +1 -0
  223. package/esm/tree-sitter-shim/src/tree_sitter/node.js +1 -0
  224. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts +7 -0
  225. package/esm/tree-sitter-shim/src/tree_sitter/parser.d.ts.map +1 -0
  226. package/esm/tree-sitter-shim/src/tree_sitter/parser.js +5 -0
  227. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts +6 -0
  228. package/esm/tree-sitter-shim/src/tree_sitter/tree.d.ts.map +1 -0
  229. package/esm/tree-sitter-shim/src/tree_sitter/tree.js +1 -0
  230. package/esm/wasm/src/mod.d.ts +12 -0
  231. package/esm/wasm/src/mod.d.ts.map +1 -0
  232. package/esm/wasm/src/mod.js +48 -0
  233. package/esm/wasm/wasm.d.ts +138 -0
  234. package/esm/wasm/wasm.d.ts.map +1 -0
  235. package/esm/wasm/wasm.js +120 -0
  236. package/package.json +5 -25
  237. package/esm/extension-codemirror/src/NodeDocumentCode.d.ts +0 -7
  238. package/esm/extension-codemirror/src/NodeDocumentCode.d.ts.map +0 -1
  239. package/esm/extension-codemirror/src/NodeDocumentCode.js +0 -37
  240. package/esm/extension-codemirror/src/y-remote-selections.d.ts.map +0 -1
  241. package/esm/extension-codemirror/src/y-sync.d.ts +0 -11
  242. package/esm/extension-codemirror/src/y-sync.d.ts.map +0 -1
@@ -1,15 +1,15 @@
1
1
  import * as cmView from '@codemirror/view';
2
2
  import * as cmState from '@codemirror/state';
3
- import { YSyncConfig } from './y-sync.js';
3
+ import { RemoteSyncConfig } from './remote-sync.js';
4
4
  export declare const yRemoteSelectionsTheme: cmState.Extension;
5
5
  export declare class YRemoteSelectionsPluginValue {
6
- conf: YSyncConfig;
7
- private _listener;
8
- private _awareness;
6
+ conf: RemoteSyncConfig;
7
+ private editor;
9
8
  decorations: cmView.DecorationSet;
9
+ private _remoteSelectionChange;
10
10
  constructor(view: cmView.EditorView);
11
11
  destroy(): void;
12
12
  update(update: cmView.ViewUpdate): void;
13
13
  }
14
14
  export declare const yRemoteSelections: cmView.ViewPlugin<YRemoteSelectionsPluginValue, undefined>;
15
- //# sourceMappingURL=y-remote-selections.d.ts.map
15
+ //# sourceMappingURL=remote-selections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-selections.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/remote-selections.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAK7C,OAAO,EAAE,gBAAgB,EAAmB,MAAM,kBAAkB,CAAC;AAKrE,eAAO,MAAM,sBAAsB,mBAuDjC,CAAC;AA8CH,qBAAa,4BAA4B;IACvC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,CAAC,MAAM,CAAa;IAC3B,WAAW,EAAE,MAAM,CAAC,aAAa,CAAC;IAClC,OAAO,CAAC,sBAAsB,CAAa;gBAE/B,IAAI,EAAE,MAAM,CAAC,UAAU;IAcnC,OAAO;IAOP,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU;CAmHjC;AAED,eAAO,MAAM,iBAAiB,4DAK7B,CAAC"}
@@ -3,14 +3,14 @@ import * as cmState from '@codemirror/state';
3
3
  import * as dom from 'lib0/dom';
4
4
  import * as pair from 'lib0/pair';
5
5
  import * as math from 'lib0/math';
6
- import { ySyncFacet } from './y-sync.js';
6
+ import { remoteSyncFacet } from './remote-sync.js';
7
7
  export const yRemoteSelectionsTheme = cmView.EditorView.baseTheme({
8
- '.cm-ySelection': {},
9
- '.cm-yLineSelection': {
8
+ '.cm-rSelection': {},
9
+ '.cm-rLineSelection': {
10
10
  padding: 0,
11
11
  margin: '0px 2px 0px 4px',
12
12
  },
13
- '.cm-ySelectionCaret': {
13
+ '.cm-rSelectionCaret': {
14
14
  position: 'relative',
15
15
  borderLeft: '1px solid black',
16
16
  borderRight: '1px solid black',
@@ -19,7 +19,7 @@ export const yRemoteSelectionsTheme = cmView.EditorView.baseTheme({
19
19
  boxSizing: 'border-box',
20
20
  display: 'inline',
21
21
  },
22
- '.cm-ySelectionCaretDot': {
22
+ '.cm-rSelectionCaretDot': {
23
23
  borderRadius: '50%',
24
24
  position: 'absolute',
25
25
  width: '.4em',
@@ -30,11 +30,11 @@ export const yRemoteSelectionsTheme = cmView.EditorView.baseTheme({
30
30
  transition: 'transform .3s ease-in-out',
31
31
  boxSizing: 'border-box',
32
32
  },
33
- '.cm-ySelectionCaret:hover > .cm-ySelectionCaretDot': {
33
+ '.cm-rSelectionCaret:hover > .cm-rSelectionCaretDot': {
34
34
  transformOrigin: 'bottom center',
35
35
  transform: 'scale(0)',
36
36
  },
37
- '.cm-ySelectionInfo': {
37
+ '.cm-rSelectionInfo': {
38
38
  position: 'absolute',
39
39
  top: '-1.05em',
40
40
  left: '-1px',
@@ -55,7 +55,7 @@ export const yRemoteSelectionsTheme = cmView.EditorView.baseTheme({
55
55
  transitionDelay: '0s',
56
56
  whiteSpace: 'nowrap',
57
57
  },
58
- '.cm-ySelectionCaret:hover > .cm-ySelectionInfo': {
58
+ '.cm-rSelectionCaret:hover > .cm-rSelectionInfo': {
59
59
  opacity: 1,
60
60
  transitionDelay: '0s',
61
61
  },
@@ -115,85 +115,50 @@ export class YRemoteSelectionsPluginValue {
115
115
  writable: true,
116
116
  value: void 0
117
117
  });
118
- Object.defineProperty(this, "_listener", {
118
+ Object.defineProperty(this, "editor", {
119
119
  enumerable: true,
120
120
  configurable: true,
121
121
  writable: true,
122
122
  value: void 0
123
123
  });
124
- Object.defineProperty(this, "_awareness", {
124
+ Object.defineProperty(this, "decorations", {
125
125
  enumerable: true,
126
126
  configurable: true,
127
127
  writable: true,
128
128
  value: void 0
129
129
  });
130
- Object.defineProperty(this, "decorations", {
130
+ Object.defineProperty(this, "_remoteSelectionChange", {
131
131
  enumerable: true,
132
132
  configurable: true,
133
133
  writable: true,
134
134
  value: void 0
135
135
  });
136
- this.conf = view.state.facet(ySyncFacet);
137
- this._listener = ({ added, updated, removed }) => {
138
- const clients = added.concat(updated).concat(removed);
139
- if (clients.findIndex((id) => id !== this.conf.awareness.doc.clientID) >= 0) {
140
- view.dispatch({ annotations: [yRemoteSelectionsAnnotation.of([])] });
141
- }
142
- };
143
- this._awareness = this.conf.awareness;
144
- this._awareness.on('change', this._listener);
136
+ this.conf = view.state.facet(remoteSyncFacet);
137
+ this.editor = this.conf.editor;
145
138
  this.decorations = cmState.RangeSet.of([]);
139
+ this._remoteSelectionChange = () => {
140
+ view.dispatch({ annotations: [yRemoteSelectionsAnnotation.of([])] });
141
+ };
142
+ this.editor.addEventListener('remoteSelectionChange', this._remoteSelectionChange);
146
143
  }
147
144
  destroy() {
148
- this._awareness.off('change', this._listener);
145
+ this.editor.removeEventListener('remoteSelectionChange', this._remoteSelectionChange);
149
146
  }
150
147
  update(update) {
151
- const awareness = this.conf.awareness;
152
148
  const decorations = [];
153
- const localAwarenessState = this.conf.awareness.getLocalState();
154
- // set local awareness state (update cursors)
155
- if (localAwarenessState != null) {
156
- const hasFocus = update.view.hasFocus &&
157
- update.view.dom.ownerDocument.hasFocus();
158
- const sel = hasFocus ? update.state.selection.main : null;
159
- if (sel != null && 'function' === typeof this.conf.getPmPos) {
160
- const nodePos = this.conf.getPmPos();
161
- const currentAnchor = localAwarenessState['cm-cursor'] == null
162
- ? -1
163
- : localAwarenessState['cm-cursor'].anchor - nodePos;
164
- const currentHead = localAwarenessState['cm-cursor'] == null
165
- ? -1
166
- : localAwarenessState['cm-cursor'].head - nodePos;
167
- const anchor = nodePos + sel.anchor;
168
- const head = nodePos + sel.head;
169
- if (localAwarenessState['cm-cursor'] == null ||
170
- (currentAnchor != anchor) || (currentHead != head)) {
171
- awareness.setLocalStateField('cm-cursor', {
172
- anchor,
173
- head,
174
- });
175
- }
176
- }
177
- else if (localAwarenessState['cm-cursor'] != null && hasFocus) {
178
- awareness.setLocalStateField('cm-cursor', null);
179
- }
180
- }
181
- // update decorations (remote selections)
182
- awareness.getStates().forEach((state, clientId) => {
183
- if (clientId === awareness.doc.clientID) {
184
- return;
185
- }
186
- if (!state.user) {
187
- return;
188
- }
189
- const cursor = state['cm-cursor'];
190
- if (cursor == null || cursor.anchor == null || cursor.head == null) {
149
+ const extension = this.editor.getExtension('remote-selection');
150
+ const remoteStates = extension.getRemoteStates();
151
+ for (const state of remoteStates) {
152
+ const clientId = state.clientId;
153
+ const cursor = state.cursor;
154
+ if (cursor?.anchor == null || cursor?.head == null) {
191
155
  return;
192
156
  }
193
- if ('function' === typeof this.conf.getPmPos) {
194
- const nodeAnchor = this.conf.getPmPos();
195
- const nodeHead = this.conf.getPmPos() + this.conf.getNode().nodeSize;
196
- if (cursor.anchor >= nodeAnchor && cursor.anchor <= nodeHead) {
157
+ const nodeAnchor = this.conf.getPmPos();
158
+ if ('undefined' !== typeof nodeAnchor) {
159
+ const nodeHead = nodeAnchor + this.conf.getNode().nodeSize;
160
+ if (cursor.anchor >= nodeAnchor && cursor.anchor < nodeHead &&
161
+ cursor.head >= nodeAnchor && cursor.head < nodeHead) {
197
162
  const anchor = { index: cursor.anchor - nodeAnchor };
198
163
  const head = { index: cursor.head - nodeAnchor };
199
164
  try {
@@ -211,7 +176,7 @@ export class YRemoteSelectionsPluginValue {
211
176
  to: end,
212
177
  value: cmView.Decoration.mark({
213
178
  attributes: { style: `background-color: ${colorLight}` },
214
- class: 'cm-ySelection',
179
+ class: 'cm-rSelection',
215
180
  }),
216
181
  });
217
182
  }
@@ -223,7 +188,7 @@ export class YRemoteSelectionsPluginValue {
223
188
  to: startLine.from + startLine.length,
224
189
  value: cmView.Decoration.mark({
225
190
  attributes: { style: `background-color: ${colorLight}` },
226
- class: 'cm-ySelection',
191
+ class: 'cm-rSelection',
227
192
  }),
228
193
  });
229
194
  // render text-selection in the last line
@@ -232,7 +197,7 @@ export class YRemoteSelectionsPluginValue {
232
197
  to: end,
233
198
  value: cmView.Decoration.mark({
234
199
  attributes: { style: `background-color: ${colorLight}` },
235
- class: 'cm-ySelection',
200
+ class: 'cm-rSelection',
236
201
  }),
237
202
  });
238
203
  for (let i = startLine.number + 1; i < endLine.number; i++) {
@@ -243,7 +208,7 @@ export class YRemoteSelectionsPluginValue {
243
208
  value: cmView.Decoration.line({
244
209
  attributes: {
245
210
  style: `background-color: ${colorLight}`,
246
- class: 'cm-yLineSelection',
211
+ class: 'cm-rLineSelection',
247
212
  },
248
213
  }),
249
214
  });
@@ -264,8 +229,23 @@ export class YRemoteSelectionsPluginValue {
264
229
  }
265
230
  }
266
231
  }
267
- });
232
+ }
268
233
  this.decorations = cmView.Decoration.set(decorations, true);
234
+ const hasFocus = update.view.hasFocus &&
235
+ update.view.dom.ownerDocument.hasFocus();
236
+ const sel = hasFocus ? update.state.selection.main : null;
237
+ const nodePos = this.conf.getPmPos();
238
+ if (sel != null && 'undefined' !== typeof nodePos) {
239
+ const anchor = nodePos + sel.anchor;
240
+ const head = nodePos + sel.head;
241
+ const event = new CustomEvent('localPositionChanged', {
242
+ detail: {
243
+ anchor,
244
+ head,
245
+ },
246
+ });
247
+ this.editor.dispatchEvent(event);
248
+ }
269
249
  }
270
250
  }
271
251
  export const yRemoteSelections = cmView.ViewPlugin.fromClass(YRemoteSelectionsPluginValue, {
@@ -0,0 +1,11 @@
1
+ import * as cmState from '@codemirror/state';
2
+ import { Node } from 'prosemirror-model';
3
+ import type { CoreEditor } from '../../editor/src/mod.js';
4
+ export declare class RemoteSyncConfig {
5
+ getNode: () => Node;
6
+ getPmPos: () => number | undefined;
7
+ editor: CoreEditor;
8
+ constructor(getNode: () => Node, getPmPos: () => number | undefined, editor: CoreEditor);
9
+ }
10
+ export declare const remoteSyncFacet: cmState.Facet<RemoteSyncConfig, RemoteSyncConfig>;
11
+ //# sourceMappingURL=remote-sync.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-sync.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/remote-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,qBAAa,gBAAgB;IAElB,OAAO,EAAE,MAAM,IAAI;IACnB,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS;IAClC,MAAM,EAAE,UAAU;gBAFlB,OAAO,EAAE,MAAM,IAAI,EACnB,QAAQ,EAAE,MAAM,MAAM,GAAG,SAAS,EAClC,MAAM,EAAE,UAAU;CAG5B;AAED,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,KAAK,CACzC,gBAAgB,EAChB,gBAAgB,CAMd,CAAC"}
@@ -1,6 +1,6 @@
1
- import * as cmState from '@codemirror/state'; // eslint-disable-line
2
- export class YSyncConfig {
3
- constructor(getNode, getPmPos, awareness) {
1
+ import * as cmState from '@codemirror/state';
2
+ export class RemoteSyncConfig {
3
+ constructor(getNode, getPmPos, editor) {
4
4
  Object.defineProperty(this, "getNode", {
5
5
  enumerable: true,
6
6
  configurable: true,
@@ -13,15 +13,15 @@ export class YSyncConfig {
13
13
  writable: true,
14
14
  value: getPmPos
15
15
  });
16
- Object.defineProperty(this, "awareness", {
16
+ Object.defineProperty(this, "editor", {
17
17
  enumerable: true,
18
18
  configurable: true,
19
19
  writable: true,
20
- value: awareness
20
+ value: editor
21
21
  });
22
22
  }
23
23
  }
24
- export const ySyncFacet = cmState.Facet
24
+ export const remoteSyncFacet = cmState.Facet
25
25
  .define({
26
26
  combine(inputs) {
27
27
  return inputs[inputs.length - 1];
@@ -3,28 +3,28 @@ import { EditorView as CodemirrorView } from '@codemirror/view';
3
3
  import { Node } from 'prosemirror-model';
4
4
  import { EditorView } from 'prosemirror-view';
5
5
  import { LanguageSupport } from '@codemirror/language';
6
- import { Extension } from '@codemirror/state';
6
+ import { Extension as CmExtension } from '@codemirror/state';
7
+ import { type Transport } from '../../extension-lsp/src/mod.js';
7
8
  export type LanguageLoaders = Record<string, () => Promise<LanguageSupport>>;
8
9
  export type ThemeItem = {
9
- extension: Extension;
10
+ extension: CmExtension;
10
11
  name: string;
11
12
  };
12
13
  export type CodeBlockSettings = {
13
- provider?: any;
14
- createSelect: (settings: CodeBlockSettings, dom: HTMLElement, node: Node, view: EditorView, getPos: (() => number) | boolean) => () => void;
15
- updateSelect: (settings: CodeBlockSettings, dom: HTMLElement, node: Node, view: EditorView, getPos: (() => number) | boolean, oldNode: Node) => void;
16
- createCopyButton: (settings: CodeBlockSettings, dom: HTMLElement, node: Node, view: EditorView, codeMirrorView: CodemirrorView, getPos: (() => number) | boolean) => () => void;
17
- stopEvent: (e: Event, node: Node, getPos: (() => number) | boolean, view: EditorView, dom: HTMLElement) => boolean;
14
+ createSelect: (settings: CodeBlockSettings, dom: HTMLElement, node: Node, view: EditorView, getPos: () => number | undefined) => () => void;
15
+ updateSelect: (settings: CodeBlockSettings, dom: HTMLElement, node: Node, view: EditorView, getPos: () => number | undefined, oldNode: Node) => void;
16
+ createCopyButton: (settings: CodeBlockSettings, dom: HTMLElement, node: Node, view: EditorView, codeMirrorView: CodemirrorView, getPos: () => number | undefined) => () => void;
17
+ stopEvent: (e: Event, node: Node, getPos: () => number | undefined, view: EditorView, dom: HTMLElement) => boolean;
18
18
  languageLoaders?: LanguageLoaders;
19
19
  languageNameMap?: Record<string, string>;
20
20
  languageWhitelist?: string[];
21
21
  undo?: (state: EditorState, dispatch: (tr: Transaction) => void) => void;
22
22
  redo?: (state: EditorState, dispatch: (tr: Transaction) => void) => void;
23
- theme?: Extension[];
24
- readOnly: boolean;
23
+ theme?: CmExtension[];
25
24
  themes: ThemeItem[];
25
+ readOnly?: boolean;
26
26
  getCurrentTheme?: () => string;
27
27
  codeBlockName?: string;
28
- shadowRoot?: ShadowRoot;
28
+ lspTransport?: Transport;
29
29
  };
30
30
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,eAAe,CAAC,CAA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ACvB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC"}
@@ -3,18 +3,19 @@ import { EditorView as PMEditorView } from 'prosemirror-view';
3
3
  import { Node } from 'prosemirror-model';
4
4
  import { EditorView } from '@codemirror/view';
5
5
  import { Compartment } from '@codemirror/state';
6
- import { CodeBlockSettings, ThemeItem } from './types.js';
6
+ import type { CodeBlockSettings, ThemeItem } from './types.js';
7
+ import type { CoreEditor } from '../../editor/src/mod.js';
7
8
  export declare const CodeBlockNodeName = "code_block";
8
9
  export declare function computeChange(oldVal: string, newVal: string): {
9
10
  from: number;
10
11
  to: number;
11
12
  text: string;
12
13
  } | null;
13
- export declare const asProseMirrorSelection: (pmDoc: Node, cmView: EditorView, getPos: (() => number) | boolean) => TextSelection;
14
- export declare const forwardSelection: (cmView: EditorView, pmView: PMEditorView, getPos: (() => number) | boolean) => void;
15
- export declare const valueChanged: (textUpdate: string, node: Node, getPos: (() => number) | boolean, view: PMEditorView) => void;
16
- export declare const maybeEscape: (unit: "char" | "line", dir: -1 | 1, cm: EditorView, view: PMEditorView, getPos: boolean | (() => number)) => boolean;
17
- export declare const backspaceHandler: (pmView: PMEditorView, view: EditorView) => boolean;
14
+ export declare const asProseMirrorSelection: (pmDoc: Node, cmView: EditorView, getPos: () => number | undefined) => TextSelection;
15
+ export declare const forwardSelection: (cmView: EditorView, pmView: PMEditorView, getPos: () => number | undefined) => void;
16
+ export declare const valueChanged: (textUpdate: string, node: Node, getPos: () => number | undefined, view: PMEditorView) => void;
17
+ export declare const maybeEscape: (unit: "char" | "line", dir: -1 | 1, cm: EditorView, view: PMEditorView, getPos: () => number | undefined) => boolean;
18
+ export declare const backspaceHandler: (pmView: PMEditorView, view: EditorView, editor: CoreEditor) => boolean;
18
19
  export declare const setMode: (lang: string, cmView: EditorView, settings: CodeBlockSettings, languageConf: Compartment) => Promise<void>;
19
20
  export declare const setTheme: (cmView: EditorView, themeConfig: Compartment, theme: Array<ThemeItem | undefined>) => Promise<void>;
20
21
  export declare const createCodeBlock: (state: EditorState, dispatch: ((tr: Transaction) => void) | undefined, attributes: object) => boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/extension-codemirror/src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,OAAO,EACP,WAAW,EAEX,aAAa,EACb,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1D,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAM9C,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;;;;SAoB3D;AAED,eAAO,MAAM,sBAAsB,GACjC,OAAO,IAAI,EACX,QAAQ,UAAU,EAClB,QAAQ,CAAC,MAAM,MAAM,CAAC,GAAG,OAAO,kBAMjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,UAAU,EAClB,QAAQ,YAAY,EACpB,QAAQ,CAAC,MAAM,MAAM,CAAC,GAAG,OAAO,SAOjC,CAAC;AAEF,eAAO,MAAM,YAAY,GACvB,YAAY,MAAM,EAClB,MAAM,IAAI,EACV,QAAQ,CAAC,MAAM,MAAM,CAAC,GAAG,OAAO,EAChC,MAAM,YAAY,SAenB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,GAAG,MAAM,EACrB,KAAK,CAAC,CAAC,GAAG,CAAC,EACX,IAAI,UAAU,EACd,MAAM,YAAY,EAClB,QAAQ,OAAO,GAAG,CAAC,MAAM,MAAM,CAAC,YAqBjC,CAAC;AA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C,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,EACjD,YAAY,MAAM,YA4DnB,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,OAAO,WAAW,EAClB,UAAU,CAAC,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,YAwBlD,CAAC;AAEF,eAAO,MAAM,eAAe,GAC1B,OAAO,WAAW,EAClB,UAAU,CAAC,CAAC,EAAE,EAAE,WAAW,KAAK,IAAI,CAAC,GAAG,SAAS,EACjD,YAAY,MAAM,YAanB,CAAC;AAEF,eAAO,MAAM,sBAAsB;;;;;CAKlC,CAAC;AAEF,eAAO,MAAM,uBAAuB;iBACF,OAAO;CACxC,CAAC;AAEF,eAAO,MAAM,eAAe;;;;;iBAHM,OAAO;CAMxC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  // From prosemirror guide
2
2
  import { Selection, TextSelection, } from 'prosemirror-state';
3
- import { setBlockType } from '../../editor/src/commands/mod.js';
3
+ import { LSPPlugin } from './lsp/plugin.js';
4
4
  export const CodeBlockNodeName = 'code_block';
5
5
  function nonEmpty(value) {
6
6
  return value !== null && value !== undefined;
@@ -39,11 +39,14 @@ export const forwardSelection = (cmView, pmView, getPos) => {
39
39
  };
40
40
  export const valueChanged = (textUpdate, node, getPos, view) => {
41
41
  const change = computeChange(node.textContent, textUpdate);
42
- if (change && typeof getPos === 'function') {
43
- const start = getPos() + 1;
44
- let pmTr = view.state.tr;
45
- pmTr = pmTr.replaceWith(start + change.from, start + change.to, change.text ? view.state.schema.text(change.text) : []);
46
- view.dispatch(pmTr);
42
+ if (change) {
43
+ const pos = getPos();
44
+ if ('undefined' !== typeof pos) {
45
+ const start = pos + 1;
46
+ let pmTr = view.state.tr;
47
+ pmTr = pmTr.replaceWith(start + change.from, start + change.to, change.text ? view.state.schema.text(change.text) : []);
48
+ view.dispatch(pmTr);
49
+ }
47
50
  }
48
51
  };
49
52
  export const maybeEscape = (unit, dir, cm, view, getPos) => {
@@ -57,19 +60,23 @@ export const maybeEscape = (unit, dir, cm, view, getPos) => {
57
60
  return false;
58
61
  }
59
62
  view.focus();
60
- const node = view.state.doc.nodeAt(getPos());
63
+ const pos = getPos();
64
+ if (!pos) {
65
+ return false;
66
+ }
67
+ const node = view.state.doc.nodeAt(pos);
61
68
  if (!node)
62
69
  return false;
63
- const targetPos = getPos() + (dir < 0 ? 0 : node.nodeSize);
70
+ const targetPos = pos + (dir < 0 ? 0 : node.nodeSize);
64
71
  const selection = Selection.near(view.state.doc.resolve(targetPos), dir);
65
72
  view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
66
73
  view.focus();
67
74
  return true;
68
75
  };
69
- export const backspaceHandler = (pmView, view) => {
76
+ export const backspaceHandler = (pmView, view, editor) => {
70
77
  const { selection } = view.state;
71
78
  if (selection.main.empty && selection.main.from === 0) {
72
- setBlockType(pmView.state.schema.nodes.paragraph)(pmView.state, pmView.dispatch);
79
+ editor.commandFactories.setBlockType(pmView.state.schema.nodes.paragraph)(pmView.state, pmView.dispatch);
73
80
  setTimeout(() => pmView.focus(), 20);
74
81
  return true;
75
82
  }
@@ -82,6 +89,10 @@ export const setMode = async (lang, cmView, settings, languageConf) => {
82
89
  effects: languageConf.reconfigure(support),
83
90
  });
84
91
  }
92
+ const lspPlugin = LSPPlugin.get(cmView);
93
+ if (lspPlugin) {
94
+ lspPlugin.setLang(lang);
95
+ }
85
96
  };
86
97
  const isTheme = (theme) => {
87
98
  if (!Array.isArray(theme)) {
@@ -0,0 +1,32 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { ExtensionLsp } from './ExtensionLsp.js';
3
+ import { PositionMapper } from '../../extension-markdown/src/PositionMapper.js';
4
+ interface LspRange {
5
+ line: number;
6
+ character: number;
7
+ }
8
+ interface DiagnosticsItem {
9
+ severity: number;
10
+ range: {
11
+ start: LspRange;
12
+ end: LspRange;
13
+ };
14
+ message: string;
15
+ source: string;
16
+ code: string;
17
+ data: any;
18
+ }
19
+ interface DiagnosticPluginState {
20
+ diagnostics: DiagnosticsItem[];
21
+ mapper?: PositionMapper;
22
+ }
23
+ interface DiagnosticConfig {
24
+ }
25
+ export declare class DiagnosticPlugin extends Plugin<DiagnosticPluginState> {
26
+ diagListener: ((event: Event) => void) | undefined;
27
+ listenerDisconnect: ((event: Event) => void) | undefined;
28
+ listenerChange: ((event: Event) => void) | undefined;
29
+ constructor(config: DiagnosticConfig, extension: ExtensionLsp);
30
+ }
31
+ export {};
32
+ //# sourceMappingURL=DiagnosticPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiagnosticPlugin.d.ts","sourceRoot":"","sources":["../../../src/extension-lsp/src/DiagnosticPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAEhF,UAAU,QAAQ;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QACL,KAAK,EAAE,QAAQ,CAAC;QAChB,GAAG,EAAE,QAAQ,CAAC;KACf,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;CACX;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,UAAU,gBAAgB;CACzB;AAID,qBAAa,gBAAiB,SAAQ,MAAM,CAAC,qBAAqB,CAAC;IACjE,YAAY,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACnD,kBAAkB,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACzD,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;gBAEzC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY;CA8J9D"}
@@ -0,0 +1,131 @@
1
+ import { Plugin, PluginKey } from 'prosemirror-state';
2
+ import { Decoration, DecorationSet } from 'prosemirror-view';
3
+ const DiagnosticPluginKey = new PluginKey('lsp-diagnostic');
4
+ export class DiagnosticPlugin extends Plugin {
5
+ constructor(config, extension) {
6
+ super({
7
+ key: DiagnosticPluginKey,
8
+ view(view) {
9
+ return {
10
+ destroy: () => {
11
+ const client = extension.getClient(extension.mainLang);
12
+ if (this.listener && client) {
13
+ client.removeEventListener('textDocument/publishDiagnostics', this.listener);
14
+ }
15
+ if (this.listenerDisconnect && client) {
16
+ client.removeEventListener('close', this.listenerDisconnect);
17
+ }
18
+ if (this.changeListener) {
19
+ extension.getEditor().removeEventListener('change', this.changeListener);
20
+ }
21
+ },
22
+ };
23
+ },
24
+ state: {
25
+ init() {
26
+ return {
27
+ diagnostics: [],
28
+ };
29
+ },
30
+ apply(tr, prev, oldState, newState) {
31
+ const next = { ...prev };
32
+ const meta = tr.getMeta(DiagnosticPluginKey);
33
+ if (meta?.diagnostics) {
34
+ next.diagnostics = meta.diagnostics;
35
+ }
36
+ if (meta?.mapper) {
37
+ next.mapper = meta.mapper;
38
+ }
39
+ return next;
40
+ },
41
+ },
42
+ props: {
43
+ decorations(state) {
44
+ const decorations = [];
45
+ const pluginState = this.getState(state);
46
+ if (pluginState) {
47
+ const { diagnostics, mapper } = pluginState;
48
+ if (mapper) {
49
+ for (const diag of diagnostics) {
50
+ const from = mapper.fromLineChar(diag.range.start.line, diag.range.start.character);
51
+ const end = mapper.fromLineChar(diag.range.end.line, diag.range.end.character);
52
+ if (from > -1 && end > -1) {
53
+ const decoration = Decoration.inline(from, end, { class: 'kb-lsp__error', title: diag.message });
54
+ decorations.push(decoration);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ return DecorationSet.create(state.doc, decorations);
60
+ },
61
+ },
62
+ });
63
+ Object.defineProperty(this, "diagListener", {
64
+ enumerable: true,
65
+ configurable: true,
66
+ writable: true,
67
+ value: void 0
68
+ });
69
+ Object.defineProperty(this, "listenerDisconnect", {
70
+ enumerable: true,
71
+ configurable: true,
72
+ writable: true,
73
+ value: void 0
74
+ });
75
+ Object.defineProperty(this, "listenerChange", {
76
+ enumerable: true,
77
+ configurable: true,
78
+ writable: true,
79
+ value: void 0
80
+ });
81
+ let lastDiag = 0;
82
+ const editor = extension.getEditor();
83
+ const uri = editor.config.uri;
84
+ if (uri) {
85
+ const client = extension.getClient(extension.mainLang);
86
+ this.diagListener = (event) => {
87
+ const detail = event.detail;
88
+ if (detail.params.uri !== uri) {
89
+ return;
90
+ }
91
+ event.preventDefault();
92
+ lastDiag = +Date();
93
+ if (client) {
94
+ const file = client.workspace.getFile(uri);
95
+ if (file) {
96
+ const { mapper } = file;
97
+ const tr = editor.view.state.tr.setMeta(DiagnosticPluginKey, {
98
+ diagnostics: detail.params.diagnostics,
99
+ mapper,
100
+ });
101
+ editor.view.dispatch(tr);
102
+ }
103
+ }
104
+ };
105
+ if (client) {
106
+ client.addEventListener('textDocument/publishDiagnostics', this.diagListener);
107
+ }
108
+ this.listenerDisconnect = (event) => {
109
+ const tr = editor.view.state.tr.setMeta(DiagnosticPluginKey, {
110
+ diagnostics: [],
111
+ mapper: undefined,
112
+ });
113
+ editor.view.dispatch(tr);
114
+ };
115
+ if (client) {
116
+ client.addEventListener('close', this.listenerDisconnect);
117
+ }
118
+ this.listenerChange = (event) => {
119
+ if (lastDiag === 0 && +Date() - lastDiag > 10_1000) {
120
+ return;
121
+ }
122
+ const tr = editor.view.state.tr.setMeta(DiagnosticPluginKey, {
123
+ diagnostics: [],
124
+ mapper: undefined,
125
+ });
126
+ editor.view.dispatch(tr);
127
+ };
128
+ // extension.getEditor().addEventListener('changed', this.listenerChange);
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,25 @@
1
+ import { Plugin } from 'prosemirror-state';
2
+ import { Extension } from '../../editor/src/mod.js';
3
+ import { type ExtensionMarkdown } from '../../extension-markdown/src/ExtensionMarkdown.js';
4
+ import { type ExtensionAutocomplete } from '../../extension-autocomplete/src/mod.js';
5
+ import { LSPClient, Transport } from './LSPClient.js';
6
+ import { LspSource } from './workspace.js';
7
+ export type LspTransportGetter = (lang: string) => Transport | undefined;
8
+ export interface LspConfig {
9
+ getLspTransport: LspTransportGetter;
10
+ }
11
+ export declare class ExtensionLsp extends Extension {
12
+ protected config: LspConfig;
13
+ name: string;
14
+ clients: Record<string, LSPClient>;
15
+ uri: string | undefined;
16
+ extensionMarkdown: ExtensionMarkdown;
17
+ extensionAutocomplete: ExtensionAutocomplete;
18
+ mainLang: string;
19
+ source: LspSource;
20
+ constructor(config: LspConfig);
21
+ getProseMirrorPlugins(): Plugin[];
22
+ created(): void;
23
+ getClient(lang: string): LSPClient | undefined;
24
+ }
25
+ //# sourceMappingURL=ExtensionLsp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionLsp.d.ts","sourceRoot":"","sources":["../../../src/extension-lsp/src/ExtensionLsp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,mDAAmD,CAAC;AAC3F,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAGrF,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAItD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;AAEzE,MAAM,WAAW,SAAS;IACxB,eAAe,EAAE,kBAAkB,CAAC;CACrC;AAED,qBAAa,YAAa,SAAQ,SAAS;cASV,MAAM,EAAE,SAAS;IARhD,IAAI,SAAS;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAM;IACxC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,iBAAiB,EAAG,iBAAiB,CAAC;IACtC,qBAAqB,EAAG,qBAAqB,CAAC;IAC9C,QAAQ,EAAE,MAAM,CAAc;IAC9B,MAAM,EAAG,SAAS,CAAC;gBAEY,MAAM,EAAE,SAAS;IAIvC,qBAAqB,IAAI,MAAM,EAAE;IAWjC,OAAO;IA6DhB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAW/C"}