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

Server state randomly corrupts and collapses the iink editor content #1

Closed
pvnick opened this issue Jan 3, 2024 · 4 comments
Closed
Assignees

Comments

@pvnick
Copy link

pvnick commented Jan 3, 2024

I set up a editor to automatically convert strokes to text after a couple seconds of inactivity. Before long, the server seems to tell the client to collapse everything into a jumbled mess. "Undo" does not fix the situation - running the undo command will temporarily revert to the clean state on the client side, but the next time "convert" is run the content will get messed up again.

Minimal example to recreate the issue:

export class HandwritingEditor {
    private iinkEditor: IInkEditor
    private editorContainer: HTMLElement
    private editorElement: HTMLElement
    private resizeObserver: ResizeObserver
    private lastChangeID: string = ""

    constructor(applicationKey: string, hmacKey: string) {
        this.editorContainer = document.createElement('div')
        this.editorContainer.id = 'handwriting-editor-container'
        this.editorElement = document.createElement('div')
        this.editorElement.id = 'handwriting-editor'
        this.editorContainer.appendChild(this.editorElement)
        this.iinkEditor = new IInkEditor(this.editorElement,
            {
                configuration: {
                    server: {
                        scheme: "https",
                        host: "cloud.myscript.com",
                        applicationKey: applicationKey,
                        hmacKey: hmacKey,
                    },
                },
            }
        )
        setTimeout(() => {
            this.iinkEditor.initialize().then(() => {
                this.iinkEditor.events.addEventListener("changed", (evt: any) => {
                    const changeID = crypto.randomUUID()
                    this.lastChangeID = changeID
                    setTimeout(() => {
                        if (changeID == this.lastChangeID) {
                            this.iinkEditor.convert()
                        }
                    }, 2000)
                })
            })
        })
        this.resizeObserver = new ResizeObserver(this.refreshSize.bind(this));
        this.resizeObserver.observe(this.editorElement);
        this.refreshSize()
    }

    getEditorContainer() {
        return this.editorContainer
    }

    refreshSize() {
        this.iinkEditor.resize()
    }
}

let editor = HandwritingEditor("app key", "hmac key")
document.body.appendChild(editor.getEditorContainer())

Before collapse:
pre-jumble

After collapse:
after-jumble

@pvnick
Copy link
Author

pvnick commented Jan 3, 2024

Btw I should also add that I think your service is really impressive and amazing, and I'm excited to continue using it.

@srobert-myscript
Copy link
Collaborator

Hello pvnick, thank you for your support.
This bug was already identified and our team solved it.
It should be present in the next release.

For your information it is due to a force convert at reconnect.

We add a new Configuration parameter:

convert: {
      force: {
        'on-stylesheet-change': false
      }
},

@pvnick
Copy link
Author

pvnick commented Jan 12, 2024

Cool! Thank you!

@leJsboureau
Copy link
Collaborator

New version (1.0.4) with fix configuration available.
Thank you for your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants