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

Help getContents #435

Closed
anhdoantm opened this issue Jul 8, 2020 · 15 comments
Closed

Help getContents #435

anhdoantm opened this issue Jul 8, 2020 · 15 comments
Labels
Milestone

Comments

@anhdoantm
Copy link

anhdoantm commented Jul 8, 2020

Hi, @JiHong88 Editor very good

I used editor.getContents(); to validators to get text values to receive notifications, but in this case it gets the whole code of textarea instead of key text.
Only get text, is there any method to do that, I'm using formvalidation.
Take a look at the code and look through the link below for info.
Thanks in advance.

            "post[content2]": {
                validators: {
                    callback: {
                        message: 'The contents must be between 5 and 2000 characters long',
                        callback: function(value) {
                            // Get the plain text without HTML
                            const text = editor.getContents({
                                //format: 'text'
                            });
                            return text.length <= 2000 && text.length >= 5;
                        }
                    }		
                }
            }
@JiHong88
Copy link
Owner

JiHong88 commented Jul 8, 2020

Hi,
I'll add get Text method.
Until then, you can get it in the following way:
editor.core.context.element.wysiwyg.textContent

@anhdoantm
Copy link
Author

anhdoantm commented Jul 8, 2020

Thanks for the quick help,
I have tried your code but it has no response, the message of that callback does not appear,
See if there's a way for that callback.

There is another question, I found another Editor while searching on cssscript.com seems to have changed the name but I know it's the product of your previous version.
Because I don't see any link to your branch or from you there. I thought it was illegal

@JiHong88
Copy link
Owner

JiHong88 commented Jul 8, 2020

editor.core.context.element.wysiwyg.textContent is undefined?

https://github.com/kothing/Kothing-Editor

Thanks for the link.
Do you know how to deal with this?

@anhdoantm
Copy link
Author

they only work on github or gitee, you need to report to the website vendors that they operate, cssscript also needs to report, they are long-standing websites or large storage places for code and they will stop working action.
What worries me is that they bring viruses into these software, if that is very dangerous, we do not know what their purpose is. I have downloaded it and have deleted it now.

@JiHong88 JiHong88 added this to the 2.31.1 milestone Jul 8, 2020
@JiHong88
Copy link
Owner

JiHong88 commented Jul 8, 2020

@anhdoantm
Are you resolved this issue?

@JiHong88 JiHong88 removed the question label Jul 8, 2020
@anhdoantm
Copy link
Author

Thanks for this feedback.
I tried the code but it didn't work, I haven't solved it yet.

@JiHong88
Copy link
Owner

JiHong88 commented Jul 8, 2020

editor.core.context.element.wysiwyg.textContent What part of this doesn't work?

@anhdoantm
Copy link
Author

anhdoantm commented Jul 8, 2020

I tried all the elements in the code and the combination reversed, but it all failed. It didn't work.
For this code editor.getContents it works but it counts everything including Div P or even Image data it counts, , It should be taken according to CharCount.

Ảnh chụp màn hình (22)

@JiHong88
Copy link
Owner

JiHong88 commented Jul 9, 2020

You can use the getCharCount
And it is same editor.getCharCount("char") === editor.core.context.element.wysiwyg.textContent.length

@anhdoantm
Copy link
Author

Somehow, he doesn't accept it.
Too difficult to ignore. 😂😊

So wait Add GetContent NO Code So.

@JiHong88
Copy link
Owner

Hmm.. is right?
editor.getContents is working
editor.getCharCount is not working
editor.core.context.element.wysiwyg.textContent.length is not working

JiHong88 added a commit that referenced this issue Jul 10, 2020
@anhdoantm
Copy link
Author

That's right, only editor.getContents works.
So If adding or changing 1Get please make editor.getContents("text").

@JiHong88
Copy link
Owner

Are you using suneditor-react?
I added a getText method.
You can use it at the next version.

@anhdoantm
Copy link
Author

No, I'm targeting only using pure javscript, I don't want to rely on the 3rd library.
Thank you for the effort.

@JiHong88
Copy link
Owner

The 2.31.1 version has been updated.
If this issue has not been resolved, please reopen this issue.
Thank you.

PS: The lack of other attributes in editor is that something is wrong.

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

No branches or pull requests

2 participants