marksmith 0.4.5 → 0.4.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6cc55be2a301ad325d9f754e10ae36b9934152bdd36f3e16dac91946e2ce9215
4
- data.tar.gz: 559d9ab0c0224494bddce9693522b4371785edb4cb0a87990617a362ffcf86cd
3
+ metadata.gz: e1d5b2c4a0d4db7b3a054c7059c057679275bbecce5d97652daa3257cacb93dc
4
+ data.tar.gz: 8d836efd54a1f4ef8a6c1c70ad055a413387f2ac39fa44791cc56f767f7494ed
5
5
  SHA512:
6
- metadata.gz: 7cead70f3cb46b24c4b2850f146d17f6792761bdb7e386203d61d6c870ea4fc688ca3540425a20619745127f98857c295c2ed9da9b1e4cf0a59da608c3979ae1
7
- data.tar.gz: 19ee1acd0cbfd57b1d6bf463ec947f772f53b3dd2e0e6bfa2174ca061701c2bd1554b3bf36006a41eefc95ec9eb8d4ff57fe015cefebf1356b9fb75a0b3a2412
6
+ metadata.gz: 4f81f2f31b7011f281fbd2d00cd31feeb99bd659cb758977aed56d28d0bbd33e9a0d7c09bbb52a7631edf14d1f4522eb534770b7594f3c221714df7ef06dcea5
7
+ data.tar.gz: eb655f70633ed583a635e38cc96bcf8dfb9ca5bf78f761cbe0dc47c40527e176450d04dbd77f08ce095bd681a2830e5ecbbcb30274957ebfe96d29ba78f6d88c
@@ -3367,6 +3367,18 @@ var MarksmithController = (function () {
3367
3367
  this.editor?.chain().focus().setAttachment(editorAttachments).run();
3368
3368
  }
3369
3369
 
3370
+ indent(event) {
3371
+ event.preventDefault();
3372
+ // add a tab before the current cursor position
3373
+ const start = this.fieldElementTarget.selectionStart;
3374
+ const end = this.fieldElementTarget.selectionEnd;
3375
+ const text = this.fieldElementTarget.value;
3376
+ const newText = text.slice(0, start) + '\t' + text.slice(start, end) + text.slice(end);
3377
+ this.fieldElementTarget.value = newText;
3378
+ this.fieldElementTarget.selectionStart = start + 1;
3379
+ this.fieldElementTarget.selectionEnd = end + 1;
3380
+ }
3381
+
3370
3382
  #uploadFiles(files) {
3371
3383
  Array.from(files).forEach((file) => this.#uploadFile(file));
3372
3384
  }
@@ -2877,6 +2877,18 @@ var MarksmithController = (function (stimulus) {
2877
2877
  this.editor?.chain().focus().setAttachment(editorAttachments).run();
2878
2878
  }
2879
2879
 
2880
+ indent(event) {
2881
+ event.preventDefault();
2882
+ // add a tab before the current cursor position
2883
+ const start = this.fieldElementTarget.selectionStart;
2884
+ const end = this.fieldElementTarget.selectionEnd;
2885
+ const text = this.fieldElementTarget.value;
2886
+ const newText = text.slice(0, start) + '\t' + text.slice(start, end) + text.slice(end);
2887
+ this.fieldElementTarget.value = newText;
2888
+ this.fieldElementTarget.selectionStart = start + 1;
2889
+ this.fieldElementTarget.selectionEnd = end + 1;
2890
+ }
2891
+
2880
2892
  #uploadFiles(files) {
2881
2893
  Array.from(files).forEach((file) => this.#uploadFile(file));
2882
2894
  }
@@ -1163,6 +1163,9 @@
1163
1163
  }
1164
1164
  .marksmith, .marksmith * {
1165
1165
  box-sizing: border-box;
1166
+ & textarea.marksmith-textarea {
1167
+ tab-size: var(--tab-size, 4);
1168
+ }
1166
1169
  }
1167
1170
  .ms\:button-spinner {
1168
1171
  width: 24px;
@@ -20,6 +20,10 @@
20
20
  .marksmith,
21
21
  .marksmith * {
22
22
  box-sizing: border-box;
23
+
24
+ & textarea.marksmith-textarea {
25
+ tab-size: var(--tab-size, 4);
26
+ }
23
27
  }
24
28
 
25
29
  .ms\:button-spinner {
@@ -135,6 +135,18 @@ export default class extends Controller {
135
135
  this.editor?.chain().focus().setAttachment(editorAttachments).run();
136
136
  }
137
137
 
138
+ indent(event) {
139
+ event.preventDefault()
140
+ // add a tab before the current cursor position
141
+ const start = this.fieldElementTarget.selectionStart
142
+ const end = this.fieldElementTarget.selectionEnd
143
+ const text = this.fieldElementTarget.value
144
+ const newText = text.slice(0, start) + '\t' + text.slice(start, end) + text.slice(end)
145
+ this.fieldElementTarget.value = newText
146
+ this.fieldElementTarget.selectionStart = start + 1
147
+ this.fieldElementTarget.selectionEnd = end + 1
148
+ }
149
+
138
150
  #uploadFiles(files) {
139
151
  Array.from(files).forEach((file) => this.#uploadFile(file))
140
152
  }
@@ -1,5 +1,5 @@
1
1
  <%= tag.markdown_toolbar for: textarea_id,
2
- class: class_names("ms:flex ms:flex-wrap ms:px-2 ms:py-1", "ms:pointer-events-none": disabled),
2
+ class: class_names("marksmith-action-bar ms:flex ms:flex-wrap ms:px-2 ms:py-1", "ms:pointer-events-none": disabled),
3
3
  data: { marksmith_target: "toolbar" } do
4
4
  %>
5
5
  <%= marksmith_toolbar_button "bold", hotkey: "Meta+b", hotkey_scope: textarea_id %>
@@ -1,6 +1,6 @@
1
1
  <%= content_tag :div,
2
2
  id: editor.id,
3
- class: "marksmith ms:block ms:flex-col ms:w-full ms:border ms:border-neutral-500 ms:rounded-md ms:@container ms:focus-within:outline-2 ms:outline-blue-500 ms:-outline-offset-1",
3
+ class: "marksmith-editor-wrapper marksmith ms:block ms:flex-col ms:w-full ms:border ms:border-neutral-500 ms:rounded-md ms:@container ms:focus-within:outline-2 ms:outline-blue-500 ms:-outline-offset-1",
4
4
  data: {
5
5
  controller: "marksmith list-continuation",
6
6
  action: "
@@ -16,7 +16,7 @@
16
16
  **editor.controller_data_attributes,
17
17
  } do %>
18
18
  <%= render partial: "marksmith/shared/toolbar", locals: { textarea_id: editor.textarea_id, disabled: editor.disabled} %>
19
- <div class="ms:border-t ms:w-full ms:border-neutral-500 ms:flex ms:flex-1">
19
+ <div class="marksmith-editor-content ms:border-t ms:w-full ms:border-neutral-500 ms:flex ms:flex-1">
20
20
  <%= render partial: "marksmith/shared/editor_pane", locals: { editor: } %>
21
21
  <%= render partial: "marksmith/shared/preview_pane", locals: { editor: } %>
22
22
  </div>
@@ -1,13 +1,13 @@
1
- <%= content_tag :div, class: "ms:flex ms:flex-1 ms:flex-col ms:size-full", data: { marksmith_target: "fieldContainer" } do %>
1
+ <%= content_tag :div, class: "marksmith-editor-pane ms:flex ms:flex-1 ms:flex-col ms:size-full", data: { marksmith_target: "fieldContainer" } do %>
2
2
  <%= text_area_tag editor.field_name, editor.value,
3
3
  id: editor.textarea_id,
4
4
  class: class_names(
5
- "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",
6
6
  "ms:dark:bg-neutral-800 ms:dark:text-neutral-200",
7
7
  editor.classes
8
8
  ),
9
9
  data: {
10
- action: "drop->marksmith#dropUpload paste->marksmith#pasteUpload",
10
+ action: "drop->marksmith#dropUpload paste->marksmith#pasteUpload keydown.tab->marksmith#indent",
11
11
  marksmith_target: "fieldElement",
12
12
  **editor.data_attributes
13
13
  },
@@ -17,17 +17,17 @@
17
17
  style: editor.style
18
18
  %>
19
19
  <% toolbar_button_classes = "ms:cursor-pointer ms:hover:bg-neutral-200 ms:px-1 ms:py-px ms:rounded ms:text-sm ms:dark:text-neutral-300 ms:dark:hover:bg-neutral-600" %>
20
- <div class="ms:flex ms:flex-1 ms:flex-grow ms:space-x-2 ms:py-1 ms:border-t ms:border-neutral-500 ms:px-2 ms:font-sans ms:text-sm ms:p-2 ms:dark:bg-neutral-800 ms:dark:text-neutral-300 ms:rounded-b-md">
21
- <%= link_to "https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax", target: "_blank", class: class_names("ms:flex ms:items-center ms:text-neutral-800 ms:no-underline ms:gap-1", toolbar_button_classes) do %>
20
+ <div class="marksmith-bottom-toolbar ms:flex ms:flex-1 ms:flex-grow ms:space-x-2 ms:py-1 ms:border-t ms:border-neutral-500 ms:px-2 ms:font-sans ms:text-sm ms:p-2 ms:dark:bg-neutral-800 ms:dark:text-neutral-300 ms:rounded-b-md">
21
+ <%= link_to "https://docs.github.com/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax", target: "_blank", class: class_names("marksmith-help-link ms:flex ms:items-center ms:text-neutral-800 ms:no-underline ms:gap-1", toolbar_button_classes) do %>
22
22
  <%= marksmith_inline_svg("app/assets/images/marksmith/svgs/markdown.svg") %> <span><%= t("marksmith.markdown_is_supported").humanize %></span>
23
23
  <% end %>
24
24
  <% if editor.enable_file_uploads %>
25
- <%= button_tag data: { action: "click->marksmith#buttonUpload" }, class: class_names("ms:bg-none ms:border-none ms:bg-transparent ms:text-neutral-600 ms:items-center ms:flex ms:gap-1", toolbar_button_classes) do %>
25
+ <%= button_tag data: { action: "click->marksmith#buttonUpload" }, class: class_names("marksmith-upload-button ms:bg-none ms:border-none ms:bg-transparent ms:text-neutral-600 ms:items-center ms:flex ms:gap-1", toolbar_button_classes) do %>
26
26
  <%= marksmith_inline_svg("app/assets/images/marksmith/svgs/paperclip.svg") %> <span><%= t("marksmith.upload_files").humanize %></span>
27
27
  <% end %>
28
28
  <% end %>
29
29
  <% if editor.gallery_enabled %>
30
- <%= link_to editor.gallery_full_path, data: { turbo_frame: editor.gallery_turbo_frame }, class: class_names("ms:flex ms:items-center ms:text-neutral-800 ms:no-underline ms:gap-1", toolbar_button_classes) do %>
30
+ <%= link_to editor.gallery_full_path, data: { turbo_frame: editor.gallery_turbo_frame }, class: class_names("marksmith-gallery-link ms:flex ms:items-center ms:text-neutral-800 ms:no-underline ms:gap-1", toolbar_button_classes) do %>
31
31
  <%= marksmith_inline_svg("app/assets/images/marksmith/svgs/gallery.svg") %> <span><%= t("marksmith.attach_from_gallery").humanize %></span>
32
32
  <% end %>
33
33
  <% end %>
@@ -1,4 +1,4 @@
1
- <div class="ms:button-spinner">
2
- <div class="double-bounce1"></div>
3
- <div class="double-bounce2"></div>
1
+ <div class="marksmith-loading-indicator ms:button-spinner">
2
+ <div class="marksmith-loading-bounce1 double-bounce1"></div>
3
+ <div class="marksmith-loading-bounce2 double-bounce2"></div>
4
4
  </div>
@@ -1,5 +1,5 @@
1
1
  <%= content_tag :div,
2
- class: "ms:hidden ms:markdown-preview ms:size-full ms:flex-1 ms:flex ms:size-full ms:p-2 ms:overflow-auto ms:bg-white ms:dark:bg-neutral-800 ms:rounded-b-md",
2
+ class: "marksmith-preview-pane ms:hidden ms:markdown-preview ms:size-full ms:flex-1 ms:flex ms:size-full ms:p-2 ms:overflow-auto ms:bg-white ms:dark:bg-neutral-800 ms:rounded-b-md",
3
3
  id: editor.preview_pane_id,
4
4
  data: {
5
5
  marksmith_target: "previewPane",
@@ -1,3 +1,3 @@
1
- <%= content_tag :div, class: "ms:block ms:w-full ms:prose ms:max-w-none ms:prose-neutral ms:dark:prose-invert" do %>
1
+ <%= content_tag :div, class: "marksmith-rendered-body ms:block ms:w-full ms:prose ms:max-w-none ms:prose-neutral ms:dark:prose-invert" do %>
2
2
  <%= sanitize(body, tags: %w(table th tr td span) + ActionView::Helpers::SanitizeHelper.sanitizer_vendor.safe_list_sanitizer.allowed_tags.to_a) %>
3
3
  <% end %>
@@ -1,8 +1,8 @@
1
- <div class="ms:flex-1 ms:flex ms:items:center">
2
- <button class="<%= marksmith_tab_classes %> active" data-action="click->marksmith#switchToWrite" data-marksmith-target="writeTabButton" type="button">
1
+ <div class="marksmith-tabs ms:flex-1 ms:flex ms:items:center">
2
+ <button class="marksmith-tab marksmith-write-tab <%= marksmith_tab_classes %> active" data-action="click->marksmith#switchToWrite" data-marksmith-target="writeTabButton" type="button">
3
3
  <%= t('marksmith.write').humanize %>
4
4
  </button>
5
- <button class="<%= marksmith_tab_classes %>" data-action="click->marksmith#switchToPreview" data-marksmith-target="previewTabButton" type="button">
5
+ <button class="marksmith-tab marksmith-preview-tab <%= marksmith_tab_classes %>" data-action="click->marksmith#switchToPreview" data-marksmith-target="previewTabButton" type="button">
6
6
  <%= t('marksmith.preview').humanize %>
7
7
  </button>
8
8
  </div>
@@ -1,5 +1,5 @@
1
1
  <%= tag.div class: class_names(
2
- "ms:flex-1 ms:flex-col-reverse ms:@md:flex-row ms:grow ms:flex ms:justify-bewteen ms:bg-neutral-50 ms:rounded-t-md ms:gap-y-1",
2
+ "marksmith-toolbar ms:flex-1 ms:flex-col-reverse ms:@md:flex-row ms:grow ms:flex ms:justify-bewteen 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" %>
@@ -0,0 +1,17 @@
1
+ it:
2
+ marksmith:
3
+ attach_from_gallery: Allega dalla galleria
4
+ bold: grassetto
5
+ code: codice
6
+ header: intestazione
7
+ image: immagine
8
+ italic: corsivo
9
+ link: link
10
+ markdown_is_supported: Markdown è supportato
11
+ ordered_list: elenco ordinato
12
+ preview: anteprima
13
+ quote: citazione
14
+ task_list: elenco di attività
15
+ unordered_list: elenco non ordinato
16
+ upload_files: carica file
17
+ write: scrivi
@@ -0,0 +1,17 @@
1
+ pt-BR:
2
+ marksmith:
3
+ attach_from_gallery: Anexar da galeria
4
+ bold: negrito
5
+ code: código
6
+ header: cabeçalho
7
+ image: imagem
8
+ italic: itálico
9
+ link: link
10
+ markdown_is_supported: Markdown é suportado
11
+ ordered_list: lista ordenada
12
+ preview: pré-visualização
13
+ quote: citação
14
+ task_list: lista de tarefas
15
+ unordered_list: lista não ordenada
16
+ upload_files: enviar arquivos
17
+ write: escrever
@@ -9,7 +9,18 @@ module Marksmith
9
9
 
10
10
  module FormBuilderExtensions
11
11
  def marksmith(*args, **kwargs, &block)
12
- @template.marksmith_tag(*args, **kwargs.merge(form: self), &block)
12
+ # If the template has a 'marksmith_tag' method, use it to call the 'marksmith_tag' method
13
+ # ViewComponent has 'helpers' method, and from 4.0.0 we need to use it to call the 'marksmith_tag' method
14
+ # Otherwise, fallback to the template and raise error
15
+ marksmith_caller_object = if @template.respond_to?(:marksmith_tag)
16
+ @template
17
+ elsif @template.respond_to?(:helpers) && @template.helpers.respond_to?(:marksmith_tag)
18
+ @template.helpers
19
+ else
20
+ @template
21
+ end
22
+
23
+ marksmith_caller_object.marksmith_tag(*args, **kwargs.merge(form: self), &block)
13
24
  end
14
25
  end
15
26
 
@@ -1,3 +1,3 @@
1
1
  module Marksmith
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marksmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-05-08 00:00:00.000000000 Z
11
+ date: 2025-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -84,6 +84,8 @@ files:
84
84
  - app/views/marksmith/shared/_toolbar.html.erb
85
85
  - config/locales/marksmith.de.yml
86
86
  - config/locales/marksmith.en.yml
87
+ - config/locales/marksmith.it.yml
88
+ - config/locales/marksmith.pt-BR.yml
87
89
  - config/routes.rb
88
90
  - config/vite.json
89
91
  - lib/generators/marksmith/install_generator.rb
@@ -101,7 +103,7 @@ metadata:
101
103
  homepage_uri: https://github.com/avo-hq/marksmith
102
104
  source_code_uri: https://github.com/avo-hq/marksmith
103
105
  changelog_uri: https://github.com/avo-hq/marksmith/releases
104
- post_install_message:
106
+ post_install_message:
105
107
  rdoc_options: []
106
108
  require_paths:
107
109
  - lib
@@ -116,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
118
  - !ruby/object:Gem::Version
117
119
  version: '0'
118
120
  requirements: []
119
- rubygems_version: 3.5.9
120
- signing_key:
121
+ rubygems_version: 3.5.22
122
+ signing_key:
121
123
  specification_version: 4
122
124
  summary: Marksmith is a GitHub-style markdown editor for Ruby on Rails applications.
123
125
  test_files: []