@sciflow/editor-start 0.0.1-beta → 0.0.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 +83 -2
- package/THIRD_PARTY_LICENSES +9 -0
- package/bin/extract-translations.mjs +54 -0
- package/dist/bundle/sciflow-editor.css +1 -1
- package/dist/bundle/sciflow-editor.js +10590 -15324
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/lib/citation-source-adapter.d.ts +22 -2
- package/dist/lib/citation-source-adapter.d.ts.map +1 -1
- package/dist/lib/citation-source-adapter.js +104 -48
- package/dist/lib/drag-preview.d.ts +13 -0
- package/dist/lib/drag-preview.d.ts.map +1 -0
- package/dist/lib/drag-preview.js +43 -0
- package/dist/lib/editor-element.d.ts +30 -4
- package/dist/lib/editor-element.d.ts.map +1 -1
- package/dist/lib/editor-element.js +131 -30
- package/dist/lib/format-bar.d.ts +26 -2
- package/dist/lib/format-bar.d.ts.map +1 -1
- package/dist/lib/format-bar.js +369 -56
- package/dist/lib/ghost-cursor.d.ts +10 -0
- package/dist/lib/ghost-cursor.d.ts.map +1 -0
- package/dist/lib/ghost-cursor.js +59 -0
- package/dist/lib/icons-generated.d.ts +14 -0
- package/dist/lib/icons-generated.d.ts.map +1 -0
- package/dist/lib/icons-generated.js +60 -0
- package/dist/lib/outline.d.ts +18 -10
- package/dist/lib/outline.d.ts.map +1 -1
- package/dist/lib/outline.js +184 -28
- package/dist/lib/reference-list.d.ts +10 -2
- package/dist/lib/reference-list.d.ts.map +1 -1
- package/dist/lib/reference-list.js +47 -9
- package/dist/lib/selection-editor.d.ts +83 -5
- package/dist/lib/selection-editor.d.ts.map +1 -1
- package/dist/lib/selection-editor.js +1225 -147
- package/dist/lib/selection-transform-registry.d.ts +16 -0
- package/dist/lib/selection-transform-registry.d.ts.map +1 -0
- package/dist/lib/selection-transform-registry.js +24 -0
- package/dist/lib/selection-ui-renderer.d.ts +22 -0
- package/dist/lib/selection-ui-renderer.d.ts.map +1 -0
- package/dist/lib/selection-ui-renderer.js +244 -0
- package/dist/lib/selection-widget-host.d.ts +67 -0
- package/dist/lib/selection-widget-host.d.ts.map +1 -0
- package/dist/lib/selection-widget-host.js +151 -0
- package/dist/lib/selection-widget-registry.d.ts +16 -0
- package/dist/lib/selection-widget-registry.d.ts.map +1 -0
- package/dist/lib/selection-widget-registry.js +30 -0
- package/dist/lib/test-fixtures/soak-documents.d.ts +13 -0
- package/dist/lib/test-fixtures/soak-documents.d.ts.map +1 -0
- package/dist/lib/test-fixtures/soak-documents.js +69 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +22 -13
- package/dist/demo/demo.js +0 -56
- package/dist/demo/index.html +0 -169
- package/dist/lib/citation-drop.d.ts +0 -25
- package/dist/lib/citation-drop.d.ts.map +0 -1
- package/dist/lib/citation-drop.js +0 -53
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated – do not edit.
|
|
3
|
+
* Run `node scripts/generate-icons.mjs` to regenerate.
|
|
4
|
+
*
|
|
5
|
+
* Icons: Material Symbols Rounded, weight 400, unfilled.
|
|
6
|
+
* Source: @material-symbols/svg-400 (Apache License 2.0, Copyright Google LLC)
|
|
7
|
+
* https://github.com/google/material-design-icons
|
|
8
|
+
*/
|
|
9
|
+
/** SVG viewBox shared by all Material Symbols icons. */
|
|
10
|
+
const V = '0 -960 960 960';
|
|
11
|
+
/**
|
|
12
|
+
* Builds a complete inline SVG string for a Material Symbols icon.
|
|
13
|
+
* The SVG inherits `currentColor` via the `fill` attribute for easy theming.
|
|
14
|
+
*/
|
|
15
|
+
const svg = (d) => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${V}" fill="currentColor" aria-hidden="true">${d}</svg>`;
|
|
16
|
+
/**
|
|
17
|
+
* Map of icon names (as used in CommandMetadata.icon) → inline SVG markup.
|
|
18
|
+
* Only the icons actually used by the editor are included (~29 icons).
|
|
19
|
+
*/
|
|
20
|
+
export const materialIcons = {
|
|
21
|
+
'format_bold': svg(`<path d="M335-200q-25 0-42.5-17.5T275-260v-440q0-25 17.5-42.5T335-760h168q66 0 114.5 42T666-612q0 38-21 70t-56 49v6q43 14 69.5 50t26.5 81q0 68-52.5 112T510-200H335Zm26-76h144q38 0 66-25t28-63q0-37-28-62t-66-25H361v175Zm0-247h136q35 0 60.5-23t25.5-58q0-35-25.5-58.5T497-686H361v163Z"/>`),
|
|
22
|
+
'format_italic': svg(`<path d="M264-199q-16.8 0-28.4-11.64-11.6-11.64-11.6-28.5t11.6-28.36Q247.2-279 264-279h94l139-409H378q-16.8 0-28.4-11.64-11.6-11.64-11.6-28.5t11.6-28.36Q361.2-768 378-768h300q16.8 0 28.4 11.64 11.6 11.64 11.6 28.5t-11.6 28.36Q694.8-688 678-688h-94L445-279h119q16.8 0 28.4 11.64 11.6 11.64 11.6 28.5t-11.6 28.36Q580.8-199 564-199H264Z"/>`),
|
|
23
|
+
'format_quote': svg(`<path d="m275-287 67-115q-5 1-11 1.5t-11 .5q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 21-5.5 41T458-480L329-255q-4 8-11.5 11.5T302-240q-18 0-27-15.5t0-31.5Zm360 0 67-115q-5 1-11 1.5t-11 .5q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 21-5.5 41T818-480L689-255q-4 8-11.5 11.5T662-240q-18 0-27-15.5t0-31.5ZM376.5-503.5Q400-527 400-560t-23.5-56.5Q353-640 320-640t-56.5 23.5Q240-593 240-560t23.5 56.5Q287-480 320-480t56.5-23.5Zm360 0Q760-527 760-560t-23.5-56.5Q713-640 680-640t-56.5 23.5Q600-593 600-560t23.5 56.5Q647-480 680-480t56.5-23.5ZM680-560Zm-360 0Z"/>`),
|
|
24
|
+
'format_list_bulleted': svg(`<path d="M407-198q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h403q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H407Zm0-252q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h403q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H407Zm0-253q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h403q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H407ZM189-161q-28.05 0-48.02-19Q121-199 121-227.5t19.5-48q19.5-19.5 48-19.5t47.5 19.98q19 19.97 19 48.02 0 27.23-19.39 46.61Q216.23-161 189-161Zm0-252q-28.05 0-48.02-19.5Q121-452 121-480t19.98-47.5Q160.95-547 189-547q27.23 0 46.61 19.5Q255-508 255-480t-19.39 47.5Q216.23-413 189-413Zm-48.5-272.5Q121-705 121-733t19.5-47.5Q160-800 188-800t47.5 19.5Q255-761 255-733t-19.5 47.5Q216-666 188-666t-47.5-19.5Z"/>`),
|
|
25
|
+
'format_list_numbered': svg(`<path d="M150-80q-13 0-21.5-8.5T120-110q0-13 8.5-21.5T150-140h70v-30h-30q-13 0-21.5-8.5T160-200q0-13 8.5-21.5T190-230h30v-30h-70q-13 0-21.5-8.5T120-290q0-13 8.5-21.5T150-320h90q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80h-90Zm-7-280q-9 0-16-7t-7-16v-87q0-17 11.5-28.5T160-510h60v-30h-70q-13 0-21.5-8.5T120-570q0-13 8.5-21.5T150-600h90q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h70q13 0 21.5 8.5T280-390q0 13-8.5 21.5T250-360H143Zm45.5-288.5Q180-657 180-670v-150h-30q-13 0-21.5-8.5T120-850q0-13 8.5-21.5T150-880h68q9 0 15.5 6.5T240-858v188q0 13-8.5 21.5T210-640q-13 0-21.5-8.5ZM399-209q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h411q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H399Zm0-243q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h411q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H399Zm0-243q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h411q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H399Z"/>`),
|
|
26
|
+
'format_indent_increase': svg(`<path d="M150-120q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm320-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H470Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H470Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H470ZM150-780q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm-5 412q-8 7-16.5 3.25T120-379v-205q0-9.92 9.5-13.46Q139-601 146-594l104 104q5 5 5 10.5t-5 10.5L145-368Z"/>`),
|
|
27
|
+
'format_indent_decrease': svg(`<path d="M150-120q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm320-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H470Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H470Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H470ZM150-780q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm85 412L131-472q-5-4.64-5-10.82 0-6.18 5-11.18l105-100q8-7 16.5-3.46T261-584v205q0 10.5-9.5 14.25T235-368Z"/>`),
|
|
28
|
+
'asterisk': svg(`<path d="M458.5-128.63Q450-137.25 450-150v-258L268-226q-8.8 9-20.9 9-12.1 0-21.1-8.84-9-8.84-9-21t9-21.16l182-182H150q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h259L226-693q-9-8.8-9-20.9 0-12.1 8.84-21.1 8.84-9 21-9t21.16 9l182 182v-257q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v258l183-183q8.8-9 20.9-9 12.1 0 21.1 8.84 9 8.84 9 21T735-693L552-510h258q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H553l182 182q9 8.8 9 20.9 0 12.1-8.84 21.1-8.84 9-21 9T693-226L510-409v259q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Z"/>`),
|
|
29
|
+
'functions': svg(`<path d="M515-480 250-728q-4.62-4.7-7.31-10.57-2.69-5.86-2.69-12.13v-18q0-13.3 8.91-22.3 8.92-9 22.09-9h399q20.83 0 35.42 14.62Q720-770.76 720-749.88q0 20.88-14.58 35.38Q690.83-700 670-700H396l212 198q10 9.13 10 22.07Q618-467 608-458L396-260h274q20.83 0 35.42 14.62Q720-230.76 720-209.88q0 20.88-14.58 35.38Q690.83-160 670-160H263q-9.52 0-16.26-6.72-6.74-6.73-6.74-16.22V-213q0-4.94 1.5-9.47T247-230l268-250Z"/>`),
|
|
30
|
+
'image': svg(`<path d="M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Zm0-60h600v-600H180v600Zm0 0v-600 600Zm86-97h429q8.5 0 12.75-8t-.75-16L590-457q-5-6-12-6t-12 6L446-302l-81-111q-5-6-12-6t-12 6l-86 112q-6 8-1.75 16t12.75 8Z"/>`),
|
|
31
|
+
'link': svg(`<path d="M280-280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h140q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H280q-58.33 0-99.17 40.76-40.83 40.77-40.83 99Q140-422 180.83-381q40.84 41 99.17 41h140q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H280Zm75-170q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h250q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H355Zm185 170q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h140q58.33 0 99.17-40.76 40.83-40.77 40.83-99Q820-538 779.17-579q-40.84-41-99.17-41H540q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h140q83 0 141.5 58.5T880-480q0 83-58.5 141.5T680-280H540Z"/>`),
|
|
32
|
+
'table_chart': svg(`<path d="M780-121H180q-24 0-42-18t-18-42v-599q0-24 18-42t42-18h600q24 0 42 18t18 42v599q0 24-18 42t-42 18ZM180-639h600v-141H180v141Zm130 60H180v398h130v-398Zm340 0v398h130v-398H650Zm-60 0H370v398h220v-398Z"/>`),
|
|
33
|
+
'chevron_left': svg(`<path d="m406-481 177 177q9 9 8.5 21t-9.5 21q-9 9-21.5 9t-21.5-9L341-460q-5-5-7-10t-2-11q0-6 2-11t7-10l199-199q9-9 21.5-9t21.5 9q9 9 9 21.5t-9 21.5L406-481Z"/>`),
|
|
34
|
+
'chevron_right': svg(`<path d="M530-481 353-658q-9-9-8.5-21t9.5-21q9-9 21.5-9t21.5 9l198 198q5 5 7 10t2 11q0 6-2 11t-7 10L396-261q-9 9-21 8.5t-21-9.5q-9-9-9-21.5t9-21.5l176-176Z"/>`),
|
|
35
|
+
'delete': svg(`<path d="M261-120q-24.75 0-42.37-17.63Q201-155.25 201-180v-570h-11q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h158q0-13 8.63-21.5 8.62-8.5 21.37-8.5h204q12.75 0 21.38 8.62Q612-822.75 612-810h158q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5h-11v570q0 24.75-17.62 42.37Q723.75-120 699-120H261Zm438-630H261v570h438v-570ZM418.5-274.63q8.5-8.62 8.5-21.37v-339q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v339q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63Zm166 0q8.5-8.62 8.5-21.37v-339q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v339q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63ZM261-750v570-570Z"/>`),
|
|
36
|
+
'remove': svg(`<path d="M230-450q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h500q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H230Z"/>`),
|
|
37
|
+
'expand_less': svg(`<path d="M480-554 304-378q-9 9-21 8.5t-21-9.5q-9-9-9-21.5t9-21.5l197-197q9-9 21-9t21 9l198 198q9 9 9 21t-9 21q-9 9-21.5 9t-21.5-9L480-554Z"/>`),
|
|
38
|
+
'expand_more': svg(`<path d="M469-358q-5-2-10-7L261-563q-9-9-8.5-21.5T262-606q9-9 21.5-9t21.5 9l175 176 176-176q9-9 21-8.5t21 9.5q9 9 9 21.5t-9 21.5L501-365q-5 5-10 7t-11 2q-6 0-11-2Z"/>`),
|
|
39
|
+
'merge_type': svg(`<path d="M681.5-172.5Q669-172 660-181L463-378q-8-8-12.5-19.5T446-421v-303L345-623q-9 9-21.5 9t-21.5-9q-9-9-9-21.5t9-21.5l152-153q5-5 10.5-7t11.5-2q6 0 11 2t10 7l152 152q9 9 9 21.5t-9 21.5q-9 9-21.5 9.5T606-623L506-724v303l197 197q9 9 9 21t-9 21q-9 9-21.5 9.5ZM251-182q-9-9-9-21t9-21l119-120q9-9 21.5-9t21.5 9q9 9 9 21.5t-9 21.5L294-182q-9 9-21.5 9t-21.5-9Z"/>`),
|
|
40
|
+
'call_split': svg(`<path d="M220-698v93q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-165q0-12.75 8.63-21.38Q177.25-800 190-800h165q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5h-92l231 231q8 8 13 19.28 5 11.28 5 23.72v276q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-276L220-698Zm520 0L586-545q-8.8 9-20.9 9-12.1 0-21.1-9-9-9-9-21.2 0-12.19 9-20.8l153-153h-92q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h165q12.75 0 21.38 8.62Q800-782.75 800-770v165q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-93Z"/>`),
|
|
41
|
+
'table_rows': svg(`<path d="M780-180v-157H180v157h600Zm0-217v-166H180v166h600Zm0-226v-157H180v157h600ZM180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h600q24 0 42 18t18 42v600q0 24-18 42t-42 18H180Z"/>`),
|
|
42
|
+
'view_column': svg(`<path d="M120-260v-440q0-24.75 17.63-42.38Q155.25-760 180-760h600q24.75 0 42.38 17.62Q840-724.75 840-700v440q0 24.75-17.62 42.37Q804.75-200 780-200H180q-24.75 0-42.37-17.63Q120-235.25 120-260Zm60 0h160v-440H180v440Zm220 0h160v-440H400v440Zm220 0h160v-440H620v440Z"/>`),
|
|
43
|
+
'keyboard_tab': svg(`<path d="M828.5-248.5Q820-257 820-270v-420q0-13 8.5-21.5T850-720q13 0 21.5 8.5T880-690v420q0 13-8.5 21.5T850-240q-13 0-21.5-8.5ZM606-450H110q-13 0-21.5-8.5T80-480q0-13 8.5-21.5T110-510h496L459-658q-9-9-9-21t9-21q9-9 21-9t21 9l199 199q5 5 7 10t2 11q0 6-2 11t-7 10L501-260q-9 9-21 9t-21-9q-9-9-9-21.5t9-21.5l147-147Z"/>`),
|
|
44
|
+
'delete_sweep': svg(`<path d="M185-200q-24 0-42-18t-18-42v-415q-13 0-21.5-8.68-8.5-8.67-8.5-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h125v-15.14q0-12.86 8.63-21.36 8.62-8.5 21.37-8.5h75q12.75 0 21.38 8.62Q385-762.75 385-750v15h125q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5v415q0 24-18 42t-42 18H185Zm445-30q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h85q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5h-85Zm0-184q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h175q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H630Zm0-184q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h220q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H630Zm-445-77v415h265v-415H185Z"/>`),
|
|
45
|
+
'format_align_left': svg(`<path d="M150-120q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h420q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h420q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"/>`),
|
|
46
|
+
'format_align_center': svg(`<path d="M150-120q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm160-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H310ZM150-450q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm160-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h340q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H310ZM150-780q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"/>`),
|
|
47
|
+
'format_align_right': svg(`<path d="M150-780q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm240 165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h420q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H390ZM150-450q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm240 165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h420q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H390ZM150-120q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"/>`),
|
|
48
|
+
'format_align_justify': svg(`<path d="M150-120q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"/>`),
|
|
49
|
+
'subscript': svg(`<path d="M799-160q-12.75 0-21.37-8.63Q769-177.25 769-190v-40q0-12.75 8.63-21.38Q786.25-260 799-260h91v-40H784q-6 0-10.5-4.5T769-315q0-6 4.5-10.5T784-330h106q12.75 0 21.38 8.62Q920-312.75 920-300v40q0 12.75-8.62 21.37Q902.75-230 890-230h-91v40h106q6 0 10.5 4.5T920-175q0 6-4.5 10.5T905-160H799Zm-499-80q-21.29 0-31.14-18.5Q259-277 270-295l150-236-136-213q-11-18-1.5-37t31.03-19q9.94 0 18.22 4.45T345-783l124 196 124-196q4.89-8.1 13.45-12.55 8.57-4.45 17.53-4.45 22.02 0 31.52 19t-1.5 37L518-531l150 236q11 18 .84 36.5-10.15 18.5-30.46 18.5-9.38 0-17.84-4.45Q612.08-248.9 607-257L469-474 331-257q-4.89 8.1-13.46 12.55Q308.97-240 300-240Z"/>`),
|
|
50
|
+
'superscript': svg(`<path d="M799-630q-12.75 0-21.37-8.63Q769-647.25 769-660v-40q0-12.75 8.63-21.38Q786.25-730 799-730h91v-40H784q-6 0-10.5-4.5T769-785q0-6 4.5-10.5T784-800h106q12.75 0 21.38 8.62Q920-782.75 920-770v40q0 12.75-8.62 21.37Q902.75-700 890-700h-91v40h106q6 0 10.5 4.5T920-645q0 6-4.5 10.5T905-630H799ZM300-160q-21.29 0-31.14-18.5Q259-197 270-215l150-236-136-213q-11-18-1.5-37t31.03-19q9.94 0 18.22 4.45T345-703l124 196 124-196q4.89-8.1 13.45-12.55 8.57-4.45 17.53-4.45 22.02 0 31.52 19t-1.5 37L518-451l150 236q11 18 .84 36.5-10.15 18.5-30.46 18.5-9.38 0-17.84-4.45Q612.08-168.9 607-177L469-394 331-177q-4.89 8.1-13.46 12.55Q308.97-160 300-160Z"/>`),
|
|
51
|
+
'undo': svg(`<path d="M289-200q-13 0-21.5-8.5T259-230q0-13 8.5-21.5T289-260h280q70 0 120.5-46.5T740-422q0-69-50.5-115.5T569-584H274l93 93q9 9 9 21t-9 21q-9 9-21 9t-21-9L181-593q-5-5-7-10t-2-11q0-6 2-11t7-10l144-144q9-9 21-9t21 9q9 9 9 21t-9 21l-93 93h294q95 0 163.5 64T800-422q0 94-68.5 158T568-200H289Z"/>`),
|
|
52
|
+
'redo': svg(`<path d="M686-584H391q-70 0-120.5 46.5T220-422q0 69 50.5 115.5T391-260h280q13 0 21.5 8.5T701-230q0 13-8.5 21.5T671-200H392q-95 0-163.5-64T160-422q0-94 68.5-158T392-644h294l-93-93q-9-9-9-21t9-21q9-9 21-9t21 9l144 144q5 5 7 10t2 11q0 6-2 11t-7 10L635-449q-9 9-21 9t-21-9q-9-9-9-21t9-21l93-93Z"/>`),
|
|
53
|
+
'info': svg(`<path d="M504.5-288.63q8.5-8.62 8.5-21.37v-180q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v180q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63Zm-1-314.57q9.5-9.2 9.5-22.8 0-14.45-9.48-24.22-9.48-9.78-23.5-9.78t-23.52 9.78Q447-640.45 447-626q0 13.6 9.48 22.8 9.48 9.2 23.5 9.2t23.52-9.2ZM480.27-80q-82.74 0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66Q143-709 197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5Q709-817 763-763t85.5 127Q880-563 880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80Zm.23-60Q622-140 721-239.5t99-241Q820-622 721.19-721T480-820q-141 0-240.5 98.81T140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z"/>`),
|
|
54
|
+
'notifications': svg(`<path d="M190-200q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h50v-304q0-84 49.5-150.5T420-798v-22q0-25 17.5-42.5T480-880q25 0 42.5 17.5T540-820v22q81 17 130.5 83.5T720-564v304h50q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H190Zm290-302Zm0 422q-33 0-56.5-23.5T400-160h160q0 33-23.5 56.5T480-80ZM300-260h360v-304q0-75-52.5-127.5T480-744q-75 0-127.5 52.5T300-564v304Z"/>`),
|
|
55
|
+
'arrow_back': svg(`<path d="m274-450 227 227q9 9 9 21t-9 21q-9 9-21 9t-21-9L181-459q-5-5-7-10t-2-11q0-6 2-11t7-10l278-278q9-9 21-9t21 9q9 9 9 21t-9 21L274-510h496q13 0 21.5 8.5T800-480q0 13-8.5 21.5T770-450H274Z"/>`),
|
|
56
|
+
'menu_book': svg(`<path d="M248-300q53.57 0 104.28 12.5Q403-275 452-250v-427q-45-30-97.62-46.5Q301.76-740 248-740q-38 0-74.5 9.5T100-707v434q31-14 70.5-20.5T248-300Zm264 50q50-25 98-37.5T712-300q38 0 78.5 6t69.5 16v-429q-34-17-71.82-25-37.82-8-76.18-8-54 0-104.5 16.5T512-677v427Zm-44.5 77.5Q461-174 456-178q-47-29-99.85-45-52.84-16-108.15-16-36.54 0-71.77 9T106-208q-23.1 11-44.55-3Q40-225 40-251v-463q0-15 7-27.5T68-761q42-20 87.39-29.5 45.4-9.5 92.61-9.5 63 0 122.5 17T482-731q51-35 109.5-52T712-800q46.87 0 91.93 9.5Q849-781 891-761q14 7 21.5 19.5T920-714v463q0 27.89-22.5 42.45Q875-194 853-208q-34-14-69.23-22.5Q748.54-239 712-239q-54.27 0-106.14 16Q554-207 508-178q-5 4-11.5 5.5T482-171q-8 0-14.5-1.5ZM276-489Zm284-119q0-5.52 4.02-11.34 4.03-5.82 8.98-7.66 30-11 61.34-17 31.33-6 65.91-6 21.61 0 42.68 2.5T784-640q6 2 11 7.4 5 5.39 5 12.13 0 11.47-7.5 17.47-7.5 6-18.5 3-16.8-5-35.4-7.5Q720-610 700-610q-29 0-56 5.5T591-588q-14 5-22.5-.5T560-608Zm0 220q0-5.81 4.02-11.94 4.03-6.12 8.98-8.06 30-11 61.34-16.5 31.33-5.5 65.91-5.5 21.61 0 42.68 2.5T784-420q6 2 11 7.4 5 5.39 5 12.13 0 11.47-7.5 17.47-7.5 6-18.5 3-16.8-5-35.4-7.5Q720-390 700-390q-29 0-56 5t-53 16q-14 5-22.5 0t-8.5-19Zm0-110q0-5.52 4.02-11.34 4.03-5.82 8.98-7.66 30-11 61.34-17 31.33-6 65.91-6 21.61 0 42.68 2.5T784-530q6 2 11 7.4 5 5.39 5 12.13 0 11.47-7.5 17.47-7.5 6-18.5 3-16.8-5-35.4-7.5Q720-500 700-500q-29 0-56 5.5T591-478q-14 5-22.5-.5T560-498Z"/>`),
|
|
57
|
+
'tune': svg(`<path d="M435.5-128.63Q427-137.25 427-150v-165q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v53h323q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H487v52q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM150-202q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h187q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm165.5-174.63Q307-385.25 307-398v-52H150q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h157v-54q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v166q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM457-450q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h353q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H457Zm144.5-173.63Q593-632.25 593-645v-165q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v52h157q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H653v53q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM150-698q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h353q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"/>`),
|
|
58
|
+
'toc': svg(`<path d="M150-280q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h490q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-170q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h490q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-170q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h490q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm659.5 340q-12.5 0-21-8.63-8.5-8.62-8.5-21.37 0-12 8.63-21 8.62-9 21.37-9 12 0 21 9t9 21.5q0 12.5-9 21t-21.5 8.5Zm0-170q-12.5 0-21-8.63-8.5-8.62-8.5-21.37 0-12 8.63-21 8.62-9 21.37-9 12 0 21 9t9 21.5q0 12.5-9 21t-21.5 8.5Zm0-170q-12.5 0-21-8.63-8.5-8.62-8.5-21.37 0-12 8.63-21 8.62-9 21.37-9 12 0 21 9t9 21.5q0 12.5-9 21t-21.5 8.5Z"/>`),
|
|
59
|
+
'toggle_on': svg(`<path d="M280-240q-100 0-170-70T40-480q0-100 70-170t170-70h400q100 0 170 70t70 170q0 100-70 170t-170 70H280Zm0-60h400q75 0 127.5-52.5T860-480q0-75-52.5-127.5T680-660H280q-75 0-127.5 52.5T100-480q0 75 52.5 127.5T280-300Zm472.5-108.5Q782-438 782-480t-29.5-71.5Q723-581 681-581t-71.5 29.5Q580-522 580-480t29.5 71.5Q639-379 681-379t71.5-29.5ZM480-480Z"/>`),
|
|
60
|
+
};
|
package/dist/lib/outline.d.ts
CHANGED
|
@@ -13,21 +13,19 @@ 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
|
-
/**
|
|
28
|
-
* Helper used by the demo to expose outline data for debugging.
|
|
29
|
-
*/
|
|
30
|
-
export declare function logDocumentOutline(doc: SciFlowDocJSON | null | undefined, pmDoc?: ProsemirrorNode | null): DocumentOutline;
|
|
31
29
|
/**
|
|
32
30
|
* Web component that renders a document outline and stays in sync with a
|
|
33
31
|
* <sciflow-editor> instance. Hosts can either set the `for` attribute to point
|
|
@@ -55,12 +53,20 @@ export declare class SciFlowOutlineElement extends LitElement {
|
|
|
55
53
|
/** Custom label renderer for headings. Receives the heading and its index. */
|
|
56
54
|
renderHeadingLabel?: (heading: OutlineHeading, index: number) => unknown;
|
|
57
55
|
private headings;
|
|
56
|
+
private figures;
|
|
58
57
|
private activeHeadingKey;
|
|
58
|
+
/**
|
|
59
|
+
* When `true`, the Insert ref buttons are enabled. The component sets this
|
|
60
|
+
* automatically via `editor-selection-change` when an editor is bound. In
|
|
61
|
+
* doc-only mode (no bound editor), hosts can set this property directly.
|
|
62
|
+
*/
|
|
63
|
+
cursorActive: boolean;
|
|
59
64
|
private resolvedEditor;
|
|
60
65
|
private selectionListener?;
|
|
61
66
|
private changeListener?;
|
|
62
67
|
private readyListener?;
|
|
63
68
|
private lastSelection;
|
|
69
|
+
private localeListener?;
|
|
64
70
|
private themeUnsub?;
|
|
65
71
|
private themeStyleElements;
|
|
66
72
|
static styles: import("lit").CSSResult;
|
|
@@ -69,6 +75,9 @@ export declare class SciFlowOutlineElement extends LitElement {
|
|
|
69
75
|
protected updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
70
76
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
71
77
|
private renderHeadingItem;
|
|
78
|
+
private renderFigureItem;
|
|
79
|
+
private handleCrossReferenceDragStart;
|
|
80
|
+
private handleInsertCrossReference;
|
|
72
81
|
private handleHeadingKeydown;
|
|
73
82
|
private handleHeadingClick;
|
|
74
83
|
private resolveEditorReference;
|
|
@@ -84,7 +93,6 @@ export declare class SciFlowOutlineElement extends LitElement {
|
|
|
84
93
|
private getHeadingSelectionPosition;
|
|
85
94
|
private extractDocFromEditor;
|
|
86
95
|
private normalizeClickBehavior;
|
|
87
|
-
private dispatchOutlineChange;
|
|
88
96
|
}
|
|
89
97
|
declare global {
|
|
90
98
|
interface HTMLElementTagNameMap {
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/lib/outline.ts"],"names":[],"mappings":"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"}
|
package/dist/lib/outline.js
CHANGED
|
@@ -2,7 +2,8 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
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
|
-
import { SourceField, } from '@sciflow/editor-core';
|
|
5
|
+
import { SourceField, t, LOCALE_CHANGE_EVENT, } 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 : t('outline.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((n) => n?.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 : t('outline.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,20 +134,19 @@ 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);
|
|
102
148
|
return outline;
|
|
103
149
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Helper used by the demo to expose outline data for debugging.
|
|
106
|
-
*/
|
|
107
|
-
export function logDocumentOutline(doc, pmDoc = null) {
|
|
108
|
-
const outline = collectDocumentOutline(doc, pmDoc);
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- instrumentation hook only
|
|
110
|
-
globalThis.__SCIFLOW_OUTLINE__ = outline;
|
|
111
|
-
return outline;
|
|
112
|
-
}
|
|
113
150
|
/**
|
|
114
151
|
* Web component that renders a document outline and stays in sync with a
|
|
115
152
|
* <sciflow-editor> instance. Hosts can either set the `for` attribute to point
|
|
@@ -129,13 +166,20 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
129
166
|
/** Optional document JSON source when not listening to an editor element. */
|
|
130
167
|
this.doc = null;
|
|
131
168
|
/** Placeholder text displayed when no headings are present. */
|
|
132
|
-
this.emptyText = '
|
|
169
|
+
this.emptyText = '';
|
|
133
170
|
/** Controls click behavior: disabled, set selection, or set selection + scroll. */
|
|
134
171
|
this.clickBehavior = 'scroll';
|
|
135
172
|
/** Filter the outline to specific heading levels (e.g., "1-3" or "1,2,3"). */
|
|
136
173
|
this.levels = null;
|
|
137
174
|
this.headings = [];
|
|
175
|
+
this.figures = [];
|
|
138
176
|
this.activeHeadingKey = null;
|
|
177
|
+
/**
|
|
178
|
+
* When `true`, the Insert ref buttons are enabled. The component sets this
|
|
179
|
+
* automatically via `editor-selection-change` when an editor is bound. In
|
|
180
|
+
* doc-only mode (no bound editor), hosts can set this property directly.
|
|
181
|
+
*/
|
|
182
|
+
this.cursorActive = false;
|
|
139
183
|
this.resolvedEditor = null;
|
|
140
184
|
this.lastSelection = null;
|
|
141
185
|
this.themeStyleElements = [];
|
|
@@ -146,10 +190,16 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
146
190
|
this.themeUnsub = subscribeToSciFlowTheme((cssTexts) => {
|
|
147
191
|
this.themeStyleElements = applyThemeStylesToRoot(this.renderRoot, this.themeStyleElements, cssTexts);
|
|
148
192
|
});
|
|
193
|
+
this.localeListener = () => this.requestUpdate();
|
|
194
|
+
document.addEventListener(LOCALE_CHANGE_EVENT, this.localeListener);
|
|
149
195
|
this.resolveEditorReference();
|
|
150
196
|
}
|
|
151
197
|
disconnectedCallback() {
|
|
152
198
|
this.detachEditorListeners();
|
|
199
|
+
if (this.localeListener) {
|
|
200
|
+
document.removeEventListener(LOCALE_CHANGE_EVENT, this.localeListener);
|
|
201
|
+
this.localeListener = undefined;
|
|
202
|
+
}
|
|
153
203
|
this.themeUnsub?.();
|
|
154
204
|
this.themeUnsub = undefined;
|
|
155
205
|
super.disconnectedCallback();
|
|
@@ -169,16 +219,19 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
169
219
|
}
|
|
170
220
|
}
|
|
171
221
|
render() {
|
|
172
|
-
|
|
222
|
+
const hasHeadings = this.headings.length > 0;
|
|
223
|
+
const hasFigures = this.figures.length > 0;
|
|
224
|
+
if (!hasHeadings && !hasFigures) {
|
|
173
225
|
return html `
|
|
174
226
|
<ol class="outline-list" part="list">
|
|
175
|
-
<li class="outline-placeholder" part="placeholder">${this.emptyText}</li>
|
|
227
|
+
<li class="outline-placeholder" part="placeholder">${this.emptyText || t('outline.noHeadings')}</li>
|
|
176
228
|
</ol>
|
|
177
229
|
`;
|
|
178
230
|
}
|
|
179
231
|
return html `
|
|
180
232
|
<ol class="outline-list" part="list">
|
|
181
233
|
${this.headings.map((heading, index) => this.renderHeadingItem(heading, index))}
|
|
234
|
+
${this.figures.map((figure, index) => this.renderFigureItem(figure, index))}
|
|
182
235
|
</ol>
|
|
183
236
|
`;
|
|
184
237
|
}
|
|
@@ -186,7 +239,8 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
186
239
|
const key = this.headingKey(heading, index);
|
|
187
240
|
const isActive = this.activeHeadingKey === key;
|
|
188
241
|
const clickable = this.clickBehavior !== 'none' && heading.position !== null && heading.position !== undefined;
|
|
189
|
-
const label = this.renderHeadingLabel?.(heading, index) ?? heading.text?.trim() ?? '
|
|
242
|
+
const label = this.renderHeadingLabel?.(heading, index) ?? heading.text?.trim() ?? t('outline.untitledSection');
|
|
243
|
+
const draggable = Boolean(heading.id?.trim());
|
|
190
244
|
return html `
|
|
191
245
|
<li
|
|
192
246
|
class=${classMap({
|
|
@@ -196,22 +250,126 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
196
250
|
})}
|
|
197
251
|
part=${`item${isActive ? ' item-active' : ''}`}
|
|
198
252
|
data-level=${heading.level ?? ''}
|
|
253
|
+
data-outline-id=${heading.id ?? ''}
|
|
199
254
|
role=${clickable ? 'button' : 'listitem'}
|
|
200
255
|
tabindex=${clickable ? 0 : -1}
|
|
201
256
|
aria-current=${isActive ? 'true' : 'false'}
|
|
257
|
+
draggable=${draggable ? 'true' : 'false'}
|
|
202
258
|
@click=${clickable ? () => this.handleHeadingClick(heading, index) : undefined}
|
|
203
259
|
@keydown=${clickable ? (event) => this.handleHeadingKeydown(event, heading, index) : undefined}
|
|
260
|
+
@dragstart=${draggable ? (e) => this.handleCrossReferenceDragStart(e, 'heading', heading.id, String(label ?? '')) : undefined}
|
|
204
261
|
>
|
|
262
|
+
${heading.level ? html `<span class="outline-level" part="level" aria-hidden="true">H${heading.level}</span>` : nothing}
|
|
205
263
|
<span class="outline-text" part="text">${label}</span>
|
|
206
264
|
<span class="outline-meta" part="meta">
|
|
207
|
-
${heading.level ? html `<span part="level">H${heading.level}</span>` : nothing}
|
|
208
265
|
${heading.id
|
|
209
|
-
? html `<code class="outline-id" part="id" aria-label=${
|
|
266
|
+
? html `<code class="outline-id" part="id" aria-label=${`${t('outline.headingIdAriaLabel')} ${heading.id}`}>${heading.id}</code>`
|
|
267
|
+
: nothing}
|
|
268
|
+
${draggable
|
|
269
|
+
? html `
|
|
270
|
+
<button
|
|
271
|
+
type="button"
|
|
272
|
+
class="outline-insert-btn"
|
|
273
|
+
title=${t('outline.insertCrossReferenceAriaLabel')}
|
|
274
|
+
aria-label=${t('outline.insertCrossReferenceAriaLabel')}
|
|
275
|
+
?disabled=${!this.cursorActive}
|
|
276
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
277
|
+
@click=${(e) => {
|
|
278
|
+
e.stopPropagation();
|
|
279
|
+
if (this.cursorActive)
|
|
280
|
+
this.handleInsertCrossReference('heading', heading.id, String(label ?? ''));
|
|
281
|
+
}}
|
|
282
|
+
>${t('outline.insertCrossReference')}</button>
|
|
283
|
+
<span class="outline-drag" aria-hidden="true">drag</span>
|
|
284
|
+
`
|
|
210
285
|
: nothing}
|
|
211
286
|
</span>
|
|
212
287
|
</li>
|
|
213
288
|
`;
|
|
214
289
|
}
|
|
290
|
+
renderFigureItem(figure, index) {
|
|
291
|
+
const id = figure.id?.trim();
|
|
292
|
+
const draggable = Boolean(id);
|
|
293
|
+
const label = figure.text?.trim() || (id ?? `${t('outline.figure')} ${index + 1}`);
|
|
294
|
+
return html `
|
|
295
|
+
<li
|
|
296
|
+
class=${classMap({
|
|
297
|
+
'outline-item': true,
|
|
298
|
+
'outline-item--figure': true,
|
|
299
|
+
})}
|
|
300
|
+
part="item"
|
|
301
|
+
data-outline-id=${figure.id ?? ''}
|
|
302
|
+
role="listitem"
|
|
303
|
+
tabindex="0"
|
|
304
|
+
draggable=${draggable ? 'true' : 'false'}
|
|
305
|
+
@dragstart=${draggable && id ? (e) => this.handleCrossReferenceDragStart(e, 'figure', id, label) : undefined}
|
|
306
|
+
>
|
|
307
|
+
<span class="outline-level outline-level--figure" aria-hidden="true">Fig</span>
|
|
308
|
+
<span class="outline-text" part="text">${label}</span>
|
|
309
|
+
<span class="outline-meta" part="meta">
|
|
310
|
+
${id
|
|
311
|
+
? html `<code class="outline-id" part="id" aria-label=${`${t('outline.figureIdAriaLabel')} ${id}`}>${id}</code>`
|
|
312
|
+
: nothing}
|
|
313
|
+
${draggable && id
|
|
314
|
+
? html `
|
|
315
|
+
<button
|
|
316
|
+
type="button"
|
|
317
|
+
class="outline-insert-btn"
|
|
318
|
+
title=${t('outline.insertCrossReferenceAriaLabel')}
|
|
319
|
+
aria-label=${t('outline.insertCrossReferenceAriaLabel')}
|
|
320
|
+
?disabled=${!this.cursorActive}
|
|
321
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
322
|
+
@click=${(e) => {
|
|
323
|
+
e.stopPropagation();
|
|
324
|
+
if (this.cursorActive)
|
|
325
|
+
this.handleInsertCrossReference('figure', id, label);
|
|
326
|
+
}}
|
|
327
|
+
>${t('outline.insertCrossReference')}</button>
|
|
328
|
+
<span class="outline-drag" aria-hidden="true">drag</span>
|
|
329
|
+
`
|
|
330
|
+
: nothing}
|
|
331
|
+
</span>
|
|
332
|
+
</li>
|
|
333
|
+
`;
|
|
334
|
+
}
|
|
335
|
+
handleCrossReferenceDragStart(event, refType, id, text) {
|
|
336
|
+
const transfer = event.dataTransfer;
|
|
337
|
+
if (!transfer)
|
|
338
|
+
return;
|
|
339
|
+
setTransparentDragImage(event, { opacity: 0.35, offsetY: 44, scale: 0.8 });
|
|
340
|
+
const href = `#${id}`;
|
|
341
|
+
transfer.setData('application/x-sciflow-cross-reference', 'outline');
|
|
342
|
+
transfer.effectAllowed = 'copy';
|
|
343
|
+
const payload = {
|
|
344
|
+
type: 'cross-reference',
|
|
345
|
+
refType,
|
|
346
|
+
id,
|
|
347
|
+
href,
|
|
348
|
+
text,
|
|
349
|
+
};
|
|
350
|
+
try {
|
|
351
|
+
transfer.setData('application/json', JSON.stringify(payload));
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
// ignore
|
|
355
|
+
}
|
|
356
|
+
if (text) {
|
|
357
|
+
transfer.setData('text/plain', text);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
handleInsertCrossReference(refType, id, text) {
|
|
361
|
+
this.dispatchEvent(new CustomEvent('sciflow-insert-cross-reference', {
|
|
362
|
+
bubbles: true,
|
|
363
|
+
composed: true,
|
|
364
|
+
detail: {
|
|
365
|
+
type: 'cross-reference',
|
|
366
|
+
refType,
|
|
367
|
+
id,
|
|
368
|
+
href: `#${id}`,
|
|
369
|
+
text,
|
|
370
|
+
},
|
|
371
|
+
}));
|
|
372
|
+
}
|
|
215
373
|
handleHeadingKeydown(event, heading, index) {
|
|
216
374
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
217
375
|
event.preventDefault();
|
|
@@ -257,7 +415,7 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
257
415
|
}
|
|
258
416
|
}
|
|
259
417
|
this.activeHeadingKey = this.headingKey(heading, index);
|
|
260
|
-
this.dispatchEvent(new CustomEvent('outline-navigate', {
|
|
418
|
+
this.dispatchEvent(new CustomEvent('sciflow-outline-navigate', {
|
|
261
419
|
detail: {
|
|
262
420
|
heading,
|
|
263
421
|
behavior: this.clickBehavior,
|
|
@@ -320,8 +478,10 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
320
478
|
this.selectionListener = (event) => {
|
|
321
479
|
const selection = event.detail;
|
|
322
480
|
this.updateActiveHeading(selection);
|
|
481
|
+
this.cursorActive = true;
|
|
323
482
|
};
|
|
324
483
|
this.readyListener = () => {
|
|
484
|
+
this.cursorActive = false;
|
|
325
485
|
const pmDoc = editor.editorView?.state?.doc ?? null;
|
|
326
486
|
this.updateHeadingsFromDoc(this.doc ?? this.extractDocFromEditor(editor), pmDoc);
|
|
327
487
|
if (pmDoc) {
|
|
@@ -359,8 +519,8 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
359
519
|
const outline = collectDocumentOutline(doc, pmDoc);
|
|
360
520
|
const filtered = this.applyLevelFilter(outline.headings);
|
|
361
521
|
this.headings = filtered;
|
|
522
|
+
this.figures = outline.figures ?? [];
|
|
362
523
|
this.updateActiveHeading(this.lastSelection);
|
|
363
|
-
this.dispatchOutlineChange(filtered);
|
|
364
524
|
}
|
|
365
525
|
applyLevelFilter(headings) {
|
|
366
526
|
const levelSet = this.getLevelFilterSet();
|
|
@@ -442,16 +602,6 @@ let SciFlowOutlineElement = class SciFlowOutlineElement extends LitElement {
|
|
|
442
602
|
normalizeClickBehavior(value) {
|
|
443
603
|
return CLICK_BEHAVIORS.includes(value) ? value : 'scroll';
|
|
444
604
|
}
|
|
445
|
-
dispatchOutlineChange(headings) {
|
|
446
|
-
this.dispatchEvent(new CustomEvent('outline-change', {
|
|
447
|
-
detail: {
|
|
448
|
-
headings,
|
|
449
|
-
active: this.activeHeadingKey,
|
|
450
|
-
},
|
|
451
|
-
bubbles: true,
|
|
452
|
-
composed: true,
|
|
453
|
-
}));
|
|
454
|
-
}
|
|
455
605
|
};
|
|
456
606
|
__decorate([
|
|
457
607
|
property({ attribute: false })
|
|
@@ -482,9 +632,15 @@ __decorate([
|
|
|
482
632
|
__decorate([
|
|
483
633
|
state()
|
|
484
634
|
], SciFlowOutlineElement.prototype, "headings", void 0);
|
|
635
|
+
__decorate([
|
|
636
|
+
state()
|
|
637
|
+
], SciFlowOutlineElement.prototype, "figures", void 0);
|
|
485
638
|
__decorate([
|
|
486
639
|
state()
|
|
487
640
|
], SciFlowOutlineElement.prototype, "activeHeadingKey", void 0);
|
|
641
|
+
__decorate([
|
|
642
|
+
property({ type: Boolean, attribute: false })
|
|
643
|
+
], SciFlowOutlineElement.prototype, "cursorActive", void 0);
|
|
488
644
|
SciFlowOutlineElement = __decorate([
|
|
489
645
|
customElement('sciflow-outline')
|
|
490
646
|
], SciFlowOutlineElement);
|
|
@@ -14,8 +14,8 @@ type ReferenceAuthor = {
|
|
|
14
14
|
} | null;
|
|
15
15
|
export type ReferenceListEntry = {
|
|
16
16
|
id?: string | null;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
rawReference?: string | null;
|
|
18
|
+
raw_reference?: string | null;
|
|
19
19
|
author?: ReferenceAuthor[] | null;
|
|
20
20
|
issued?: {
|
|
21
21
|
'date-parts'?: Array<Array<number | string | null> | null> | null;
|
|
@@ -31,8 +31,15 @@ export declare class SciFlowReferenceListElement extends LitElement {
|
|
|
31
31
|
references: ReferenceListEntry[] | null;
|
|
32
32
|
/** Reference IDs to highlight. */
|
|
33
33
|
highlightedIds: string[];
|
|
34
|
+
/**
|
|
35
|
+
* Whether the editor has an active cursor. Controls the enabled state of
|
|
36
|
+
* the "Cite" button. Set to true when the editor has focus/selection and
|
|
37
|
+
* false when it does not.
|
|
38
|
+
*/
|
|
39
|
+
cursorActive: boolean;
|
|
34
40
|
/** Text displayed when no references are available. */
|
|
35
41
|
emptyText: string;
|
|
42
|
+
private localeListener?;
|
|
36
43
|
private themeUnsub?;
|
|
37
44
|
private themeStyleElements;
|
|
38
45
|
static styles: import("lit").CSSResult;
|
|
@@ -47,6 +54,7 @@ export declare class SciFlowReferenceListElement extends LitElement {
|
|
|
47
54
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
48
55
|
private formatReference;
|
|
49
56
|
private formatAuthor;
|
|
57
|
+
private handleInsertCitation;
|
|
50
58
|
private handleDragStart;
|
|
51
59
|
}
|
|
52
60
|
declare global {
|
|
@@ -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;
|
|
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;AAQhE,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,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,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,EAAE,MAAM,EAAE,CAAM;IAE9B;;;;OAIG;IAEH,YAAY,UAAS;IAErB,uDAAuD;IAEvD,SAAS,SAAM;IAEf,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,UAAU,CAAC,CAAa;IAChC,OAAO,CAAC,kBAAkB,CAA0B;IAEpD,OAAgB,MAAM,0BAAuC;IAEpD,iBAAiB,IAAI,IAAI;IAazB,oBAAoB,IAAI,IAAI;IAUrC;;;;OAIG;IACH,SAAS,CAAC,YAAY,GAAE,QAAQ,CAAC,MAAM,CAAM,GAAG,IAAI;cAMjC,MAAM;IAuDzB,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,YAAY;IAUpB,OAAO,CAAC,oBAAoB;IAU5B,OAAO,CAAC,eAAe;CAiCxB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,wBAAwB,EAAE,2BAA2B,CAAC;KACvD;CACF"}
|