Skip to content

Mark Text Preference - #1003

Merged
Jocs merged 49 commits into
developfrom
preference
May 9, 2019
Merged

Jocs merged 49 commits into
developfrom
preference

Conversation

@Jocs

@Jocs Jocs commented May 3, 2019 •

Copy link
Copy Markdown
Member
Q A
Bug fix? yes
New feature? add some preferences
BC breaks? yes titleBarStyle is not available on macOs
Deprecations? font in view menu
New tests added? not needed
Fixed tickets #998
License MIT
  • Refactor the appWindow, appMenu, and preference singletons into factory mode. @fxha Originally this should be done in the main process refactoring, but in order to refactor the preference, I modified it first, it may not be perfect, I just guarantee that the function is the same as before.

  • Add Mark Text Preference UI.

  • Update autoSave and themes in menu.

  • Remove font... in view menu.

Known bugs:

  • titleBarStyle in undefined when first startup.
  • Prevent scale setting window.
  • Error: Object has been destroyed at EventEmitter.eval (webpack-internal:///./src/main/app/windowManager.js:216:23)
  • No need to open another setting window if there is already one setting window.

Some follow-up PR's

  • Update autoPair and other muya options in runtime.
  • Other disabled setting(not implement yet)
  • Can you help add Windows controls button in title bar @fxha
  • tabSize and list indentation update in muya

@Jocs Jocs changed the title dynamic change element-ui theme to our themeColor [WIP] Mark Text Preference May 3, 2019
@Jocs Jocs added the 🐜 in progress This issue is in progress label May 3, 2019
@Jocs
Jocs force-pushed the preference branch 2 times, most recently from 29728fb to 0742819 Compare May 4, 2019 14:52
@Jocs Jocs changed the title [WIP] Mark Text Preference Mark Text Preference May 5, 2019
@Jocs
Jocs requested a review from fxha May 5, 2019 18:05
@Jocs Jocs added 🔍 need review This PR need review and removed 🐜 in progress This issue is in progress labels May 5, 2019

@fxha fxha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some testing but not a full code review yet and found two improvements:

  • How can I add another font family to the drop-down menu (editor and code family)?
  • AutoSave should be disabled by default because it automatically format you files (or destroy your text files if it was not markdown file 😿). What do you think?

The titlebar style should only be applied to existing windows and only to new windows or after a restart because we cannot change the BrowserWindow style at runtime. Do you know why AppVeyor testing freezes since the last build for this PR?

@Jocs

Jocs commented May 6, 2019

Copy link
Copy Markdown
Member Author

How can I add another font family to the drop-down menu (editor and code family)?

Now give the enumeration value, do we need to add a new font? The drop-down box has the advantage that the user does not enter invalid fonts.

AutoSave should be disabled by default because it automatically format you files (or destroy your text files if it was not markdown file 😿). What do you think?

Ok, I'll update it.

The titlebar style should only be applied to existing windows and only to new windows or after a restart because we cannot change the BrowserWindow style at runtime. Do you know why AppVeyor testing freezes since the last build for this PR?

I don't know either.

@fxha

fxha commented May 6, 2019

Copy link
Copy Markdown
Contributor

Now give the enumeration value, do we need to add a new font? The drop-down box has the advantage that the user does not enter invalid fonts.

FYI we have fallback font if we should load an invalid font but we could use font-manager and patch the library to work with Electron 5.

I'll cancel all AppVeyor builds because they will all freeze and get cancelled after 1 hour and try to reproduce the issue on Windows. Seem as the XSS tests fail on Windows.

@Jocs

Jocs commented May 6, 2019

Copy link
Copy Markdown
Member Author

font-manager

it's great!

@fxha

fxha commented May 6, 2019

Copy link
Copy Markdown
Contributor

@Jocs I added the custom titlebar but I don't know what the difference between BrowserWindow moveToTop() and focus() are expect that moveToTop() is not supported on Linux.

@Jocs

Jocs commented May 6, 2019

Copy link
Copy Markdown
Member Author

I tried focus on macOs and it didn't work. I changed it to moveTop. Electron don't have this method on Linux, it shouldn't matter. Will it report an error? If you get an error, add a judgment(if (!isLinux) {}).

In the control buttons of macOs, maximization and minimization are disabled, and the setting window is only allowed to close.

@fxha

fxha commented May 6, 2019 •

Copy link
Copy Markdown
Contributor

There are two exceptions during window loading on Windows:

1. vue-js-devtools (maybe due Electron 5?)

background.js:1 Uncaught TypeError: Cannot read property 'addListener' of undefined
    at Object.127 (background.js:1)
    at t (background.js:1)
    at background.js:1
    at background.js:1

2. Mark Text exception and the BrowserWindow is crashed due this exception:

newElementStyle = newElementStyle.replace(new RegExp(color, 'ig'), variable); <-- L139

Uncaught TypeError: newElementStyle.replace is not a function
    at addElementStyle (webpack-internal:///./src/renderer/util/theme.js:139)
    at eval (webpack-internal:///./src/renderer/main.js:95)
    at Module../src/renderer/main.js (renderer.js:10574)
    at __webpack_require__ (renderer.js:768)
    at fn (renderer.js:131)
    at Object.1 (renderer.js:11545)
    at __webpack_require__ (renderer.js:768)
    at renderer.js:903
    at renderer.js:906

Edit: typeof newElementStyle returns object and not string!

@fxha fxha left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found the one or the other typo.

Comment thread doc/PREFERENCE.md Resolved
Comment thread doc/PREFERENCE.md Resolved
Comment thread doc/PREFERENCE.md Resolved
Comment thread doc/PREFERENCE.md Resolved
Comment thread src/main/preferences/schema.json Resolved
Comment thread src/main/windows/setting.js Resolved
@Jocs

Jocs commented May 7, 2019

Copy link
Copy Markdown
Member Author

Edit: typeof newElementStyle returns object and not string!

is it also because the path separator?

@Jocs

Jocs commented May 7, 2019

Copy link
Copy Markdown
Member Author

@fxha I add a setting window menu, it also the fallback menu. pls review.

@Jocs
Jocs requested a review from fxha May 7, 2019 15:09
@fxha

fxha commented May 7, 2019

Copy link
Copy Markdown
Contributor

@Jocs Did you have change the GUI settings text also? There are still typo's like prefer instead of preferred and the titlebarStyle is still changed in all windows that should be not committed to existing windows.

@Jocs

Jocs commented May 8, 2019

Copy link
Copy Markdown
Member Author

@fxha What's the meaning of csd one of the optional value of titlebarStyle in preferences?

@fxha

fxha commented May 8, 2019

Copy link
Copy Markdown
Contributor

What's the meaning of csd one of the optional value of titlebarStyle in preferences?

Client-Side Decoration

@Jocs

Jocs commented May 8, 2019

Copy link
Copy Markdown
Member Author

@fxha I remove the csd option of titleBarStyle, and titleBarStyle only work for Windows and Linux now. macOs will always show a frameless window.

@Jocs

Jocs commented May 8, 2019

Copy link
Copy Markdown
Member Author

@fxha The titleBarStyle updated will not broadcast to windows any more, Can you help test it?

Comment thread src/main/preferences/index.js Resolved
Comment thread src/main/preferences/index.js Outdated

if (!defaultSettings) {
console.error('Can not load static preference.json file')
return

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throw an exception to crash Mark Text. Otherwise Mark Text will crash later because no settings are set, right?

Comment thread src/main/windows/editor.js Resolved
Comment thread src/main/windows/setting.js Resolved
Comment thread src/main/windows/editor.js Resolved
Comment thread src/renderer/pages/preference.vue Resolved
@Jocs
Jocs requested a review from fxha May 8, 2019 17:00
@Jocs
Jocs merged commit 4bd22b6 into develop May 9, 2019
@Jocs
Jocs deleted the preference branch May 12, 2019 16:00
Jocs added a commit that referenced this pull request Aug 7, 2019
* dynamic change element-ui theme to our themeColor

* add some ui components

* add preference doc

* add json schema file

* update preference.json and schema.json

* reset to old commit

* rename preference file for rebase

* rebase develop

* add setting window

* user electron-store to store preferences

* add themes setting

* add select component

* add markdown pref

* fix: bool and select init value

* add font size setting

* editor pref

* add general preference

* search preference

* update menu after preference changed

* update muya codes

* prevent scale setting window

* fix: titlebar undefined

* update input style

* remove window from windowManager after close setting window

* remove old docs and preference.md

* if a setting window is already created, no need to create another one, just move it to top

* rename openFilesInNewWindow to openFileInNewWindow

* change aidou runtime

* change hideQuickInsertHint by setting page runtime

* change autopair runtime

* change codefont and codefontfamily dynamic

* change default value of autoSave to false

* update bulletListMarker

* fix style error

* add custom titlebar to settings window

* add window shadow for Linux and Windows

* fix Windows build

* fix some typo error

* update doc

* add default menu and setting menu

* fix update menu bug

* fix typo

* remove mac titlebarstyle

* do not need to send titlebarstyle to renderer

* fix typo

* crash Mark Text if no initial preference.json file

* update the path

* add showCustomTitleBar prop

* set empty settings menu on Linux/Windows + workaround
thimbleberrysystems pushed a commit to thimbleberrysystems/WordBird that referenced this pull request Jun 21, 2026
* dynamic change element-ui theme to our themeColor

* add some ui components

* add preference doc

* add json schema file

* update preference.json and schema.json

* reset to old commit

* rename preference file for rebase

* rebase develop

* add setting window

* user electron-store to store preferences

* add themes setting

* add select component

* add markdown pref

* fix: bool and select init value

* add font size setting

* editor pref

* add general preference

* search preference

* update menu after preference changed

* update muya codes

* prevent scale setting window

* fix: titlebar undefined

* update input style

* remove window from windowManager after close setting window

* remove old docs and preference.md

* if a setting window is already created, no need to create another one, just move it to top

* rename openFilesInNewWindow to openFileInNewWindow

* change aidou runtime

* change hideQuickInsertHint by setting page runtime

* change autopair runtime

* change codefont and codefontfamily dynamic

* change default value of autoSave to false

* update bulletListMarker

* fix style error

* add custom titlebar to settings window

* add window shadow for Linux and Windows

* fix Windows build

* fix some typo error

* update doc

* add default menu and setting menu

* fix update menu bug

* fix typo

* remove mac titlebarstyle

* do not need to send titlebarstyle to renderer

* fix typo

* crash Mark Text if no initial preference.json file

* update the path

* add showCustomTitleBar prop

* set empty settings menu on Linux/Windows + workaround
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔍 need review This PR need review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants