项目作者: bxute

项目描述 :
A WYSIWYG MarkDown editor for Android.
高级语言: Java
项目地址: git://github.com/bxute/MarkDEditor.git
创建时间: 2018-07-19T07:53:42Z
项目社区:https://github.com/bxute/MarkDEditor

开源协议:

下载


MarkDEditor

A Markdown Editor For Android.

Your editor will look something like:

Supported Styles

  • Normal Text
  • H1, H2, H3, H4, H5
  • UL (Unordered List)
  • OL (Ordered List)
  • Blockquote
  • Links
  • Horizontal rulers
  • Images.

    How to use it ?

    Step 1. Add the JitPack repository to your build file

    1. allprojects {
    2. repositories {
    3. maven { url 'https://jitpack.io' }
    4. }
    5. }

Step 2. Add the dependency

  1. dependencies {
  2. implementation 'com.github.bxute:MarkDEditor:v0.16'
  3. }

Step 3. Add XML declaration

  1. <ScrollView
  2. android:background="#ffffff"
  3. android:layout_above="@+id/controlBar"
  4. android:layout_width="match_parent"
  5. android:layout_height="match_parent">
  6. <xute.markdeditor.MarkDEditor
  7. android:id="@+id/mdEditor"
  8. android:layout_width="match_parent"
  9. android:layout_height="match_parent" ></xute.markdeditor.MarkDEditor>
  10. </ScrollView>
  11. <xute.markdeditor.EditorControlBar
  12. android:id="@+id/controlBar"
  13. android:layout_alignParentBottom="true"
  14. android:layout_width="match_parent"
  15. android:layout_height="48dp" ></xute.markdeditor.EditorControlBar>

Step 4. In Activity file

  1. MarkDEditor markDEditor = findViewById(R.id.mdEditor);
  2. editorControlBar = findViewById(R.id.controlBar);
  3. editorControlBar.setEditorControlListener(this);
  4. markDEditor.configureEditor(
  5. "",//server url for image upload
  6. "", //serverToken
  7. true, // isDraft: set true when you are loading draft
  8. "Type here...", //default hint of input box
  9. NORMAL
  10. );
  11. //load draft
  12. //markDEditor.loadDraft(getDraftContent());
  13. editorControlBar.setEditor(markDEditor);

Step 5. Implement Callback methods

  1. @Override
  2. public void onInsertImageClicked() {
  3. //openGallery();
  4. }
  5. @Override
  6. public void onInserLinkClicked() {
  7. //markDEditor.addLink("Click Here", "http://www.hapramp.com");
  8. }

Inserting Image

  1. markDEditor.insertImage(filePath);

Inserting Link

  1. markDEditor.addLink("Click Here", "http://www.hapramp.com");

Note: You can add take input for link using a DialogFragment.

Getting Markdown from Editor

  1. String md = markDEditor.getMarkdownContent();

Getting List of Images

  1. List<String> images = markDEditor.getImageList();

Contributions

Any contributions are welcome. You can send PR or open issues.

License

MIT License

Copyright (c) 2018 Hapramp Studio Pvt. Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.