svedit 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 +21 -0
- package/README.md +323 -0
- package/dist/AnnotatedStringProperty.svelte +126 -0
- package/dist/AnnotatedStringProperty.svelte.d.ts +7 -0
- package/dist/AnnotatedStringProperty.svelte.d.ts.map +1 -0
- package/dist/CustomProperty.svelte +40 -0
- package/dist/CustomProperty.svelte.d.ts +8 -0
- package/dist/CustomProperty.svelte.d.ts.map +1 -0
- package/dist/Document.svelte.d.ts +191 -0
- package/dist/Document.svelte.d.ts.map +1 -0
- package/dist/Document.svelte.js +681 -0
- package/dist/Node.svelte +41 -0
- package/dist/Node.svelte.d.ts +7 -0
- package/dist/Node.svelte.d.ts.map +1 -0
- package/dist/NodeArrayProperty.svelte +45 -0
- package/dist/NodeArrayProperty.svelte.d.ts +7 -0
- package/dist/NodeArrayProperty.svelte.d.ts.map +1 -0
- package/dist/Svedit.svelte +936 -0
- package/dist/Svedit.svelte.d.ts +12 -0
- package/dist/Svedit.svelte.d.ts.map +1 -0
- package/dist/Transaction.svelte.d.ts +198 -0
- package/dist/Transaction.svelte.d.ts.map +1 -0
- package/dist/Transaction.svelte.js +577 -0
- package/dist/UnknownNode.svelte +12 -0
- package/dist/UnknownNode.svelte.d.ts +12 -0
- package/dist/UnknownNode.svelte.d.ts.map +1 -0
- package/dist/commands.svelte.d.ts +5 -0
- package/dist/commands.svelte.d.ts.map +1 -0
- package/dist/commands.svelte.js +261 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/types.d.ts +264 -0
- package/dist/util.d.ts +4 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +78 -0
- package/package.json +65 -0
- package/src/lib/AnnotatedStringProperty.svelte +126 -0
- package/src/lib/CustomProperty.svelte +40 -0
- package/src/lib/Document.svelte.js +681 -0
- package/src/lib/Node.svelte +41 -0
- package/src/lib/NodeArrayProperty.svelte +45 -0
- package/src/lib/Svedit.svelte +936 -0
- package/src/lib/Transaction.svelte.js +577 -0
- package/src/lib/UnknownNode.svelte +12 -0
- package/src/lib/commands.svelte.js +261 -0
- package/src/lib/index.js +14 -0
- package/src/lib/types.d.ts +264 -0
- package/src/lib/util.js +78 -0
package/dist/Node.svelte
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
|
|
4
|
+
/** @import { NodeProps } from './types.d.ts'; */
|
|
5
|
+
|
|
6
|
+
const svedit = getContext('svedit');
|
|
7
|
+
let NodeCursorTrap = $derived(svedit.doc.config.system_components.NodeCursorTrap);
|
|
8
|
+
|
|
9
|
+
/** @type {NodeProps} */
|
|
10
|
+
let {
|
|
11
|
+
path,
|
|
12
|
+
children
|
|
13
|
+
} = $props();
|
|
14
|
+
|
|
15
|
+
// NOTE: When the next to last path segment is a node_array property, the node is wrapped in a node_array
|
|
16
|
+
let is_inside_node_array = $derived(path.length > 1 && svedit.doc.inspect(path.slice(0, -1))?.type === 'node_array');
|
|
17
|
+
let node = $derived(svedit.doc.get(path));
|
|
18
|
+
let is_first_node_array_child = $derived(is_inside_node_array && parseInt(String(path.at(-1)), 10) === 0);
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<div
|
|
22
|
+
class="node"
|
|
23
|
+
data-node-id={node.id}
|
|
24
|
+
data-path={path.join('.')}
|
|
25
|
+
data-type="node"
|
|
26
|
+
style="anchor-name: --{path.join('-')};"
|
|
27
|
+
>
|
|
28
|
+
{#if is_first_node_array_child}
|
|
29
|
+
<NodeCursorTrap {path} type="position-zero-cursor-trap" />
|
|
30
|
+
{/if}
|
|
31
|
+
{@render children()}
|
|
32
|
+
{#if is_inside_node_array}
|
|
33
|
+
<NodeCursorTrap {path} type="after-node-cursor-trap" />
|
|
34
|
+
{/if}
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<style>
|
|
38
|
+
div {
|
|
39
|
+
position: relative;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default Node;
|
|
2
|
+
type Node = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<NodeProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Node: import("svelte").Component<import("./types.d.ts").NodeProps, {}, "">;
|
|
7
|
+
//# sourceMappingURL=Node.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Node.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Node.svelte.js"],"names":[],"mappings":";;;;;AAuCA,yFAAmD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import UnknownNode from './UnknownNode.svelte';
|
|
4
|
+
import { snake_to_pascal } from './util.js';
|
|
5
|
+
|
|
6
|
+
/** @import { NodeArrayPropertyProps } from './types.d.ts'; */
|
|
7
|
+
|
|
8
|
+
const svedit = getContext('svedit');
|
|
9
|
+
let NodeCursorTrap = $derived(svedit.doc.config.system_components.NodeCursorTrap);
|
|
10
|
+
|
|
11
|
+
/** @type {NodeArrayPropertyProps} */
|
|
12
|
+
let {
|
|
13
|
+
path,
|
|
14
|
+
class: css_class,
|
|
15
|
+
} = $props();
|
|
16
|
+
|
|
17
|
+
let nodes = $derived(svedit.doc.get(path).map(/** @param {string} node_id */ (node_id) => svedit.doc.get(node_id)));
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<div class={css_class} data-type="node_array" data-path={path.join('.')}>
|
|
21
|
+
{#if nodes.length === 0}
|
|
22
|
+
<!--
|
|
23
|
+
Experimental: We'll let .empty-node-array act like a node, so the existing
|
|
24
|
+
code paths for selection mapping will work as expected.
|
|
25
|
+
|
|
26
|
+
TODO: Need to figure out a way to make .empty-node-array customizable.
|
|
27
|
+
-->
|
|
28
|
+
<div
|
|
29
|
+
class="node empty-node-array"
|
|
30
|
+
data-path={[...path, 0].join('.')}
|
|
31
|
+
data-type="node"
|
|
32
|
+
style="anchor-name: --{[...path, 0].join('-')}; position: relative; min-height: 40px; min-width: 40px;"
|
|
33
|
+
>
|
|
34
|
+
<NodeCursorTrap path={[...path, 0]} type="position-zero-cursor-trap" />
|
|
35
|
+
</div>
|
|
36
|
+
{/if}
|
|
37
|
+
{#each nodes as node, index (index) }
|
|
38
|
+
{@const Component = svedit.doc.config.node_components[snake_to_pascal(node.type)]}
|
|
39
|
+
{#if Component}
|
|
40
|
+
<Component path={[...path, index]} />
|
|
41
|
+
{:else}
|
|
42
|
+
<UnknownNode path={[...path, index]} />
|
|
43
|
+
{/if}
|
|
44
|
+
{/each}
|
|
45
|
+
</div>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default NodeArrayProperty;
|
|
2
|
+
type NodeArrayProperty = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<NodeArrayPropertyProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const NodeArrayProperty: import("svelte").Component<import("./types.d.ts").NodeArrayPropertyProps, {}, "">;
|
|
7
|
+
//# sourceMappingURL=NodeArrayProperty.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeArrayProperty.svelte.d.ts","sourceRoot":"","sources":["../src/lib/NodeArrayProperty.svelte.js"],"names":[],"mappings":";;;;;AA6CA,mHAAgE"}
|