Giter Site home page Giter Site logo

Checkbox state about richeditor-android HOT 3 OPEN

tised avatar tised commented on June 11, 2024
Checkbox state

from richeditor-android.

Comments (3)

tised avatar tised commented on June 11, 2024

Just pinging here, as it quite serious issue for us

from richeditor-android.

tised avatar tised commented on June 11, 2024

Ping again :)

from richeditor-android.

Hongyang666 avatar Hongyang666 commented on June 11, 2024

对源码做如下修改:

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="user-scalable=no">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="normalize.css">
    <link rel="stylesheet" type="text/css" href="style.css">
    <link rel="stylesheet" type="text/css" href="checkbox_style.css">
</head>
<body>
<div id="editor" contenteditable="true"></div>
<script type="text/javascript" src="rich_editor.js"></script>
</body>
</html>

checkbox_style.css

input[type=checkbox] {
    cursor: pointer;
    position: relative;
}

input[type=checkbox]:not([class=checkbox-checked]):after {
    position: absolute;
    top: 0;
    background-color: white;
    width: 18px;
    height: 18px;
    display: inline-block;
    visibility: visible;
    padding-left: 0px;
    text-align: center;
    content: '';
    border-radius: 2px;
    box-sizing: border-box;
    border: 1px solid #ddd;
}

.checkbox-checked::after {
    position: absolute;
    top: 0;
    background-color: blue;
    width: 18px;
    height: 18px;
    display: inline-block;
    visibility: visible;
    padding-left: 0px;
    text-align: center;
    content: '';
    border-radius: 2px;
    box-sizing: border-box;
    border: 1px solid #ddd;
}

/**选中对号样式*/
.checkbox-checked::before {
    content: '';
    position: absolute;
    top: 1px;
    left: 6px;
    width: 4px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    z-index: 1;
}

rich_editor.js 最后面添加

// 复选框点击事件
RE.editor.addEventListener("click", function(ev){
    var target = ev.target || ev.srcElement;
    if(target.nodeName.toLowerCase() == 'input' && target.type == 'checkbox'){
        if(target.className == 'checkbox-checked'){
            target.removeAttribute("class");
        }else {
            target.className = 'checkbox-checked';
        }
    }
});

from richeditor-android.

Related Issues (20)

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.