@sciflow/editor-start 0.0.1-beta → 0.0.1-beta2

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 (43) hide show
  1. package/README.md +34 -0
  2. package/dist/bundle/sciflow-editor.css +1 -1
  3. package/dist/bundle/sciflow-editor.js +7643 -5555
  4. package/dist/index.d.ts +1 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/lib/citation-source-adapter.d.ts +22 -2
  8. package/dist/lib/citation-source-adapter.d.ts.map +1 -1
  9. package/dist/lib/citation-source-adapter.js +104 -48
  10. package/dist/lib/drag-preview.d.ts +13 -0
  11. package/dist/lib/drag-preview.d.ts.map +1 -0
  12. package/dist/lib/drag-preview.js +36 -0
  13. package/dist/lib/editor-element.d.ts +16 -1
  14. package/dist/lib/editor-element.d.ts.map +1 -1
  15. package/dist/lib/editor-element.js +107 -30
  16. package/dist/lib/format-bar.d.ts +7 -0
  17. package/dist/lib/format-bar.d.ts.map +1 -1
  18. package/dist/lib/format-bar.js +79 -10
  19. package/dist/lib/outline.d.ts +10 -5
  20. package/dist/lib/outline.d.ts.map +1 -1
  21. package/dist/lib/outline.js +112 -1
  22. package/dist/lib/reference-list.d.ts.map +1 -1
  23. package/dist/lib/reference-list.js +2 -0
  24. package/dist/lib/selection-editor.d.ts +67 -5
  25. package/dist/lib/selection-editor.d.ts.map +1 -1
  26. package/dist/lib/selection-editor.js +1060 -125
  27. package/dist/lib/selection-transform-registry.d.ts +16 -0
  28. package/dist/lib/selection-transform-registry.d.ts.map +1 -0
  29. package/dist/lib/selection-transform-registry.js +24 -0
  30. package/dist/lib/selection-ui-renderer.d.ts +21 -0
  31. package/dist/lib/selection-ui-renderer.d.ts.map +1 -0
  32. package/dist/lib/selection-ui-renderer.js +244 -0
  33. package/dist/lib/selection-widget-host.d.ts +67 -0
  34. package/dist/lib/selection-widget-host.d.ts.map +1 -0
  35. package/dist/lib/selection-widget-host.js +151 -0
  36. package/dist/lib/selection-widget-registry.d.ts +16 -0
  37. package/dist/lib/selection-widget-registry.d.ts.map +1 -0
  38. package/dist/lib/selection-widget-registry.js +30 -0
  39. package/dist/lib/test-fixtures/soak-documents.d.ts +13 -0
  40. package/dist/lib/test-fixtures/soak-documents.d.ts.map +1 -0
  41. package/dist/lib/test-fixtures/soak-documents.js +69 -0
  42. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  43. package/package.json +9 -5
@@ -56,6 +56,10 @@ export declare class SciFlowFormatBarElement extends LitElement {
56
56
  * command runner so the UI stays in sync with the currently loaded features.
57
57
  */
58
58
  protected render(): import("lit-html").TemplateResult<1>;
59
+ /**
60
+ * Render fixed toolbar commands that are not driven by metadata groups.
61
+ */
62
+ private renderFixedCommandButton;
59
63
  /**
60
64
  * Find the target editor element and attach listeners for selection changes.
61
65
  * This mirrors the wiring a framework component would perform in `useEffect`.
@@ -76,9 +80,12 @@ export declare class SciFlowFormatBarElement extends LitElement {
76
80
  private getActiveBlockStyle;
77
81
  /** Check if a style option can be executed against the current editor state. */
78
82
  private canUseStyleOption;
83
+ /** True if the current selection is inside a table (cell or header). */
84
+ private isSelectionInTable;
79
85
  /**
80
86
  * Render a set of command buttons that share the same metadata group.
81
87
  * Groups are sorted by each command's declared order so feature authors control layout.
88
+ * When onlyCommandNames is set, only those commands in the group are rendered.
82
89
  */
83
90
  private renderCommandGroup;
84
91
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"format-bar.d.ts","sourceRoot":"","sources":["../../src/lib/format-bar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAa,UAAU,EAAa,MAAM,KAAK,CAAC;AAKvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAoBhE;;;;;;;;;;;GAWG;AACH,qBACa,uBAAwB,SAAQ,UAAU;IACrD,oFAAoF;IAEpF,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAQ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;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAoB1B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuC3B;;OAEG;IACH,OAAO,CAAC,gBAAgB;CA2BzB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,mBAAmB,EAAE,uBAAuB,CAAC;KAC9C;CACF"}
@@ -89,6 +89,7 @@ let SciFlowFormatBarElement = class SciFlowFormatBarElement extends LitElement {
89
89
  const tableGroup = 'table';
90
90
  const primaryGroups = commandGroups.filter((group) => group !== tableGroup);
91
91
  const tableGroups = commandGroups.filter((group) => group === tableGroup);
92
+ const selectionInTable = this.isSelectionInTable();
92
93
  return html `
93
94
  <select
94
95
  class="style-select"
@@ -107,20 +108,60 @@ let SciFlowFormatBarElement = class SciFlowFormatBarElement extends LitElement {
107
108
  </option>
108
109
  `)}
109
110
  </select>
