@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
package/dist/index.d.ts
CHANGED
|
@@ -6,12 +6,17 @@
|
|
|
6
6
|
* bundling strategy used for the demo so integrators have a single import path.
|
|
7
7
|
*/
|
|
8
8
|
export * from './lib/editor-element.js';
|
|
9
|
+
export { ghostCursorFeature } from './lib/ghost-cursor.js';
|
|
9
10
|
export * from './lib/format-bar.js';
|
|
11
|
+
export { materialIcons } from './lib/icons-generated.js';
|
|
10
12
|
export * from './lib/outline.js';
|
|
11
13
|
export * from './lib/reference-list.js';
|
|
12
14
|
export * from './lib/selection-editor.js';
|
|
13
15
|
export * from './lib/theme.js';
|
|
14
16
|
export { defaultCitationSourceAdapter, getCitationSourceAdapter, setCitationSourceAdapter, type CitationItem, type CitationSourceEditorAdapter, type CitationSourceEditorContext, } from './lib/citation-source-adapter.js';
|
|
15
|
-
export { SourceField } from '@sciflow/editor-core';
|
|
16
|
-
export {
|
|
17
|
+
export { SourceField, t, getLocale, setLocale, registerTranslations, LOCALE_CHANGE_EVENT, getCitedReferenceIds, validateDocumentResources, defaultTranslations } from '@sciflow/editor-core';
|
|
18
|
+
export type { MissingResource, TranslationDictionary } from '@sciflow/editor-core';
|
|
19
|
+
export { generateJatsBody } from '@sciflow/schema-prosemirror';
|
|
20
|
+
export type { Locale, TranslationKey } from '@sciflow/editor-core';
|
|
21
|
+
export { citationFeature, crossReferenceFeature, createFigureFeature, listFeature, blockquoteFeature, copyPasteFeature, installMockImageServer, configureImageUploadHandlers, requestImageFile, uploadImageFile, promptForFigureOptions, figureFeature, footnoteFeature, headingFeature, hyperlinkFeature, markFormattingFeature, mathFeature, paragraphFeature, tableFeature, } from '@sciflow/editor-core';
|
|
17
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,GACjC,MAAM,kCAAkC,CAAC;AAG1C,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7L,YAAY,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,EAC5B,gBAAgB,EAChB,eAAe,EACf,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,gBAAgB,EAChB,YAAY,GACb,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* bundling strategy used for the demo so integrators have a single import path.
|
|
7
7
|
*/
|
|
8
8
|
export * from './lib/editor-element.js';
|
|
9
|
+
export { ghostCursorFeature } from './lib/ghost-cursor.js';
|
|
9
10
|
export * from './lib/format-bar.js';
|
|
11
|
+
export { materialIcons } from './lib/icons-generated.js';
|
|
10
12
|
export * from './lib/outline.js';
|
|
11
13
|
export * from './lib/reference-list.js';
|
|
12
14
|
export * from './lib/selection-editor.js';
|
|
13
15
|
export * from './lib/theme.js';
|
|
14
16
|
export { defaultCitationSourceAdapter, getCitationSourceAdapter, setCitationSourceAdapter, } from './lib/citation-source-adapter.js';
|
|
15
|
-
// Convenience re-
|
|
16
|
-
export { SourceField } from '@sciflow/editor-core';
|
|
17
|
-
export {
|
|
17
|
+
// Convenience re-exports: allow downstream bundles to pull these from here.
|
|
18
|
+
export { SourceField, t, getLocale, setLocale, registerTranslations, LOCALE_CHANGE_EVENT, getCitedReferenceIds, validateDocumentResources, defaultTranslations } from '@sciflow/editor-core';
|
|
19
|
+
export { generateJatsBody } from '@sciflow/schema-prosemirror';
|
|
20
|
+
export { citationFeature, crossReferenceFeature, createFigureFeature, listFeature, blockquoteFeature, copyPasteFeature, installMockImageServer, configureImageUploadHandlers, requestImageFile, uploadImageFile, promptForFigureOptions, figureFeature, footnoteFeature, headingFeature, hyperlinkFeature, markFormattingFeature, mathFeature, paragraphFeature, tableFeature, } from '@sciflow/editor-core';
|
|
@@ -7,12 +7,32 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { CitationItem } from '@sciflow/editor-core';
|
|
9
9
|
export type { CitationItem };
|
|
10
|
+
/**
|
|
11
|
+
* Reference entry for the citation ID dropdown (id + optional display label).
|
|
12
|
+
*/
|
|
13
|
+
export interface CitationReferenceOption {
|
|
14
|
+
id: string;
|
|
15
|
+
rawReference?: string;
|
|
16
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* Context passed to the adapter when rendering or updating.
|
|
12
19
|
*/
|
|
13
20
|
export interface CitationSourceEditorContext {
|
|
14
|
-
/**
|
|
15
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Apply updated source string to the node via command API (immediate commit).
|
|
23
|
+
* Optional when using draft flow; then only onSourceChange is used until an explicit Update.
|
|
24
|
+
*/
|
|
25
|
+
applySource?: (encoded: string | null) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Draft callback: called when source fields change without applying to the document.
|
|
28
|
+
* When provided, the adapter uses this instead of applySource for field changes.
|
|
29
|
+
*/
|
|
30
|
+
onSourceChange?: (encoded: string | null) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Optional list of references available in the editor (for ID dropdown).
|
|
33
|
+
* When provided, the default adapter renders a dropdown for the ID field instead of a text input.
|
|
34
|
+
*/
|
|
35
|
+
getReferences?: () => CitationReferenceOption[];
|
|
16
36
|
}
|
|
17
37
|
/**
|
|
18
38
|
* Adapter interface for rendering and editing citation source (CSL citation items).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"citation-source-adapter.d.ts","sourceRoot":"","sources":["../../src/lib/citation-source-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C
|
|
1
|
+
{"version":3,"file":"citation-source-adapter.d.ts","sourceRoot":"","sources":["../../src/lib/citation-source-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGzD,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC;IAClD;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAClD;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,uBAAuB,EAAE,CAAC;CACjD;AAED;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;;;;OAKG;IACH,MAAM,CACJ,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,YAAY,EAAE,EACrB,OAAO,EAAE,2BAA2B,GACnC,IAAI,CAAC;IAER;;;;;OAKG;IACH,MAAM,CAAC,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC;IAEnG;;;OAGG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,2BAiL1C,CAAC;AAKF;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,2BAA2B,GAAG,IAAI,GAAG,IAAI,CAE1F;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,2BAA2B,CAEtE"}
|
|
@@ -24,61 +24,117 @@ export const defaultCitationSourceAdapter = {
|
|
|
24
24
|
})
|
|
25
25
|
.filter((item) => item !== null);
|
|
26
26
|
const encoded = SourceField.toString(normalized);
|
|
27
|
-
context.
|
|
27
|
+
if (context.onSourceChange) {
|
|
28
|
+
context.onSourceChange(encoded);
|
|
29
|
+
}
|
|
30
|
+
else if (context.applySource) {
|
|
31
|
+
context.applySource(encoded);
|
|
32
|
+
}
|
|
28
33
|
};
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
34
|
+
const appendTextInput = (fieldDiv, idAttr, item, key, index, itemsList, applyFn) => {
|
|
35
|
+
const input = document.createElement('input');
|
|
36
|
+
input.type = 'text';
|
|
37
|
+
input.id = idAttr;
|
|
38
|
+
input.className = 'selection-editor-input';
|
|
39
|
+
input.placeholder = 'No value';
|
|
40
|
+
const val = item[key];
|
|
41
|
+
input.value = typeof val === 'string' ? val : val != null ? String(val) : '';
|
|
42
|
+
input.addEventListener('change', () => {
|
|
43
|
+
const v = input.value.trim();
|
|
44
|
+
itemsList[index][key] = v || undefined;
|
|
45
|
+
applyFn();
|
|
46
|
+
});
|
|
47
|
+
fieldDiv.appendChild(input);
|
|
48
|
+
};
|
|
49
|
+
const idFieldOnly = [
|
|
50
|
+
{ key: 'id', label: 'ID', type: 'text', required: true },
|
|
51
|
+
];
|
|
52
|
+
const extraFields = [
|
|
53
|
+
{ key: 'label', label: 'Label', type: 'text' },
|
|
54
|
+
{ key: 'locator', label: 'Locator', type: 'text' },
|
|
55
|
+
{ key: 'prefix', label: 'Prefix', type: 'text' },
|
|
56
|
+
{ key: 'suffix', label: 'Suffix', type: 'text' },
|
|
57
|
+
{ key: 'suppress-author', label: 'Suppress author', type: 'checkbox' },
|
|
58
|
+
{ key: 'author-only', label: 'Author only', type: 'checkbox' },
|
|
59
|
+
];
|
|
60
|
+
const renderField = (section, item, index, key, label, type) => {
|
|
61
|
+
const fieldDiv = document.createElement('div');
|
|
62
|
+
fieldDiv.className =
|
|
63
|
+
type === 'checkbox' ? 'citation-source-field citation-source-field--checkbox' : 'citation-source-field';
|
|
64
|
+
fieldDiv.setAttribute('data-field', key);
|
|
65
|
+
const idAttr = `citation-${index}-${key}`;
|
|
66
|
+
const labelEl = document.createElement('label');
|
|
67
|
+
labelEl.htmlFor = idAttr;
|
|
68
|
+
labelEl.className = 'selection-editor-attr-label';
|
|
69
|
+
labelEl.textContent = `${label}:`;
|
|
70
|
+
fieldDiv.appendChild(labelEl);
|
|
71
|
+
if (type === 'checkbox') {
|
|
72
|
+
const input = document.createElement('input');
|
|
73
|
+
input.type = 'checkbox';
|
|
74
|
+
input.id = idAttr;
|
|
75
|
+
input.className = 'selection-editor-input';
|
|
76
|
+
const val = item[key];
|
|
77
|
+
input.checked = val === 1 || val === true;
|
|
78
|
+
input.addEventListener('change', () => {
|
|
79
|
+
items[index][key] = input.checked ? 1 : undefined;
|
|
80
|
+
apply();
|
|
81
|
+
});
|
|
82
|
+
fieldDiv.appendChild(input);
|
|
83
|
+
}
|
|
84
|
+
else if (key === 'id' && context.getReferences) {
|
|
85
|
+
const refs = context.getReferences();
|
|
86
|
+
if (refs.length > 0) {
|
|
87
|
+
const select = document.createElement('select');
|
|
88
|
+
select.id = idAttr;
|
|
89
|
+
select.className = 'selection-editor-input selection-editor-select';
|
|
90
|
+
const currentId = typeof item.id === 'string' ? item.id : item.id != null ? String(item.id) : '';
|
|
91
|
+
const emptyOpt = document.createElement('option');
|
|
92
|
+
emptyOpt.value = '';
|
|
93
|
+
emptyOpt.textContent = 'No value';
|
|
94
|
+
select.appendChild(emptyOpt);
|
|
95
|
+
refs.forEach((ref) => {
|
|
96
|
+
const opt = document.createElement('option');
|
|
97
|
+
opt.value = ref.id;
|
|
98
|
+
opt.textContent = (ref.rawReference ?? ref.id).trim() || ref.id;
|
|
99
|
+
select.appendChild(opt);
|
|
62
100
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const input = document.createElement('input');
|
|
67
|
-
input.type = 'text';
|
|
68
|
-
input.id = idAttr;
|
|
69
|
-
input.className = 'selection-editor-input';
|
|
70
|
-
input.placeholder = 'No value';
|
|
71
|
-
const val = item[key];
|
|
72
|
-
input.value = typeof val === 'string' ? val : val != null ? String(val) : '';
|
|
73
|
-
input.addEventListener('change', () => {
|
|
74
|
-
const v = input.value.trim();
|
|
101
|
+
select.value = refs.some((r) => r.id === currentId) ? currentId : '';
|
|
102
|
+
select.addEventListener('change', () => {
|
|
103
|
+
const v = select.value.trim();
|
|
75
104
|
items[index][key] = v || undefined;
|
|
76
105
|
apply();
|
|
77
106
|
});
|
|
78
|
-
fieldDiv.appendChild(
|
|
107
|
+
fieldDiv.appendChild(select);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
appendTextInput(fieldDiv, idAttr, item, key, index, items, apply);
|
|
79
111
|
}
|
|
80
|
-
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
appendTextInput(fieldDiv, idAttr, item, key, index, items, apply);
|
|
115
|
+
}
|
|
116
|
+
section.appendChild(fieldDiv);
|
|
117
|
+
};
|
|
118
|
+
items.forEach((item, index) => {
|
|
119
|
+
const section = document.createElement('div');
|
|
120
|
+
section.className = 'citation-source-item';
|
|
121
|
+
section.setAttribute('data-citation-index', String(index));
|
|
122
|
+
idFieldOnly.forEach(({ key, label, type }) => {
|
|
123
|
+
renderField(section, item, index, key, label, type);
|
|
124
|
+
});
|
|
125
|
+
const details = document.createElement('details');
|
|
126
|
+
details.className = 'citation-source-details';
|
|
127
|
+
const summary = document.createElement('summary');
|
|
128
|
+
summary.className = 'citation-source-details-summary';
|
|
129
|
+
summary.textContent = 'Label, locator, prefix…';
|
|
130
|
+
details.appendChild(summary);
|
|
131
|
+
const detailsBody = document.createElement('div');
|
|
132
|
+
detailsBody.className = 'citation-source-details-body';
|
|
133
|
+
extraFields.forEach(({ key, label, type }) => {
|
|
134
|
+
renderField(detailsBody, item, index, key, label, type);
|
|
81
135
|
});
|
|
136
|
+
details.appendChild(detailsBody);
|
|
137
|
+
section.appendChild(details);
|
|
82
138
|
if (items.length > 1) {
|
|
83
139
|
const removeBtn = document.createElement('button');
|
|
84
140
|
removeBtn.type = 'button';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configure a transparent, offset drag image for HTML5 drag operations.
|
|
3
|
+
* Makes it easier to see the drop cursor while dragging references or headings.
|
|
4
|
+
*
|
|
5
|
+
* @param event - The dragstart event
|
|
6
|
+
* @param options - Optional opacity (0–1), vertical offset (positive = above cursor), and scale (0–1)
|
|
7
|
+
*/
|
|
8
|
+
export declare function setTransparentDragImage(event: DragEvent, options?: {
|
|
9
|
+
opacity?: number;
|
|
10
|
+
offsetY?: number;
|
|
11
|
+
scale?: number;
|
|
12
|
+
}): void;
|
|
13
|
+
//# sourceMappingURL=drag-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drag-preview.d.ts","sourceRoot":"","sources":["../../src/lib/drag-preview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,SAAS,EAChB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GACnE,IAAI,CAsCN"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configure a transparent, offset drag image for HTML5 drag operations.
|
|
3
|
+
* Makes it easier to see the drop cursor while dragging references or headings.
|
|
4
|
+
*
|
|
5
|
+
* @param event - The dragstart event
|
|
6
|
+
* @param options - Optional opacity (0–1), vertical offset (positive = above cursor), and scale (0–1)
|
|
7
|
+
*/
|
|
8
|
+
export function setTransparentDragImage(event, options = {}) {
|
|
9
|
+
const transfer = event.dataTransfer;
|
|
10
|
+
// Prefer currentTarget (the draggable element) over target (the clicked child).
|
|
11
|
+
// When a user clicks a small child element (e.g. a "drag" badge), event.target
|
|
12
|
+
// is that tiny child — cloning it gives near-zero dimensions, which combined with
|
|
13
|
+
// a negative offsetY produces a negative setDragImage y-coordinate that causes
|
|
14
|
+
// browsers to fall back to the default opaque drag image.
|
|
15
|
+
const target = (event.currentTarget ?? event.target);
|
|
16
|
+
if (!transfer || !(target instanceof HTMLElement))
|
|
17
|
+
return;
|
|
18
|
+
const { opacity = 0.5, offsetY = 20, scale = 1 } = options;
|
|
19
|
+
const clone = target.cloneNode(true);
|
|
20
|
+
clone.style.opacity = String(opacity);
|
|
21
|
+
clone.style.transform = `scale(${scale})`;
|
|
22
|
+
clone.style.transformOrigin = 'bottom center';
|
|
23
|
+
clone.style.position = 'absolute';
|
|
24
|
+
clone.style.top = '-9999px';
|
|
25
|
+
clone.style.left = '-9999px';
|
|
26
|
+
clone.style.pointerEvents = 'none';
|
|
27
|
+
clone.style.maxWidth = '18rem';
|
|
28
|
+
clone.style.fontSize = '0.65rem';
|
|
29
|
+
clone.style.background = 'transparent';
|
|
30
|
+
clone.style.boxShadow = 'none';
|
|
31
|
+
const root = target.getRootNode();
|
|
32
|
+
const container = root instanceof ShadowRoot ? root : document.body;
|
|
33
|
+
container.appendChild(clone);
|
|
34
|
+
const rect = clone.getBoundingClientRect();
|
|
35
|
+
const x = Math.floor(rect.width / 2);
|
|
36
|
+
const y = Math.max(0, Math.floor(rect.height) + offsetY);
|
|
37
|
+
try {
|
|
38
|
+
transfer.setDragImage(clone, x, y);
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
requestAnimationFrame(() => clone.remove());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -27,7 +27,7 @@ import { LitElement } from 'lit';
|
|
|
27
27
|
import type { PropertyValues } from 'lit';
|
|
28
28
|
import type { Node as ProsemirrorNode, ResolvedPos } from 'prosemirror-model';
|
|
29
29
|
import type { PluginKey } from 'prosemirror-state';
|
|
30
|
-
import { Editor, type CommandRunner, type Feature, type Operation, type SciFlowDocJSON, type SnapshotFile, type SnapshotReference, type SelectionJSON, type Version } from '@sciflow/editor-core';
|
|
30
|
+
import { Editor, type CommandRunner, type Feature, type Locale, type Operation, type SciFlowDocJSON, type SnapshotFile, type SnapshotReference, type SelectionJSON, type Version } from '@sciflow/editor-core';
|
|
31
31
|
/**
|
|
32
32
|
* Detail payload emitted with the `editor-change` event.
|
|
33
33
|
* Consumers receive both the latest document snapshot and the batch of
|
|
@@ -59,7 +59,7 @@ export interface PositionAPI {
|
|
|
59
59
|
}
|
|
60
60
|
export interface PluginAPI {
|
|
61
61
|
getState<T>(key: PluginKey<T>): T | null;
|
|
62
|
-
dispatchMeta(key: PluginKey, meta:
|
|
62
|
+
dispatchMeta(key: PluginKey, meta: unknown): boolean;
|
|
63
63
|
}
|
|
64
64
|
export interface DomAPI {
|
|
65
65
|
getBoundingRect(): DOMRect | null;
|
|
@@ -108,6 +108,25 @@ export declare class SciFlowEditorElement extends LitElement {
|
|
|
108
108
|
headingText: string;
|
|
109
109
|
/** Paragraph text used when no initial content is provided. */
|
|
110
110
|
placeholder: string;
|
|
111
|
+
/**
|
|
112
|
+
* Max-width of the ProseMirror content area.
|
|
113
|
+
* Approximates page-like text columns at 11pt:
|
|
114
|
+
* - 'narrow': narrow column (~52 characters per line)
|
|
115
|
+
* - 'wide': normal column (~82 characters per line)
|
|
116
|
+
* Styles are applied to the shadow DOM.
|
|
117
|
+
*/
|
|
118
|
+
editorWidth: 'narrow' | 'wide';
|
|
119
|
+
/**
|
|
120
|
+
* UI locale for all editor components and command metadata.
|
|
121
|
+
* Setting this attribute calls `setLocale()` and triggers a
|
|
122
|
+
* `sciflow-locale-change` event so all components re-render.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```html
|
|
126
|
+
* <sciflow-editor locale="de"></sciflow-editor>
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
locale: Locale | null;
|
|
111
130
|
private view;
|
|
112
131
|
private editor?;
|
|
113
132
|
private docUnsub?;
|
|
@@ -121,12 +140,17 @@ export declare class SciFlowEditorElement extends LitElement {
|
|
|
121
140
|
private shadowStyleElements;
|
|
122
141
|
private themeUnsub?;
|
|
123
142
|
private themeStyleElements;
|
|
143
|
+
private _hostDragoverBound;
|
|
124
144
|
/** Access the underlying ProseMirror view instance. */
|
|
125
145
|
get editorView(): ReturnType<Editor['getView']> | null;
|
|
126
146
|
/** Access SciFlow command helpers bound to the current editor view. */
|
|
127
147
|
get commands(): CommandRunner | null;
|
|
128
148
|
/** Get read-only access to the document structure for traversal. */
|
|
129
149
|
get document(): ProsemirrorNode | null;
|
|
150
|
+
/** Get the current references (bibliography) stored with the document. */
|
|
151
|
+
get references(): SnapshotReference[];
|
|
152
|
+
/** Get the merged selection UI schema (Draft-07 + _ui_*), when available. */
|
|
153
|
+
getSelectionUiSchema(): import("@sciflow/editor-core").SelectionUiSchema | undefined;
|
|
130
154
|
/** Get position utilities for coordinate mapping. */
|
|
131
155
|
get positions(): {
|
|
132
156
|
coordsAtPos: (pos: number) => {
|
|
@@ -140,7 +164,7 @@ export declare class SciFlowEditorElement extends LitElement {
|
|
|
140
164
|
/** Get plugin management utilities. */
|
|
141
165
|
get plugins(): {
|
|
142
166
|
getState: <T>(key: PluginKey<T>) => NonNullable<T> | null;
|
|
143
|
-
dispatchMeta: (key: PluginKey, meta:
|
|
167
|
+
dispatchMeta: (key: PluginKey, meta: unknown) => boolean;
|
|
144
168
|
};
|
|
145
169
|
/** Get editor DOM utilities. */
|
|
146
170
|
get dom(): {
|
|
@@ -185,6 +209,8 @@ export declare class SciFlowEditorElement extends LitElement {
|
|
|
185
209
|
private isExternalDocUpdate;
|
|
186
210
|
private extractDocFromInput;
|
|
187
211
|
private buildSyncUpdate;
|
|
212
|
+
private isNoopSyncUpdate;
|
|
213
|
+
private deepEqualsJSON;
|
|
188
214
|
/**
|
|
189
215
|
* Determine which document should be loaded on startup.
|
|
190
216
|
* Preference order: externally supplied JSON, provided PM node, fallback.
|
|
@@ -243,9 +269,9 @@ export declare class SciFlowEditorElement extends LitElement {
|
|
|
243
269
|
private destroyEditor;
|
|
244
270
|
private capturePendingOps;
|
|
245
271
|
private applyShadowStyles;
|
|
272
|
+
private getEditorWidthStyles;
|
|
246
273
|
private normalizeShadowStyles;
|
|
247
274
|
private extractCssFromSheet;
|
|
248
|
-
private debugTestLog;
|
|
249
275
|
}
|
|
250
276
|
declare global {
|
|
251
277
|
interface HTMLElementTagNameMap {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor-element.d.ts","sourceRoot":"","sources":["../../src/lib/editor-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAwB,U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