@dineug/erd-editor 3.9.1 → 3.9.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.
package/README.md CHANGED
@@ -160,6 +160,24 @@ erd-editor {
160
160
  | `change` | The document changed. Debounced, and never fired while `readonly`. Read `editor.value`. |
161
161
  | `changePresetTheme` | The theme was changed from inside the editor. `event.detail` carries the new options. |
162
162
 
163
+ ## Key bindings
164
+
165
+ `createKeyBindingMap()` returns the shortcuts an editor listens for until `setKeyBindingMap`
166
+ changes them, as a new map on every call. Each is a [tinykeys](https://github.com/jamiebuilds/tinykeys)
167
+ chord that names its key by `KeyboardEvent.code`, where `$mod` is Cmd on macOS and Ctrl elsewhere.
168
+
169
+ ```js
170
+ import { createKeyBindingMap } from '@dineug/erd-editor';
171
+
172
+ const shortcuts = Object.values(createKeyBindingMap())
173
+ .flat()
174
+ .map(({ shortcut }) => shortcut); // '$mod+KeyK', 'Alt+Enter', ...
175
+ ```
176
+
177
+ The editor listens on its own element, so a host that takes keys before the page does, with
178
+ global hotkeys or a capture-phase `keydown` listener, has to let these through while the editor
179
+ is focused. The `KeyBindingMap`, `KeyBindingName` and `ShortcutOption` types come with it.
180
+
163
181
  ## Syntax highlighting
164
182
 
165
183
  The SQL and code-generation panels are highlighted by [Shiki](https://shiki.style), in a shared
@@ -1,34 +1,34 @@
1
- import { Li as e, Tn as t, Zn as n, b as r, c as i, g as a, m as o, rn as s, t as c, tt as l, ya as u } from "../store-hooks-DuNN9ZKu.js";
2
- import { n as d, t as f } from "../schemaGCService-_8A8Oh9Q.js";
1
+ import { Ii as e, Xn as t, c as n, et as r, h as i, nn as a, p as o, t as s, va as c, wn as l, y as u } from "../store-hooks-DuzDVhPy.js";
2
+ import { n as d, t as f } from "../schemaGCService-BagQ1wfF.js";
3
3
  import { isEmpty as p } from "es-toolkit/compat";
4
4
  import { omit as m } from "es-toolkit";
5
5
  import { Observable as h, Subject as g, debounceTime as _, map as v } from "rxjs";
6
6
  //#region src/engine/replication-store.ts
7
7
  var y = { change: "change" };
8
8
  function b(b) {
9
- let x = /* @__PURE__ */ new Set(), S = a(b), C = i(S, !1);
10
- C.dispatchSync(t({
9
+ let x = /* @__PURE__ */ new Set(), S = i(b), C = n(S, !1);
10
+ C.dispatchSync(l({
11
11
  width: 0,
12
12
  height: 0
13
13
  }));
14
- let w = c(C), T = new g(), E = new h((e) => C.subscribe((t) => e.next(t))).pipe(o(r), _(200)), D = /* @__PURE__ */ new Set(), O = new f(), k = (e) => (D.has(e) || D.add(e), () => {
14
+ let w = s(C), T = new g(), E = new h((e) => C.subscribe((t) => e.next(t))).pipe(o(u), _(200)), D = /* @__PURE__ */ new Set(), O = new f(), k = (e) => (D.has(e) || D.add(e), () => {
15
15
  D.delete(e);
16
16
  }), A = (e, t) => {
17
17
  D.forEach((n) => {
18
18
  let r = Reflect.get(n, e);
19
- s(r, t);
19
+ a(r, t);
20
20
  });
21
- }, j = (t) => {
22
- let r = e(t);
23
- C.dispatchSync(l(p(r) ? "{}" : r)), O.run(u(C.state)).then((e) => {
24
- (e.tableIds.length || e.tableColumnIds.length || e.relationshipIds.length || e.indexIds.length || e.indexColumnIds.length || e.memoIds.length) && (d(C.state, e), C.dispatchSync(n()));
21
+ }, j = (n) => {
22
+ let i = e(n);
23
+ C.dispatchSync(r(p(i) ? "{}" : i)), O.run(c(C.state)).then((e) => {
24
+ (e.tableIds.length || e.tableColumnIds.length || e.relationshipIds.length || e.indexIds.length || e.indexColumnIds.length || e.memoIds.length) && (d(C.state, e), C.dispatchSync(t()));
25
25
  });
26
26
  }, M = (e) => {
27
27
  T.next([e].flat());
28
28
  };
29
- return x.add(E.subscribe(() => A(y.change, void 0))).add(T.pipe(o(r), v((e) => e.map((e) => m(e, ["tags"])))).subscribe(C.dispatchSync)), Object.freeze({
29
+ return x.add(E.subscribe(() => A(y.change, void 0))).add(T.pipe(o(u), v((e) => e.map((e) => m(e, ["tags"])))).subscribe(C.dispatchSync)), Object.freeze({
30
30
  get value() {
31
- return u(C.state);
31
+ return c(C.state);
32
32
  },
33
33
  on: k,
34
34
  setInitialValue: j,
@@ -6,4 +6,10 @@ import { StreamBufferOperator } from './groupByStreamActions';
6
6
  * pending emits nothing and an extra tick is harmless.
7
7
  */
8
8
  export declare const flushOnNotifier: (notifier$: Observable<unknown>) => StreamBufferOperator;
9
+ /**
10
+ * Closes a stream buffer after groupByStreamActions' 200 ms quiet period, or
11
+ * at once when the notifier fires: the editor keeps its timing, and a host
12
+ * can still send what is held before it lets the store go.
13
+ */
14
+ export declare const quietPeriodOrNotifier: (notifier$: Observable<unknown>, quietMs?: number) => StreamBufferOperator;
9
15
  //# sourceMappingURL=flushOnNotifier.d.ts.map
@@ -8,8 +8,8 @@ export type SharedStore = {
8
8
  dispatchSync: (actions: Array<AnyAction> | AnyAction) => void;
9
9
  subscribe: (fn: (value: AnyAction[]) => void) => Unsubscribe;
10
10
  /**
11
- * Sends the stream groups still held back from the peers, now. A no-op
12
- * unless the store was created with manualStreamFlush.
11
+ * Sends the stream groups still held back from the peers, now, rather than
12
+ * after their quiet period: what a host calls before it lets a store go.
13
13
  */
14
14
  flushStreamBuffers: () => void;
15
15
  destroy: () => void;