@dxos/ui-editor 0.8.4-main.fcfe5033a5 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/browser/index.mjs +1258 -1004
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +26 -6
- package/dist/lib/browser/types/index.mjs.map +4 -4
- package/dist/lib/node-esm/index.mjs +1258 -1003
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +27 -6
- package/dist/lib/node-esm/types/index.mjs.map +4 -4
- package/dist/types/src/defaults.d.ts.map +1 -1
- package/dist/types/src/extensions/annotations.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/types/src/extensions/autocomplete/match.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/src/extensions/autocomplete/typeahead.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts +1 -1
- package/dist/types/src/extensions/automerge/automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts +1 -1
- package/dist/types/src/extensions/automerge/cursor.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/defs.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts +1 -1
- package/dist/types/src/extensions/automerge/sync.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts +1 -1
- package/dist/types/src/extensions/automerge/update-automerge.d.ts.map +1 -1
- package/dist/types/src/extensions/automerge/update-codemirror.d.ts.map +1 -1
- package/dist/types/src/extensions/awareness/awareness-provider.d.ts.map +1 -1
- package/dist/types/src/extensions/awareness/awareness.d.ts.map +1 -1
- package/dist/types/src/extensions/blast.d.ts.map +1 -1
- package/dist/types/src/extensions/comments.d.ts +19 -1
- package/dist/types/src/extensions/comments.d.ts.map +1 -1
- package/dist/types/src/extensions/debug.d.ts.map +1 -1
- package/dist/types/src/extensions/dnd.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.d.ts +3 -2
- package/dist/types/src/extensions/factories.d.ts.map +1 -1
- package/dist/types/src/extensions/factories.test.d.ts +2 -0
- package/dist/types/src/extensions/factories.test.d.ts.map +1 -0
- package/dist/types/src/extensions/focus.d.ts +1 -1
- package/dist/types/src/extensions/index.d.ts +3 -4
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/json.d.ts +1 -1
- package/dist/types/src/extensions/json.d.ts.map +1 -1
- package/dist/types/src/extensions/listener.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/bundle.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/changes.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/debug.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/decorate.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/formatting.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/highlight.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/image.d.ts +13 -2
- package/dist/types/src/extensions/markdown/image.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/image.test.d.ts +2 -0
- package/dist/types/src/extensions/markdown/image.test.d.ts.map +1 -0
- package/dist/types/src/extensions/markdown/link.d.ts.map +1 -1
- package/dist/types/src/extensions/markdown/table.d.ts.map +1 -1
- package/dist/types/src/extensions/mention.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/menu.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/outliner.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/outliner/tree.d.ts.map +1 -1
- package/dist/types/src/extensions/preview/preview.d.ts +2 -2
- package/dist/types/src/extensions/preview/preview.d.ts.map +1 -1
- package/dist/types/src/extensions/replacer.d.ts.map +1 -1
- package/dist/types/src/extensions/scrolling/auto-scroll.d.ts +18 -0
- package/dist/types/src/extensions/scrolling/auto-scroll.d.ts.map +1 -0
- package/dist/types/src/extensions/scrolling/crawler.d.ts +83 -0
- package/dist/types/src/extensions/scrolling/crawler.d.ts.map +1 -0
- package/dist/types/src/extensions/scrolling/index.d.ts +6 -0
- package/dist/types/src/extensions/scrolling/index.d.ts.map +1 -0
- package/dist/types/src/extensions/scrolling/scroll-past-end.d.ts.map +1 -0
- package/dist/types/src/extensions/scrolling/scrollbar-autohide.d.ts +15 -0
- package/dist/types/src/extensions/scrolling/scrollbar-autohide.d.ts.map +1 -0
- package/dist/types/src/extensions/scrolling/scroller.d.ts +16 -0
- package/dist/types/src/extensions/scrolling/scroller.d.ts.map +1 -0
- package/dist/types/src/extensions/selection.d.ts.map +1 -1
- package/dist/types/src/extensions/snippets.d.ts +10 -0
- package/dist/types/src/extensions/snippets.d.ts.map +1 -0
- package/dist/types/src/extensions/spacing.d.ts +3 -0
- package/dist/types/src/extensions/spacing.d.ts.map +1 -0
- package/dist/types/src/extensions/submit.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/extended-markdown.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/fader.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/index.d.ts +3 -1
- package/dist/types/src/extensions/tags/index.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/typewriter.d.ts +43 -0
- package/dist/types/src/extensions/tags/typewriter.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/typewriter.test.d.ts +2 -0
- package/dist/types/src/extensions/tags/typewriter.test.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-block-decoration.d.ts +31 -0
- package/dist/types/src/extensions/tags/xml-block-decoration.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-formatting.d.ts +24 -0
- package/dist/types/src/extensions/tags/xml-formatting.d.ts.map +1 -0
- package/dist/types/src/extensions/tags/xml-tags.d.ts +1 -8
- package/dist/types/src/extensions/tags/xml-tags.d.ts.map +1 -1
- package/dist/types/src/extensions/tags/xml-util.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/styles/theme.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/util/cursor.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/decorations.d.ts.map +1 -1
- package/dist/types/src/util/dom.d.ts.map +1 -1
- package/dist/types/src/util/facet.d.ts.map +1 -1
- package/dist/types/src/util/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +55 -57
- package/src/defaults.ts +6 -4
- package/src/extensions/autocomplete/placeholder.ts +37 -18
- package/src/extensions/automerge/automerge.test.tsx +35 -9
- package/src/extensions/automerge/automerge.ts +1 -1
- package/src/extensions/automerge/cursor.ts +1 -1
- package/src/extensions/automerge/sync.ts +1 -1
- package/src/extensions/automerge/update-automerge.ts +1 -1
- package/src/extensions/comments.ts +54 -31
- package/src/extensions/factories.test.ts +88 -0
- package/src/extensions/factories.ts +22 -4
- package/src/extensions/index.ts +3 -4
- package/src/extensions/json.ts +1 -1
- package/src/extensions/markdown/decorate.ts +1 -1
- package/src/extensions/markdown/image.test.ts +54 -0
- package/src/extensions/markdown/image.ts +70 -9
- package/src/extensions/markdown/link.ts +7 -2
- package/src/extensions/outliner/outliner.ts +1 -1
- package/src/extensions/preview/preview.ts +14 -12
- package/src/extensions/scrolling/auto-scroll.ts +261 -0
- package/src/extensions/{scroller.ts → scrolling/crawler.ts} +89 -48
- package/src/extensions/scrolling/index.ts +9 -0
- package/src/extensions/{scroll-past-end.ts → scrolling/scroll-past-end.ts} +6 -6
- package/src/extensions/scrolling/scrollbar-autohide.ts +61 -0
- package/src/extensions/scrolling/scroller.ts +27 -0
- package/src/extensions/snippets.ts +67 -0
- package/src/extensions/spacing.ts +15 -0
- package/src/extensions/tags/index.ts +3 -1
- package/src/extensions/tags/testing/text.md +36 -0
- package/src/extensions/tags/testing/text.txt +35 -0
- package/src/extensions/tags/{wire.test.ts → typewriter.test.ts} +2 -2
- package/src/extensions/tags/typewriter.ts +594 -0
- package/src/extensions/tags/xml-block-decoration.ts +123 -0
- package/src/extensions/tags/xml-formatting.ts +125 -0
- package/src/extensions/tags/xml-tags.ts +6 -32
- package/src/extensions/tags/xml-util.test.ts +90 -3
- package/src/extensions/tags/xml-util.ts +62 -5
- package/src/index.ts +0 -1
- package/src/styles/theme.ts +23 -13
- package/src/typings.d.ts +8 -0
- package/dist/lib/browser/chunk-D724USEC.mjs +0 -34
- package/dist/lib/browser/chunk-D724USEC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRVJWKQF.mjs +0 -36
- package/dist/lib/node-esm/chunk-JRVJWKQF.mjs.map +0 -7
- package/dist/types/src/extensions/auto-scroll.d.ts +0 -8
- package/dist/types/src/extensions/auto-scroll.d.ts.map +0 -1
- package/dist/types/src/extensions/scroll-past-end.d.ts.map +0 -1
- package/dist/types/src/extensions/scroller.d.ts +0 -63
- package/dist/types/src/extensions/scroller.d.ts.map +0 -1
- package/dist/types/src/extensions/tags/wire.d.ts +0 -23
- package/dist/types/src/extensions/tags/wire.d.ts.map +0 -1
- package/dist/types/src/extensions/tags/wire.test.d.ts +0 -2
- package/dist/types/src/extensions/tags/wire.test.d.ts.map +0 -1
- package/dist/types/src/extensions/typewriter.d.ts +0 -10
- package/dist/types/src/extensions/typewriter.d.ts.map +0 -1
- package/src/extensions/auto-scroll.ts +0 -179
- package/src/extensions/tags/wire.ts +0 -459
- package/src/extensions/typewriter.ts +0 -68
- /package/dist/types/src/extensions/{scroll-past-end.d.ts → scrolling/scroll-past-end.d.ts} +0 -0
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/types/types.ts
|
|
2
|
-
import * as Schema from "effect/Schema";
|
|
3
|
-
var EditorViewModes = [
|
|
4
|
-
"preview",
|
|
5
|
-
"readonly",
|
|
6
|
-
"source"
|
|
7
|
-
];
|
|
8
|
-
var EditorViewMode = Schema.Union(Schema.Literal("preview").annotations({
|
|
9
|
-
title: "Preview"
|
|
10
|
-
}), Schema.Literal("readonly").annotations({
|
|
11
|
-
title: "Read-only"
|
|
12
|
-
}), Schema.Literal("source").annotations({
|
|
13
|
-
title: "Source"
|
|
14
|
-
}));
|
|
15
|
-
var EditorInputModes = [
|
|
16
|
-
"default",
|
|
17
|
-
"vim",
|
|
18
|
-
"vscode"
|
|
19
|
-
];
|
|
20
|
-
var EditorInputMode = Schema.Union(Schema.Literal("default").annotations({
|
|
21
|
-
title: "Default"
|
|
22
|
-
}), Schema.Literal("vim").annotations({
|
|
23
|
-
title: "Vim"
|
|
24
|
-
}), Schema.Literal("vscode").annotations({
|
|
25
|
-
title: "VS Code"
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
EditorViewModes,
|
|
30
|
-
EditorViewMode,
|
|
31
|
-
EditorInputModes,
|
|
32
|
-
EditorInputMode
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=chunk-D724USEC.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type EditorView } from '@codemirror/view';\nimport * as Schema from 'effect/Schema';\n\n// Runtime data structure.\nexport type Range = {\n from: number;\n to: number;\n};\n\n// Persistent data structure.\n// TODO(burdon): Rename annotation?\nexport type Comment = {\n id: string;\n cursor?: string;\n};\n\n/**\n * Callback that renders into a DOM element within the editor.\n */\nexport type RenderCallback<Props extends object> = (el: HTMLElement, props: Props, view: EditorView) => void;\n\nexport const EditorViewModes = ['preview', 'readonly', 'source'] as const;\nexport const EditorViewMode = Schema.Union(\n Schema.Literal('preview').annotations({ title: 'Preview' }),\n Schema.Literal('readonly').annotations({ title: 'Read-only' }),\n Schema.Literal('source').annotations({ title: 'Source' }),\n);\nexport type EditorViewMode = Schema.Schema.Type<typeof EditorViewMode>;\n\nexport const EditorInputModes = ['default', 'vim', 'vscode'] as const;\nexport const EditorInputMode = Schema.Union(\n Schema.Literal('default').annotations({ title: 'Default' }),\n Schema.Literal('vim').annotations({ title: 'Vim' }),\n Schema.Literal('vscode').annotations({ title: 'VS Code' }),\n);\nexport type EditorInputMode = Schema.Schema.Type<typeof EditorInputMode>;\n"],
|
|
5
|
-
"mappings": ";AAKA,YAAYA,YAAY;AAoBjB,IAAMC,kBAAkB;EAAC;EAAW;EAAY;;AAChD,IAAMC,iBAAwBC,aAC5BC,eAAQ,SAAA,EAAWC,YAAY;EAAEC,OAAO;AAAU,CAAA,GAClDF,eAAQ,UAAA,EAAYC,YAAY;EAAEC,OAAO;AAAY,CAAA,GACrDF,eAAQ,QAAA,EAAUC,YAAY;EAAEC,OAAO;AAAS,CAAA,CAAA;AAIlD,IAAMC,mBAAmB;EAAC;EAAW;EAAO;;AAC5C,IAAMC,kBAAyBL,aAC7BC,eAAQ,SAAA,EAAWC,YAAY;EAAEC,OAAO;AAAU,CAAA,GAClDF,eAAQ,KAAA,EAAOC,YAAY;EAAEC,OAAO;AAAM,CAAA,GAC1CF,eAAQ,QAAA,EAAUC,YAAY;EAAEC,OAAO;AAAU,CAAA,CAAA;",
|
|
6
|
-
"names": ["Schema", "EditorViewModes", "EditorViewMode", "Union", "Literal", "annotations", "title", "EditorInputModes", "EditorInputMode"]
|
|
7
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/types/types.ts
|
|
4
|
-
import * as Schema from "effect/Schema";
|
|
5
|
-
var EditorViewModes = [
|
|
6
|
-
"preview",
|
|
7
|
-
"readonly",
|
|
8
|
-
"source"
|
|
9
|
-
];
|
|
10
|
-
var EditorViewMode = Schema.Union(Schema.Literal("preview").annotations({
|
|
11
|
-
title: "Preview"
|
|
12
|
-
}), Schema.Literal("readonly").annotations({
|
|
13
|
-
title: "Read-only"
|
|
14
|
-
}), Schema.Literal("source").annotations({
|
|
15
|
-
title: "Source"
|
|
16
|
-
}));
|
|
17
|
-
var EditorInputModes = [
|
|
18
|
-
"default",
|
|
19
|
-
"vim",
|
|
20
|
-
"vscode"
|
|
21
|
-
];
|
|
22
|
-
var EditorInputMode = Schema.Union(Schema.Literal("default").annotations({
|
|
23
|
-
title: "Default"
|
|
24
|
-
}), Schema.Literal("vim").annotations({
|
|
25
|
-
title: "Vim"
|
|
26
|
-
}), Schema.Literal("vscode").annotations({
|
|
27
|
-
title: "VS Code"
|
|
28
|
-
}));
|
|
29
|
-
|
|
30
|
-
export {
|
|
31
|
-
EditorViewModes,
|
|
32
|
-
EditorViewMode,
|
|
33
|
-
EditorInputModes,
|
|
34
|
-
EditorInputMode
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=chunk-JRVJWKQF.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/types/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { type EditorView } from '@codemirror/view';\nimport * as Schema from 'effect/Schema';\n\n// Runtime data structure.\nexport type Range = {\n from: number;\n to: number;\n};\n\n// Persistent data structure.\n// TODO(burdon): Rename annotation?\nexport type Comment = {\n id: string;\n cursor?: string;\n};\n\n/**\n * Callback that renders into a DOM element within the editor.\n */\nexport type RenderCallback<Props extends object> = (el: HTMLElement, props: Props, view: EditorView) => void;\n\nexport const EditorViewModes = ['preview', 'readonly', 'source'] as const;\nexport const EditorViewMode = Schema.Union(\n Schema.Literal('preview').annotations({ title: 'Preview' }),\n Schema.Literal('readonly').annotations({ title: 'Read-only' }),\n Schema.Literal('source').annotations({ title: 'Source' }),\n);\nexport type EditorViewMode = Schema.Schema.Type<typeof EditorViewMode>;\n\nexport const EditorInputModes = ['default', 'vim', 'vscode'] as const;\nexport const EditorInputMode = Schema.Union(\n Schema.Literal('default').annotations({ title: 'Default' }),\n Schema.Literal('vim').annotations({ title: 'Vim' }),\n Schema.Literal('vscode').annotations({ title: 'VS Code' }),\n);\nexport type EditorInputMode = Schema.Schema.Type<typeof EditorInputMode>;\n"],
|
|
5
|
-
"mappings": ";;;AAKA,YAAYA,YAAY;AAoBjB,IAAMC,kBAAkB;EAAC;EAAW;EAAY;;AAChD,IAAMC,iBAAwBC,aAC5BC,eAAQ,SAAA,EAAWC,YAAY;EAAEC,OAAO;AAAU,CAAA,GAClDF,eAAQ,UAAA,EAAYC,YAAY;EAAEC,OAAO;AAAY,CAAA,GACrDF,eAAQ,QAAA,EAAUC,YAAY;EAAEC,OAAO;AAAS,CAAA,CAAA;AAIlD,IAAMC,mBAAmB;EAAC;EAAW;EAAO;;AAC5C,IAAMC,kBAAyBL,aAC7BC,eAAQ,SAAA,EAAWC,YAAY;EAAEC,OAAO;AAAU,CAAA,GAClDF,eAAQ,KAAA,EAAOC,YAAY;EAAEC,OAAO;AAAM,CAAA,GAC1CF,eAAQ,QAAA,EAAUC,YAAY;EAAEC,OAAO;AAAU,CAAA,CAAA;",
|
|
6
|
-
"names": ["Schema", "EditorViewModes", "EditorViewMode", "Union", "Literal", "annotations", "title", "EditorInputModes", "EditorInputMode"]
|
|
7
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Enable or disable autoscroll. */
|
|
2
|
-
export declare const autoScrollEffect: import("@codemirror/state").StateEffectType<boolean>;
|
|
3
|
-
export type AutoScrollProps = {};
|
|
4
|
-
/**
|
|
5
|
-
* Extension that supports pinning the scroll position and automatically scrolls to the bottom when content is added.
|
|
6
|
-
*/
|
|
7
|
-
export declare const autoScroll: (_?: AutoScrollProps) => import("@codemirror/state").Extension[];
|
|
8
|
-
//# sourceMappingURL=auto-scroll.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-scroll.d.ts","sourceRoot":"","sources":["../../../../src/extensions/auto-scroll.ts"],"names":[],"mappings":"AAaA,oCAAoC;AACpC,eAAO,MAAM,gBAAgB,sDAAgC,CAAC;AAE9D,MAAM,MAAM,eAAe,GAAG,EAAE,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,IAAG,eAAoB,4CAuIjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-past-end.d.ts","sourceRoot":"","sources":["../../../../src/extensions/scroll-past-end.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAwBnD,eAAO,MAAM,aAAa,QAAO,SAGhC,CAAC"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { EditorView } from '@codemirror/view';
|
|
2
|
-
/**
|
|
3
|
-
* Parameters for the scroll to line effect.
|
|
4
|
-
*/
|
|
5
|
-
export type ScrollToProps = {
|
|
6
|
-
/**
|
|
7
|
-
* Zero-based line number; -1 for end of document.
|
|
8
|
-
* NOTE: view.state.doc.lineAt() uses 1-based line numbers.
|
|
9
|
-
*/
|
|
10
|
-
line: number;
|
|
11
|
-
/**
|
|
12
|
-
* Additional offset from the target line in pixels.
|
|
13
|
-
* Positive values scroll past the line, negative values stop before it.
|
|
14
|
-
* @default 0
|
|
15
|
-
*/
|
|
16
|
-
offset?: number;
|
|
17
|
-
/**
|
|
18
|
-
* Position of the target line in the viewport.
|
|
19
|
-
* - 'start': Line appears at the start (top) of the screen
|
|
20
|
-
* - 'end': Line appears at the end (bottom) of the screen
|
|
21
|
-
* @default 'start'
|
|
22
|
-
*/
|
|
23
|
-
position?: 'start' | 'end';
|
|
24
|
-
/**
|
|
25
|
-
* Whether to use smooth scrolling.
|
|
26
|
-
* @default 'instant'
|
|
27
|
-
*/
|
|
28
|
-
behavior?: ScrollBehavior;
|
|
29
|
-
};
|
|
30
|
-
/** Scroll to a specific line. */
|
|
31
|
-
export declare const scrollerLineEffect: import("@codemirror/state").StateEffectType<ScrollToProps>;
|
|
32
|
-
/** Start/stop crawling the end of the document. */
|
|
33
|
-
export declare const scrollerCrawlEffect: import("@codemirror/state").StateEffectType<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Helper function to scroll to a specific line.
|
|
36
|
-
* This is a convenience function that can be used directly with an EditorView.
|
|
37
|
-
*/
|
|
38
|
-
export declare const scrollToLine: (view: EditorView, options: ScrollToProps) => void;
|
|
39
|
-
export type ScrollerOptions = {
|
|
40
|
-
/** Threshold in px to trigger scroll from bottom. */
|
|
41
|
-
overScroll?: number;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Extension that provides smooth scrolling to specific lines in the editor.
|
|
45
|
-
*/
|
|
46
|
-
export declare const scroller: ({ overScroll }?: ScrollerOptions) => import("@codemirror/state").Extension[];
|
|
47
|
-
/**
|
|
48
|
-
* Creates a smooth crawler that follows the live bottom of a CodeMirror 6 EditorView.
|
|
49
|
-
*
|
|
50
|
-
* Uses a velocity-based approach with easing:
|
|
51
|
-
* - Accelerates smoothly when content starts arriving.
|
|
52
|
-
* - Maintains a steady cruise velocity during continuous streaming.
|
|
53
|
-
* - Decelerates smoothly when content stops arriving.
|
|
54
|
-
*
|
|
55
|
-
* @param accel Acceleration in px/frame^2 for ease-in/ease-out.
|
|
56
|
-
* @param maxVelocity Maximum scroll velocity in px/frame.
|
|
57
|
-
* @param snapThreshold Snap-to-target threshold in px.
|
|
58
|
-
*/
|
|
59
|
-
export declare function createCrawler(view: EditorView, accel?: number, maxVelocity?: number, snapThreshold?: number): {
|
|
60
|
-
scroll: () => void;
|
|
61
|
-
cancel: () => void;
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=scroller.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scroller.d.ts","sourceRoot":"","sources":["../../../../src/extensions/scroller.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAc,MAAM,kBAAkB,CAAC;AAI1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAE3B;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAEF,iCAAiC;AACjC,eAAO,MAAM,kBAAkB,4DAAsC,CAAC;AAEtE,mDAAmD;AACnD,eAAO,MAAM,mBAAmB,sDAAgC,CAAC;AAEjE;;;GAGG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,UAAU,EAAE,SAAS,aAAa,SAIpE,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,iBAAoB,eAAoB,4CAgHhE,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,SAAO,EAAE,WAAW,SAAI,EAAE,aAAa,SAAM;;;EAqDjG"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
/** Annotate a transaction to bypass the wire buffer (content appears immediately). */
|
|
3
|
-
export declare const wireBypass: import("@codemirror/state").AnnotationType<boolean>;
|
|
4
|
-
export type WireOptions = {
|
|
5
|
-
/** Characters per second. */
|
|
6
|
-
rate?: number;
|
|
7
|
-
/** Show a blinking cursor at the insertion point while streaming. */
|
|
8
|
-
cursor?: boolean;
|
|
9
|
-
/** Tag names whose inner content should be streamed (not buffered until close). */
|
|
10
|
-
streamingTags?: Set<string>;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Extension that intercepts appended text and inserts it one character at a time,
|
|
14
|
-
* except for XML tags, links, and images which are flushed atomically.
|
|
15
|
-
*/
|
|
16
|
-
export declare const wire: (options?: WireOptions) => Extension;
|
|
17
|
-
/**
|
|
18
|
-
* Returns the length of a complete XML element at the start of the buffer, or 0 if the element is incomplete.
|
|
19
|
-
* Handles self-closing tags, closing tags, and opening tags with nested content.
|
|
20
|
-
* E.g., `<foo>content<bar />more</foo>` returns the full length.
|
|
21
|
-
*/
|
|
22
|
-
export declare const xmlElementLength: (buffer: string) => number;
|
|
23
|
-
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/tags/wire.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,SAAS,EAIf,MAAM,mBAAmB,CAAC;AAG3B,sFAAsF;AACtF,eAAO,MAAM,UAAU,qDAA+B,CAAC;AASvD,MAAM,MAAM,WAAW,GAAG;IACxB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mFAAmF;IACnF,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,IAAI,GAAI,UAAS,WAAgB,KAAG,SAqJhD,CAAC;AA4LF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,MAAM,KAAG,MAkDjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wire.test.d.ts","sourceRoot":"","sources":["../../../../../src/extensions/tags/wire.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Extension } from '@codemirror/state';
|
|
2
|
-
export type DemoOptions = {
|
|
3
|
-
delay?: number;
|
|
4
|
-
items?: string[];
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Configurable plugin that let's user cycle through pre-configured input script.
|
|
8
|
-
*/
|
|
9
|
-
export declare const typewriter: ({ delay, items }?: DemoOptions) => Extension;
|
|
10
|
-
//# sourceMappingURL=typewriter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typewriter.d.ts","sourceRoot":"","sources":["../../../../src/extensions/typewriter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKnD,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,mBAAsC,WAAgB,KAAG,SAgDnF,CAAC"}
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { StateEffect } from '@codemirror/state';
|
|
6
|
-
import { EditorView, ViewPlugin } from '@codemirror/view';
|
|
7
|
-
|
|
8
|
-
import { addEventListener, combine, throttle } from '@dxos/async';
|
|
9
|
-
import { Domino } from '@dxos/ui';
|
|
10
|
-
import { getSize } from '@dxos/ui-theme';
|
|
11
|
-
|
|
12
|
-
import { scrollerCrawlEffect, scrollerLineEffect } from './scroller';
|
|
13
|
-
|
|
14
|
-
/** Enable or disable autoscroll. */
|
|
15
|
-
export const autoScrollEffect = StateEffect.define<boolean>();
|
|
16
|
-
|
|
17
|
-
export type AutoScrollProps = {};
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Extension that supports pinning the scroll position and automatically scrolls to the bottom when content is added.
|
|
21
|
-
*/
|
|
22
|
-
export const autoScroll = (_: AutoScrollProps = {}) => {
|
|
23
|
-
let buttonContainer: HTMLDivElement | undefined;
|
|
24
|
-
let isPinned = true;
|
|
25
|
-
let jumpPending = false;
|
|
26
|
-
let enabled = true;
|
|
27
|
-
let firstUpdate = true;
|
|
28
|
-
|
|
29
|
-
const setPinned = (pinned: boolean) => {
|
|
30
|
-
buttonContainer?.classList.toggle('opacity-0', pinned);
|
|
31
|
-
isPinned = pinned;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
return [
|
|
35
|
-
// Update listener for scrolling when content changes.
|
|
36
|
-
EditorView.updateListener.of((update) => {
|
|
37
|
-
const { view, heightChanged, state, startState } = update;
|
|
38
|
-
|
|
39
|
-
// Handle enable/disable effect.
|
|
40
|
-
for (const tr of update.transactions) {
|
|
41
|
-
for (const effect of tr.effects) {
|
|
42
|
-
if (effect.is(autoScrollEffect)) {
|
|
43
|
-
enabled = effect.value;
|
|
44
|
-
if (enabled) {
|
|
45
|
-
setPinned(true);
|
|
46
|
-
view.dispatch({
|
|
47
|
-
effects: scrollerCrawlEffect.of(true),
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
view.dispatch({
|
|
51
|
-
effects: scrollerCrawlEffect.of(false),
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!enabled) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Jump to bottom instantly when content first appears (either inserted into
|
|
63
|
-
// an empty doc, or present as initialValue when the editor is created).
|
|
64
|
-
if (isPinned && (firstUpdate || startState.doc.length === 0) && state.doc.length > 0) {
|
|
65
|
-
firstUpdate = false;
|
|
66
|
-
jumpPending = true;
|
|
67
|
-
requestAnimationFrame(() => {
|
|
68
|
-
view.scrollDOM.scrollTop = view.scrollDOM.scrollHeight;
|
|
69
|
-
jumpPending = false;
|
|
70
|
-
});
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
firstUpdate = false;
|
|
74
|
-
|
|
75
|
-
// Suppress crawl while the initial jump is pending.
|
|
76
|
-
if (jumpPending) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Maybe scroll if doc changed and pinned.
|
|
81
|
-
// NOTE: Geometry changed is triggered when widgets change height (e.g., toggle tool block).
|
|
82
|
-
if (heightChanged) {
|
|
83
|
-
if (isPinned) {
|
|
84
|
-
// NOTE: Use scroll geometry instead of coordsAtPos to avoid forced layout/scroll side-effects.
|
|
85
|
-
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
86
|
-
const delta = scrollHeight - scrollTop - clientHeight;
|
|
87
|
-
if (delta > 0) {
|
|
88
|
-
setPinned(true);
|
|
89
|
-
view.dispatch({
|
|
90
|
-
effects: scrollerCrawlEffect.of(true),
|
|
91
|
-
});
|
|
92
|
-
} else if (delta < -1) {
|
|
93
|
-
setPinned(false);
|
|
94
|
-
}
|
|
95
|
-
} else {
|
|
96
|
-
// TODO(burdon): Should re-pin if content shrinks.
|
|
97
|
-
if (state.doc.length === 0) {
|
|
98
|
-
setPinned(true);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}),
|
|
103
|
-
|
|
104
|
-
// Detect user scroll and unpin (or re-pin if scrolled to the bottom).
|
|
105
|
-
ViewPlugin.fromClass(
|
|
106
|
-
class {
|
|
107
|
-
private readonly cleanup: () => void;
|
|
108
|
-
constructor(view: EditorView) {
|
|
109
|
-
this.cleanup = createUserScrollDetector(
|
|
110
|
-
view.scrollDOM,
|
|
111
|
-
throttle(() => {
|
|
112
|
-
requestAnimationFrame(() => {
|
|
113
|
-
const { scrollTop, scrollHeight, clientHeight } = view.scrollDOM;
|
|
114
|
-
const delta = scrollHeight - scrollTop - clientHeight;
|
|
115
|
-
const pinned = delta === 0;
|
|
116
|
-
setPinned(pinned);
|
|
117
|
-
if (!pinned) {
|
|
118
|
-
view.dispatch({ effects: scrollerCrawlEffect.of(false) });
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}, 500),
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
destroy() {
|
|
125
|
-
this.cleanup();
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
),
|
|
129
|
-
|
|
130
|
-
// Scroll button.
|
|
131
|
-
ViewPlugin.fromClass(
|
|
132
|
-
class {
|
|
133
|
-
constructor(view: EditorView) {
|
|
134
|
-
const icon = Domino.of('dx-icon' as any)
|
|
135
|
-
.classNames(getSize(4))
|
|
136
|
-
.attributes({ icon: 'ph--arrow-down--regular' });
|
|
137
|
-
const button = Domino.of('button')
|
|
138
|
-
.classNames('dx-button bg-accent-surface')
|
|
139
|
-
.attributes({ 'data-density': 'fine' })
|
|
140
|
-
.append(icon)
|
|
141
|
-
.on('click', () => {
|
|
142
|
-
setPinned(true);
|
|
143
|
-
view.dispatch({
|
|
144
|
-
effects: scrollerLineEffect.of({ line: -1, position: 'end', behavior: 'smooth' }),
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
buttonContainer = Domino.of('div')
|
|
149
|
-
.classNames('cm-scroll-button transition-opacity duration-300 opacity-0')
|
|
150
|
-
.append(button).root as HTMLDivElement;
|
|
151
|
-
|
|
152
|
-
view.scrollDOM.parentElement!.appendChild(buttonContainer);
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
),
|
|
156
|
-
];
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Attaches listeners to detect genuine user-initiated scrolling on an element.
|
|
161
|
-
* Two sources are covered:
|
|
162
|
-
* - `wheel`: fires only from physical mouse wheel / trackpad gestures.
|
|
163
|
-
* - `pointerdown` on the scrollbar gutter: detected by comparing clientX to
|
|
164
|
-
* the element's clientWidth (the content area, excluding the scrollbar).
|
|
165
|
-
* Returns a cleanup function that removes the listeners.
|
|
166
|
-
*/
|
|
167
|
-
// TODO(burdon): Still jumps when widgets are rendered.
|
|
168
|
-
// - Track position of specific element/line in document and scroll relative to that.
|
|
169
|
-
function createUserScrollDetector(element: HTMLElement, onUserScroll: () => void): () => void {
|
|
170
|
-
return combine(
|
|
171
|
-
addEventListener(element, 'wheel', () => onUserScroll(), { passive: true }),
|
|
172
|
-
addEventListener(element, 'pointerdown', (event) => {
|
|
173
|
-
// If the pointer lands beyond the content width it hit the scrollbar gutter.
|
|
174
|
-
if (event.clientX > element.getBoundingClientRect().right - (element.offsetWidth - element.clientWidth)) {
|
|
175
|
-
onUserScroll();
|
|
176
|
-
}
|
|
177
|
-
}),
|
|
178
|
-
);
|
|
179
|
-
}
|