ProseMirror / prosemirror

The ProseMirror WYSIWYM editor
http://prosemirror.net/
MIT License
7.59k stars 335 forks source link

edit link with chinese will insert unexpected character in Chrome #1408

Open monologueH opened 1 year ago

monologueH commented 1 year ago

@marijnh excuse me, i'd like to edit link in prosemirror editor. when i select the last characters and input chinese using sougouInput or mac default Input.it apears incorrect result.

platform:(chrome is incorrect)

steps:

  1. a link like this : www.baidu.com
  2. create a selection eg. select .com
  3. use shougouInput and input sss , it actualy set four s in the editor

you can repetition this using the prosemirror-example-setup. below is my test code using vue3.

<template>
  <div>
    <div id="editor2" style="margin-bottom: 23px"></div>
    <div style="display: none" id="content2">
      <h3>Hello ProseMirror</h3>
      <a href="www.baidu.com">www.baidu.com</a>
    </div>
  </div>
</template>
<script setup lang="ts">
import { EditorState } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
import { Schema, DOMParser } from "prosemirror-model";
import { schema } from "prosemirror-schema-basic";
import { exampleSetup } from "prosemirror-example-setup";
import { addListNodes } from "prosemirror-schema-list";
import { onMounted } from "vue";

onMounted(() => {
  const mySchema = new Schema({
    nodes: addListNodes(schema.spec.nodes, "paragraph block*", "block"),
    marks: schema.spec.marks,
  });

  console.log(document.querySelector("#content2"));
  new EditorView(document.querySelector("#editor2"), {
    state: EditorState.create({
      doc: DOMParser.fromSchema(mySchema).parse(
        document.querySelector("#content2") as Node
      ),
      plugins: exampleSetup({ schema: mySchema, menuBar: false }),
    }),
  });
});
</script>
<style scoped>
.rich-editor {
  padding: 20px;
  width: 800px;
}

#editor2 {
  width: 800px;
  height: 200px;
  border: 1px #aaa solid;
  overflow: auto;
}
</style>

https://github.com/ProseMirror/prosemirror/assets/30610963/7a84cc72-0fb0-4887-8dea-8bb54bd77986