110
- <div class="command-rows">
111
- ${primaryGroups.length
112
- ? html `<div class="command-row">
113
- ${primaryGroups.map((group) => this.renderCommandGroup(runner, commandMetadata, group))}
114
- </div>`
111
+ <div class="history-commands" aria-label="History commands">
112
+ ${this.renderFixedCommandButton(runner, 'undo', 'undo', 'Undo', 'Undo last change')}
113
+ ${this.renderFixedCommandButton(runner, 'redo', 'redo', 'Redo', 'Redo last change')}
114
+ </div>
115
+ <div class=${classMap({ 'command-rows': true, 'command-rows--table-expanded': selectionInTable })}>
116
+ <div class="command-row command-row--primary">
117
+ ${primaryGroups.map((group) => this.renderCommandGroup(runner, commandMetadata, group))}
118
+ ${tableGroups.length && !selectionInTable
119
+ ? html `<span class="table-commands ${primaryGroups.length ? 'table-commands--with-separator' : ''}">
120
+ ${tableGroups.map((group) => this.renderCommandGroup(runner, commandMetadata, group, ['insertNativeTableFigure']))}
121
+ </span>`
115
122
  : null}
116
- ${tableGroups.length
117
- ? html `<div class="command-row table-row">
123
+ </div>
124
+ ${tableGroups.length && selectionInTable
125
+ ? html `<div class="command-row command-row--table table-tools-expanded">
118
126
  ${tableGroups.map((group) => this.renderCommandGroup(runner, commandMetadata, group))}
119
127
  </div>`
120
128
  : null}
121
129
  </div>
122
130
  `;
123
131
  }
132
+ /**
133
+ * Render fixed toolbar commands that are not driven by metadata groups.
134
+ */
135
+ renderFixedCommandButton(runner, commandName, icon, label, description) {
136
+ const command = runner?.commands?.[commandName];
137
+ if (typeof command !== 'function') {
138
+ return null;
139
+ }
140
+ const availability = runner?.available?.();
141
+ const canExecute = availability?.[commandName] ? availability[commandName]() : true;
142
+ const handleClick = () => {
143
+ if (!canExecute) {
144
+ return;
145
+ }
146
+ const result = command();
147
+ if (result) {
148
+ this.selectionVersion++;
149
+ this.requestUpdate();
150
+ }
151
+ };
152
+ return html `
153
+ <button
154
+ type="button"
155
+ aria-label=${label}
156
+ title=${description}
157
+ ?disabled=${!canExecute}
158
+ data-tooltip=${description}
159
+ @click=${handleClick}
160
+ >
161
+ <span class="material-symbols-rounded" aria-hidden="true">${icon}</span>
162
+ </button>
163
+ `;
164
+ }
124
165
  /**
125
166
  * Find the target editor element and attach listeners for selection changes.
126
167
  * This mirrors the wiring a framework component would perform in `useEffect`.
@@ -306,13 +347,41 @@ let SciFlowFormatBarElement = class SciFlowFormatBarElement extends LitElement {
306
347
  }
307
348
  return commands.setHeading?.(level) ?? false;
308
349
  }
350
+ /** True if the current selection is inside a table (cell or header). */
351
+ isSelectionInTable() {
352
+ const state = this.resolvedEditor?.editorView?.state;
353
+ if (!state) {
354
+ return false;
355
+ }
356
+ const { table, table_cell, table_header } = state.schema.nodes;
357
+ if (!table || !table_cell || !table_header) {
358
+ return false;
359
+ }
360
+ const { $from } = state.selection;
361
+ for (let d = $from.depth; d > 0; d--) {
362
+ const node = $from.node(d);
363
+ if (node.type === table || node.type === table_cell || node.type === table_header) {
364
+ return true;
365
+ }
366
+ }
367
+ return false;
368
+ }
309
369
  /**
310
370
  * Render a set of command buttons that share the same metadata group.
311
371
  * Groups are sorted by each command's declared order so feature authors control layout.
372
+ * When onlyCommandNames is set, only those commands in the group are rendered.
312
373
  */
313
- renderCommandGroup(runner, metadata, group) {
374
+ renderCommandGroup(runner, metadata, group, onlyCommandNames) {
314
375
  return Object.entries(metadata)
315
- .filter(([, meta]) => meta?.group === group && (meta.icon || meta.label))
376
+ .filter(([name, meta]) => {
377
+ if (meta?.group !== group || !(meta.icon || meta.label)) {
378
+ return false;
379
+ }
380
+ if (onlyCommandNames !== undefined && !onlyCommandNames.includes(name)) {
381
+ return false;
382
+ }
383
+ return true;
384
+ })
316
385
  .sort(([, a], [, b]) => (a?.order ?? 0) - (b?.order ?? 0))
317
386
  .map(([name, meta]) => this.renderCommandButton(name, meta, runner));
318
387
  }
@@ -345,7 +414,7 @@ let SciFlowFormatBarElement = class SciFlowFormatBarElement extends LitElement {
345
414
  class=${classMap({ active: isActive })}
346
415
  aria-label=${meta.label ?? name}
347
416
  title=${meta.description ?? meta.label ?? name}
348
- ?aria-pressed=${meta.isActive ? (isActive ? 'true' : 'false') : undefined}
417
+ aria-pressed=${meta.isActive ? (isActive ? 'true' : 'false') : undefined}
349
418
  ?disabled=${!canExecute}
350
419
  data-tooltip=${meta.description ?? meta.label ?? name}
351
420
  @click=${handleClick}
@@ -13,16 +13,18 @@ export type OutlineCitation = {
13
13
  id: string | null;
14
14
  source: Array<Record<string, unknown>>;
15
15
  };
16
+ export type OutlineFigure = {
17
+ id: string | null;
18
+ text: string;
19
+ position: number | null;
20
+ end: number | null;
21
+ };
16
22
  export type DocumentOutline = {
17
23
  headings: OutlineHeading[];
18
24
  citations: OutlineCitation[];
25
+ figures: OutlineFigure[];
19
26
  };
20
27
  export type OutlineClickBehavior = 'none' | 'select' | 'scroll';
21
- /**
22
- * Collect heading and citation metadata from a SciFlow document snapshot.
23
- * When a ProseMirror document is available, positions and node boundaries are
24
- * included so navigation and selection syncing can be precise.
25
- */
26
28
  export declare function collectDocumentOutline(doc: SciFlowDocJSON | null | undefined, pmDoc?: ProsemirrorNode | null): DocumentOutline;
27
29
  /**
28
30
  * Helper used by the demo to expose outline data for debugging.
@@ -55,6 +57,7 @@ export declare class SciFlowOutlineElement extends LitElement {
55
57
  /** Custom label renderer for headings. Receives the heading and its index. */
56
58
  renderHeadingLabel?: (heading: OutlineHeading, index: number) => unknown;
57
59
  private headings;
60
+ private figures;
58
61
  private activeHeadingKey;
59
62
  private resolvedEditor;
60
63
  private selectionListener?;
@@ -69,6 +72,8 @@ export declare class SciFlowOutlineElement extends LitElement {
69
72
  protected updated(changedProperties: Map<string | number | symbol, unknown>): void;
70
73
  protected render(): import("lit-html").TemplateResult<1>;
71
74
  private renderHeadingItem;
75
+ private renderFigureItem;
76
+ private handleCrossReferenceDragStart;
72
77
  private handleHeadingKeydown;
73
78
  private handleHeadingClick;
74
79
  private resolveEditorReference;
@@ -1 +1 @@
1
- {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/lib/outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAsB,MAAM,KAAK,CAAC;AAGhE,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAGL,KAAK,cAAc,EAEpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAIhE,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,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;IAoBnC,OAAO,CAAC,oBAAoB;IAK5B,OAAO,CAAC,sBAAsB;IAI9B,OAAO,CAAC,qBAAqB;CAY9B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,qBAAqB,CAAC;KAC1C;CACF"}
@@ -3,6 +3,7 @@ import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
3
3
  import { customElement, property, state } from 'lit/decorators.js';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
5
  import { SourceField, } from '@sciflow/editor-core';
6
+ import { setTransparentDragImage } from './drag-preview.js';
6
7
  import outlineStyles from './outline.css?inline';
7
8
  import { applyThemeStylesToRoot, subscribeToSciFlowTheme } from './theme.js';
8
9
  const CLICK_BEHAVIORS = ['none', 'select', 'scroll'];
@@ -45,10 +46,39 @@ const parseLevelsFromAttribute = (value) => {
45
46
  * When a ProseMirror document is available, positions and node boundaries are
46
47
  * included so navigation and selection syncing can be precise.
47
48
  */
49
+ function figureLabel(node) {
50
+ const text = node.textContent?.trim();
51
+ if (text)
52
+ return text;
53
+ const alt = node.attrs?.alt;
54
+ if (typeof alt === 'string' && alt.trim())
55
+ return alt.trim();
56
+ const id = node.attrs?.id;
57
+ return typeof id === 'string' && id.trim() ? id : 'Figure';
58
+ }
59
+ function figureLabelFromJson(node) {
60
+ const alt = node?.attrs?.alt;
61
+ if (typeof alt === 'string' && alt.trim())
62
+ return alt.trim();
63
+ const content = node?.content ?? [];
64
+ for (const child of content) {
65
+ if (child?.type === 'caption' && Array.isArray(child.content)) {
66
+ const text = child.content
67
+ .map((c) => c?.content?.map((t) => t?.text ?? '').join('') ?? '')
68
+ .join('')
69
+ .trim();
70
+ if (text)
71
+ return text;
72
+ }
73
+ }
74
+ const id = node?.attrs?.id;
75
+ return typeof id === 'string' && id.trim() ? id : 'Figure';
76
+ }
48
77
  export function collectDocumentOutline(doc, pmDoc = null) {
49
78
  const outline = {
50
79
  headings: [],
51
80
  citations: [],
81
+ figures: [],
52
82
  };
53
83
  // Fast path: traverse the live ProseMirror document for accurate positions.
54
84
  if (pmDoc) {
@@ -68,6 +98,14 @@ export function collectDocumentOutline(doc, pmDoc = null) {
68
98
  source: SourceField.fromString(node.attrs?.source ?? null),
69
99
  });
70
100
  }
101
+ if (node.type.name === 'figure') {
102
+ outline.figures.push({
103
+ id: node.attrs?.id ?? null,
104
+ text: figureLabel(node),
105
+ position,
106
+ end: position + node.nodeSize,
107
+ });
108
+ }
71
109
  return true;
72
110
  });
73
111
  return outline;
@@ -96,6 +134,14 @@ export function collectDocumentOutline(doc, pmDoc = null) {
96
134
  source: SourceField.fromString(attrs.source ?? null),
97
135
  });
98
136
  }
137
+ if (type === 'figure') {
138
+ outline.figures.push({
139
+ id: attrs.id ?? null,
140
+ text: figureLabelFromJson(node),
141
+ position: null,
142
+ end: null,
143
+ });
144
+ }
99
145
  content.forEach((child) => walk(child));
100
146
  };
101
147
  walk(doc);
@@ -135,6 +181,7 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
135
181
  /** Filter the outline to specific heading levels (e.g., "1-3" or "1,2,3"). */
136
182
  this.levels = null;
137
183
  this.headings = [];
184
+ this.figures = [];
138
185
  this.activeHeadingKey = null;
139
186
  this.resolvedEditor = null;
140
187
  this.lastSelection = null;
@@ -169,7 +216,9 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
169
216
  }
