Skip to content

Conversation

wxiaoguang
Copy link
Contributor

@wxiaoguang wxiaoguang commented Mar 4, 2022

The PR #18911 removes global window.CodeMirror, now when input Enter in EasyMDE, there is an error (window.CodeMirror.Pass):

EasyMDE.js:80 Uncaught TypeError: Cannot read properties of undefined (reading 'Pass')
    at Enter (EasyMDE.js:80:34)
    at doHandleBinding (easymde.js:8129:14)
    at easymde.js:8200:61
    at lookupKey (easymde.js:7774:26)
    at lookupKeyForEditor (easymde.js:8142:37)
    at dispatchKeyInner (easymde.js:8170:18)
    at dispatchKey (easymde.js:8166:12)
    at handleKeyBinding (easymde.js:8200:14)
    at CodeMirror.onKeyDown (easymde.js:8219:19)
    at HTMLTextAreaElement.<anonymous> (easymde.js:4928:22)

This PR fixes the error.

@wxiaoguang wxiaoguang added type/bug issue/regression Indicates a previously functioning feature or behavior that has broken or regressed after a change labels Mar 4, 2022
@wxiaoguang wxiaoguang added this to the 1.17.0 milestone Mar 4, 2022
@wxiaoguang wxiaoguang requested a review from silverwind March 4, 2022 17:53
@wxiaoguang wxiaoguang added the topic/ui Change the appearance of the Gitea UI label Mar 4, 2022
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Mar 4, 2022
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 4, 2022
const tributeContainer = document.querySelector('.tribute-container');
if (!tributeContainer || tributeContainer.style.display === 'none') {
return window.CodeMirror.Pass;
cm.execCommand('newlineAndIndent');
Copy link
Member

Choose a reason for hiding this comment

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

Why not cm.Pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CodeMirror.Pass exists, while cm = CodeMirror(...); cm.Pass doesn't exist.

I have read through the EasyMDE and CodeMirror code, it's impossible to access CodeMirror.Xxx in Gitea now.

Copy link
Member

Choose a reason for hiding this comment

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

Fine I guess if the end result is the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the same. CodeMirror document said: the default command for Enter is newlineAndIndent.

https://codemirror.net/doc/manual.html

image

@wxiaoguang wxiaoguang merged commit 3e28fa7 into go-gitea:main Mar 5, 2022
@wxiaoguang wxiaoguang deleted the fix-easymde-enter branch March 5, 2022 17:53
zjjhot added a commit to zjjhot/gitea that referenced this pull request Mar 6, 2022
* giteaofficial/main:
  Fix EasyMDE error when input Enter (go-gitea#19004)
  Fix update hint bug (go-gitea#18996)
  Fix the editor height in review box (go-gitea#19003)
  Add a "admin user generate-access-token" subcommand (go-gitea#17722)
  Fix potential assignee query for repo (go-gitea#18994)
  Add config option to disable "Update branch by rebase" (go-gitea#18745)
  Update `go-enry` to v2.8.0 (go-gitea#18993)
  homebrew updates via cron
  ignore missing comment for user notifications (go-gitea#18954)
  allow overwrite artifacts for github releases (go-gitea#18987)
  fix & refactor (go-gitea#18973)
Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/regression Indicates a previously functioning feature or behavior that has broken or regressed after a change lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants