5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 23:06:21 +00:00

Merge branch 'usar-sutty-editor' into issue-9357-1

This commit is contained in:
f 2023-01-04 12:56:19 -03:00
commit 02da0db75f
17 changed files with 4600 additions and 486 deletions

View file

@ -362,6 +362,8 @@ GEM
rack (>= 2.0.0)
rack-mini-profiler (3.0.0)
rack (>= 1.2.0)
rack-proxy (0.7.4)
rack
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (6.1.7)
@ -472,6 +474,7 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
semantic_range (3.0.0)
sexp_processor (4.16.0)
simpleidn (0.2.1)
unf (~> 0.1.4)

View file

@ -505,3 +505,43 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
}
}
}
@import "new_editor";
.new-editor {
.editor {
table {
@extend .table;
@extend .table-responsive;
}
}
}
.content {
p { min-height: $font-size-base * $line-height-base; }
h1 { min-height: $h1-font-size * $headings-line-height; }
h2 { min-height: $h2-font-size * $headings-line-height; }
h3 { min-height: $h3-font-size * $headings-line-height; }
h4 { min-height: $h4-font-size * $headings-line-height; }
h5 { min-height: $h5-font-size * $headings-line-height; }
h6 { min-height: $h6-font-size * $headings-line-height; }
iframe { border: 0; }
audio { width: 100%; }
img,
video,
iframe {
@extend .img-fluid;
height: auto;
}
& > * {
margin-bottom: 1rem;
&:last-child {
margin-bottom: 0;
}
}
}

View file

@ -1,4 +1,4 @@
.editor {
.old.editor {
box-sizing: border-box;
*, *::before, *::after { box-sizing: inherit; }

View file

@ -0,0 +1,22 @@
.new-editor {
.editor {
.menubar {
z-index: 1;
label.btn {
margin-bottom: 0.3rem !important;
}
.btn-group {
.btn {
margin-right: 0;
}
}
}
.ProseMirror,
& > ol li {
margin-bottom: 1rem;
}
}
}

View file

@ -6,6 +6,16 @@ module ActiveStorage
extend ActiveSupport::Concern
included do
alias_method :original_show, :show
# Permitir incrustar archivos subidos (especialmente PDFs) desde
# otros sitios.
def show
original_show.tap do |s|
response.headers.delete 'X-Frame-Options'
end
end
# Asociar el archivo subido al sitio correspondiente. Cada sitio
# tiene su propio servicio de subida de archivos.
def update

View file

@ -6,3 +6,4 @@ import './prosemirror'
import './timezone'
import './turbolinks-anchors'
import './validation'
import './new_editor'

View file

@ -0,0 +1,14 @@
import SuttyEditor from "@suttyweb/editor";
import "@suttyweb/editor/dist/editor.css";
document.addEventListener("turbolinks:load", () => {
document.querySelectorAll(".new-editor").forEach((editorContainer) => {
new SuttyEditor({
target: editorContainer,
props: {
textareaEl: editorContainer.querySelector("textarea"),
},
});
});
});

View file

@ -0,0 +1,4 @@
# frozen_string_literal: true
# Testear el nuevo editor
class MetadataNewContent < MetadataContent; end

View file

@ -0,0 +1,4 @@
# frozen_string_literal: true
# Campos en HTML con el nuevo editor
class MetadataNewHtml < MetadataHtml; end

View file

@ -198,12 +198,12 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
def allowed_attributes
@allowed_attributes ||= %w[style href src alt controls data-align data-multimedia data-multimedia-inner id
name].freeze
name rel target referrerpolicy class colspan rowspan].freeze
end
def allowed_tags
@allowed_tags ||= %w[strong em del u mark p h1 h2 h3 h4 h5 h6 ul ol li img iframe audio video div figure blockquote
figcaption a sub sup small].freeze
figcaption a sub sup small table thead tbody tfoot tr th td br].freeze
end
# Decifra el valor

View file

@ -0,0 +1,3 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ lang: locale, dir: dir }= metadata.value

View file

@ -0,0 +1,3 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ lang: locale, dir: dir }= metadata.value.html_safe

View file

@ -3,7 +3,7 @@
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata
.editor{ id: attribute, data: { editor: '' } }
.old.editor{ id: attribute, data: { editor: '' } }
-# Esto es para luego decirle al navegador que se olvide estas cosas.
= hidden_field_tag 'storage_keys[]', "#{request.original_url}##{attribute}", data: { target: 'storage-key' }
.alert.alert-info

View file

@ -0,0 +1,9 @@
.form-group
= label_tag "#{base}_#{attribute}", post_label_t(attribute, post: post)
= render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata
.new-editor.content{ id: attribute }
= text_area_tag "#{base}[#{attribute}]", metadata.value.html_safe,
dir: dir, lang: locale,
**field_options(attribute, metadata), class: 'd-none'

View file

@ -0,0 +1,6 @@
-# Editor de contenido
= render 'posts/attributes/new_content',
base: 'post', post: post, attribute: attribute,
metadata: metadata, site: site,
dir: dir, locale: locale,
autofocus: (post.attributes.first == attribute)

View file

@ -37,5 +37,5 @@
- next if metadata.front_matter?
- cache [metadata, I18n.locale] do
%section.editor{ id: attr, dir: dir }
%section.content.pb-3{ id: attr, dir: dir }
= @post.public_send(attr).value.html_safe

4957
yarn.lock

File diff suppressed because it is too large Load diff