170
217
  }
171
218
  render() {
172
- if (!this.headings.length) {
219
+ const hasHeadings = this.headings.length > 0;
220
+ const hasFigures = this.figures.length > 0;
221
+ if (!hasHeadings && !hasFigures) {
173
222
  return html `
174
223
  <ol class="outline-list" part="list">
175
224
  <li class="outline-placeholder" part="placeholder">${this.emptyText}</li>
@@ -179,6 +228,7 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
179
228
  return html `
180
229
  <ol class="outline-list" part="list">
181
230
  ${this.headings.map((heading, index) => this.renderHeadingItem(heading, index))}
231
+ ${this.figures.map((figure, index) => this.renderFigureItem(figure, index))}
182
232
  </ol>
183
233
  `;
184
234
  }
@@ -187,6 +237,7 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
187
237
  const isActive = this.activeHeadingKey === key;
188
238
  const clickable = this.clickBehavior !== 'none' && heading.position !== null && heading.position !== undefined;
189
239
  const label = this.renderHeadingLabel?.(heading, index) ?? heading.text?.trim() ?? 'Untitled section';
240
+ const draggable = Boolean(heading.id?.trim());
190
241
  return html `
191
242
  <li
192
243
  class=${classMap({
@@ -196,11 +247,14 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
196
247
  })}
197
248
  part=${`item${isActive ? ' item-active' : ''}`}
198
249
  data-level=${heading.level ?? ''}
250
+ data-outline-id=${heading.id ?? ''}
199
251
  role=${clickable ? 'button' : 'listitem'}
200
252
  tabindex=${clickable ? 0 : -1}
201
253
  aria-current=${isActive ? 'true' : 'false'}
254
+ draggable=${draggable ? 'true' : 'false'}
202
255
  @click=${clickable ? () => this.handleHeadingClick(heading, index) : undefined}
203
256
  @keydown=${clickable ? (event) => this.handleHeadingKeydown(event, heading, index) : undefined}
257
+ @dragstart=${draggable ? (e) => this.handleCrossReferenceDragStart(e, 'heading', heading.id, String(label ?? '')) : undefined}
204
258
  >
205
259
  <span class="outline-text" part="text">${label}</span>
206
260
  <span class="outline-meta" part="meta">
@@ -208,10 +262,63 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
208
262
  ${heading.id
209
263
  ? html `<code class="outline-id" part="id" aria-label=${`Heading id ${heading.id}`}>${heading.id}</code>`
210
264
  : nothing}
265
+ ${draggable ? html `<span class="outline-drag" aria-hidden="true">drag</span>` : nothing}
211
266
  </span>
212
267
  </li>
213
268
  `;
214
269
  }
270
+ renderFigureItem(figure, index) {
271
+ const id = figure.id?.trim();
272
+ const draggable = Boolean(id);
273
+ const label = figure.text?.trim() || (id ?? `Figure ${index + 1}`);
274
+ return html `
275
+ <li
276
+ class=${classMap({
277
+ 'outline-item': true,
278
+ 'outline-item--figure': true,
279
+ })}
280
+ part="item"
281
+ data-outline-id=${figure.id ?? ''}
282
+ role="listitem"
283
+ tabindex="-1"
284
+ draggable=${draggable ? 'true' : 'false'}
285
+ @dragstart=${draggable && id ? (e) => this.handleCrossReferenceDragStart(e, 'figure', id, label) : undefined}
286
+ >
287
+ <span class="outline-text" part="text">${label}</span>
288
+ <span class="outline-meta" part="meta">
289
+ ${id
290
+ ? html `<code class="outline-id" part="id" aria-label=${`Figure id ${id}`}>${id}</code>`
291
+ : nothing}
292
+ ${draggable && id ? html `<span class="outline-drag" aria-hidden="true">drag</span>` : nothing}
293
+ </span>
294
+ </li>
295
+ `;
296
+ }
297
+ handleCrossReferenceDragStart(event, refType, id, text) {
298
+ const transfer = event.dataTransfer;
299
+ if (!transfer)
300
+ return;
301
+ setTransparentDragImage(event, { opacity: 0.35, offsetY: 44, scale: 0.8 });
302
+ const href = `#${id}`;
303
+ transfer.setData('application/x-sciflow-cross-reference', 'outline');
304
+ transfer.effectAllowed = 'copy';
305
+ const payload = {
306
+ type: 'cross-reference',
307
+ refType,
308
+ id,
309
+ href,
310
+ text,
311
+ };
312
+ try {
313
+ transfer.setData('application/json', JSON.stringify(payload));
314
+ }
315
+ catch {
316
+ // ignore
317
+ }
318
+ if (text) {
319
+ transfer.setData('text/plain', text);
320
+ }
321
+ }
215
322
  handleHeadingKeydown(event, heading, index) {
216
323
  if (event.key === 'Enter' || event.key === ' ') {
217
324
  event.preventDefault();
@@ -359,6 +466,7 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
359
466
  const outline = collectDocumentOutline(doc, pmDoc);
360
467
  const filtered = this.applyLevelFilter(outline.headings);
361
468
  this.headings = filtered;
469
+ this.figures = outline.figures ?? [];
362
470
  this.updateActiveHeading(this.lastSelection);
363
471
  this.dispatchOutlineChange(filtered);
364
472
  }
@@ -482,6 +590,9 @@ __decorate([
482
590
  __decorate([
483
591
  state()
484
592
  ], SciFlowOutlineElement.prototype, "headings", void 0);
593
+ __decorate([
594
+ state()
595
+ ], SciFlowOutlineElement.prototype, "figures", void 0);
485
596
  __decorate([
486
597
  state()
487
598
  ], SciFlowOutlineElement.prototype, "activeHeadingKey", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"reference-list.d.ts","sourceRoot":"","sources":["../../src/lib/reference-list.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAa,UAAU,EAAsB,MAAM,KAAK,CAAC;AAMhE,KAAK,eAAe,GAAG;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,GAAG,IAAI,CAAC;AAET,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,MAAM,CAAC,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IAClC,MAAM,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACtF,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,qBACa,2BAA4B,SAAQ,UAAU;IACzD,4BAA4B;IAE5B,UAAU,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAQ;IAE/C,kCAAkC;IAElC,cAAc,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CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,qBACa,2BAA4B,SAAQ,UAAU;IACzD,4BAA4B;IAE5B,UAAU,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAQ;IAE/C,kCAAkC;IAElC,cAAc,EAAE,MAAM,EAAE,CAAM;IAE9B,uDAAuD;IAEvD,SAAS,SAAwB;IAEjC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,kBAAkB,CAA0B;IAEpD,OAAgB,MAAM,0BAAuC;IAEpD,iBAAiB,IAAI,IAAI;IAWzB,oBAAoB,IAAI,IAAI;IAMrC;;;;OAIG;IACH,SAAS,CAAC,YAAY,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,IAAI;cAMjC,MAAM;IA2CzB,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,eAAe;CAiCxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,wBAAwB,EAAE,2BAA2B,CAAC;KACvD;CACF"}
@@ -11,6 +11,7 @@ import { __decorate } from "tslib";
11
11
  import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
12
12
  import { customElement, property } from 'lit/decorators.js';
13
13
  import { classMap } from 'lit/directives/class-map.js';
14
+ import { setTransparentDragImage } from './drag-preview.js';
14
15
  import referenceListCss from './reference-list.css?inline';
15
16
  import { applyThemeStylesToRoot, subscribeToSciFlowTheme } from './theme.js';
16
17
  let SciFlowReferenceListElement = class SciFlowReferenceListElement extends LitElement {
@@ -125,6 +126,7 @@ let SciFlowReferenceListElement = class SciFlowReferenceListElement extends LitE
125
126
  if (!transfer) {
126
127
  return;
127
128
  }
129
+ setTransparentDragImage(event, { opacity: 0.35, offsetY: -44, scale: 0.8 });
128
130
  transfer.setData('application/x-sciflow-reference', 'sidebar');
129
131
  transfer.effectAllowed = 'copy';
130
132
  const payload = {
@@ -15,6 +15,7 @@
15
15
  import { LitElement } from 'lit';
16
16
  import type { SciFlowEditorElement } from './editor-element.js';
17
17
  import { type CitationSourceEditorAdapter } from './citation-source-adapter.js';
18
+ import './selection-widget-host.js';
18
19
  /**
19
20
  * Custom element that displays and edits the selected element's attributes.
20
21
  *
@@ -32,12 +33,31 @@ export declare class SciFlowSelectionEditorElement extends LitElement {
32
33
  /** Custom adapter for editing citation source. When unset, uses the global adapter. */
33
34
  citationSourceAdapter: CitationSourceEditorAdapter | null;
34
35
  private elementInfo;
36
+ /** Draft values for math sidebar (tex, style, label). Synced from node attrs when math is selected. */
37
+ private mathDraft;
38
+ /** Last preview result for math (error/warnings). SVG is rendered into mathPreviewContainer. */
39
+ private mathPreviewResult;
40
+ /** Draft values for citation sidebar (content + source). Applied only on Update. */
41
+ private citationDraft;
42
+ /** Draft values for cross-reference sidebar (display text + target href). */
43
+ private crossReferenceDraft;
44
+ private draftAttrs;
45
+ private draftDirty;
46
+ private pinSelection;
35
47
  private resolvedEditor;
36
48
  private selectionListener?;
37
49
  private readyListener?;
38
50
  private themeUnsub?;
39
51
  private themeStyleElements;
40
52
  private citationSourceContainer;
53
+ private mathPreviewContainer;
54
+ private mathPreviewDebounce;
55
+ private citationContentEditorContainer;
56
+ private citationContentView;
57
+ private citationContentEditorPosition;
58
+ private selectionDebounce;
59
+ private outlineTargetOptionsCacheDoc;
60
+ private outlineTargetOptionsCache;
41
61
  static styles: import("lit").CSSResult;
42
62
  connectedCallback(): void;
43
63
  disconnectedCallback(): void;
@@ -50,10 +70,25 @@ export declare class SciFlowSelectionEditorElement extends LitElement {
50
70
  private resolveEditor;
51
71
  /** Clean up listeners attached to the last editor instance. */
52
72
  private detachEditorListeners;
73
+ private scheduleSelectionUpdate;
53
74
  /**
54
75
  * Extract element information from the current selection.
55
76
  */
56
77
  private updateElementInfo;
78
+ /** Get the selected citation node's text content from the main document (for draft init). */
79
+ private getCitationNodeTextContent;
80
+ /** Get the selected citation node's content as a Fragment (same schema as citation allows). */
81
+ private getCitationNodeContentFragment;
82
+ /** Get the citation node at the current selection, or null. */
83
+ private getCitationNode;
84
+ /** Get the selected cross-reference link node's text content from the main document. */
85
+ private getLinkNodeTextContent;
86
+ /** Get the selected cross-reference link node at current selection, or null. */
87
+ private getLinkNode;
88
+ /** Build outline target options for link href dropdown (headings and figures with id). */
89
+ private getOutlineTargetOptions;
90
+ private destroyCitationContentView;
91
+ private mountCitationContentEditor;
57
92
  /** Convenience getter mirroring `editor.getCommands()`. */
58
93
  private getCommandRunner;
59
94
  /**
@@ -66,21 +101,48 @@ export declare class SciFlowSelectionEditorElement extends LitElement {
66
101
  private decodeSpecialAttribute;
67
102
  /**
68
103
  * Mount the citation source adapter UI when a citation node is selected.
104
+ * Uses draft context (onSourceChange) so changes apply only on Update.
69
105
  */
70
106
  private mountCitationSourceAdapter;
71
107
  /**
72
108
  * Unmount the citation source adapter and clean up.
73
109
  */
74
110
  private unmountCitationSourceAdapter;
111
+ private handleDraftAttrChange;
75
112
  /**
76
- * Handle attribute field changes.
113
+ * Render the figure sidebar: type, id, alt text.
77
114
  */
78
- private handleAttrChange;
115
+ private renderFigureSidebar;
79
116
  /**
80
- * Update node attributes using the command API.
81
- * Preserves the 'data' attribute if it exists, even though it's not displayed.
117
+ * Render the math equation sidebar: TeX source, style, label, preview, status, Apply/Cancel.
82
118
  */
83
- private updateNodeAttribute;
119
+ private renderMathSidebar;
120
+ private scheduleMathPreview;
121
+ private runMathPreview;
122
+ private applyMathDraft;
123
+ private cancelMathDraft;
124
+ private handleMathKeydown;
125
+ /**
126
+ * Render the citation sidebar: content editor, source fields, Update button.
127
+ */
128
+ private renderCitationSidebar;
129
+ private applyCitationDraft;
130
+ private handleCitationKeydown;
131
+ /**
132
+ * Render the cross-reference sidebar: display text + target, Update button.
133
+ */
134
+ private renderCrossReferenceSidebar;
135
+ private applyCrossReferenceDraft;
136
+ private handleCrossReferenceKeydown;
137
+ private resetDraftAttrs;
138
+ private getEffectiveAttrs;
139
+ private setDraftAttr;
140
+ private applyDraftAttrs;
141
+ private revertDraftAttrs;
142
+ private renderDraftActions;
143
+ private renderSelectionControls;
144
+ private togglePinSelection;
145
+ private handleGenericKeydown;
84
146
  /**
85
147
  * Encode a source string/JSON into the URI-encoded source field format.
86
148
  */
@@ -1 +1 @@
1
- {"version":3,"file":"selection-editor.d.ts","sourceRoot":"","sources":["../../src/lib/selection-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAa,UAAU,EAAa,MAAM,KAAK,CAAC;AAMvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,8BAA8B,CAAC;AAWtC;;;;;;;;GAQG;AACH,qBACa,6BAA8B,SAAQ,UAAU;IAC3D,oFAAoF;IAEpF,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAQ;IAE3C,gEAAgE;IAEhE,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,uFAAuF;IAEvF,qBAAqB,EAAE,2BAA2B,GAAG,IAAI,CAAQ;IAGjE,OAAO,CAAC,WAAW,CAAqB;IAExC,OAAO,CAAC,cAAc,CAAqC;IAC3D,OAAO,CAAC,iBAAiB,CAAC,CAAgB;IAC1C,OAAO,CAAC,aAAa,CAAC,CAAgB;IACtC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,kBAAkB,CAA0B;IACpD,OAAO,CAAC,uBAAuB,CAA4B;IAE3D,OAAgB,MAAM,0BAAyC;IAEtD,iBAAiB,IAAI,IAAI;IAYzB,oBAAoB,IAAI,IAAI;IAO5B,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,GAAG,MA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