Giter Club home page Giter Club logo

android-wysiwyg-editor's Introduction

Download  enter image description here License

Android-WYSIWYG-Editor

An iframe free text editor that uses native components in the content tree. Motivation was to create a clean native feel WYSIWYG editor like medium.com has.

Changelog

[3.0.4 - 30 July 2019]

  • Updates glide to 4.9.0

[3.0.3 - 20 December 2018]

  • Introducing Macro's - Macro's are equivalent to components in react/vue.js. It lets you add a custom block into the editor where you get to control what gets rendered into the editor. Read more about this below on Macro's section.

  • Add blockquote support

  • Replaced image loader library Picasso with Glide, so to make use of it's rich customization api.

  • An improved editor navigation.

[2.3.2 - 01 December 2018]

  • Links on editor will now respond to click
  • Fix for editor rendering wrong order from serialised string/html

Please find all the latest releases/changelogs on https://github.com/irshuLx/Android-WYSIWYG-Editor/releases

Contributions

You can clone from the master branch. Once ready to merge , please open a pull request to dev branch. Be sure to merge the latest from "upstream" before making a pull request! I can then review and merge it back to master

Download

gradle:

compile 'com.github.irshulx:laser-native-editor:3.0.3'

or maven:

<dependency>
  <groupId>com.github.irshulx</groupId>
  <artifactId>laser-native-editor</artifactId>
  <version>3.0.3</version>
  <type>pom</type>
</dependency>

Demo

     

   

Features

  • Renderer or Editor: You can use it as a Renderer to Render the content or use it as an Editor to create the content.

  • No Webviews used to render the content. It uses Native EditText, ImageView and as such to render the contents.

  • HTML Parser: Render your HTML Code into the editor and vice versa.

  • Integration with web based WYSIWYG's: HTMLParser helps the Editor to work seemlessly with the WYSIWYG editor on your web platform.

The editor is built, so that every part of the design have been exposed and is available for customization.

Available Controls:

Control Usage
H1, H2 and H3 Insert Headings
Blockquote Insert a blockquote
Bold, Italic,Color, Intent & Outdent Format the text
Image Picker Insert Images to the editor from storage or a URL
Hyperlinks Add Links to the editor
Location Selector Use the embedded map editor to tag and insert locations to the editor
Numbered and Bulleted Lists Let's you created Unorderd and Ordered lists
Line Divider Add a divider

Usage

For a complete overview of the implementation, please take a look at EditorTestActivity.java

Layout XML

<com.github.irshulx.Editor
    android:layout_width="match_parent"
    android:id="@+id/editor"
    app:render_type="Editor"
    app:placeholder="Start writing here..."
    android:paddingTop="10dp"
    android:paddingLeft="10dp"
    android:paddingRight="10dp"
    android:layout_height="wrap_content"
    android:paddingBottom="100dp"
/>

Activity

 @Override
 protected void onCreate(Bundle savedInstanceState) {

    editor = (Editor) findViewById(R.id.editor);
    findViewById(R.id.action_h1).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.H1);
        }
    });

    findViewById(R.id.action_h2).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.H2);
        }
    });

    findViewById(R.id.action_h3).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.H3);
        }
    });

    findViewById(R.id.action_bold).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.BOLD);
        }
    });

    findViewById(R.id.action_Italic).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.ITALIC);
        }
    });

    findViewById(R.id.action_indent).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.INDENT);
        }
    });

    findViewById(R.id.action_outdent).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.OUTDENT);
        }
    });

    findViewById(R.id.action_bulleted).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.insertList(false);
        }
    });
    
       findViewById(R.id.action_color).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextColor("#FF3333");
        }
    });

    findViewById(R.id.action_unordered_numbered).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.insertList(true);
        }
    });

    findViewById(R.id.action_hr).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.insertDivider();
        }
    });

    findViewById(R.id.action_insert_image).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.openImagePicker();
        }
    });

    findViewById(R.id.action_insert_link).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.insertLink();
        }
    });


    findViewById(R.id.action_erase).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.clearAllContents();
        }
    });

findViewById(R.id.action_blockquote).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            editor.updateTextStyle(EditorTextStyle.BLOCKQUOTE);
        }
    });
    
    editor.render();
    
}

If you are using Image Pickers, Add the following into your Activity:

     @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == editor.PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK&& data != null && data.getData() != null) {
        Uri uri = data.getData();
        try {
            Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
            editor.insertImage(bitmap);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    else if (resultCode == Activity.RESULT_CANCELED) {
       // editor.RestoreState();
    }
}

You can also programmatically append text into the editor using HTML like so:

editor.render("<p>Hello man, whats up!</p>");
editor.render("<div>This is another paragraph!</div>");

Please be reminded, nested HTML ARE NOT supported at the moment except for <ul> and <ol>, for eg: <p><h2>Hello world</h2></p> won't work since <h2> is nested inside <p>. Following HTML tags are supported:

  • <p>,<div>
  • <h1>,<h2>,<h3>
  • <blockquote>
  • <img>
  • <ul>,<ol>
  • <hr/>
  • <br/>

API

  • render(); Render the editor. This method must be called to render the editor.

  • render(String html); Render the editor with HTML as parameter.

  • render(EditorState state); Render the editor with the state as parameter

  • getContent(); returns the content in the editor as EditorState

  • getContentAsSerialized(); returns the content as serialized form of EditorState

  • getContentAsSerialized(EditorState state); returns the provided parameter as serialized.

  • getContentAsHTML(); returns the editor content in HTML format.

  • updateTextStyle(EditorTextStyle style); Update the text style for the currently active block. Possible values are H1,H2,H3,BOLD,ITALIC,BLOCKQUOTE,INDENT and OUTDENT .

  • setH1TextSize(int size), setH2TextSize(int size) and setH3TextSize(int size); Override the existing text sizes. There are getter methods as well to retrieve the existing text sizes for each.

  • setFontFace(int resource); Sets the FontFace for the editor.

  • setLineSpacing(float value); Sets the linespace for the editor.

  • setEditorTextColor("#FF3333"); Sets the global text color of the editor (default is #000000).

  • updateTextColor("#FF3333"); Changes the text color of the focused text.

  • openImagePicker(); Opens up the image picker. Once the user has selected the image, it's automatically inserted to the editor. But you must configure a remote URL ,where you want the image to be uploaded. If the Remote URL is not specifed, the image is not persisted.

  • insertImage(Bitmap bitmap); Insert a bitmap image into the editor.

  • setEditorImageLayout(int layout); Override the default layout for images in the editor.

  • insertList(boolean isOrdered);Insert an Ordered or Unordered List.

  • setListItemLayout(int layout); Override the default layout for list items.

  • insertMacro(String name,View view, Map<String, Object> props); Insert macro(custom component).

  • insertDivider(); Insert a line divider

  • setDividerLayout(int layout); Override the default layout for dividers

If you are using image uploads, use the below to add the uploaded image to editor:

  editor.setEditorListener(new EditorListener() {
            @Override
            public void onTextChanged(EditText editText, Editable text) {
                // Toast.makeText(EditorTestActivity.this, text, Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onUpload(Bitmap image, String uuid) {
               
               //do your upload image operations here, once done, call onImageUploadComplete and pass the url and uuid as reference.
                editor.onImageUploadComplete("http://www.videogamesblogger.com/wp-content/uploads/2015/08/metal-gear-solid-5-the-phantom-pain-cheats-640x325.jpg",uuid);
               // editor.onImageUploadFailed(uuid);
            }
        });

Macro's

A macro is equivalent to a component in react/vue.js.

for eg: In vue, you define a component author-tag as:

 Vue.component('author-tag', {  
     props: ['author-name', 'date'],
     template: '<div>
                  <span class="name" {{author-name}}></span>
                  <span class="date" {{date}}></span>
               </div>'  
    });

You can then use this component as a custom HTML element in your markup:

<author-tag author-name="Thomas Isaac" date="12 July 2018">
</author-tag>

When a custom html tag is found on the HTML text that's fed to the editor, View onRenderMacro(String name, Map<String, Object> props, int index); will be invoked. All you need to do is to inflate your custom view created to handle author-tag and return that view to the editor:

editor.setEditorListener(new EditorListener() {
    ...
    @Override  
    public View onRenderMacro(String name, Map<String, Object> props, int index) {  
        View layout = getLayoutInflater().inflate(R.layout.layout_authored_by, null);  
        TextView lblName = layout.findViewById(R.id.lbl_author_name);
        lblName.setText(props.get("author-name"));
	return layout;  
     }
});

To insert a macro, use:

private void insertAuthorMacro() {  
  View layout = getLayoutInflater().inflate(R.layout.layout_authored_by, null);  
  Map<String, Object> props = new HashMap<>();  
  props.put("author-name", "Thomas Isaac");  
  props.put("date","12 July 2018");  
  editor.insertMacro("author-tag",layout, props);  
}

When content is extracted using editor.getContentAsHTML(); the html string will contain:

"<author-tag author-name=\"Thomas Isaac\" date=\"12 July 2018\"></author-tag>"

Custom Fonts

You can set your own fonts for the editor.

    Map<Integer, String> headingTypeface = getHeadingTypeface();
    Map<Integer, String> contentTypeface = getContentface();
    editor.setHeadingTypeface(headingTypeface);
    editor.setContentTypeface(contentTypeface);

     public Map<Integer,String> getHeadingTypeface() {
    Map<Integer, String> typefaceMap = new HashMap<>();
    typefaceMap.put(Typeface.NORMAL,"fonts/GreycliffCF-Bold.ttf");
    typefaceMap.put(Typeface.BOLD,"fonts/GreycliffCF-Heavy.ttf");
    typefaceMap.put(Typeface.ITALIC,"fonts/GreycliffCF-Heavy.ttf");
    typefaceMap.put(Typeface.BOLD_ITALIC,"fonts/GreycliffCF-Bold.ttf");
    return typefaceMap;
}

public Map<Integer,String> getContentface() {
    Map<Integer, String> typefaceMap = new HashMap<>();
    typefaceMap.put(Typeface.NORMAL,"fonts/Lato-Medium.ttf");
    typefaceMap.put(Typeface.BOLD,"fonts/Lato-Bold.ttf");
    typefaceMap.put(Typeface.ITALIC,"fonts/Lato-MediumItalic.ttf");
    typefaceMap.put(Typeface.BOLD_ITALIC,"fonts/Lato-BoldItalic.ttf");
    return typefaceMap;
}

Overridable layouts

You can create your own layouts with the same Id's with the required Id's and put them in your app's layout directory. App will then override the library's layout and pick the one from your app's layout directory. As of now, you can override the following layouts.

Layout Description Required Id's
R.layout.tmpl_image_view To insert an image to the editor @+id/progress, @+id/lblStatus,@+id/imageView,@+id/btn_remove
R.layout.tmpl_list_item To insert an ordered/unordered list @+id/lblOrder, @+id/txtText,@+id/lblText
R.layout.tmpl_divider_layout To insert a line divider -

You could also set the layouts via the API:

  • editor.setEditorImageLayout(R.layout.tmpl_image_view);

  • editor.setListItemLayout(R.layout.tmpl_list_item);

  • editor.setDividerLayout(R.layout.tmpl_divider_layout);

If you have minifyEnabled, below are the proguard rules:

  -keep class com.google.gson.** { *; }  
  -dontwarn com.squareup.picasso.**  
  -dontwarn com.squareup.okhttp.**  
  -keep public class org.jsoup.** { public *; }

Best Practices

Since the endusers are hard typing the content, it's always considered good idea to backup the content every specific interval to be safe.

timer = new Timer();  
timer.scheduleAtFixedRate(new TimerTask() {  
  @Override  
  public void run() {  
     String text = editor.getContentAsSerialized();
     sharedPreferences.putString(String.format("backup-{0}",  new SimpleDateFormat("dd-MM-yyyy hh:mm:ss").format(new Date())),   text);
     sharedPreferences.apply();
  }
}, 0, backupInterval);

Future Plans

  • Add videos support

  • Address the issues and feature requests from fellow devs.

Contributions are much appreciated, feel free to fork and customize for your needs.

If you come across any bugs or needs, please mention it on issues, i will address it and resolve it the latest possible.

Libraries Used

  • Glide, Gson, Jsoup

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-wysiwyg-editor's People

Contributors

agferrier avatar andy-wong avatar irshu355 avatar karuhanga avatar lunarwatcher avatar ngwing avatar ricky641b avatar sunnyaditya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-wysiwyg-editor's Issues

How to remove auto focus from editor

I have 1 Edittext with named "title" before this editot and I would like to have focus on that title edittext when screen open but it show the focus on this editor.

I called below api to remove focus but failed.

description.clearAllContents(); description.clearChildFocus(description); title.requestFocus(); description.clearFocus();

Is there any way to remove focus from editor in starting?

java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable com.github.irshulx.Components.CustomEditText.getText()' on a null object reference

Gives me this error when I have multiple lines of text and then I put the cursor in the very beginning and presses the back button. The app finally crashes.

Also when I paste an English or a Korean text, it does not paste it correctly. With English text paste I get some text missing while in case of Korean text, I get multiple same text.

java.lang.NullPointerException: Attempt to invoke virtual method 'android.text.Editable com.github.irshulx.Components.CustomEditText.getText()' on a null object reference
        at com.github.irshulx.EditorCore.onKey(EditorCore.java:604)
        at com.github.irshulx.Editor.onKey(Editor.java:304)
        at com.github.irshulx.Components.InputExtensions$1.onKey(InputExtensions.java:176)

Not able to update/render OL and UL

Query 1 :
I am not able to edit/render order and unorder list.

Edit text :

String dummyText =
                "<p>Genertaing &nbsp;html from ckeditor blah blah blah<br>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod<br>tempor " +
                        "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,<br>quis nostrud exercitation ullamco laboris nisi ut aliquip " +
                        "ex ea commodo<br>consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse<br>cillum dolore eu fugiat nulla pariatur" +
                        ". Excepteur sint occaecat cupidatat non<br>proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><p>&nbsp;" +
                        "</p><ol><li>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod<br>tempor incididunt ut labore et dolore magna " +
                        "aliqua. Ut enim ad minim veniam,<br>quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo<br>consequat. Duis aute " +
                        "irure dolor in reprehenderit in voluptate velit esse<br>cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat " +
                        "non<br>proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br><br><strong>ohh bold text<br><em>Why not " +
                        "italicize</em></strong><br>&nbsp;</li><li><strong><em>no</em></strong></li><li><strong><em>no</em></strong></li><li><strong><em>no" +
                        "</em></strong></li></ol>";

When i try to render this text, it repeats the data 4 times in order list format. Expected result : 2 order list items and 2 unorder list items

String dummy2 ="<p><strong>abcasd sad</strong></p><ol><li>12345</li><li>9833232</li></ol><ul><li>bullet</li><li>ok " +
            "http</li></ul><p><em>asd1111221</em></p><p><em><a href=\\\"http://abc.com\\\">http://abc.com</a></em></p>";

When i try to render this text, it repeats the same data items in order and underorder list format. Expected result : order/unorder list items have different items. It should repeated data.

Query 2 :
Will the performace hamper if I use this editor for each row-item in recyclerview. There could n no of instance of editor in recyclerview. Do you recommend to use inside recyclerview?

Copy paste issue

pasting multiple lines when copy from clipboard.
Android 5.0.1

HTML render problem.

editor.render("HTML CONTENT") renders randomly and updates the editor. How can i render the html content serially as per original html content one by one?

example:
original html -> input-image-input-image
rendered -> input-image-image-input.

How can i get it to render properly as per the original html content?

REEdit Numbering and Bullets

when reediting numbering and bullets, the editor render will show the list but it will change and use the first value in the list for all list item. Please help me solve this issue. thanks

IndexOutOfBoundsException

at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2560)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5740)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:260)
at java.util.ArrayList.get(ArrayList.java:313)
at org.jsoup.select.Elements.get(Elements.java:544)
at org.jsoup.nodes.Element.child(Element.java:171)
at com.github.irshulx.Components.HTMLExtensions.RenderImage(HTMLExtensions.java:78)
at com.github.irshulx.Components.HTMLExtensions.buildNode(HTMLExtensions.java:63)
at com.github.irshulx.Components.HTMLExtensions.parseHtml(HTMLExtensions.java:33)
at com.github.irshulx.EditorCore.renderEditorFromHtml(EditorCore.java:538)
at com.github.irshulx.Editor.render(Editor.java:75)

How to add text programmatically?

I can't write or append text programmatically like when I am using keyboard.
I used render() and getInputExtensions().insertEditText(0 ,null ,"TEXT"); and none of them working correctly.

How can I append my text like I'm typing?

Manifest - Backup

Is there a reason to have the backup enabled? Manifest merger exception when attempting to add to a project with backup set to false.

laser-native-editor:2.0.0 Gradle error

Downloading with gradle is impossible. I use this line in gradle module file:
compile 'com.github.irshulx:laser-native-editor:2.0.0'

Compiler gives failed to resolve error. I use the latest version of Android Studio.

What is the Proguard rules?

Hey. Firstly, thank you for this amazing library. But When use minify enable, what proguard rules am I have to use ?. This error coming from jsoup I think. Stack trace is below. Thanks!

`

    at org.a.b.h.a(Entities.java:18)
    at org.a.b.h$a.<clinit>(Entities.java:21) 
    at org.a.b.e$a.<init>(Document.java:226) 
    at org.a.b.e.<init>(Document.java:18) 
    at org.a.c.l.b(TreeBuilder.java:27) 
    at org.a.c.l.a(TreeBuilder.java:40) 
    at org.a.c.b.a(HtmlTreeBuilder.java:55) 
    at org.a.c.f.a(Parser.java:90)
    at org.a.a.a(Jsoup.java:58)
    at com.github.irshulx.Components.HTMLExtensions.parseHtml(HTMLExtensions.java:29)
    at com.github.irshulx.EditorCore.renderEditorFromHtml(EditorCore.java:543)
    at com.github.irshulx.Editor.render(Editor.java:76)`

authentication during upload

our server forbids upload from anonymous users and in order to upload, you must login first.
in upload process, I must send credentials as http headers to server so that it recognize me and accept uploading.
please add a method to set http headers
something like this:

editor.setHttpHeader(Map<String,String> headers)

java.lang.NullPointerException: Attempt to read from field 'com.github.irshulx.models.EditorType com.github.irshulx.models.EditorControl.Type' on a null object reference

I have trouble with putting pictures in the article.

If I put a picture only, it works, but if i put a picture with some tags(ex, number tag, ul, ...)
it doesn't work.

There is an error message.
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://media/external/images/media/10170 flg=0x1 (has extras) }} to activity {com.ted.android.driving/com.ted.android.driving.TextEditActivity}: java.lang.NullPointerException: Attempt to read from field 'com.github.irshulx.models.EditorType com.github.irshulx.models.EditorControl.Type' on a null object reference

I don't know why this happens.

Copy Paste Issue

when copy multiple line.its not handling (ANR) how to reslove this issue

Render images in html

In the render mode images are not shown. Is it a bug or the module has not this feature? I am using v2.0.0.

upload pdf, zip, video and even record audio!

It is desirable to have some button next to upload image that after click, selects a file and uploads it to server and inserts it's link at a new line.
of a button that after click, we record an audio and upload it to server and embed it to the document with tag.
and two buttons to select and upload audio and video as well.
all you should do putting some ImageButtons and implementing these methods:
editor.insertLink(String displayName ,String url)
editor.insertAudio(Uri file, String url, String fileName)
editor.insertVideo(Uri file, String url, String fileName)
all that elements will be displayed in new line

rendering problem

I am trying to use android-wysiwyg-editor in fragment.
but I've got a rendering problem with below exception.

could you help me?

java.lang.ClassCastException: com.android.layoutlib.bridge.android.BridgeContext cannot be cast to android.app.Activity
at com.github.irshulx.BaseClass.(BaseClass.java:73)
at com.github.irshulx.Editor.(Editor.java:26)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

Render(HTML) throws error

I/TextInputLayout: EditText added is not a TextInputEditText. Please switch to using that class instead

method(setLineSpacing) is not work

Thanks to it, I use it well.
I have a problem with high word height.

method(setLineSpacing) is not work.
editor.setLineSpacing(float) = cannot resolve method setLineSpacing

Thank you very much.

(Google Translator)

Exception when I add new empty line twice

08-29 13:56:35.417 10860-10860/com.example.abdulkader.e_document_android_project E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.abdulkader.e_document_android_project, PID: 10860
java.lang.StringIndexOutOfBoundsException
at android.text.SpannableStringBuilder.(SpannableStringBuilder.java:58)
at android.text.SpannableStringBuilder.subSequence(SpannableStringBuilder.java:907)
at com.github.irshulx.Components.InputExtensions$3.afterTextChanged(InputExtensions.java:211)
at android.widget.TextView.sendAfterTextChanged(TextView.java:7695)
at android.widget.TextView$ChangeWatcher.afterTextChanged(TextView.java:9483)
at android.text.SpannableStringBuilder.sendAfterTextChanged(SpannableStringBuilder.java:972)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:516)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:454)
at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:33)
at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:685)
at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:197)
at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:184)
at android.view.inputmethod.InputConnectionWrapper.commitText(InputConnectionWrapper.java:82)
at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:286)
at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Exception on InsertLink When current line is empty

java.lang.StringIndexOutOfBoundsException: length=0; index=-1 at java.lang.String.indexAndLength(String.java:500) at java.lang.String.charAt(String.java:494) at com.github.irshulx.Components.InputExtensions.trimLineEnding(InputExtensions.java:428) at com.github.irshulx.Components.InputExtensions.InsertLink(InputExtensions.java:401) at com.github.irshulx.Components.InputExtensions.access$000(InputExtensions.java:50) at com.github.irshulx.Components.InputExtensions$5.onClick(InputExtensions.java:383)

