@dxos/react-ui-editor 0.4.8-main.7d8f6a4 → 0.4.8-main.7ef1486

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.
@@ -24,7 +24,7 @@ var translations_default = [
24
24
  ];
25
25
 
26
26
  // packages/ui/react-ui-editor/src/index.ts
27
- import { keymap as keymap10 } from "@codemirror/view";
27
+ import { keymap as keymap11 } from "@codemirror/view";
28
28
  import { tags as tags2 } from "@lezer/highlight";
29
29
  import { TextKind } from "@dxos/protocols/proto/dxos/echo/model/text";
30
30
  import { Doc, YText, YXmlFragment } from "@dxos/text-model";
@@ -1952,11 +1952,12 @@ var dnd = () => {
1952
1952
  };
1953
1953
 
1954
1954
  // packages/ui/react-ui-editor/src/extensions/factories.ts
1955
- import { closeBrackets } from "@codemirror/autocomplete";
1956
- import { history } from "@codemirror/commands";
1955
+ import { closeBrackets, closeBracketsKeymap } from "@codemirror/autocomplete";
1956
+ import { history, historyKeymap, indentWithTab, standardKeymap } from "@codemirror/commands";
1957
1957
  import { bracketMatching } from "@codemirror/language";
1958
+ import { searchKeymap } from "@codemirror/search";
1958
1959
  import { EditorState } from "@codemirror/state";
