@thomasfosterau/effect-richtext 0.0.0 → 0.1.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 +48 -0
- package/README.md +117 -1
- package/dist/_virtual/_rolldown/runtime.js +12 -0
- package/dist/commands/commands.d.ts +323 -0
- package/dist/commands/commands.js +722 -0
- package/dist/commands/internal.js +43 -0
- package/dist/commands/keymaps.d.ts +46 -0
- package/dist/commands/keymaps.js +64 -0
- package/dist/commands.d.ts +3 -0
- package/dist/commands.js +3 -0
- package/dist/compat/commands.d.ts +250 -0
- package/dist/compat/commands.js +275 -0
- package/dist/compat/internal/core.d.ts +20 -0
- package/dist/compat/internal/core.js +148 -0
- package/dist/compat/internal/props.js +82 -0
- package/dist/compat/keymap.d.ts +21 -0
- package/dist/compat/keymap.js +38 -0
- package/dist/compat/model.d.ts +893 -0
- package/dist/compat/model.js +1212 -0
- package/dist/compat/orderedmap.d.ts +74 -0
- package/dist/compat/orderedmap.js +124 -0
- package/dist/compat/schema-basic.d.ts +38 -0
- package/dist/compat/schema-basic.js +238 -0
- package/dist/compat/schema-list.d.ts +81 -0
- package/dist/compat/schema-list.js +156 -0
- package/dist/compat/state.d.ts +415 -0
- package/dist/compat/state.js +689 -0
- package/dist/compat/test-builder.d.ts +98 -0
- package/dist/compat/test-builder.js +197 -0
- package/dist/compat/transform.d.ts +458 -0
- package/dist/compat/transform.js +803 -0
- package/dist/compat/view.d.ts +411 -0
- package/dist/compat/view.js +409 -0
- package/dist/dropcursor.d.ts +46 -0
- package/dist/dropcursor.js +176 -0
- package/dist/extensions/defaults.d.ts +716 -0
- package/dist/extensions/defaults.js +209 -0
- package/dist/extensions/editor.d.ts +246 -0
- package/dist/extensions/editor.js +271 -0
- package/dist/extensions/extension.d.ts +375 -0
- package/dist/extensions/extension.js +233 -0
- package/dist/extensions.d.ts +4 -0
- package/dist/extensions.js +4 -0
- package/dist/gapcursor.d.ts +66 -0
- package/dist/gapcursor.js +273 -0
- package/dist/history.d.ts +178 -0
- package/dist/history.js +412 -0
- package/dist/html.d.ts +158 -0
- package/dist/html.js +164 -0
- package/dist/inputrules.d.ts +271 -0
- package/dist/inputrules.js +321 -0
- package/dist/internal/attempt.js +15 -0
- package/dist/internal/json.js +29 -0
- package/dist/keymap/keymap.d.ts +130 -0
- package/dist/keymap/keymap.js +159 -0
- package/dist/keymap.d.ts +2 -0
- package/dist/keymap.js +1 -0
- package/dist/markdown/errors.d.ts +23 -0
- package/dist/markdown/errors.js +26 -0
- package/dist/markdown/from_markdown.d.ts +185 -0
- package/dist/markdown/from_markdown.js +266 -0
- package/dist/markdown/schema.d.ts +522 -0
- package/dist/markdown/schema.js +292 -0
- package/dist/markdown/to_markdown.d.ts +251 -0
- package/dist/markdown/to_markdown.js +413 -0
- package/dist/markdown.d.ts +5 -0
- package/dist/markdown.js +5 -0
- package/dist/model/attrsCodec.js +48 -0
- package/dist/model/comparedeep.js +17 -0
- package/dist/model/content.d.ts +232 -0
- package/dist/model/content.js +630 -0
- package/dist/model/diff.js +66 -0
- package/dist/model/dom.d.ts +3 -0
- package/dist/model/errors.d.ts +90 -0
- package/dist/model/errors.js +76 -0
- package/dist/model/fragment.d.ts +131 -0
- package/dist/model/fragment.js +262 -0
- package/dist/model/from_dom.d.ts +299 -0
- package/dist/model/from_dom.js +618 -0
- package/dist/model/json.d.ts +37 -0
- package/dist/model/json.js +126 -0
- package/dist/model/mark.d.ts +73 -0
- package/dist/model/mark.js +121 -0
- package/dist/model/node.d.ts +267 -0
- package/dist/model/node.js +434 -0
- package/dist/model/replace.d.ts +78 -0
- package/dist/model/replace.js +207 -0
- package/dist/model/resolvedpos.d.ts +196 -0
- package/dist/model/resolvedpos.js +305 -0
- package/dist/model/schema.d.ts +740 -0
- package/dist/model/schema.js +451 -0
- package/dist/model/to_dom.d.ts +169 -0
- package/dist/model/to_dom.js +238 -0
- package/dist/model.d.ts +12 -0
- package/dist/model.js +12 -0
- package/dist/placeholder.d.ts +53 -0
- package/dist/placeholder.js +79 -0
- package/dist/reactive/observer.d.ts +54 -0
- package/dist/reactive/observer.js +61 -0
- package/dist/reactive/selectors.d.ts +22 -0
- package/dist/reactive/selectors.js +61 -0
- package/dist/reactive/stateref.d.ts +72 -0
- package/dist/reactive/stateref.js +71 -0
- package/dist/reactive/streams.d.ts +83 -0
- package/dist/reactive/streams.js +85 -0
- package/dist/reactive.d.ts +16 -0
- package/dist/reactive.js +26 -0
- package/dist/schema-basic.d.ts +448 -0
- package/dist/schema-basic.js +269 -0
- package/dist/schema-list/commands.d.ts +66 -0
- package/dist/schema-list/commands.js +203 -0
- package/dist/schema-list.d.ts +92 -0
- package/dist/schema-list.js +100 -0
- package/dist/state/errors.d.ts +39 -0
- package/dist/state/errors.js +32 -0
- package/dist/state/plugin.d.ts +232 -0
- package/dist/state/plugin.js +82 -0
- package/dist/state/selection.d.ts +297 -0
- package/dist/state/selection.js +486 -0
- package/dist/state/state.d.ts +212 -0
- package/dist/state/state.js +489 -0
- package/dist/state/transaction.d.ts +145 -0
- package/dist/state/transaction.js +195 -0
- package/dist/state.d.ts +6 -0
- package/dist/state.js +6 -0
- package/dist/test-builder.d.ts +3582 -0
- package/dist/test-builder.js +239 -0
- package/dist/transform/attr_step.d.ts +60 -0
- package/dist/transform/attr_step.js +105 -0
- package/dist/transform/errors.d.ts +50 -0
- package/dist/transform/errors.js +35 -0
- package/dist/transform/map.d.ts +182 -0
- package/dist/transform/map.js +280 -0
- package/dist/transform/mark.js +98 -0
- package/dist/transform/mark_set_step.js +69 -0
- package/dist/transform/mark_step.d.ts +113 -0
- package/dist/transform/mark_step.js +225 -0
- package/dist/transform/replace.d.ts +18 -0
- package/dist/transform/replace.js +381 -0
- package/dist/transform/replace_step.d.ts +109 -0
- package/dist/transform/replace_step.js +175 -0
- package/dist/transform/step.d.ts +157 -0
- package/dist/transform/step.js +168 -0
- package/dist/transform/structure.d.ts +89 -0
- package/dist/transform/structure.js +350 -0
- package/dist/transform/transform.d.ts +248 -0
- package/dist/transform/transform.js +373 -0
- package/dist/transform.d.ts +10 -0
- package/dist/transform.js +10 -0
- package/dist/view/browser.js +39 -0
- package/dist/view/capturekeys.js +282 -0
- package/dist/view/clipboard.d.ts +8 -0
- package/dist/view/clipboard.js +245 -0
- package/dist/view/decoration.d.ts +339 -0
- package/dist/view/decoration.js +566 -0
- package/dist/view/dom.d.ts +18 -0
- package/dist/view/dom.js +140 -0
- package/dist/view/domchange.js +295 -0
- package/dist/view/domcoords.d.ts +22 -0
- package/dist/view/domcoords.js +448 -0
- package/dist/view/domobserver.d.ts +47 -0
- package/dist/view/domobserver.js +328 -0
- package/dist/view/errors.d.ts +18 -0
- package/dist/view/errors.js +21 -0
- package/dist/view/input.d.ts +58 -0
- package/dist/view/input.js +704 -0
- package/dist/view/selection.js +198 -0
- package/dist/view/view.d.ts +699 -0
- package/dist/view/view.js +623 -0
- package/dist/view/viewdesc.d.ts +236 -0
- package/dist/view/viewdesc.js +1205 -0
- package/dist/view-css.d.ts +43 -0
- package/dist/view-css.js +124 -0
- package/dist/view.d.ts +6 -0
- package/dist/view.js +4 -0
- package/package.json +200 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { acquireSource, publishTransactions, setState, streamsOf } from "./streams.js";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Cause from "effect/Cause";
|
|
5
|
+
import * as Exit from "effect/Exit";
|
|
6
|
+
import * as Semaphore from "effect/Semaphore";
|
|
7
|
+
// src/reactive/stateref.ts
|
|
8
|
+
/**
|
|
9
|
+
* `StateRef`: an editor state held in a `SubscriptionRef`, without a view.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
var stateref_exports = /* @__PURE__ */ __exportAll({
|
|
14
|
+
StateRefTypeId: () => StateRefTypeId,
|
|
15
|
+
make: () => make
|
|
16
|
+
});
|
|
17
|
+
/**
|
|
18
|
+
* @since 0.1.0
|
|
19
|
+
* @category symbols
|
|
20
|
+
*/
|
|
21
|
+
const StateRefTypeId = Symbol.for("effect-richtext/reactive/StateRef");
|
|
22
|
+
/**
|
|
23
|
+
* Run a synchronous effect, throwing its squashed cause on failure.
|
|
24
|
+
*/
|
|
25
|
+
const runSyncOrThrow = (effect) => {
|
|
26
|
+
const exit = Effect.runSyncExit(effect);
|
|
27
|
+
if (Exit.isFailure(exit)) throw Cause.squash(exit.cause);
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Create a `StateRef` holding `initial`. The current context (providing
|
|
31
|
+
* the plugins' requirements `R`) is captured to run plugin hooks when
|
|
32
|
+
* transactions are dispatched. Its streams end when the scope closes.
|
|
33
|
+
*
|
|
34
|
+
* ```ts skip-type-checking
|
|
35
|
+
* const ref = yield* StateRef.make(EditorState.createUnsafe({ schema }))
|
|
36
|
+
* yield* ref.dispatch(ref.state.getUnsafe().tr.insertTextUnsafe("hi"))
|
|
37
|
+
* yield* ref.execute(toggleMark(schema.marks.strong))
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @since 0.1.0
|
|
41
|
+
* @category constructors
|
|
42
|
+
*/
|
|
43
|
+
const make = (initial) => Effect.gen(function* () {
|
|
44
|
+
const context = yield* Effect.context();
|
|
45
|
+
const source = yield* acquireSource(initial);
|
|
46
|
+
const semaphore = Semaphore.makeUnsafe(1);
|
|
47
|
+
const applyUnlocked = (tr) => Effect.suspend(() => {
|
|
48
|
+
const prevState = source.ref.value;
|
|
49
|
+
return Effect.map(prevState.applyTransaction(tr), ({ state, transactions }) => {
|
|
50
|
+
setState(source, state);
|
|
51
|
+
publishTransactions(source, transactions, state, prevState);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
const dispatch = (tr) => Effect.provideContext(semaphore.withPermit(applyUnlocked(tr)), context);
|
|
55
|
+
const dispatchUnsafe = (tr) => runSyncOrThrow(Effect.provideContext(applyUnlocked(tr), context));
|
|
56
|
+
const set = (state) => semaphore.withPermit(Effect.sync(() => setState(source, state)));
|
|
57
|
+
const execute = (command) => Effect.suspend(() => {
|
|
58
|
+
let failure;
|
|
59
|
+
const commandDispatch = (tr) => failure ? Effect.void : Effect.catchCause(dispatch(tr), (cause) => Effect.sync(() => void (failure = cause)));
|
|
60
|
+
return Effect.flatMap(command(source.ref.value, commandDispatch), (result) => failure ? Effect.failCause(failure) : Effect.succeed(result));
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
[StateRefTypeId]: StateRefTypeId,
|
|
64
|
+
...streamsOf(source),
|
|
65
|
+
dispatch,
|
|
66
|
+
dispatchUnsafe,
|
|
67
|
+
set,
|
|
68
|
+
execute
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
export { StateRefTypeId, make, stateref_exports };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { AnySchema, Attrs, MarkNames, MarkType, NodeNames, NodeType } from "../model/schema.js";
|
|
2
|
+
import { Node } from "../model/node.js";
|
|
3
|
+
import "../model.js";
|
|
4
|
+
import { Command, Transaction } from "../state/transaction.js";
|
|
5
|
+
import { Selection } from "../state/selection.js";
|
|
6
|
+
import { EditorState } from "../state/state.js";
|
|
7
|
+
import "../state.js";
|
|
8
|
+
import * as Effect from "effect/Effect";
|
|
9
|
+
import "effect/SubscriptionRef";
|
|
10
|
+
import "effect/PubSub";
|
|
11
|
+
import * as Stream from "effect/Stream";
|
|
12
|
+
import "effect/Scope";
|
|
13
|
+
/**
|
|
14
|
+
* A transaction applied to an editor state, as emitted by the
|
|
15
|
+
* `transactions` stream.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
* @category models
|
|
19
|
+
*/
|
|
20
|
+
export interface TransactionEvent<Sc extends AnySchema = AnySchema, R = never, E = never> {
|
|
21
|
+
/** The dispatched transaction. */
|
|
22
|
+
readonly tr: Transaction<Sc>;
|
|
23
|
+
/**
|
|
24
|
+
* All the transactions that were applied: `tr` followed by those
|
|
25
|
+
* appended by plugins (`appendTransaction`).
|
|
26
|
+
*/
|
|
27
|
+
readonly transactions: ReadonlyArray<Transaction<Sc>>;
|
|
28
|
+
/** The state after the transactions were applied. */
|
|
29
|
+
readonly state: EditorState<Sc, R, E>;
|
|
30
|
+
/** The state before the transactions were applied. */
|
|
31
|
+
readonly prevState: EditorState<Sc, R, E>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A read-only view of a `SubscriptionRef`.
|
|
35
|
+
*
|
|
36
|
+
* @since 0.1.0
|
|
37
|
+
* @category models
|
|
38
|
+
*/
|
|
39
|
+
export interface ReadonlyRef<A> {
|
|
40
|
+
/** The current value. */
|
|
41
|
+
readonly get: Effect.Effect<A>;
|
|
42
|
+
/** The current value, read synchronously. */
|
|
43
|
+
readonly getUnsafe: () => A;
|
|
44
|
+
/** The current value followed by every subsequent change. */
|
|
45
|
+
readonly changes: Stream.Stream<A>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The reactive streams of an editor state, shared by `StateRef` (headless)
|
|
49
|
+
* and `EditorObserver` (bound to a view).
|
|
50
|
+
*
|
|
51
|
+
* The state-like streams (`state.changes`, `docChanges`, `selection`,
|
|
52
|
+
* `select` and the convenience selectors) start with the current value
|
|
53
|
+
* and only emit when the projected value changes. `transactions` is hot:
|
|
54
|
+
* subscribers only see the transactions applied after they subscribed.
|
|
55
|
+
* All streams end when the scope the source was created in closes.
|
|
56
|
+
*
|
|
57
|
+
* @since 0.1.0
|
|
58
|
+
* @category models
|
|
59
|
+
*/
|
|
60
|
+
export interface EditorStreams<Sc extends AnySchema = AnySchema, R = never, E = never> {
|
|
61
|
+
/** The current state, and its changes. */
|
|
62
|
+
readonly state: ReadonlyRef<EditorState<Sc, R, E>>;
|
|
63
|
+
/** The transactions applied to the state (hot). */
|
|
64
|
+
readonly transactions: Stream.Stream<TransactionEvent<Sc, R, E>>;
|
|
65
|
+
/** The document, emitted again whenever it changes. */
|
|
66
|
+
readonly docChanges: Stream.Stream<Node<Sc>>;
|
|
67
|
+
/** The selection, emitted again whenever it changes (compared with `Selection.eq`). */
|
|
68
|
+
readonly selection: Stream.Stream<Selection<Sc>>;
|
|
69
|
+
/**
|
|
70
|
+
* A projection of the state, emitted again whenever it changes, as
|
|
71
|
+
* determined by `eq` (default: `Equal.equals`).
|
|
72
|
+
*/
|
|
73
|
+
readonly select: <A>(f: (state: EditorState<Sc, R, E>) => A, eq?: (self: A, that: A) => boolean) => Stream.Stream<A>;
|
|
74
|
+
/** Whether a mark is active in the selection (see `isMarkActive`). */
|
|
75
|
+
readonly isMarkActive: (type: MarkType<Sc, any> | MarkNames<Sc>) => Stream.Stream<boolean>;
|
|
76
|
+
/** Whether a node is selected or wraps the selection (see `isNodeActive`). */
|
|
77
|
+
readonly isNodeActive: (type: NodeType<Sc, any> | NodeNames<Sc>, attrs?: Attrs) => Stream.Stream<boolean>;
|
|
78
|
+
/**
|
|
79
|
+
* Whether a command can be executed (the command is run without a
|
|
80
|
+
* dispatch function for each new state).
|
|
81
|
+
*/
|
|
82
|
+
readonly canExecute: <CE, CR>(command: Command<Sc, CE, CR>) => Stream.Stream<boolean, CE, CR>;
|
|
83
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { isMarkActive, isNodeActive } from "./selectors.js";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import * as Equal from "effect/Equal";
|
|
4
|
+
import * as SubscriptionRef from "effect/SubscriptionRef";
|
|
5
|
+
import * as PubSub from "effect/PubSub";
|
|
6
|
+
import * as Stream from "effect/Stream";
|
|
7
|
+
// src/reactive/streams.ts
|
|
8
|
+
/**
|
|
9
|
+
* The streams shared by `StateRef` and `EditorObserver`.
|
|
10
|
+
*
|
|
11
|
+
* @since 0.1.0
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Create a `SubscriptionRef` whose pubsub is shut down (ending its
|
|
15
|
+
* `changes` streams) when the scope closes.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
const acquireRef = (initial) => Effect.acquireRelease(SubscriptionRef.make(initial), (ref) => PubSub.shutdown(ref.pubsub));
|
|
20
|
+
/**
|
|
21
|
+
* Set a `SubscriptionRef` synchronously, publishing the value when it
|
|
22
|
+
* changed (by identity). Used for writes made from synchronous callbacks
|
|
23
|
+
* (view listeners, DOM events, synchronous dispatches).
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
const setRefUnsafe = (ref, value) => {
|
|
28
|
+
if (ref.value === value) return;
|
|
29
|
+
ref.value = value;
|
|
30
|
+
PubSub.publishUnsafe(ref.pubsub, value);
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Create the source of the streams; its pubsubs are shut down (ending all
|
|
34
|
+
* streams) when the scope closes.
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
const acquireSource = (initial) => Effect.zipWith(acquireRef(initial), Effect.acquireRelease(PubSub.unbounded(), PubSub.shutdown), (ref, pubsub) => ({
|
|
39
|
+
ref,
|
|
40
|
+
pubsub
|
|
41
|
+
}));
|
|
42
|
+
/**
|
|
43
|
+
* Set the current state synchronously (publishing it when it changed).
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
const setState = (source, state) => setRefUnsafe(source.ref, state);
|
|
48
|
+
/**
|
|
49
|
+
* Publish an applied transaction (and the resulting state).
|
|
50
|
+
*
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
const publishTransactions = (source, transactions, state, prevState) => {
|
|
54
|
+
if (transactions.length) PubSub.publishUnsafe(source.pubsub, {
|
|
55
|
+
tr: transactions[0],
|
|
56
|
+
transactions,
|
|
57
|
+
state,
|
|
58
|
+
prevState
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Build the streams of a source.
|
|
63
|
+
*
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
const streamsOf = (source, view) => {
|
|
67
|
+
const { pubsub, ref } = source;
|
|
68
|
+
const changes = SubscriptionRef.changes(ref);
|
|
69
|
+
const select = (f, eq = Equal.equals) => Stream.changesWith(Stream.map(changes, f), eq);
|
|
70
|
+
return {
|
|
71
|
+
state: {
|
|
72
|
+
get: SubscriptionRef.get(ref),
|
|
73
|
+
getUnsafe: () => ref.value,
|
|
74
|
+
changes
|
|
75
|
+
},
|
|
76
|
+
transactions: Stream.fromPubSub(pubsub),
|
|
77
|
+
docChanges: select((state) => state.doc, (a, b) => a === b),
|
|
78
|
+
selection: select((state) => state.selection, (a, b) => a.eq(b)),
|
|
79
|
+
select,
|
|
80
|
+
isMarkActive: (type) => select((state) => isMarkActive(state, type)),
|
|
81
|
+
isNodeActive: (type, attrs) => select((state) => isNodeActive(state, type, attrs)),
|
|
82
|
+
canExecute: (command) => Stream.changesWith(Stream.mapEffect(changes, (state) => command(state, void 0, view)), (a, b) => a === b)
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
export { acquireRef, acquireSource, publishTransactions, setRefUnsafe, setState, streamsOf };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AnySchema } from "./model/schema.js";
|
|
2
|
+
import "./model.js";
|
|
3
|
+
import { EditorView } from "./view/view.js";
|
|
4
|
+
import "./view.js";
|
|
5
|
+
import { EditorObserver, observer_d_exports } from "./reactive/observer.js";
|
|
6
|
+
import { stateref_d_exports } from "./reactive/stateref.js";
|
|
7
|
+
import { isMarkActive, isNodeActive } from "./reactive/selectors.js";
|
|
8
|
+
import { EditorStreams, ReadonlyRef, TransactionEvent } from "./reactive/streams.js";
|
|
9
|
+
/**
|
|
10
|
+
* Observe an editor view (alias of `EditorObserver.make`).
|
|
11
|
+
*
|
|
12
|
+
* @since 0.1.0
|
|
13
|
+
* @category constructors
|
|
14
|
+
*/
|
|
15
|
+
export declare const observe: <Sc extends AnySchema, R, E>(view: EditorView<Sc, R, E>) => import("effect/Effect").Effect<EditorObserver<Sc, R, E>, never, import("effect/Scope").Scope>;
|
|
16
|
+
export { observer_d_exports as EditorObserver, type EditorStreams, type ReadonlyRef, stateref_d_exports as StateRef, type TransactionEvent, isMarkActive, isNodeActive };
|
package/dist/reactive.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { make, observer_exports } from "./reactive/observer.js";
|
|
2
|
+
import { stateref_exports } from "./reactive/stateref.js";
|
|
3
|
+
import { isMarkActive, isNodeActive } from "./reactive/selectors.js";
|
|
4
|
+
// src/reactive.ts
|
|
5
|
+
/**
|
|
6
|
+
* Framework-neutral reactive bindings: editor states and views as
|
|
7
|
+
* `SubscriptionRef`s and `Stream`s.
|
|
8
|
+
*
|
|
9
|
+
* - `StateRef.make(state)` holds a state without a view (headless editing,
|
|
10
|
+
* servers, tests) and applies dispatched transactions.
|
|
11
|
+
* - `EditorObserver.make(view)` (or `observe(view)`) follows a view.
|
|
12
|
+
*
|
|
13
|
+
* Both expose the same `EditorStreams`: `state`, `transactions`,
|
|
14
|
+
* `docChanges`, `selection`, `select(f, eq?)`, `isMarkActive`,
|
|
15
|
+
* `isNodeActive` and `canExecute`.
|
|
16
|
+
*
|
|
17
|
+
* @since 0.1.0
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Observe an editor view (alias of `EditorObserver.make`).
|
|
21
|
+
*
|
|
22
|
+
* @since 0.1.0
|
|
23
|
+
* @category constructors
|
|
24
|
+
*/
|
|
25
|
+
const observe = make;
|
|
26
|
+
export { observer_exports as EditorObserver, stateref_exports as StateRef, isMarkActive, isNodeActive, observe };
|