easywebhub / tasks

List of tasks for EasyWeb members
1 stars 4 forks source link

Inline Editing not work on Built Application #94

Open baotnq opened 6 years ago

baotnq commented 6 years ago

Mô tả

nemesisqp commented 6 years ago

Bản beta-10 đó sau master tới 21 commit mà changes

baotnq commented 6 years ago

@nemesisqp do tránh phải đổi download url trên web nên anh replace bản beta-10 thành bản build mới nhất, mà vẫn bị vậy.

Em thử lại bằng cách build .zip trên local, và test luôn dùm anh nghe.

nemesisqp commented 6 years ago

fix

 tag/bottom-bar.tag | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tag/bottom-bar.tag b/tag/bottom-bar.tag
index baa3827f..da891f3c 100644
--- a/tag/bottom-bar.tag
+++ b/tag/bottom-bar.tag
@@ -216,6 +216,8 @@
             me.output.innerHTML = '';
             me.webview.src = ewhDataUri;

+            let isAsarMode = process.mainModule.filename.indexOf('app.asar') !== -1;
+            let prefixPath = isAsarMode ? process.resourcesPath + '\\app.asar\\' : '';
             me.webview.addEventListener('did-finish-load', Promise.coroutine(function*(event) {
                 try {
                     console.log('webpage finished load, start injecting');
@@ -224,13 +226,13 @@

                     if (!isJqueryExists) {
                         console.log('injecting jQuery');
-                        yield executeJavaScript((yield Fs.readFileAsync('assets/js/jquery.min.js')).toString());
+                        yield executeJavaScript((yield Fs.readFileAsync(prefixPath + 'assets/js/jquery.min.js')).toString());
                     }

                     // inject medium inline editor
-                    me.webview.insertCSS((yield Fs.readFileAsync('assets/css/medium-editor.min.css')).toString());
-                    me.webview.insertCSS((yield Fs.readFileAsync('assets/css/medium-editor-default.min.css')).toString());
-                    yield executeJavaScript((yield Fs.readFileAsync('assets/js/medium-editor.js')).toString());
+                    me.webview.insertCSS((yield Fs.readFileAsync(prefixPath + 'assets/css/medium-editor.min.css')).toString());
+                    me.webview.insertCSS((yield Fs.readFileAsync(prefixPath + 'assets/css/medium-editor-default.min.css')).toString());
+                    yield executeJavaScript((yield Fs.readFileAsync(prefixPath + 'assets/js/medium-editor.js')).toString());

                     setTimeout(function () {
                         executeJavaScript(`(function defer() { if (!window.MediumEditor) {
baotnq commented 6 years ago

@nemesisqp cái này push lên chưa em, sao anh tìm ko thấy trên github?

baotnq commented 6 years ago

@nemesisqp cái này anh build, test lại OK với default pillar website của em.

Tuy nhiên khi áp dụng với website khác, trang chi tiết thì không chạy được. https://github.com/easywebhub/newspaper/commit/db04c2f37986fe2c4466b5e4da037c3efeaee650

Hình chụp screen shot 2017-08-04 at 9 39 40 am

Em xem và fix dùm nghe.

baotnq commented 6 years ago

@nemesisqp hỗ trợ dùm anh nghe, cảm ơn ku!

nemesisqp commented 6 years ago

done in easywebhub/easyapp@28e25b804465c630f2f1dc4ed4d75f395926fbc6 sẽ còn case tên file content có khoảng trắng

baotnq commented 6 years ago

anh test lại còn bị 2 lỗi như sau:

em pull các repo newspaper trên, và test lại dùm anh nghe.

nemesisqp commented 6 years ago

fixed in easywebhub/easyapp@a573e088c832ee1ace2693c7cde26437b7aed12a

baotnq commented 6 years ago

@quocvo thử test lại tính năng trên để hiểu trước nghe. Inline Editing là tính năng cho phép, Right Click 2 lần vào text trên phần Preview nằm trong EasyBuilder, sẽ cho phép điều chỉnh và lưu lại luôn.

Tuy nhiên muốn có tính năng này, thì phần binding trong HTML, CSS phải có thêm các thông số, ví dụ data-ea-type, data-eq-object-patch, ...

Trong file layout, ví dụ index.html, gõ F1, chọn 1 biến có prefix :DATA ví dụ title, sẽ thấy sinh ra thông số này.

Em đọc kĩ phần comment trên để thử với website mẫu luôn nghe.

baotnq commented 6 years ago

@nemesisqp phần Preview trong EasyBuilder, khi Inline Edit trang chi tiết, thì Browser Reload sẽ load lại trang chủ, mất công vô lại. Giờ muốn điều chỉnh như thế này được ko

  1. khi Reload sẽ giữ nguyên Url hiện tại
  2. trên sidebar chọn vào 1 bài viết, có slug là bai-viet-xxx thì Preview sẽ load trang tương ứng, ví dụ http://localhost:3000/bai-viet-xxx

Cái 2. nếu mất thời gian, thì hướng dẫn cho @quocvo nắm cách vận hành, bạn ấy sẽ tìm cách thực hiện

nemesisqp commented 6 years ago

Cái review đó là 1 cái webview api nó có getUrl, setUrl thì set thẳng attribute src là được hoặc executeJavascript code change location với nó có mấy cái event navigate nên tùy muốn custom thì code tiếp thôi cái webview nó nằm trong file bottombar.tag cái file list bên trái thì chính là file file-list-flat.tag user click vào list item -> tính ra cái slug -> raise event cross tag cho bottom-bar setUrl cũng là 1 hướng Cái reload giữ url hiện tại thì nhìn api đoán đoán thì tạm thấy 2 hướng:

  1. là khi inline edit trước khi write file content gọi pause api của browserSync, ghi file xong call resume nhưng se phải thêm code message cross process giữa app với browserSync trong process gulp, hướng này nhìn api đoán thôi test cái pause voi resume mới chắc được
  2. disable hoàn toàn tính năng refresh của browserSync khi có edit thi gọi webview refresh, webview get set url src thì đều được mất công handle event edit tay thôi
quocvo commented 6 years ago

trên sidebar Cái này ở chỗ nào trên app vậy anh

quocvo commented 6 years ago

Mình có tool/script nào để insert inline edting vào tất cả các tag trong web chưa? Ý là khi mình edit bằng app thì trước khi edit nó tự động chèn những thuộc tính đó zô để enable inline editing rồi khi done tất cả thì sẽ remove mấy cái đó đi trả lại như ban đầu.

baotnq commented 6 years ago

@quocvo em xem mô tả bên trên của @nemesisqp gần nhất, có hiểu gì ko @baotnq : Cai' 2 thihieu idea con cai 1 thì chưa hiểu "nhưng se phải thêm code message cross process giữa app với browserSync trong process gulp"

nemesisqp commented 6 years ago

sidebar là cái list file ben trái ấy, chrome debugger inspect la thấy tên tag thôi, app chỉ mới dump insert mấy cái thuộc tính thôi muốn đi xa thêm phải chọc cái monaco editor