Created
November 8, 2016 13:45
-
-
Save mahmut-gundogdu/16ba2dcadea61d3043544d531859ee7c to your computer and use it in GitHub Desktop.
summernote note için örnek pluggin geliştirme örneği .Super simple wysiwyg editor v0.8.2 için test edilmiştir.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (factory) { | |
/* global define */ | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['jquery'], factory); | |
} else if (typeof module === 'object' && module.exports) { | |
// Node/CommonJS | |
module.exports = factory(require('jquery')); | |
} else { | |
// Browser globals | |
factory(window.jQuery); | |
} | |
}(function ($) { | |
$.extend($.summernote.plugins, { | |
//MgButton Ornek plugin adımız | |
'MgButton': function (context) { | |
var self = this; | |
var ui = $.summernote.ui; | |
//asıl işlevimizi bu blok içinde | |
var modal = $("#fileModal"); //örnek olarak modal acacahız | |
// toolbar için butonumuzu olusturuyoruz | |
context.memo('button.MgButton', function () { | |
var textarea = context.layoutInfo.editor.parent().find("textarea"); | |
var button = ui.button({ | |
contents: '<i class="fa fa-file"/> Dosya Seç', //bu bizim butonumuzun toolbardaki görünecek hali | |
click: function () { | |
if (modal.length) { | |
//cursor konumunu saklıyoruz | |
context.invoke('editor.saveRange'); | |
modal.modal('show');//sürek burada başlıyor | |
//Modalımızı kapatacak buton | |
$("#fileModal .btn-primary").click(function () { | |
//cursor konumunu geri yüklüyoruz. | |
context.invoke('editor.restoreRange'); | |
context.invoke('editor.focus'); | |
context.invoke('createLink', | |
{ | |
text: "bu bizim linkimizin başlığı modalda bir kontrolden veya db den alabiliriz o size kalmıs", | |
url: "http://mahmutgundogdu.wordpress.com",//linkimiz dbden veya modal içindeki bir kontrolden gelebilr tabi | |
newWindow: true //yeni pencerede acsn linki yani a href="_Blan" diyor. | |
}); | |
modal.modal('hide'); | |
//burada bitiyor | |
})//eof click; | |
} | |
} | |
}); | |
// create jQuery object from button instance. | |
return button.render(); | |
}); | |
//asıl işlevimizi bu blok içinde ve burada bitiyor. gerisi template,boilterplate ne derseniz. | |
// constructor gibi işlevi. | |
this.initialize = function () { | |
}; | |
// Class.Dispose gibi düşünün | |
this.destroy = function () { | |
}; | |
} | |
}); | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment