yrby 0.8.1 → 0.9.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +117 -0
- data/Cargo.lock +43 -29
- data/README.md +18 -3
- data/ext/yrby/Cargo.toml +3 -1
- data/ext/yrby/crates/html-core/Cargo.toml +2 -2
- data/ext/yrby/crates/html-core/src/lib.rs +34 -3
- data/ext/yrby/crates/lexical-html/Cargo.toml +3 -3
- data/ext/yrby/crates/lexical-html/src/lib.rs +46 -16
- data/ext/yrby/crates/prosemirror-html/Cargo.toml +3 -3
- data/ext/yrby/crates/prosemirror-html/src/lib.rs +30 -5
- data/ext/yrby/src/array.rs +408 -0
- data/ext/yrby/src/lib.rs +996 -40
- data/ext/yrby/src/map.rs +385 -0
- data/ext/yrby/src/read.rs +3 -3
- data/ext/yrby/src/shared.rs +580 -0
- data/ext/yrby/src/text.rs +291 -0
- data/ext/yrby/src/xml_text.rs +740 -0
- data/lib/y/anchor.rb +34 -0
- data/lib/y/array.rb +17 -0
- data/lib/y/collaborative/attribute.rb +36 -0
- data/lib/y/collaborative/helper.rb +13 -10
- data/lib/y/collaborative.rb +14 -11
- data/lib/y/doc.rb +79 -0
- data/lib/y/lexical_markdown.rb +175 -0
- data/lib/y/lexical_writer.rb +142 -0
- data/lib/y/lexxy.rb +25 -0
- data/lib/y/map.rb +12 -0
- data/lib/y/rendering.rb +3 -3
- data/lib/y/text.rb +13 -0
- data/lib/y/version.rb +1 -1
- data/lib/y/xml_text.rb +36 -0
- data/lib/y.rb +8 -0
- metadata +14 -1
data/lib/y/rendering.rb
CHANGED
|
@@ -125,7 +125,7 @@ module Y
|
|
|
125
125
|
# A template: String literal, Symbol attribute reference, or an Array of
|
|
126
126
|
# both.
|
|
127
127
|
def compile_parts(template)
|
|
128
|
-
Array(template).map do |part|
|
|
128
|
+
Kernel.Array(template).map do |part|
|
|
129
129
|
case part
|
|
130
130
|
when Symbol then { "ref" => part.to_s }
|
|
131
131
|
else { "lit" => part.to_s }
|
|
@@ -227,7 +227,7 @@ module Y
|
|
|
227
227
|
|
|
228
228
|
def to_html(root = nil)
|
|
229
229
|
result = root.nil? ? @native.to_html : @native.to_html(root)
|
|
230
|
-
return result unless result.is_a?(Array)
|
|
230
|
+
return result unless result.is_a?(::Array)
|
|
231
231
|
|
|
232
232
|
RenderRules.splice(result, @render_callbacks)
|
|
233
233
|
end
|
|
@@ -274,7 +274,7 @@ module Y
|
|
|
274
274
|
|
|
275
275
|
def to_html(root = nil)
|
|
276
276
|
result = root.nil? ? @native.to_html : @native.to_html(root)
|
|
277
|
-
return result unless result.is_a?(Array)
|
|
277
|
+
return result unless result.is_a?(::Array)
|
|
278
278
|
|
|
279
279
|
RenderRules.splice(result, @render_callbacks)
|
|
280
280
|
end
|
data/lib/y/text.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Y
|
|
4
|
+
class Text
|
|
5
|
+
# The Yjs relative position of character `index`, the shape editors put
|
|
6
|
+
# in awareness as a caret. It keeps pointing at the same character as
|
|
7
|
+
# people edit around it; `index_at` says where that is now. `assoc:` is
|
|
8
|
+
# :after (default) or :before.
|
|
9
|
+
def relative_position(index, assoc: :after)
|
|
10
|
+
native_relative_position(index, assoc.to_s)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/y/version.rb
CHANGED
data/lib/y/xml_text.rb
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Y
|
|
4
|
+
# Ruby-side conveniences over the native live handle.
|
|
5
|
+
class XmlText
|
|
6
|
+
# Insert a block with `attributes` before the `ordinal`-th embedded
|
|
7
|
+
# block and return a live handle to it. A negative `ordinal` counts from
|
|
8
|
+
# the end, so -1 adds it after the last. `content` is written into the
|
|
9
|
+
# block in the same transaction, so no one sees the block before what it
|
|
10
|
+
# holds. It is an Array of Strings (text), Hashes (embeds, such as the
|
|
11
|
+
# marker Lexical puts before a text node's characters), and
|
|
12
|
+
# `[attributes, content]` pairs (blocks of their own).
|
|
13
|
+
def insert_xml_text(ordinal, attributes, content = [])
|
|
14
|
+
native_insert_xml_text(ordinal, attributes, content)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Append a block with `attributes` holding `content` (see
|
|
18
|
+
# `insert_xml_text`) and return a live handle to it.
|
|
19
|
+
def push_xml_text(attributes, content = [])
|
|
20
|
+
insert_xml_text(-1, attributes, content)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# The Yjs relative position of character `index`: the `{type, tname,
|
|
24
|
+
# item, assoc}` hash editors carry in awareness as `anchorPos`/`focusPos`.
|
|
25
|
+
# `assoc:` is `:after` (the default) or `:before`.
|
|
26
|
+
def relative_position(index, assoc: :after)
|
|
27
|
+
native_relative_position(index, assoc.to_s)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# This block's `Anchor`: a value that names the block itself, with the
|
|
31
|
+
# root's name, so the document can say where the block is later.
|
|
32
|
+
def anchor
|
|
33
|
+
Anchor.new(position: native_block_position, root: root_name)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/y.rb
CHANGED
|
@@ -14,6 +14,14 @@ end
|
|
|
14
14
|
|
|
15
15
|
require_relative "y/rendering"
|
|
16
16
|
require_relative "y/lexxy"
|
|
17
|
+
require_relative "y/lexical_writer"
|
|
18
|
+
require_relative "y/lexical_markdown"
|
|
19
|
+
require_relative "y/anchor"
|
|
20
|
+
require_relative "y/xml_text"
|
|
21
|
+
require_relative "y/text"
|
|
22
|
+
require_relative "y/map"
|
|
23
|
+
require_relative "y/array"
|
|
24
|
+
require_relative "y/doc"
|
|
17
25
|
require_relative "y/tiptap"
|
|
18
26
|
require_relative "y/decoder"
|
|
19
27
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: yrby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- JP Camara
|
|
@@ -89,22 +89,35 @@ files:
|
|
|
89
89
|
- ext/yrby/crates/prosemirror-html/Cargo.toml
|
|
90
90
|
- ext/yrby/crates/prosemirror-html/src/lib.rs
|
|
91
91
|
- ext/yrby/extconf.rb
|
|
92
|
+
- ext/yrby/src/array.rs
|
|
92
93
|
- ext/yrby/src/lib.rs
|
|
94
|
+
- ext/yrby/src/map.rs
|
|
93
95
|
- ext/yrby/src/protocol.rs
|
|
94
96
|
- ext/yrby/src/read.rs
|
|
97
|
+
- ext/yrby/src/shared.rs
|
|
98
|
+
- ext/yrby/src/text.rs
|
|
99
|
+
- ext/yrby/src/xml_text.rs
|
|
95
100
|
- lib/generators/yrby/install/install_generator.rb
|
|
96
101
|
- lib/generators/yrby/install/templates/document_channel.rb
|
|
97
102
|
- lib/generators/yrby/tables/tables_generator.rb
|
|
98
103
|
- lib/generators/yrby/tables/templates/create_y_tables.rb
|
|
99
104
|
- lib/y.rb
|
|
105
|
+
- lib/y/anchor.rb
|
|
106
|
+
- lib/y/array.rb
|
|
100
107
|
- lib/y/collaborative.rb
|
|
101
108
|
- lib/y/collaborative/attribute.rb
|
|
102
109
|
- lib/y/collaborative/helper.rb
|
|
103
110
|
- lib/y/decoder.rb
|
|
111
|
+
- lib/y/doc.rb
|
|
112
|
+
- lib/y/lexical_markdown.rb
|
|
113
|
+
- lib/y/lexical_writer.rb
|
|
104
114
|
- lib/y/lexxy.rb
|
|
115
|
+
- lib/y/map.rb
|
|
105
116
|
- lib/y/rendering.rb
|
|
117
|
+
- lib/y/text.rb
|
|
106
118
|
- lib/y/tiptap.rb
|
|
107
119
|
- lib/y/version.rb
|
|
120
|
+
- lib/y/xml_text.rb
|
|
108
121
|
- lib/yrby.rb
|
|
109
122
|
homepage: https://github.com/jpcamara/yrby
|
|
110
123
|
licenses:
|