marksmith 0.4.7 → 0.5.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/README.md +31 -0
- data/app/assets/images/marksmith/svgs/markdown.svg +1 -1
- data/app/assets/javascripts/list_continuation_controller-full.esm.js +1 -1
- data/app/assets/javascripts/list_continuation_controller-no-stimulus.esm.js +1 -1
- data/app/assets/javascripts/marksmith_controller-full.esm.js +1 -1
- data/app/assets/javascripts/marksmith_controller-no-stimulus.esm.js +1 -1
- data/app/assets/stylesheets/marksmith.css +21 -7
- data/app/helpers/marksmith/marksmith_helper.rb +3 -3
- data/app/models/marksmith/renderer.rb +1 -11
- data/app/views/marksmith/shared/_editor_pane.html.erb +1 -1
- data/app/views/marksmith/shared/_toolbar.html.erb +1 -1
- data/lib/marksmith/configuration.rb +47 -4
- data/lib/marksmith/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbea84daf14b0cab90133771f9d26505444de0aa469d28a0f51d2fdb1994d2c9
|
|
4
|
+
data.tar.gz: 754e03293a485251d0b5cac5dc48ee1d5214569a884946e3dda554c691a7d51d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cfbabde6a50498855311b9dd7a017ac52886387e57b8dfc57d2c0b4c1535beed32f9d4111816ed91904e6cc8873f18ff9b6d5f9f352631a2f3063eb0509ab048
|
|
7
|
+
data.tar.gz: 0757d7e8d1c6d7c479f75e081aaf7a5fede993ae1a15b03217163f864f3f4627e9db8c9561260b1faa1850e0ae61f5e2a2b0a9e28bc6b077e9caec2c4680fb66
|
data/README.md
CHANGED
|
@@ -23,6 +23,13 @@ Temporary live demo here, under the description field: [https://main.avodemo.com
|
|
|
23
23
|
|
|
24
24
|
## Installation
|
|
25
25
|
|
|
26
|
+
#### Prerequisites
|
|
27
|
+
|
|
28
|
+
Marksmith integrates with Rails apps using Stimulus controllers and Turbo Streams, so the following must already be installed and configured:
|
|
29
|
+
- [`@hotwired/stimulus` package](https://github.com/hotwired/stimulus)
|
|
30
|
+
- [`@hotwired/turbo` package](https://github.com/hotwired/turbo)
|
|
31
|
+
- [`turbo-rails` gem](https://github.com/hotwired/turbo-rails)
|
|
32
|
+
|
|
26
33
|
#### 1. Add `marksmith` to your `Gemfile`
|
|
27
34
|
|
|
28
35
|
Have Bundler add it by running this command:
|
|
@@ -187,6 +194,30 @@ Marksmith.configure do |config|
|
|
|
187
194
|
end
|
|
188
195
|
```
|
|
189
196
|
|
|
197
|
+
If you're using `redcarpet`, you can override the default parser flags through configuration. The defaults match the built-in behavior.
|
|
198
|
+
|
|
199
|
+
```ruby
|
|
200
|
+
# config/initializers/marksmith.rb
|
|
201
|
+
Marksmith.configure do |config|
|
|
202
|
+
config.parser = "redcarpet"
|
|
203
|
+
config.redcarpet_options = {
|
|
204
|
+
underline: false,
|
|
205
|
+
highlight: false
|
|
206
|
+
}
|
|
207
|
+
end
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Or override individual flags directly:
|
|
211
|
+
|
|
212
|
+
```ruby
|
|
213
|
+
# config/initializers/marksmith.rb
|
|
214
|
+
Marksmith.configure do |config|
|
|
215
|
+
config.parser = "redcarpet"
|
|
216
|
+
config.redcarpet_options.underline = false
|
|
217
|
+
config.redcarpet_options.highlight = false
|
|
218
|
+
end
|
|
219
|
+
```
|
|
220
|
+
|
|
190
221
|
### Add your own renderer
|
|
191
222
|
|
|
192
223
|
You can completely customize the renderer by overriding the `Marksmith::Renderer` model.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" role="img" class="ms:inline ms:size-4"><
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" role="img" class="ms:inline ms:size-4"><title>Markdown icon</title><path d="M22.269 19.385H1.731a1.73 1.73 0 0 1-1.73-1.73V6.345a1.73 1.73 0 0 1 1.73-1.73h20.538a1.73 1.73 0 0 1 1.73 1.73v11.308a1.73 1.73 0 0 1-1.73 1.731zm-16.5-3.462v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.461v7.847zM21.231 12h-2.308V8.077h-2.307V12h-2.308l3.461 4.039z"/></svg>
|
|
@@ -373,9 +373,6 @@
|
|
|
373
373
|
.ms\:pointer-events-none {
|
|
374
374
|
pointer-events: none;
|
|
375
375
|
}
|
|
376
|
-
.ms\:-my-px {
|
|
377
|
-
margin-block: -1px;
|
|
378
|
-
}
|
|
379
376
|
.ms\:prose {
|
|
380
377
|
color: var(--tw-prose-body);
|
|
381
378
|
max-width: 65ch;
|
|
@@ -791,6 +788,12 @@
|
|
|
791
788
|
margin-bottom: 0;
|
|
792
789
|
}
|
|
793
790
|
}
|
|
791
|
+
.ms\:-mt-px {
|
|
792
|
+
margin-top: -1px;
|
|
793
|
+
}
|
|
794
|
+
.ms\:-mb-px {
|
|
795
|
+
margin-bottom: -1px;
|
|
796
|
+
}
|
|
794
797
|
.ms\:-ml-px {
|
|
795
798
|
margin-left: -1px;
|
|
796
799
|
}
|
|
@@ -817,8 +820,8 @@
|
|
|
817
820
|
width: 100%;
|
|
818
821
|
height: 100%;
|
|
819
822
|
}
|
|
820
|
-
.ms\:h-\[calc\(100\%\+
|
|
821
|
-
height: calc(100% +
|
|
823
|
+
.ms\:h-\[calc\(100\%\+2px\)\] {
|
|
824
|
+
height: calc(100% + 2px);
|
|
822
825
|
}
|
|
823
826
|
.ms\:min-h-60 {
|
|
824
827
|
min-height: calc(var(--ms-spacing) * 60);
|
|
@@ -856,6 +859,9 @@
|
|
|
856
859
|
.ms\:items-center {
|
|
857
860
|
align-items: center;
|
|
858
861
|
}
|
|
862
|
+
.ms\:justify-between {
|
|
863
|
+
justify-content: space-between;
|
|
864
|
+
}
|
|
859
865
|
.ms\:gap-1 {
|
|
860
866
|
gap: calc(var(--ms-spacing) * 1);
|
|
861
867
|
}
|
|
@@ -878,6 +884,9 @@
|
|
|
878
884
|
.ms\:rounded-md {
|
|
879
885
|
border-radius: var(--ms-radius-md);
|
|
880
886
|
}
|
|
887
|
+
.ms\:rounded-none {
|
|
888
|
+
border-radius: 0;
|
|
889
|
+
}
|
|
881
890
|
.ms\:rounded-t-md {
|
|
882
891
|
border-top-left-radius: var(--ms-radius-md);
|
|
883
892
|
border-top-right-radius: var(--ms-radius-md);
|
|
@@ -1130,9 +1139,14 @@
|
|
|
1130
1139
|
border-color: var(--ms-color-neutral-500);
|
|
1131
1140
|
}
|
|
1132
1141
|
}
|
|
1133
|
-
.ms\:\[\.active\]\:
|
|
1142
|
+
.ms\:\[\.active\]\:border-b-transparent {
|
|
1143
|
+
&:is(.active) {
|
|
1144
|
+
border-bottom-color: transparent;
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
.ms\:\[\.active\]\:bg-white {
|
|
1134
1148
|
&:is(.active) {
|
|
1135
|
-
background-color: var(--ms-color-
|
|
1149
|
+
background-color: var(--ms-color-white);
|
|
1136
1150
|
}
|
|
1137
1151
|
}
|
|
1138
1152
|
.ms\:\[\.active\]\:text-neutral-900 {
|
|
@@ -42,11 +42,11 @@ module Marksmith
|
|
|
42
42
|
"marksmith-toggle-button ms:text-sm ms:hover:bg-neutral-300 ms:text-sm ms:font-medium ms:cursor-pointer ms:text-neutral-500 ms:px-3",
|
|
43
43
|
# borders
|
|
44
44
|
"ms:bg-transparent ms:hover:bg-transparent",
|
|
45
|
-
"ms:-
|
|
46
|
-
"ms:h-[calc(100%+
|
|
45
|
+
"ms:-mt-px ms:-mb-px ms:-ml-px ms:border ms:border-transparent",
|
|
46
|
+
"ms:h-[calc(100%+2px)] ms:border-b-none",
|
|
47
47
|
# "ms:border-b-neutral-00",
|
|
48
48
|
# active classes
|
|
49
|
-
"ms:[.active]:bg-
|
|
49
|
+
"ms:[.active]:bg-white ms:[.active]:text-neutral-900 ms:dark:[.active]:text-neutral-300 ms:[.active]:dark:bg-neutral-800 ms:[.active]:dark:border-neutral-500 ms:[.active]:rounded-t-md ms:[.active]:border-neutral-500 ms:[.active]:border-b-transparent",
|
|
50
50
|
|
|
51
51
|
)
|
|
52
52
|
end
|
|
@@ -23,17 +23,7 @@ module Marksmith
|
|
|
23
23
|
def render_redcarpet
|
|
24
24
|
::Redcarpet::Markdown.new(
|
|
25
25
|
::Redcarpet::Render::HTML,
|
|
26
|
-
|
|
27
|
-
lax_spacing: true,
|
|
28
|
-
fenced_code_blocks: true,
|
|
29
|
-
space_after_headers: true,
|
|
30
|
-
hard_wrap: true,
|
|
31
|
-
autolink: true,
|
|
32
|
-
strikethrough: true,
|
|
33
|
-
underline: true,
|
|
34
|
-
highlight: true,
|
|
35
|
-
quote: true,
|
|
36
|
-
with_toc_data: true
|
|
26
|
+
Marksmith.configuration.redcarpet_options.to_h
|
|
37
27
|
).render(@body)
|
|
38
28
|
end
|
|
39
29
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<%= text_area_tag editor.field_name, editor.value,
|
|
3
3
|
id: editor.textarea_id,
|
|
4
4
|
class: class_names(
|
|
5
|
-
"marksmith-textarea ms:flex ms:flex-1 ms:border-none ms:resize-none ms:focus:outline-none ms:font-mono ms:focus:ring-0 ms:leading-normal ms:p-2 ms:text-sm ms:field-sizing-content ms:min-h-60",
|
|
5
|
+
"marksmith-textarea ms:flex ms:flex-1 ms:border-none ms:resize-none ms:focus:outline-none ms:font-mono ms:focus:ring-0 ms:leading-normal ms:p-2 ms:text-sm ms:field-sizing-content ms:min-h-60 ms:rounded-none",
|
|
6
6
|
"ms:dark:bg-neutral-800 ms:dark:text-neutral-200",
|
|
7
7
|
editor.classes
|
|
8
8
|
),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%= tag.div class: class_names(
|
|
2
|
-
"marksmith-toolbar ms:flex-1 ms:flex-col-reverse ms:@md:flex-row ms:grow ms:flex
|
|
2
|
+
"marksmith-toolbar ms:flex-1 ms:flex-col-reverse ms:@md:flex-row ms:grow ms:flex ms:justify-between ms:bg-neutral-50 ms:rounded-t-md ms:gap-y-1",
|
|
3
3
|
"ms:dark:bg-neutral-700 ms:dark:text-neutral-200"
|
|
4
4
|
) do %>
|
|
5
5
|
<%= render partial: "marksmith/shared/tabs" %>
|
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
module Marksmith
|
|
2
2
|
class Configuration
|
|
3
|
-
|
|
3
|
+
class RedcarpetOptions
|
|
4
|
+
DEFAULTS = {
|
|
5
|
+
tables: true,
|
|
6
|
+
lax_spacing: true,
|
|
7
|
+
fenced_code_blocks: true,
|
|
8
|
+
space_after_headers: true,
|
|
9
|
+
hard_wrap: true,
|
|
10
|
+
autolink: true,
|
|
11
|
+
strikethrough: true,
|
|
12
|
+
underline: true,
|
|
13
|
+
highlight: true,
|
|
14
|
+
quote: true,
|
|
15
|
+
with_toc_data: true
|
|
16
|
+
}.freeze
|
|
4
17
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
DEFAULTS.each do |name, default|
|
|
19
|
+
class_attribute name, default: default
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.merge(options)
|
|
23
|
+
options.to_h.each do |key, value|
|
|
24
|
+
writer = "#{key}="
|
|
25
|
+
|
|
26
|
+
unless respond_to?(writer)
|
|
27
|
+
raise ArgumentError, "Unknown Redcarpet option: #{key}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
public_send(writer, value)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.to_h
|
|
37
|
+
DEFAULTS.keys.each_with_object({}) do |key, hash|
|
|
38
|
+
hash[key] = public_send(key)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class_attribute :automatically_mount_engine, default: true
|
|
44
|
+
class_attribute :mount_path, default: "/marksmith"
|
|
45
|
+
class_attribute :parser, default: "commonmarker"
|
|
46
|
+
class_attribute :redcarpet_options, default: RedcarpetOptions
|
|
47
|
+
|
|
48
|
+
def redcarpet_options=(options)
|
|
49
|
+
self.class.redcarpet_options = redcarpet_options.merge(options.to_h)
|
|
50
|
+
end
|
|
8
51
|
end
|
|
9
52
|
|
|
10
53
|
def self.configuration
|
data/lib/marksmith/version.rb
CHANGED