richer_text 0.16.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/app/models/richer_text/json_text.rb +4 -0
- data/db/migrate/20230926034114_create_richer_text_o_embeds.rb +1 -1
- data/lib/generators/richer_text/install/install_generator.rb +8 -0
- data/lib/richer_text/text_visitor.rb +93 -0
- data/lib/richer_text/version.rb +1 -1
- data/lib/richer_text.rb +6 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e980db9b17d908bf7d262b4c161eb9f1157fc42ee8fb8c77f48ea5badd79d0e
|
4
|
+
data.tar.gz: 39cb48282c6a278bd0e007669e7dcb55202a116e791e67679d222f0e5296d451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59a47127efcfec99b846b47ad40bf78b72b5a4149fc29b55085ddfcbad99543ef6d1b566fb5db0941e74081bf403b0f3a8d5c205f7def5888145570aa01d9a26
|
7
|
+
data.tar.gz: 761aa4710136531f6e05f63c7214f753a710375c790e0b4e715d3c6f54dbbb521f2082dcf730008d44fce29e3b75f61fe9e8662f101b0dff0b3fe97400a5a779
|
data/README.md
CHANGED
@@ -39,9 +39,6 @@ document.addEventListener("turbo:load", (event) => {
|
|
39
39
|
|
40
40
|
## Usage
|
41
41
|
|
42
|
-
> [!WARNING]
|
43
|
-
> You probably shouldn't use this gem / npm package (yet!) for anything serious. It's still undergoing development. But please do try it on a non-production app!
|
44
|
-
|
45
42
|
To use RicherText, once you've completed the installation process is a matter of doing the following:
|
46
43
|
|
47
44
|
**Add has_richer_text to a model**
|
@@ -33,6 +33,14 @@ module RicherText
|
|
33
33
|
run "pnpm add highlight.js @afomera/richer-text" if destination.join("pnpm-lock.yaml").exist?
|
34
34
|
end
|
35
35
|
|
36
|
+
if (importmap_path = destination.join("config/importmap.rb")).exist?
|
37
|
+
run "curl -Lo ./vendor/javascript/richer-text.js https://unpkg.com/@afomera/richer-text@latest/dist/bundle/index.module.js"
|
38
|
+
run "curl -Lo ./app/assets/stylesheets/richer-text.css https://unpkg.com/@afomera/richer-text@2.0.0/dist/css/richer-text.css"
|
39
|
+
|
40
|
+
say "Adding import to importmap.rb", :green
|
41
|
+
append_to_file importmap_path.to_s, %(pin "@afomera/richer-text", to: "richer-text.js"\n)
|
42
|
+
end
|
43
|
+
|
36
44
|
say "Adding import to application.js", :green
|
37
45
|
append_to_file "app/javascript/application.js", %(import "@afomera/richer-text"\n)
|
38
46
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module RicherText
|
2
|
+
class TextVisitor
|
3
|
+
def visit(node)
|
4
|
+
node.accept(self)
|
5
|
+
end
|
6
|
+
|
7
|
+
def visit_attachment_figure(node)
|
8
|
+
visit_children(node)
|
9
|
+
end
|
10
|
+
|
11
|
+
def visit_attachment_gallery(node)
|
12
|
+
visit_children(node)
|
13
|
+
end
|
14
|
+
|
15
|
+
def visit_blockquote(node)
|
16
|
+
visit_children(node)
|
17
|
+
end
|
18
|
+
|
19
|
+
def visit_bullet_list(node)
|
20
|
+
visit_children(node)
|
21
|
+
end
|
22
|
+
|
23
|
+
def visit_callout(node)
|
24
|
+
visit_children(node)
|
25
|
+
end
|
26
|
+
|
27
|
+
def visit_children(node)
|
28
|
+
node.children.map { |child| visit(child) }.join(" ")
|
29
|
+
end
|
30
|
+
|
31
|
+
def visit_code_block(node)
|
32
|
+
end
|
33
|
+
|
34
|
+
def visit_doc(node)
|
35
|
+
visit_children(node)
|
36
|
+
end
|
37
|
+
|
38
|
+
def visit_iframely_embed(node)
|
39
|
+
end
|
40
|
+
|
41
|
+
def visit_mention(node, _marks)
|
42
|
+
node.name
|
43
|
+
end
|
44
|
+
|
45
|
+
def visit_paragraph(node)
|
46
|
+
visit_children(node)
|
47
|
+
end
|
48
|
+
|
49
|
+
def visit_richer_text_embed(node)
|
50
|
+
end
|
51
|
+
|
52
|
+
def visit_list_item(node)
|
53
|
+
visit_children(node)
|
54
|
+
end
|
55
|
+
|
56
|
+
def visit_ordered_list(node)
|
57
|
+
visit_children(node)
|
58
|
+
end
|
59
|
+
|
60
|
+
def visit_heading(node)
|
61
|
+
visit_children(node)
|
62
|
+
end
|
63
|
+
|
64
|
+
def visit_hard_break(_node)
|
65
|
+
end
|
66
|
+
|
67
|
+
def visit_horizontal_rule(_node)
|
68
|
+
end
|
69
|
+
|
70
|
+
def visit_image(_node)
|
71
|
+
end
|
72
|
+
|
73
|
+
def visit_text(node, _marks)
|
74
|
+
node.text
|
75
|
+
end
|
76
|
+
|
77
|
+
def visit_table(node)
|
78
|
+
visit_children(node)
|
79
|
+
end
|
80
|
+
|
81
|
+
def visit_table_row(node)
|
82
|
+
visit_children(node)
|
83
|
+
end
|
84
|
+
|
85
|
+
def visit_table_cell(node)
|
86
|
+
visit_children(node)
|
87
|
+
end
|
88
|
+
|
89
|
+
def visit_table_header(node)
|
90
|
+
visit_children(node)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/lib/richer_text/version.rb
CHANGED
data/lib/richer_text.rb
CHANGED
@@ -20,6 +20,7 @@ module RicherText
|
|
20
20
|
autoload :Node
|
21
21
|
autoload :Mark
|
22
22
|
autoload :HTMLVisitor
|
23
|
+
autoload :TextVisitor
|
23
24
|
|
24
25
|
module Nodes
|
25
26
|
extend ActiveSupport::Autoload
|
@@ -53,10 +54,14 @@ module RicherText
|
|
53
54
|
@default_renderer ||= RicherText::HTMLVisitor.new
|
54
55
|
end
|
55
56
|
|
57
|
+
def default_text_renderer
|
58
|
+
@default_text_renderer ||= RicherText::TextVisitor.new
|
59
|
+
end
|
60
|
+
|
56
61
|
def default_form_options
|
57
62
|
@default_form_options ||= {}
|
58
63
|
end
|
59
64
|
|
60
|
-
attr_writer :default_renderer, :default_form_options
|
65
|
+
attr_writer :default_renderer, :default_text_renderer, :default_form_options
|
61
66
|
end
|
62
67
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: richer_text
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Fomera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- lib/richer_text/rendering.rb
|
105
105
|
- lib/richer_text/serialization.rb
|
106
106
|
- lib/richer_text/tag_helper.rb
|
107
|
+
- lib/richer_text/text_visitor.rb
|
107
108
|
- lib/richer_text/version.rb
|
108
109
|
- lib/tasks/richer_text_tasks.rake
|
109
110
|
homepage: https://github.com/afomera/richer_text
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
- !ruby/object:Gem::Version
|
127
128
|
version: '0'
|
128
129
|
requirements: []
|
129
|
-
rubygems_version: 3.5.
|
130
|
+
rubygems_version: 3.5.16
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: A richer text editor for Rails
|