Copy/Paste multiline text issue

When the copied text is a continuous paragraph, then paste works fine. However, if the copied text is multi-lined, then weirdly it takes the last sentence of the text and pastes it many times in between.

Please help. I tried using both English and Korean text

imagepicker wont work with fragment

the imagepicker uses startActivityForResult from editorCore which uses the context of the view
and therefor the activity. when used inside a fragment the fragment wont recieve the onActivityResult call.
i added 2 methods for this :

//my addition for fragment handle
        public void OpenFragmentImagePicker(Fragment fragment) {
            getImageExtensions().OpenFragmentImageGallery(fragment);
        }

/my extention for fragment handling
    public void OpenFragmentImageGallery(Fragment fragment) {
        int Index=this.editorCore.determineIndex(EditorType.none);
        EditorContent state= editorCore.getContent();
        Intent intent = new Intent();
// Show only images, no videos or anything else
        intent.setType("image/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
    // Always show the chooser (if there are multiple options available)
        fragment.startActivityForResult(Intent.createChooser(intent, "Select an image"), editorCore.PICK_IMAGE_REQUEST);
    }

my method is crude and this probably needs to be handled in the project

Not wokring in Landscape mode

When we try to edit the layout in landscape mode the keyboard cover the whole screen and we are not able to style our text in landscape mode

onclick event is not working

onclick event is not working on the editor. Is there any event which detect that editor got focus?
I tried focus change event too but it's not working too.

OutofMemoryError

when I try to add one more photo I got OutofMemoryError.

java.lang.OutOfMemoryError: Failed to allocate a 63701004 byte allocation with 16777216 free bytes and 48MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
at android.graphics.BitmapFactory.decodeStreamInternal(BitmapFactory.java:639)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:615)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:653)
at android.provider.MediaStore$Images$Media.getBitmap(MediaStore.java:845)
at com.pixeldirects.projectb.activity.WritePostActivity.onActivityResult(WritePostActivity.kt:72)
at android.app.Activity.dispatchActivityResult(Activity.java:6243)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3577)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3624)
at android.app.ActivityThread.access$1300(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5276)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)

How do I change text color?

Hi
Thank you for this great library.
Please, I would like to change the text color of the editor from black. How can I do that?

Text editor starts with premade text

Hi, I wanted to pass a string from an activity to the text editor activity.
I have moved the String but when I tried to make the editor start with a predefined String I can't.
Is there an option to add a method that let's the text editor start with a text that you can edit?

Not able to update/render OL and UL

Query 1 :
I am not able to edit/render order and unorder list.

# Edit text :

String dummyText =
                "<p>Genertaing &nbsp;html from ckeditor blah blah blah<br>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod<br>tempor " +
                        "incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,<br>quis nostrud exercitation ullamco laboris nisi ut aliquip " +
                        "ex ea commodo<br>consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse<br>cillum dolore eu fugiat nulla pariatur" +
                        ". Excepteur sint occaecat cupidatat non<br>proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><p>&nbsp;" +
                        "</p><ol><li>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod<br>tempor incididunt ut labore et dolore magna " +
                        "aliqua. Ut enim ad minim veniam,<br>quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo<br>consequat. Duis aute " +
                        "irure dolor in reprehenderit in voluptate velit esse<br>cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat " +
                        "non<br>proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br><br><strong>ohh bold text<br><em>Why not " +
                        "italicize</em></strong><br>&nbsp;</li><li><strong><em>no</em></strong></li><li><strong><em>no</em></strong></li><li><strong><em>no" +
                        "</em></strong></li></ol>";

When i try to render this text, it repeats the data 4 times in order list format. Expected result : 2 order list items and 2 unorder list items

String dummy2 ="<p><strong>abcasd sad</strong></p><ol><li>12345</li><li>9833232</li></ol><ul><li>bullet</li><li>ok " +
            "http</li></ul><p><em>asd1111221</em></p><p><em><a href=\\\"http://abc.com\\\">http://abc.com</a></em></p>";

When i try to render this text, it repeats the same data items in order and underorder list format. Expected result : order/unorder list items have different items. It should repeated data.

Query 2 :
Will the performace hamper if I use this editor for each row-item in recyclerview. There could n no of instance of editor in recyclerview. Do you recommend to use inside recyclerview?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.