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

Function bindToolbarEvent

static/wangEditor/js/wangEditor.js:7731–7925  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7729
7730 // 绑定toolbar事件
7731 function bindToolbarEvent() {
7732 // 统一执行命令的方法
7733 var commandFn;
7734 function customCommand(e, callback) {
7735 var cb;
7736 // 记录下执行命令之前的html内容
7737 html = $txt.html();
7738 cb = function () {
7739 if (callback) {
7740 callback();
7741 }
7742 if (html !== $txt.html()) {
7743 $txt.change();
7744 }
7745 };
7746 // 执行命令
7747 if (commandFn) {
7748 editor.customCommand(e, commandFn, cb);
7749 }
7750 }
7751
7752 // 删除
7753 $delete.click(function (e) {
7754 // 删除之前先unlink
7755 imgLink(e, '');
7756
7757 // 删除图片
7758 commandFn = function () {
7759 $currentImg.remove();
7760 };
7761 customCommand(e, function () {
7762 setTimeout(hide, 100);
7763 });
7764 });
7765
7766 // 放大
7767 $zoomBig.click(function (e) {
7768 commandFn = function () {
7769 var img = $currentImg.get(0);
7770 var width = img.width;
7771 var height = img.height;
7772 width = width * 1.1;
7773 height = height * 1.1;
7774
7775 $currentImg.css({
7776 width: width + 'px',
7777 height: height + 'px'
7778 });
7779 };
7780 customCommand(e, function () {
7781 setTimeout(show);
7782 });
7783 });
7784
7785 // 缩小
7786 $zoomSmall.click(function (e) {
7787 commandFn = function () {
7788 var img = $currentImg.get(0);

Callers 1

renderFunction · 0.85

Calls 3

imgLinkFunction · 0.85
customCommandFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected