New editor #458

Злито
elegaanz злито 13 комітів з editor до master 5 роки тому
elegaanz прокоментував(ла) 5 роки тому (Перенесено з 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] прокоментував(ла) 5 роки тому (Перенесено з 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 прокоментував(ла) 5 роки тому (Перенесено з 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 прокоментував(ла) 5 роки тому
Власник

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 прокоментував(ла) 5 роки тому (Перенесено з 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 прокоментував(ла) 5 роки тому
Власник

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 рецензовано 5 роки тому
trinity-1686a прокоментував(ла) 5 роки тому
Власник

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 рецензовано 5 роки тому
trinity-1686a прокоментував(ла) 5 роки тому
Власник

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

should this file (and fr.po~) exists?
igalic (Перенесено з github.com) рецензовано 5 роки тому
igalic (Перенесено з github.com) прокоментував(ла) 5 роки тому

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 (Перенесено з github.com) рецензовано 5 роки тому
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

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 (Перенесено з github.com) рецензовано 5 роки тому
elegaanz (Перенесено з github.com) прокоментував(ла) 5 роки тому

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 рецензовано 5 роки тому
trinity-1686a прокоментував(ла) 5 роки тому
Власник

They are only ignored in some directories, not everywhere

They are only ignored in some directories, not everywhere
elegaanz прокоментував(ла) 5 роки тому (Перенесено з 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 рецензовано 5 роки тому
trinity-1686a додав коментар
Власник

mostly code-style comment again

mostly code-style comment again
trinity-1686a прокоментував(ла) 5 роки тому
Власник

this line is duplicated

this line is duplicated
trinity-1686a прокоментував(ла) 5 роки тому
Власник

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 прокоментував(ла) 5 роки тому
Власник

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 (Перенесено з github.com) рецензовано 5 роки тому
@ -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 (Перенесено з github.com) прокоментував(ла) 5 роки тому

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 рецензовано 5 роки тому
@ -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 прокоментував(ла) 5 роки тому
Власник

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 прокоментував(ла) 5 роки тому (Перенесено з 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 (Перенесено з github.com) рецензовано 5 роки тому
@ -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 (Перенесено з github.com) прокоментував(ла) 5 роки тому

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 (Перенесено з github.com) рецензовано 5 роки тому
@ -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 (Перенесено з github.com) прокоментував(ла) 5 роки тому

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 рецензовано 5 роки тому
@ -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 прокоментував(ла) 5 роки тому
Власник

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 зміни затверджено 5 роки тому
trinity-1686a додав коментар
Власник

👍

:+1:
trinity-1686a прокоментував(ла) 5 роки тому
Власник

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

Рецензенти

trinity-1686a зміни затверджено 5 роки тому
Запит на злиття був влитиий як 9076dbaadc.
Також можна переглянути інструкції для командного рядка.

Крок 1:

У репозиторії вашого проєкту перевірте нову гілку і протестуйте зміни.
git checkout -b editor master
git pull origin editor

Крок 2:

Об'єднати зміни і оновити на Forgejo.
git checkout master
git merge --no-ff editor
git push origin master
Підпишіться щоб приєднатися до обговорення.
Немає рецензентів
Етап відсутній
Немає виконавця
2 учасників
Сповіщення
Дата завершення
Термін дії не дійсний або знаходиться за межами допустимого діапазону. Будь ласка використовуйте формат 'yyyy-mm-dd'.

Термін виконання не встановлений.

Залежності

No dependencies set.

Reference: Plume/Plume#458
Завантаження…
Тут ще немає жодного змісту.