Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I have multiple editor instances? #133

Closed
adn0n opened this issue Jun 12, 2024 · 14 comments
Closed

Can I have multiple editor instances? #133

adn0n opened this issue Jun 12, 2024 · 14 comments
Assignees
Labels
bug Something isn't working

Comments

@adn0n
Copy link

adn0n commented Jun 12, 2024

So, right now, I'm trying to have multiple notes. I'm also trying to set the initialContent to the saved content in the database. But the editor only seems to be working in one note.
It does work if I pass in a custom DEV_SERVER_URL with that note id, but I'm afraid this is going to cause some memory and scalability issues. Is there a better way of doing this?

@mandrade2
Copy link

mandrade2 commented Jun 12, 2024 via email

@17Amir17
Copy link
Collaborator

17Amir17 commented Jun 13, 2024

Hey, TenTap should work with many editor instances, you do need a new editor instance for each editor (useEditor)
DEV_SERVER_URL should only be used when developing with the advanced setup.

If no content is being displayed something must have failed inside the web-view could you send us the error? This is how you can inspect web-view logs:
https://github.com/react-native-webview/react-native-webview/blob/master/docs/Debugging.md#debugging-webview-contents

@adn0n
Copy link
Author

adn0n commented Jun 14, 2024

image This is the error I get

@17Amir17
Copy link
Collaborator

image

This is the error I get

This error should be fixed on the latest version. What version are you on, could you try updating?

@17Amir17
Copy link
Collaborator

Closing for now, lmk if it persists

@17Amir17 17Amir17 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
@adn0n
Copy link
Author

adn0n commented Jun 17, 2024

Still the same problem, experiencing it quite frequently. I'm using the latest version.
Here's the package.json file

  "name": "editor-test",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest"
  },
  "dependencies": {
    "@10play/tentap-editor": "^0.5.3",
    "@expo/vector-icons": "^14.0.2",
    "@react-native-async-storage/async-storage": "^1.23.1",
    "@react-native-voice/voice": "^3.2.4",
    "@react-navigation/bottom-tabs": "^6.5.20",
    "@react-navigation/native": "^6.1.17",
    "@react-navigation/stack": "^6.3.29",
    "@types/react-native-vector-icons": "^6.4.18",
    "axios": "^1.7.2",
    "lodash": "^4.17.21",
    "moment": "^2.30.1",
    "react": "^18.2.0",
    "react-native": "0.74.1",
    "react-native-gesture-handler": "^2.16.2",
    "react-native-modal": "^13.0.1",
    "react-native-reanimated": "^3.12.0",
    "react-native-safe-area-context": "^4.10.4",
    "react-native-screens": "^3.31.1",
    "react-native-swipe-list": "^0.0.2",
    "react-native-vector-icons": "^10.1.0",
    "react-native-webview": "^13.10.2"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/babel-preset": "0.74.83",
    "@react-native/eslint-config": "0.74.83",
    "@react-native/metro-config": "0.74.83",
    "@react-native/typescript-config": "0.74.83",
    "@types/react": "^18.2.6",
    "@types/react-test-renderer": "^18.0.0",
    "babel-jest": "^29.6.3",
    "eslint": "^8.19.0",
    "jest": "^29.6.3",
    "prettier": "2.8.8",
    "react-test-renderer": "18.2.0",
    "tailwindcss": "^3.3.2",
    "typescript": "5.0.4"
  },
  "engines": {
    "node": ">=18"
  }
}```

@17Amir17
Copy link
Collaborator

Could you provide a minimal reproducible example?

@17Amir17 17Amir17 reopened this Jun 18, 2024
@GuySerfaty
Copy link
Contributor

We can see this on very old android devices @adn0n can you verify iOS is working for you?

I see:

Scheme is missing its top node type ('doc')

Might be related to
react-native-webview/react-native-webview#1609

@adn0n
Copy link
Author

adn0n commented Jul 3, 2024

I'm using Android 14 though, could it be related to my Java and Gradle version? I'll try setting up an iOS emulator.
Java version: 17
Gradle: 8.6

Here's the code that I'm using:

HomeScreen (most recent note):

const HomeEditor = useEditorBridge({
        autofocus: false,
        initialContent: lastModifiedNote?.content || '',
        editable: false,
    });
    useEffect(() => {
        if (isMounted.current && HomeEditor) {
            HomeEditor.injectCSS(`
                body {
                    font-size: 12px;
                    color: #000;
                }
            `);
            HomeEditor.setContent(lastModifiedNote?.content || '');
        }
    }, [lastModifiedNote, HomeEditor]);
// the react native bit
                        <View style={styles.card}>
                            {HomeEditor && lastModifiedNote ? (
                                <RichText editor={HomeEditor} />
                            ) : (
                                <Text>No notes found</Text>
                            )}
                        </View>

And I have another component called NoteOpen

  var editor = useEditorBridge({
    autofocus: false,
    initialContent: loadedContent,
    onChange() {
      handleEditorChange();
    },
  });
 <RichText editor={editor} />

If I load my HomeScreen component and then go to notes, it never loads - I get

RangeError: Schema is missing its top node type ('doc')
    at hy.compile (about:blank:49:6162)
    at new Cv (about:blank:49:7312)
    at mw (about:blank:56:12761)
    at new jr (about:blank:57:2320)
    at aC.createExtensionManager (about:blank:133:2780)
    at new tC (about:blank:133:890)
    at new aC (about:blank:135:7208)
    at about:blank:135:8207
    at Jl (about:blank:48:24187)
    at Jr (about:blank:48:42189)

(presumably because the other editorBridge is already running?)

@jbernhardt-x-team
Copy link

image This is the error I get

I'm getting this exact error. I have a FlatList that renders a component that eventually renders a RichText component. I don't have multiple RichText in a single component but I noticed that only on Android some of the RichText rendered in the list throw this error. I have the very basic implementation of the RichText from here

I'm testing on a Pixel 8 Pro running latest Android version.

@17Amir17 17Amir17 self-assigned this Jul 8, 2024
@17Amir17 17Amir17 added the bug Something isn't working label Jul 8, 2024
@17Amir17
Copy link
Collaborator

17Amir17 commented Jul 8, 2024

I've found a way to reproduce this consistently.
It happens on some androids - I am using Pixel 5 API 32 Android 12L Emulator, and it only happens when reopening the app, and mounting the editor for the first time, will work on a fix

@jbernhardt-x-team
Copy link

I've found a way to reproduce this consistently. It happens on some androids - I am using Pixel 5 API 32 Android 12L Emulator, and it only happens when reopening the app, and mounting the editor for the first time, will work on a fix

In case it can by any helpful, I found this thread where an alternative prop is being exposed, I'm going to patch locally and see if I have better results

@17Amir17
Copy link
Collaborator

17Amir17 commented Jul 9, 2024

Should be fixed on 0.5.11 - let us know if this solves the case for you - if you are using the advanced setup you will need to update your index.ts https://10play.github.io/10tap-editor/docs/setup/advancedSetup#step-4---add-indexhtml-advancededitortsx-and-indextsx

@adn0n
Copy link
Author

adn0n commented Jul 9, 2024

Working fine now, thank you!

@adn0n adn0n closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants