duckfn-docs-kit 0.3.0 → 0.4.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.
package/src/sql/sql.css CHANGED
@@ -237,11 +237,13 @@ dfk-sql:not(:defined) {
237
237
 
238
238
  /* --- Icon buttons and their tooltips ------------------------------------- */
239
239
 
240
- /* The same rules (and the `[data-tip]` tooltip below) are declared in
241
- `DfkSql.css`, because the buttons are split across the shadow boundary: the
242
- code-block actions live in the shadow tree, the fullscreen toggle lives in
243
- this light-DOM tab strip. Keep the two copies in sync. */
244
- .dfk-sql-icon-button {
240
+ /* The class names are written by the shared `IconButton` widget
241
+ (`src/IconButton.ts`). The same rules (and the `[data-tip]` tooltip below) are
242
+ declared in `DfkSql.css` and `DfkMermaid.css`, because the buttons are split
243
+ across shadow boundaries: the code-block actions live in `<dfk-sql>`'s tree,
244
+ a diagram's cluster in `<dfk-mermaid>`'s, and the fullscreen toggle in this
245
+ light-DOM tab strip. Keep the copies in sync. */
246
+ .dfk-icon-button {
245
247
  position: relative;
246
248
  display: inline-flex;
247
249
  align-items: center;
@@ -257,27 +259,27 @@ dfk-sql:not(:defined) {
257
259
  transition: background 0.12s ease, color 0.12s ease;
258
260
  }
259
261
 
260
- .dfk-sql-icon-button:hover:not(:disabled),
261
- .dfk-sql-icon-button:focus-visible {
262
+ .dfk-icon-button:hover:not(:disabled),
263
+ .dfk-icon-button:focus-visible {
262
264
  background: var(--ifm-color-emphasis-200, #e6e6e6);
263
265
  color: var(--ifm-color-primary, #14459b);
264
266
  }
265
267
 
266
- .dfk-sql-icon-button:disabled {
268
+ .dfk-icon-button:disabled {
267
269
  opacity: 0.45;
268
270
  cursor: progress;
269
271
  }
270
272
 
271
- .dfk-sql-icon-button[hidden] {
273
+ .dfk-icon-button[hidden] {
272
274
  display: none;
273
275
  }
274
276
 
275
277
  /* A sticky state, e.g. the wrap toggle while wrapping is on. */
276
- .dfk-sql-icon-on {
278
+ .dfk-icon-on {
277
279
  color: var(--ifm-color-primary, #14459b);
278
280
  }
279
281
 
280
- .dfk-sql-icon {
282
+ .dfk-icon {
281
283
  font-size: 1rem;
282
284
  }
283
285
 
@@ -1,16 +0,0 @@
1
- /**
2
- * The CodeMirror 6 editor that *is* the code view of a runnable SQL block.
3
- *
4
- * Every CodeMirror module arrives through dynamic `import()` inside
5
- * {@link mountSqlEditor}: a page full of SQL examples pays nothing for the
6
- * editor on its critical path, and Docusaurus' Node prerender never evaluates
7
- * any of it.
8
- */
9
- export interface SqlEditor {
10
- getValue(): string;
11
- setValue(value: string): void;
12
- /** Soft-wraps long lines, or stops wrapping them (the block's wrap toggle). */
13
- setWrap(wrapped: boolean): void;
14
- destroy(): void;
15
- }
16
- export declare function mountSqlEditor(container: HTMLElement, value: string, onChange: (value: string) => void): Promise<SqlEditor>;
package/src/sql/editor.ts DELETED
@@ -1,75 +0,0 @@
1
- /**
2
- * The CodeMirror 6 editor that *is* the code view of a runnable SQL block.
3
- *
4
- * Every CodeMirror module arrives through dynamic `import()` inside
5
- * {@link mountSqlEditor}: a page full of SQL examples pays nothing for the
6
- * editor on its critical path, and Docusaurus' Node prerender never evaluates
7
- * any of it.
8
- */
9
-
10
- export interface SqlEditor {
11
- getValue(): string;
12
- setValue(value: string): void;
13
- /** Soft-wraps long lines, or stops wrapping them (the block's wrap toggle). */
14
- setWrap(wrapped: boolean): void;
15
- destroy(): void;
16
- }
17
-
18
- export async function mountSqlEditor(
19
- container: HTMLElement,
20
- value: string,
21
- onChange: (value: string) => void,
22
- ): Promise<SqlEditor> {
23
- const [
24
- {basicSetup},
25
- {sql},
26
- {EditorView, keymap},
27
- {defaultKeymap, historyKeymap},
28
- {Compartment},
29
- ] = await Promise.all([
30
- import('codemirror'),
31
- import('@codemirror/lang-sql'),
32
- import('@codemirror/view'),
33
- import('@codemirror/commands'),
34
- import('@codemirror/state'),
35
- ]);
36
-
37
- // Wrapping is toggled from the outside, and reconfiguring it must not disturb
38
- // the document or the undo history — that is exactly what a compartment is
39
- // for, so the extension is swapped in place rather than rebuilt.
40
- const wrap = new Compartment();
41
-
42
- const view = new EditorView({
43
- doc: value,
44
- extensions: [
45
- basicSetup,
46
- sql(),
47
- keymap.of([...defaultKeymap, ...historyKeymap]),
48
- wrap.of([]),
49
- EditorView.updateListener.of((update) => {
50
- if (update.docChanged) {
51
- onChange(update.state.doc.toString());
52
- }
53
- }),
54
- ],
55
- parent: container,
56
- // `root` is left to CodeMirror's own `getRoot(container)`. The container sits
57
- // in `<dfk-sql>`'s shadow root, so style-mod mounts the base theme into that
58
- // same shadow root — exactly where the `.cm-*` rules are needed. Pinning it
59
- // to `document` would put them outside the editor's tree instead, where a
60
- // shadow boundary stops them.
61
- });
62
-
63
- return {
64
- getValue: () => view.state.doc.toString(),
65
- setValue: (next: string) =>
66
- view.dispatch({
67
- changes: {from: 0, to: view.state.doc.length, insert: next},
68
- }),
69
- setWrap: (wrapped: boolean) =>
70
- view.dispatch({
71
- effects: wrap.reconfigure(wrapped ? EditorView.lineWrapping : []),
72
- }),
73
- destroy: () => view.destroy(),
74
- };
75
- }