1959
- import { EditorView as EditorView10, crosshairCursor, drawSelection, dropCursor, highlightActiveLine, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
1960
+ import { EditorView as EditorView10, crosshairCursor, drawSelection, dropCursor, highlightActiveLine, highlightSpecialChars, keymap as keymap5, lineNumbers, placeholder, scrollPastEnd } from "@codemirror/view";
1960
1961
  import defaultsDeep2 from "lodash.defaultsdeep";
1961
1962
  import { generateName } from "@dxos/display-name";
1962
1963
  import { log as log7 } from "@dxos/log";
@@ -2164,41 +2165,60 @@ var defaultTheme = {
2164
2165
  * </div>
2165
2166
  * </div
2166
2167
  */
2167
- ".cm-panels": {
2168
- border: `1px solid ${get3(tokens, "extend.colors.neutral.200")}`
2169
- },
2168
+ ".cm-panels": {},
2170
2169
  ".cm-panel": {
2171
- background: get3(tokens, "extend.colors.neutral.50"),
2172
2170
  fontFamily: get3(tokens, "fontFamily.body", []).join(",")
2173
2171
  },
2172
+ ".cm-panel input[type=checkbox]": {
2173
+ marginRight: "0.4rem !important"
2174
+ },
2175
+ "&light .cm-panel": {
2176
+ background: get3(tokens, "extend.colors.neutral.50")
2177
+ },
2178
+ "&dark .cm-panel": {
2179
+ background: get3(tokens, "extend.colors.neutral.850")
2180
+ },
2174
2181
  ".cm-button": {
2175
2182
  margin: "4px",
2176
2183
  fontFamily: get3(tokens, "fontFamily.body", []).join(","),
2177
- background: get3(tokens, "extend.colors.neutral.100"),
2178
2184
  backgroundImage: "none",
2179
2185
  border: "none",
2186
+ "&:active": {
2187
+ backgroundImage: "none"
2188
+ }
2189
+ },
2190
+ "&light .cm-button": {
2191
+ background: get3(tokens, "extend.colors.neutral.100"),
2180
2192
  "&:hover": {
2181
2193
  background: get3(tokens, "extend.colors.neutral.200")
2182
2194
  },
2183
2195
  "&:active": {
2184
- background: get3(tokens, "extend.colors.neutral.300"),
2185
- backgroundImage: "none"
2196
+ background: get3(tokens, "extend.colors.neutral.300")
2186
2197
  }
2187
2198
  },
2188
- ".cm-panel input[type=checkbox]": {
2189
- marginRight: "0.4rem !important"
2199
+ "&dark .cm-button": {
2200
+ background: get3(tokens, "extend.colors.neutral.800"),
2201
+ "&:hover": {
2202
+ background: get3(tokens, "extend.colors.neutral.700")
2203
+ },
2204
+ "&:active": {
2205
+ background: get3(tokens, "extend.colors.neutral.600")
2206
+ }
2190
2207
  }
2191
2208
  };
2192
2209
 
2193
2210
  // packages/ui/react-ui-editor/src/extensions/factories.ts
2194
2211
  var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-editor/src/extensions/factories.ts";
2195
2212
  var defaults = {
2213
+ allowMultipleSelections: true,
2196
2214
  bracketMatching: true,
2197
2215
  closeBrackets: true,
2198
2216
  drawSelection: true,
2199
2217
  editable: true,
2200
2218
  history: true,
2201
- lineWrapping: true
2219
+ standardKeymap: true,
2220
+ lineWrapping: true,
2221
+ search: true
2202
2222
  };
2203
2223
  var createBasicExtensions = (_props) => {
2204
2224
  const props = defaultsDeep2({}, _props, defaults);
@@ -2207,7 +2227,7 @@ var createBasicExtensions = (_props) => {
2207
2227
  EditorView10.exceptionSink.of((err) => {
2208
2228
  log7.catch(err, void 0, {
2209
2229
  F: __dxlog_file9,
2210
- L: 78,
2230
+ L: 85,
2211
2231
  S: void 0,
2212
2232
  C: (f, a) => f(...a)
2213
2233
  });
@@ -2219,6 +2239,7 @@ var createBasicExtensions = (_props) => {
2219
2239
  props.dropCursor && dropCursor(),
2220
2240
  props.drawSelection && drawSelection(),
2221
2241
  props.highlightActiveLine && highlightActiveLine(),
2242
+ highlightSpecialChars(),
2222
2243
  props.history && history(),
2223
2244
  props.lineNumbers && lineNumbers(),
2224
2245
  props.lineWrapping && EditorView10.lineWrapping,
@@ -2228,7 +2249,22 @@ var createBasicExtensions = (_props) => {
2228
2249
  EditorView10.editable.of(false)
2229
2250
  ],
2230
2251
  props.scrollPastEnd && scrollPastEnd(),
2231
- props.tabSize && EditorState.tabSize.of(props.tabSize)
2252
+ props.tabSize && EditorState.tabSize.of(props.tabSize),
2253
+ // https://codemirror.net/docs/ref/#view.KeyBinding
2254
+ keymap5.of([
2255
+ // https://codemirror.net/docs/ref/#commands.standardKeymap
2256
+ ...props.standardKeymap ? standardKeymap : [],
2257
+ // https://codemirror.net/docs/ref/#commands.indentWithTab
2258
+ ...props.indentWithTab ? [
2259
+ indentWithTab
2260
+ ] : [],
2261
+ // https://codemirror.net/docs/ref/#autocomplete.closeBracketsKeymap
2262
+ ...props.closeBrackets ? closeBracketsKeymap : [],
2263
+ // https://codemirror.net/docs/ref/#commands.historyKeymap
2264
+ ...props.history ? historyKeymap : [],
2265
+ // https://codemirror.net/docs/ref/#search.searchKeymap
2266
+ ...props.search ? searchKeymap : []
2267
+ ].filter(isNotFalsy2))
2232
2268
  ].filter(isNotFalsy2);
2233
2269
  };
2234
2270
  var defaultSlots = {
@@ -2287,14 +2323,14 @@ var listener = ({ onFocus, onChange }) => {
2287
2323
  };
2288
2324
 
2289
2325
  // packages/ui/react-ui-editor/src/extensions/markdown/bundle.ts
2290
- import { closeBracketsKeymap } from "@codemirror/autocomplete";
2291
- import { historyKeymap, indentWithTab, standardKeymap } from "@codemirror/commands";
2326
+ import { completionKeymap as completionKeymap2 } from "@codemirror/autocomplete";
2327
+ import { defaultKeymap, indentWithTab as indentWithTab2 } from "@codemirror/commands";
2292
2328
  import { markdownLanguage as markdownLanguage3, markdown } from "@codemirror/lang-markdown";
2293
2329
  import { defaultHighlightStyle, syntaxHighlighting } from "@codemirror/language";
2294
2330
  import { languages } from "@codemirror/language-data";
2295
- import { searchKeymap } from "@codemirror/search";
2331
+ import { lintKeymap } from "@codemirror/lint";
2296
2332
  import { oneDarkHighlightStyle } from "@codemirror/theme-one-dark";
2297
- import { keymap as keymap5 } from "@codemirror/view";
2333
+ import { keymap as keymap6 } from "@codemirror/view";
2298
2334
 
2299
2335
  // packages/ui/react-ui-editor/src/extensions/markdown/highlight.ts
2300
2336
  import { markdownLanguage as markdownLanguage2 } from "@codemirror/lang-markdown";
@@ -2509,17 +2545,13 @@ var createMarkdownExtensions = ({ themeMode } = {}) => {
2509
2545
  themeMode === "dark" ? syntaxHighlighting(oneDarkHighlightStyle) : syntaxHighlighting(defaultHighlightStyle),
2510
2546
  // Custom styles.
2511
2547
  syntaxHighlighting(markdownHighlightStyle()),
2512
- keymap5.of([
2548
+ keymap6.of([
2513
2549
  // https://codemirror.net/docs/ref/#commands.indentWithTab
2514
- indentWithTab,
2515
- // https://codemirror.net/docs/ref/#autocomplete.closeBracketsKeymap
2516
- ...closeBracketsKeymap,
2517
- // https://codemirror.net/docs/ref/#commands.historyKeymap
2518
- ...historyKeymap,
2519
- // https://codemirror.net/docs/ref/#search.searchKeymap
2520
- ...searchKeymap,
2521
- // https://codemirror.net/docs/ref/#commands.standardKeymap
2522
- ...standardKeymap
2550
+ indentWithTab2,
2551
+ // https://codemirror.net/docs/ref/#commands.defaultKeymap
2552
+ ...defaultKeymap,
2553
+ ...completionKeymap2,
2554
+ ...lintKeymap
2523
2555
  ])
2524
2556
  ];
2525
2557
  };
@@ -2796,7 +2828,7 @@ var formattingStyles = EditorView12.baseTheme({
2796
2828
  import { snippet } from "@codemirror/autocomplete";
2797
2829
  import { syntaxTree as syntaxTree2 } from "@codemirror/language";
2798
2830
  import { EditorSelection } from "@codemirror/state";
2799
- import { EditorView as EditorView13, keymap as keymap6 } from "@codemirror/view";
2831
+ import { EditorView as EditorView13, keymap as keymap7 } from "@codemirror/view";
2800
2832
  import { useMemo, useState } from "react";
2801
2833
  var formattingEquals = (a, b) => a.blockType === b.blockType && a.strong === b.strong && a.emphasis === b.emphasis && a.strikethrough === b.strikethrough && a.code === b.code && a.link === b.link && a.listStyle === b.listStyle && a.blockQuote === b.blockQuote;
2802
2834
  var Inline;
@@ -3668,7 +3700,7 @@ var toggleCodeblock = (target) => {
3668
3700
  };
3669
3701
  var formattingKeymap = (options = {}) => {
3670
3702
  return [
3671
- keymap6.of([
3703
+ keymap7.of([
3672
3704
  {
3673
3705
  key: "meta-b",
3674
3706
  run: toggleStrong
@@ -4142,21 +4174,30 @@ var mention = ({ onSearch }) => {
4142
4174
 
4143
4175
  // packages/ui/react-ui-editor/src/extensions/modes.ts
4144
4176
  import { Facet as Facet6 } from "@codemirror/state";
4145
- import { keymap as keymap7 } from "@codemirror/view";
4177
+ import { keymap as keymap8 } from "@codemirror/view";
4146
4178
  import { vim } from "@replit/codemirror-vim";
4179
+ import { vscodeKeymap } from "@replit/codemirror-vscode-keymap";
4147
4180
  var focusEvent = "focus.container";
4148
4181
  var editorMode = Facet6.define({
4149
4182
  combine: (modes) => modes[0] ?? {}
4150
4183
  });
4151
4184
  var EditorModes = {
4152
4185
  default: [],
4186
+ vscode: [
4187
+ // https://github.com/replit/codemirror-vscode-keymap
4188
+ editorMode.of({
4189
+ type: "vscode"
4190
+ }),
4191
+ keymap8.of(vscodeKeymap)
4192
+ ],
4153
4193
  vim: [
4194
+ // https://github.com/replit/codemirror-vim
4154
4195
  vim(),
4155
4196
  editorMode.of({
4156
4197
  type: "vim",
4157
4198
  noTabster: true
4158
4199
  }),
4159
- keymap7.of([
4200
+ keymap8.of([
4160
4201
  {
4161
4202
  key: "Alt-Escape",
4162
4203
  run: (view) => {
@@ -4172,7 +4213,7 @@ var EditorModes = {
4172
4213
 
4173
4214
  // packages/ui/react-ui-editor/src/extensions/state.ts
4174
4215
  import { Transaction as Transaction2 } from "@codemirror/state";
4175
- import { EditorView as EditorView16, keymap as keymap8 } from "@codemirror/view";
4216
+ import { EditorView as EditorView16, keymap as keymap9 } from "@codemirror/view";
4176
4217
  import { debounce as debounce2 } from "@dxos/async";
4177
4218
  import { invariant as invariant4 } from "@dxos/invariant";
4178
4219
  import { isNotFalsy as isNotFalsy3 } from "@dxos/util";
@@ -4236,7 +4277,7 @@ var state = ({ getState, setState } = {}) => {
4236
4277
  }
4237
4278
  }
4238
4279
  }),
4239
- getState && keymap8.of([
4280
+ getState && keymap9.of([
4240
4281
  {
4241
4282
  key: "ctrl-r",
4242
4283
  run: (view) => {
@@ -4258,7 +4299,7 @@ var state = ({ getState, setState } = {}) => {
4258
4299
  };
4259
4300
 
4260
4301
  // packages/ui/react-ui-editor/src/extensions/typewriter.ts
4261
- import { keymap as keymap9 } from "@codemirror/view";
4302
+ import { keymap as keymap10 } from "@codemirror/view";
4262
4303
  var defaultItems = [
4263
4304
  "hello world!",
4264
4305
  "this is a test.",
@@ -4268,7 +4309,7 @@ var typewriter = ({ delay = 75, items = defaultItems } = {}) => {
4268
4309
  let t;
4269
4310
  let idx = 0;
4270
4311
  return [
4271
- keymap9.of([
4312
+ keymap10.of([
4272
4313
  {
4273
4314
  // Reset.
4274
4315
  key: "alt-meta-'",
@@ -4975,7 +5016,7 @@ export {
4975
5016
  image,
4976
5017
  imageUpload,
4977
5018
  insertTable,
4978
- keymap10 as keymap,
5019
+ keymap11 as keymap,
4979
5020
  linkTooltip,
4980
5021
  listener,
4981
5022
  localStorageStateStoreAdapter,