MCPcopy Create free account
hub / github.com/TruthHun/BookStack / _handle

Function _handle

static/wangEditor/js/wangEditor.js:808–846  ·  view source on GitHub ↗
(editor, data, type)

Source from the content-addressed store, hash-verified

806
807 // 数据处理
808 function _handle(editor, data, type) {
809 // var range = data.range;
810 // var range2 = range.cloneRange && range.cloneRange();
811 var val = data.val;
812 var html = editor.txt.$txt.html();
813
814 if(val == null) {
815 return;
816 }
817
818 if (val === html) {
819 if (type === 'redo') {
820 editor.redo();
821 return;
822 } else if (type === 'undo') {
823 editor.undo();
824 return;
825 } else {
826 return;
827 }
828 }
829
830 // 保存数据
831 editor.txt.$txt.html(val);
832 // 更新数据到textarea(有必要的话)
833 editor.updateValue();
834
835 // onchange 事件
836 if (editor.onchange && typeof editor.onchange === 'function') {
837 editor.onchange.call(editor);
838 }
839
840 // ?????
841 // 注释:$txt 被重新赋值之后,range会被重置,cloneRange() 也不好使
842 // // 重置选区
843 // if (range2) {
844 // editor.restoreSelection(range2);
845 // }
846 }
847
848 // 记录
849 E.fn.undoRecord = function () {

Callers 1

wangEditor.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected