MCPcopy Index your code
hub / github.com/Gennki/QRichText

github.com/Gennki/QRichText @v1.0.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.4 ↗ · + Follow
122 symbols 241 edges 8 files 19 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

QRichText

效果图

效果图1效果图2

添加依赖

  1. 在项目根目录的build.gradle中添加如下语句
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }
  1. 在module下的build.gradle中添加如下语句
    dependencies {
            implementation 'com.github.Gennki:QRichText:v1.0.3'
    }

使用方法

1. xml布局如下:

<cn.qzb.richeditor.RichEditor
        android:id="@+id/editor"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

2. 在Activity的onCreate中初始化RichEditor

// init rich text editor
val re = RE.getInstance(editor)
re.setPlaceHolder("Input text here...")
re.setPadding(20, 20, 20, 20)
re.setTextBackgroundColor(Color.WHITE)

3. 常用api

Api 说明
re.getHtml() 获取富文本html代码
re.setBold() 加粗的时候调用这个方法为取消加粗,没有加粗的时候调用这个方法为加粗
re.setItalic() 斜体,使用方法和加粗相同
re.setUnderLine() 下划线,使用方法和加粗相同
re.setTextSize(fontSize) 字号大小,fontSize范围为1~7的整数
re.insertImage(url, alt, imageWidthPercent) url为图片路径,alt为图片下方显示的说明文字,暂时不支持,imageWidthPercent为图片宽度占一屏幕的百分比,默认为100
re.setTextColor(color) 设置字体颜色
re.setTextBackgroundColor(color) 设置字体背景颜色
re.moveToEndEdit() 使用场景一般为要编辑某段富文本的时候,刚进入页面的时候,光标要显示到最后,并且编辑框的内容也要滑动到底部, 需要注意的是,刚进入页面的时候马上调用此方法可能会无效,因为页面还没有渲染好 最好延时几百毫秒后调用

Extension points exported contracts — how you extend this code

OnTextChangeListener (Interface)
(no doc)
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
OnDecorationStateListener (Interface)
(no doc)
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
AfterInitialLoadListener (Interface)
(no doc)
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java

Core symbols most depended-on inside this repo

exec
called by 60
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
queryCommandState
called by 14
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
setTextBackgroundColor
called by 4
richeditor/src/main/java/cn/qzb/richeditor/RE.kt
getHtml
called by 3
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
focusEditor
called by 3
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
convertHexColorString
called by 3
richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java
getComputedStyleProperty
called by 2
richeditor/src/main/assets/rich_editor.js
colorRGB2Hex
called by 2
richeditor/src/main/assets/rich_editor.js

Shape

Method 107
Class 8
Function 3
Interface 3
Enum 1

Languages

Java66%
Kotlin31%
TypeScript2%

Modules by API surface

richeditor/src/main/java/cn/qzb/richeditor/RichEditor.java75 symbols
richeditor/src/main/java/cn/qzb/richeditor/RE.kt19 symbols
app/src/main/java/com/qinzb/qrichtext/MainActivity.kt10 symbols
richeditor/src/main/java/cn/qzb/richeditor/Utils.java6 symbols
app/src/main/java/com/qinzb/qrichtext/PreviewActivity.kt5 symbols
richeditor/src/main/assets/rich_editor.js3 symbols
app/src/test/java/com/qinzb/qrichtext/ExampleUnitTest.kt2 symbols
app/src/androidTest/java/com/qinzb/qrichtext/ExampleInstrumentedTest.kt2 symbols

For agents

$ claude mcp add QRichText \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact