New editor #458

Scalone
elegaanz scala 13 commity/ów z editor do master 5 lat temu
elegaanz skomentował(-a) 5 lat temu (Zmigrowane z github.com)

With this PR, when JS is activated and WASM supported, the article editor will be dynamically replaced with contenteditables elements. This makes the editing interface simpler and less like a regular form. It will also allow us to easily add visual formatting with native browser APIs (and to insert images or videos directly). Here is a little demo:

peek 05-03-2019 16-12

There is still a lot to do, but it is a good first step.

Fixes #255

With this PR, when JS is activated and WASM supported, the article editor will be dynamically replaced with `contenteditable`s elements. This makes the editing interface simpler and less like a regular form. It will also allow us to easily add visual formatting with native browser APIs (and to insert images or videos directly). Here is a little demo: ![peek 05-03-2019 16-12](https://user-images.githubusercontent.com/16254623/53815536-1dc05680-3f62-11e9-94d3-b363ed84eb97.gif) There is still a lot to do, but it is a good first step. Fixes #255
codecov[bot] skomentował(-a) 5 lat temu (Zmigrowane z github.com)

Codecov Report

Merging #458 into master will increase coverage by 1.64%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #458      +/-   ##
==========================================
+ Coverage   26.49%   28.13%   +1.64%     
==========================================
  Files          64       64              
  Lines        7111     7496     +385     
==========================================
+ Hits         1884     2109     +225     
- Misses       5227     5387     +160
# [Codecov](https://codecov.io/gh/Plume-org/Plume/pull/458?src=pr&el=h1) Report > Merging [#458](https://codecov.io/gh/Plume-org/Plume/pull/458?src=pr&el=desc) into [master](https://codecov.io/gh/Plume-org/Plume/commit/2a188abfa152efe7a2794174279e3b9da4a809d1?src=pr&el=desc) will **increase** coverage by `1.64%`. > The diff coverage is `n/a`. ```diff @@ Coverage Diff @@ ## master #458 +/- ## ========================================== + Coverage 26.49% 28.13% +1.64% ========================================== Files 64 64 Lines 7111 7496 +385 ========================================== + Hits 1884 2109 +225 - Misses 5227 5387 +160 ```
elegaanz skomentował(-a) 5 lat temu (Zmigrowane z github.com)

Something I just noticed: published articles are always drafts (unless you are editing an already published article)

Something I just noticed: published articles are always drafts (unless you are editing an already published article)
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

I'm having trouble making it work. I had to tinker plume-front.js. Any idea why, or how to prevent that?

I'm having trouble making it work. I had to tinker plume-front.js. Any idea why, or how to prevent that?
elegaanz skomentował(-a) 5 lat temu (Zmigrowane z github.com)

Was the build script correctly run by cargo? Like, did you saw plume(build) before plume(bin) next to the compilation progress bar? Otherwise, you can try to add a println!("cargo:rerun-if-changed=target/deploy/plume-front.js") (IIRC) to it, so that we are sure it is re-run when the JS changes (it does when the WASM changes normally, but maybe that's not enough).

Was the build script correctly run by cargo? Like, did you saw `plume(build)` before `plume(bin)` next to the compilation progress bar? Otherwise, you can try to add a `println!("cargo:rerun-if-changed=target/deploy/plume-front.js")` (IIRC) to it, so that we are sure it is re-run when the JS changes (it does when the WASM changes normally, but maybe that's not enough).
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

ok my bad, I ran cargo web deploy -o ../static so the buildscript did not update the js file as it should have

ok my bad, I ran `cargo web deploy -o ../static` so the buildscript did not update the js file as it should have
trinity-1686a zrecenzowano 5 lat temu
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

By doing the following change, I was able to copy past a picture in a post and have it rendered as expected. However when re-editing the article, < and > where escaped, leading to a messy html tag in the middle of the content. I don't know if this is considered in scope for this pr, but this might be something to look at, as it will get important once the editor get richer

                            set_value("editor-content", js!{return @{&widgets.2}.innerHTML}.as_str().unwrap_or_default());
By doing the following change, I was able to copy past a picture in a post and have it rendered as expected. However when re-editing the article, `<` and `>` where escaped, leading to a messy html tag in the middle of the content. I don't know if this is considered in scope for this pr, but this might be something to look at, as it will get important once the editor get richer ```suggestion set_value("editor-content", js!{return @{&widgets.2}.innerHTML}.as_str().unwrap_or_default()); ```
trinity-1686a zrecenzowano 5 lat temu
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

should this file (and fr.po~) exists?

should this file (and fr.po~) exists?
igalic (Zmigrowane z github.com) zrecenzowano 5 lat temu
igalic (Zmigrowane z github.com) skomentował(-a) 5 lat temu

my suggestion to @BaptisteGelez is to either add this our .gitignore or to her global .git/ignore

my suggestion to @BaptisteGelez is to either add this our `.gitignore` or to her global `.git/ignore`
elegaanz (Zmigrowane z github.com) zrecenzowano 5 lat temu
elegaanz (Zmigrowane z github.com) skomentował(-a) 5 lat temu

No, I though *.po~ was in the gitignore, but it looks like it is not. 🤷‍♀️ I will add it.

No, I though `*.po~` was in the gitignore, but it looks like it is not. :woman_shrugging: I will add it.
elegaanz (Zmigrowane z github.com) zrecenzowano 5 lat temu
elegaanz (Zmigrowane z github.com) skomentował(-a) 5 lat temu

I think it would be easy to avoid escaping here, I will try.

I think it would be easy to avoid escaping here, I will try.
trinity-1686a zrecenzowano 5 lat temu
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

They are only ignored in some directories, not everywhere

They are only ignored in some directories, not everywhere
elegaanz skomentował(-a) 5 lat temu (Zmigrowane z github.com)

I added back the character counter, but it is not as precise as the previous one, since I only took the article content in account (otherwise I would have had to rebuild all the original form every time, which would be quite long both in code and when running). I don't think that's a big issue, since the previous one was not perfectly precise neither, and that people will rarely reach this limit anyway.

I added back the character counter, but it is not as precise as the previous one, since I only took the article content in account (otherwise I would have had to rebuild all the original form every time, which would be quite long both in code and when running). I don't think that's a big issue, since the previous one was not perfectly precise neither, and that people will rarely reach this limit anyway.
trinity-1686a zrecenzowano 5 lat temu
trinity-1686a zostawił komentarz
Właściciel

mostly code-style comment again

mostly code-style comment again
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

this line is duplicated

this line is duplicated
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

this closure is really long. It would gain in readability to be divided in multiple smaller functions called one after an other (like "hide non-js form", "add js editor", "show popup", "copy editor to form"...). I understand what it's doing, but if there is something wrong, it's too complex to see it right away

this closure is really long. It would gain in readability to be divided in multiple smaller functions called one after an other (like "hide non-js form", "add js editor", "show popup", "copy editor to form"...). I understand what it's doing, but if there is something wrong, it's too complex to see it right away
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

I love that it just works like in the back-end, with nothing more to

I love that it just works like in the back-end, with nothing more to
elegaanz (Zmigrowane z github.com) zrecenzowano 5 lat temu
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
elegaanz (Zmigrowane z github.com) skomentował(-a) 5 lat temu

Yeah, that's really great! The only downside is that we include all the translations in the .wasm so it is a bit bigger, but there is like 3 or 4 messages for the moment so I guess it's fine (and I don't expect it to become much bigger, I think we will never have more than 30 messages for the front end).

Yeah, that's really great! The only downside is that we include all the translations in the .wasm so it is a bit bigger, but there is like 3 or 4 messages for the moment so I guess it's fine (and I don't expect it to become much bigger, I think we will never have more than 30 messages for the front end).
trinity-1686a zrecenzowano 5 lat temu
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

considering all Plume translations (not plume-front) are 208k on my computer, any picture loaded on the front page must cost much more than having all translations available

considering all Plume translations (not plume-front) are 208k on my computer, any picture loaded on the front page must cost much more than having all translations available
elegaanz skomentował(-a) 5 lat temu (Zmigrowane z github.com)

I tried to make the code a bit more readable, but I'm not sure it is enough…

I tried to make the code a bit more readable, but I'm not sure it is enough…
igalic (Zmigrowane z github.com) zrecenzowano 5 lat temu
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
igalic (Zmigrowane z github.com) skomentował(-a) 5 lat temu

so how big is the dynamic front-end right now? and how much of that is cachable?

so how big is the dynamic front-end right now? and how much of that is cachable?
elegaanz (Zmigrowane z github.com) zrecenzowano 5 lat temu
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
elegaanz (Zmigrowane z github.com) skomentował(-a) 5 lat temu

It is 2.2M on my computer, but there are various ways to optimize WASM size that we didn't explored yet. And I don't know how much of it is cachable? Nothing?

It is 2.2M on my computer, but there are various ways to optimize WASM size that we didn't explored yet. And I don't know how much of it is cachable? Nothing?
trinity-1686a zrecenzowano 5 lat temu
@ -6,0 +20,4 @@
lazy_static! {
static ref CATALOG: gettext::Catalog = {
let catalogs = include_i18n!();
let lang = js!{ return navigator.language }.into_string().unwrap();
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

I'd say everything, it's a static file after all. I tried compiling with cargo web deploy --release, it seems to work, and is "only" 832k. We could also try to compact plume-front.js as it's 35k with indentation and things, however I'm not sure it's that important

I'd say everything, it's a static file after all. I tried compiling with `cargo web deploy --release`, it seems to work, and is "only" 832k. We could also try to compact plume-front.js as it's 35k with indentation and things, however I'm not sure it's that important
trinity-1686a zatwierdza te zmiany 5 lat temu
trinity-1686a zostawił komentarz
Właściciel

👍

:+1:
trinity-1686a skomentował(-a) 5 lat temu
Właściciel

Oups, 2 little things : It doesn't seems to be possible to add carriage return in the content (prevent default I guess), and it may be nice to have a button to switch back to the plain markdown editor

Oups, 2 little things : It doesn't seems to be possible to add carriage return in the content (prevent default I guess), and it may be nice to have a button to switch back to the plain markdown editor

Recenzenci

trinity-1686a zatwierdza te zmiany 5 lat temu
Pull Request został scalony jako 9076dbaadc.
Możesz także zobaczyć instrukcje wiersza poleceń.

Krok 1:

Z repozytorium twojego projektu, sprawdź nową gałąź i przetestuj zmiany.
git checkout -b editor master
git pull origin editor

Krok 2:

Połącz zmiany i zaktualizuj na Forgejo.
git checkout master
git merge --no-ff editor
git push origin master
Zaloguj się, aby dołączyć do tej rozmowy.
Brak recenzentów
Brak kamienia milowego
Brak przypisanych
Uczestnicy 2
Powiadomienia
Termin realizacji
Data realizacji jest niewłaściwa lub spoza zakresu. Użyj formatu 'yyyy-mm-dd'.

Brak ustawionego terminu realizacji.

Zależności

No dependencies set.

Reference: Plume/Plume#458
Ładowanie…
Nie ma jeszcze treści.