Giter Club home page Giter Club logo

Comments (2)

zlyi avatar zlyi commented on August 14, 2024 1

这是由于点击菜单栏触发的:handleToolbarIconClick事件中this.closeAllOpenDialog(state.icon);,会触发:

this.refs.image.toggle(function (e, html) {
					editarea.focus();
					EditorSelection.restoreRange();
					if (html && html.length > 0) {
						if (EditorSelection.range) {
							if (EditorSelection.range.pasteHTML) {
								EditorSelection.range.pasteHTML('<p>' + html + '</p>');
							} else {
								var p = EditorDOM.createNodeByTag('p', html);
								EditorSelection.range.deleteContents();
								EditorSelection.insertNode(p);
							}
							// EditorHistory.execCommand('inserthtml',false,html);
						} else {
							editarea.innerHTML += '<p>' + html + '</p>';
						}
					}
				});

其中EditorSelection.restoreRange();会清空this.range(光标所在位置),等真正确定上传插入图片后,this.range=null,自然是插入最后了。
目前的解决方案是:在事件执行时加入if (!e) { return },非正常点击插入图片,直接返回,完整代码:

this.refs.image.toggle(function (e, html) {
if (!e) { return }
					editarea.focus();
					EditorSelection.restoreRange();
					if (html && html.length > 0) {
						if (EditorSelection.range) {
							if (EditorSelection.range.pasteHTML) {
								EditorSelection.range.pasteHTML('<p>' + html + '</p>');
							} else {
								var p = EditorDOM.createNodeByTag('p', html);
								EditorSelection.range.deleteContents();
								EditorSelection.insertNode(p);
							}
							// EditorHistory.execCommand('inserthtml',false,html);
						} else {
							editarea.innerHTML += '<p>' + html + '</p>';
						}
					}
				});

@linruilin 可以尝试下

from react-umeditor.

linruilin avatar linruilin commented on August 14, 2024

好多地方插入都有问题基本都改了 后期更更新建议有统一判断

from react-umeditor.

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.