@atlassianlabs/jql-editor errors

Hi,

An error occurred when I try to reproduce the example from the documentation

index.es.js:525 Uncaught TypeError: Class constructor Transform cannot be invoked without 'new'
    at new Transaction (index.es.js:525:1)
    at ./node_modules/prosemirror-state/dist/index.es.js.prototypeAccessors$1.tr.get (index.es.js:875:44)
    at index.js:521:1
    at dispatch (bind-actions.js:24:1)
    at index.js:435:1
    at dispatch (bind-actions.js:24:1)
    at index.js:963:1
    at dispatch (bind-actions.js:24:1)
    at Object.onInit (bind-actions.js:41:1)
    at Container.triggerContainerAction (container.js:67:1)

The above error occurred in the <Container(jql-editor)> component:
    in Container(jql-editor) (created by JQLEditorInner)
    in JQLEditorInner (created by Context.Consumer)
    in injectIntl(JQLEditorInner) (created by Lazy(Component))
    in Lazy(Component)
    in Suspense (created by LazySuspense)
    in LazySuspense
    in Unknown
    in ErrorBoundary
    in Unknown
    in IntlProvider
    in Unknown (created by MyJQLEditor)
    in MyJQLEditor

React will try to recreate this component tree from scratch using the error boundary you provided, ErrorBoundary.

pakage.json

"dependencies": {
    "@atlassianlabs/jql-editor": "^1.1.0",
    "@atlassianlabs/jql-editor-autocomplete-rest": "^1.0.0",
    "react": "^16.14.0",
    "react-dom": "^16.14.0"
  },

  "devDependencies": {
    "@babel/core": "^7.18.10",
    "@babel/preset-env": "^7.18.10",
    "@babel/preset-react": "^7.18.6",
    "babel-loader": "^8.2.5",    
    "html-webpack-plugin": "^4.5.2",
    "webpack": "^4.44.2",
    "webpack-cli": "^4.10.0",
    "webpack-dev-server": "^4.10.0"
  },

.babelrc

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ]
}

Please help me with bug

Best regards.

Hello @termit7000 apologies for this error you are facing. I believe this is the same issue documented here: JQLEditorConnect render error. Where there are incompatible versions being installed of the prosemirror-transform dependency.
If you specify a fixed version in your package.json, e.g. "prosemirror-transform": "1.3.2", I believe that will fix the issue.

In the meantime we’ll look to update the package to prevent this issue from recurring.

Thanks,
Kyle

Thanks for your patience. The internal jql-editor dependencies have been updated to help mitigate this issue.

It’s still possible to run into this problem if your app bundles incompatible versions of prosemirror dependencies but npm install should now work out of the box when adding @atlassianlabs/jql-editor-forge or jql-editor-connect as a fresh dependency to your app.

Hi @Kyle ,

Is the jql-editor only meant for Cloud Apps or can we use it for DC plugin development? We are getting 405 error when testing with the Atlassian SDK

Hey @ajay the pre-configured forge and connect packages are designed specifically to work with the Cloud REST API.

The package itself is a thin wrapper on top of @atlassianlabs/jql-editor - npm which implements callbacks to fetch autocomplete data, so you could leverage this package directly and call the appropriate Server/DC API’s to fetch this data (see API docs).

Hi @Kyle,

Thanks for the pointer…we were able to modify the code and get a 200 ok response… but somehow the Editor is greyed out without any errors in the console… Any clue?


@ajay Looks like the async component isn’t loading properly, I’d suggesting importing the sync component as a quick resolution.

import { JQLEditor } from '@atlassianlabs/jql-editor';

Thank you, @Kyle . Changing to the synchronous component resolved the issue. Are there any performance drawbacks associated with this change?

Additionally, is the problem we encountered with the asynchronous component a known issue?

@ajay In most cases there won’t be any noticeable difference, the async component is provided as an optimisation for experiences that may not need to render the editor in the critical path.

There are no known issues with rendering the async component so this would need further debugging. We use react-loosely-lazy under the hood so it’s possible there are some critical missing steps in your build configuration, see tooling docs.

Hi @Kyle ,

One more query on the '@atlassianlabs/jql-editor' usage in DC
The Jira shortcut keys are not getting disabled when using the editor input.

Example if I type 'Project = ’ , the C entry is causing the issue create modal to be opened up. Anyway to disable the shortcut-keys when using the editor?

Cheers
Ajay

Hello @ajay, I have the same issue, did you resolve it? Will be thankful for any information about it, thanks)

Hey @ajay this seems like a bug in the DC’s global shortcut key handler not ignoring key presses from contenteditable regions. You can raise a public support request on https://getsupport.atlassian.com/ to try and get this issue triaged. Alternatively you may be able to add a click event handler to your app and stopPropagation of the event when it’s originating from the JQL editor.

Hi @ViktoriiaDakh ,

You can prevent the event propagation using the below code snippet

  useEffect(() => {
    const handleKeyEvent = (event) => {
      event.stopPropagation(); // Stop the event from propagating further
    };
    // Attempt to find the contenteditable div within the JQLEditor after it has been rendered
    const editableDiv =  document.querySelector('div[contenteditable="true"]');
    
    // If the div is found, attach the event listener
    if (editableDiv) {
      editableDiv.addEventListener('keypress', handleKeyEvent);     
    }

    return () => {
      // Ensure to remove the event listener on cleanup to prevent memory leaks
      if (editableDiv) {
        editableDiv.removeEventListener('keypress', handleKeyEvent);
      }
    };

  }, []);

Thank you @Kyle for the suggestion. It works!

Hey @Kyle, we were earlier using the same approach as Ajay, ( JQLEditorAsync ) we also faced the issue of disabled component then we tried to change it to the Sync Component i.e JQLEditor, but in log, it is showing process is not defined, can you please help us out in regards to this issue, sharing some of the details as below:

jql-editor version : “^2.0.1”
node version : 18.17.1
Error : ReferenceError: process is not defined

Please let me know if any other info required

Hey @gauravs you’d need to look into the stack trace to narrow down where this is originating from. I can’t provide much more insight from the error message alone unfortunately.