friendsofagape / usfm-editor

A React component for WYSIWYG USFM editing.
https://friendsofagape.github.io/usfm-editor/
MIT License
5 stars 1 forks source link

Invalid USFM can yield unhelpful errors #25

Open RUN-Projects opened 3 years ago

RUN-Projects commented 3 years ago

In importing usfm-editor into a react app, there is a node path error. Am I missing something?

Imported is as follows in react project at 'C:/projects/react-app/':


function Editor() {
  const usfmString = `\\c 1
  \\v 1 This is the first verse.`;
  const setUsfmString = (editedUsfm) => {console.log(editedUsfm)};
  return (
    <UsfmEditor usfmString={usfmString} onChange={setUsfmString}></UsfmEditor>
  );
}

export default Editor;

Initial part of error message:

point
C:/projects/src/interfaces/editor.ts:903
  900 | const node = Node.get(editor, path)
  901 | 
  902 | if (!Text.isText(node)) {
> 903 |   throw new Error(
      | ^  904 |     `Cannot get the ${edge} point in the node at path [${at}] because it has no ${edge} text node.`
  905 |   )
  906 | }
Ashersam commented 3 years ago

@RUN-Projects error is caused by missing ide in usfmString input. You can check on basic demo integration here

aunger commented 3 years ago

Looks like this can be closed. Please comment and re-open if needed.

aunger commented 3 years ago

Actually, I'd like to re-name this issue and treat it a a usability bug.

RUN-Projects commented 3 years ago

Thank you @Ashersam !