@dxos/ui-editor 0.8.4-main.cb12b3f963 → 0.8.4-main.dfabb4ec29
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/dist/lib/browser/index.mjs +28 -18
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +28 -18
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/extensions/auto-scroll.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete/placeholder.d.ts +5 -2
- package/dist/types/src/extensions/autocomplete/placeholder.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -26
- package/src/extensions/auto-scroll.ts +9 -7
- package/src/extensions/autocomplete/placeholder.ts +37 -18
- package/src/extensions/scroller.ts +1 -1
|
@@ -363,30 +363,37 @@ var insertAtLineStart = (view, from, insert) => {
|
|
|
363
363
|
};
|
|
364
364
|
|
|
365
365
|
// src/extensions/autocomplete/placeholder.ts
|
|
366
|
-
var placeholder = ({ content, delay = 3e3 }) => {
|
|
366
|
+
var placeholder = ({ content, delay = 3e3, focusOnly = false }) => {
|
|
367
367
|
const plugin = ViewPlugin3.fromClass(class {
|
|
368
368
|
_timeout;
|
|
369
369
|
_decorations = Decoration3.none;
|
|
370
370
|
update(update2) {
|
|
371
|
+
if (!update2.docChanged && !update2.selectionSet && !update2.focusChanged) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
371
374
|
if (this._timeout) {
|
|
372
375
|
window.clearTimeout(this._timeout);
|
|
373
376
|
this._timeout = void 0;
|
|
374
377
|
}
|
|
378
|
+
this._decorations = Decoration3.none;
|
|
379
|
+
if (focusOnly && !update2.view.hasFocus) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
375
382
|
const activeLine = update2.view.state.doc.lineAt(update2.view.state.selection.main.head);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
const lineStart = activeLine.from;
|
|
379
|
-
this._timeout = setTimeout(() => {
|
|
380
|
-
this._decorations = Decoration3.set([
|
|
381
|
-
Decoration3.widget({
|
|
382
|
-
widget: new PlaceholderWidget(content),
|
|
383
|
-
side: 1
|
|
384
|
-
}).range(lineStart)
|
|
385
|
-
]);
|
|
386
|
-
update2.view.update([]);
|
|
387
|
-
}, delay);
|
|
383
|
+
if (activeLine.text.trim() !== "") {
|
|
384
|
+
return;
|
|
388
385
|
}
|
|
389
|
-
|
|
386
|
+
const lineStart = activeLine.from;
|
|
387
|
+
const view = update2.view;
|
|
388
|
+
this._timeout = setTimeout(() => {
|
|
389
|
+
this._decorations = Decoration3.set([
|
|
390
|
+
Decoration3.widget({
|
|
391
|
+
widget: new PlaceholderWidget(content),
|
|
392
|
+
side: 1
|
|
393
|
+
}).range(lineStart)
|
|
394
|
+
]);
|
|
395
|
+
view.update([]);
|
|
396
|
+
}, delay);
|
|
390
397
|
}
|
|
391
398
|
destroy() {
|
|
392
399
|
if (this._timeout) {
|
|
@@ -573,7 +580,7 @@ var scroller = ({ overScroll = 0 } = {}) => {
|
|
|
573
580
|
});
|
|
574
581
|
return [
|
|
575
582
|
scrollPlugin,
|
|
576
|
-
// Listen for effect.
|
|
583
|
+
// Listen for effect.
|
|
577
584
|
EditorView4.updateListener.of((update2) => {
|
|
578
585
|
update2.transactions.forEach((transaction) => {
|
|
579
586
|
try {
|
|
@@ -759,12 +766,15 @@ var autoScroll = ({ scrollOnResize = true } = {}) => {
|
|
|
759
766
|
if (this.destroyed) {
|
|
760
767
|
return;
|
|
761
768
|
}
|
|
762
|
-
view.scrollDOM.
|
|
769
|
+
view.scrollDOM.scrollTo({
|
|
770
|
+
top: view.scrollDOM.scrollHeight,
|
|
771
|
+
behavior: "instant"
|
|
772
|
+
});
|
|
763
773
|
view.dispatch({
|
|
764
|
-
effects: scrollerCrawlEffect.of(
|
|
774
|
+
effects: scrollerCrawlEffect.of(false)
|
|
765
775
|
});
|
|
766
776
|
});
|
|
767
|
-
},
|
|
777
|
+
}, 50);
|
|
768
778
|
this.observer = new ResizeObserver(() => {
|
|
769
779
|
if (this.firstObservation) {
|
|
770
780
|
this.firstObservation = false;
|