CKEditor在textarea

时间:2016-04-08 01:49:04

标签: javascript ckeditor

TinyMCE有一个选项,允许您在编辑器中创建项目不可编辑,但我找不到任何类似的CKEditor。有没有办法让编辑器中的元素不可编辑?

2 个答案:

答案 0 :(得分:1)

您可以像这样更改配置:

public class MainActivity extends AppCompatActivity {

    String message;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button StrtBtn = (Button) findViewById(R.id.StartButton);
        Button StpBtn = (Button) findViewById(R.id.StopButton);

        // Start Button Click
        StrtBtn.setOnClickListener(
                new Button.OnClickListener() {
                    public void onClick(View v) {
                        message = "Start";
                        SendUdpMsg();
                    }
                }
        );

        // Stop Button Click
        StpBtn.setOnClickListener(
                new Button.OnClickListener() {
                    public void onClick(View v) {
                        message = "Stop";

                    }
                }
        );
    }

    public void SendUdpMsg()
    {
        Thread networkThread = new Thread() {

            // No local Host 127.0.0.1 in Android
            String host = "192.168.200.3"; // Server's IP
            int port = 15000;
            DatagramSocket dsocket = null;

            public void run() {
                try {
                    // Get the Internet address of the specified host
                    InetAddress address = InetAddress.getByName(host);

                    // wrap a packet
                    DatagramPacket packetToSend = new DatagramPacket(
                            message.getBytes(),
                            message.length(),
                            address, port);

                    // Create a datagram socket, send the packet through it.
                    dsocket = new DatagramSocket();
                    dsocket.send(packetToSend);

                    // Here, I am receiving the response
                    byte[] buffer = new byte[65535]; // prepare
                    DatagramPacket packetReceived = new DatagramPacket(buffer, buffer.length); // prepare

                    while (true)
                    {
                        if(message == "Start")
                        {
                            dsocket.receive(packetReceived); // receive packet
                            byte[] buff = packetReceived.getData(); // convert packet to byte[]
                            final String Response = new String(buffer, 0, packetReceived.getLength());

                            runOnUiThread(new Runnable()
                            {
                                @Override
                                public void run()
                                {
                                    // this is executed on the main (UI) thread
                                    final TextView TextOne = (TextView)findViewById(R.id.StatusText);
                                    TextOne.setText(Response);
                                }
                            });
                        }
                        else
                        {
                            // wrap a packet to send the Stop
                            packetToSend = new DatagramPacket(
                                    message.getBytes(),
                                    message.length(),
                                    address, port);

                            // Create a datagram socket, send the packet through it.
                            dsocket = new DatagramSocket();
                            dsocket.send(packetToSend);
                            break; // break the whole thread
                        }
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        };
        networkThread.start();
    }
}

您可以在config.readOnly = true; 中使用disabled属性。

请参阅此处的文档Read Only Mode

答案 1 :(得分:0)

您可以在元素上设置contenteditable='false',CKEditor会将其正确处理为只读。

工作在3.4 +,4也绝对有效,5也可能。

<强>参考: 此链接有相关信息[略有过时,但仍适用于核心概念]: (https://docs-old.ckeditor.com/CKeditor_3.x/Users_Guide/NonEditable_Contents