react-ace icon indicating copy to clipboard operation
react-ace copied to clipboard

Disable annotations (useWorker not working)

Open JasonEtco opened this issue 8 years ago • 11 comments

Heyo 👋 I'm having trouble disabling the annotations. After searching through some issues, I've tried out the following:

<AceEditor
  value={code}
  mode="javascript"
  theme="github"
  showLineNumbers
  readOnly
  editorProps={{
    $useWorker: false,
  }}
  setOptions={{
    useWorker: false
  }}
/>

As I understand it, setting either setOptions.useWorker or editorProps.$useWorker to false should disable annotations and linting entirely, but it just isn't working. Any ideas?

Thanks!

JasonEtco avatar Oct 02 '17 01:10 JasonEtco

Try removing $useWorker: false from the editorProps. It looks like setting both of the options actually doesn't disable the linter. You just need useWorker: false in setOptions.

SidneyNemzer avatar Oct 03 '17 04:10 SidneyNemzer

@JasonEtco does @SidneyNemzer 's tip help?

securingsincity avatar Oct 04 '17 12:10 securingsincity

@SidneyNemzer @securingsincity I haven't had a chance to test it, I ended up going with a different component for my needs. Sorry!

For what its worth, I had gone through iterations of trying each one individually which didn't do the trick.

JasonEtco avatar Oct 04 '17 12:10 JasonEtco

@securingsincity, I can confirm that @SidneyNemzer tip works:

<AceEditor
  mode="javascript"
  theme="monokai"
  onChange={this.handleChange}
  value={this.state.code}
  name="editor"
  setOptions={{ useWorker: false }}
  editorProps={{ $blockScrolling: true }}
/>

successfully disables the worker. Looking forward to the eslint babel-eslint change upstream.

mattblackdev avatar Jan 26 '18 03:01 mattblackdev

Looking forward to the eslint babel-eslint change upstream

You've peaked my interest @mattblackdev. Has Ace switched to using ESLint? I haven't seen anything about that being completed on the Ace repo.

SidneyNemzer avatar Jan 26 '18 04:01 SidneyNemzer

+1 The trick didn't work for me. It keeps trying to start worker. I wonder if I set useWorker false, does it stop trying to create a worker? Or it creates one but not use it.

zirho avatar Apr 13 '18 20:04 zirho

{
  ...,
  setOptions: {
    useWorker: false
  }
}

is disabling all annotations for me

leojh avatar Jun 16 '18 11:06 leojh

I also encountered the problem of disabled annotations not taking effect. image Quick operations can still be used to annotate in development

zhangshuai0101 avatar Mar 26 '19 03:03 zhangshuai0101

Try removing $useWorker: false from the editorProps. It looks like setting both of the options actually doesn't disable the linter. You just need useWorker: false in setOptions.

yeah, this works

Abhishekbs avatar Apr 21 '20 04:04 Abhishekbs

We are also encountering this issue in our codebase. We have the following component:

<AceEditor
    mode={aceModes[mode] || 'text'}
    className={`pf-c-form-control ${className}`}
    theme="github"
    onChange={debounce(onChange, 250)}
    value={value}
    onFocus={onFocus}
    onBlur={onBlur}
    name={`${id}-editor` || 'code-editor'}
    editorProps={{ $blockScrolling: true }}
    fontSize={16}
    width="100%"
    height={height}
    hasErrors={hasErrors}
    setOptions={{
        readOnly,
        highlightActiveLine: !readOnly,
        highlightGutterLine: !readOnly,
        useWorker: false,
        showPrintMargin: false,
    }}
    commands={[
    {
        name: 'escape',
        bindKey: { win: 'Esc', mac: 'Esc' },
        exec: () => {
        wrapper.current.focus();
        },
    },
    {
        name: 'tab escape',
        bindKey: { win: 'Shift-Tab', mac: 'Shift-Tab' },
        exec: () => {
        wrapper.current.focus();
        },
    },
    ]}
    ref={editor}
/>

However when I introspect from Chrome dev tools the useWorker prop is not present:

useWorkerMissingProp

kialam avatar Jul 07 '21 15:07 kialam