securingsincity / react-ace

React Ace Component
http://securingsincity.github.io/react-ace/
MIT License
4.06k stars 604 forks source link

Cursor is not at the right site #314

Closed huangjiatian closed 6 years ago

huangjiatian commented 6 years ago

Hi,all I found the cursor is not all the right site how can i fix it 3c634b74-650d-4cf7-a56e-f247d7e4cedd

RTKSoftware commented 6 years ago

Hello I got same problem I used an example from demo (http://securingsincity.github.io/react-ace/) I was helped by the removal of fontSize = {14} from my code

securingsincity commented 6 years ago

@huangjiatian @RTKSoftware i found this tweet that might help you https://twitter.com/Maluen0/status/862636368857583616 Sounds like the exact issue with the soultion

samreaves commented 6 years ago

I had this issue when the font-size in CSS was a differing value than the one I passed to the editor props. Resolved the issue by removing the font-size from the CSS.

MM3y3r commented 6 years ago

Same issue. Please fix. Or provide a way to fix.

MatthewLarner commented 6 years ago

@MaximusDesign I also had this issue and found that ace is relying on monospace fonts. In my case the issue was caused because of global font-family settings overriding monaco that ace sets.

I found I could resolve by either setting the font in the editor to a monospace font or simply inherit

We're using styled-components so our solution looks like this.

const Editor = styled(AceEditor)`
    * {
        font-family: inherit;
    }
`;
BrianJVarley commented 5 years ago

I used a similar issue when deleting or adding to the editor the cursor is 4 spaces from the actual position. Similar to @MatthewLarner we used styled-components but instead set the font-family to Ace's default consolas and reduced the line height:

 const StyledEditor = styled.div`
      margin-top: 10px;
      * {
        font-family: consolas;
        line-height: 1;
      }
    `;

    return (
      <StyledEditor>
        <AceEditor
        mode="json"
        theme="solarized_dark"
        fontSize={14}
        value={''}
        setOptions={{
          showLineNumbers: false,
          tabSize: 2,
        }}
        editorProps={{ $blockScrolling: true }}
      />
      </StyledEditor>
    );
paulfrom commented 5 years ago

i got the same issue,but all way above does not work,then i search the solution from the origin ace, i got this https://github.com/ajaxorg/ace/issues/2548. it's certain the font cause the cursor problem. change the font to monospace worked for me. .ace_editor, .ace_editor div{ font-family:monospace }

hamzatekin commented 1 year ago

Setting the font family half solved the issue for me. The quotation marks were still problematic. I used this for complete solution:

.ace_editor,
.ace_editor * {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
}

ref: https://stackoverflow.com/a/64077083/4054579

areeb-011bq commented 3 months ago

hamzatekin solution with addition of monospace fonts worked for me.

SorryToPerson commented 3 months ago

Setting the font family half solved the issue for me. The quotation marks were still problematic. I used this for complete solution:

.ace_editor,
.ace_editor * {
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Droid Sans Mono', 'Consolas', monospace !important;
  font-weight: 400 !important;
  letter-spacing: 0 !important;
}

ref: https://stackoverflow.com/a/64077083/4054579

this worked for me, that's great!