mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 05:46:10 +01:00
WIP authentication with flask-login, restructuring of static files
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
.ext-databasic {
|
||||
position: relative;
|
||||
display: block;
|
||||
min-height: 50px;
|
||||
background-color: cyan;
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
border: 1px solid white;
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.ext-databasic p {
|
||||
color: white;
|
||||
font-size: 1.2em;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -0,0 +1,303 @@
|
||||
(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 ($) {
|
||||
|
||||
// pull in some summernote core functions
|
||||
var ui = $.summernote.ui;
|
||||
var dom = $.summernote.dom;
|
||||
|
||||
// define the popover plugin
|
||||
var DataBasicPlugin = function (context) {
|
||||
var self = this;
|
||||
var options = context.options;
|
||||
var lang = options.langInfo;
|
||||
|
||||
self.icon = '<i class="fa fa-object-group"/>';
|
||||
|
||||
// add context menu button for dialog
|
||||
context.memo('button.databasic', function () {
|
||||
return ui.button({
|
||||
contents: self.icon,
|
||||
tooltip: lang.databasic.insert,
|
||||
click: context.createInvokeHandler('databasic.showDialog')
|
||||
}).render();
|
||||
});
|
||||
|
||||
// add popover edit button
|
||||
context.memo('button.databasicDialog', function () {
|
||||
return ui.button({
|
||||
contents: self.icon,
|
||||
tooltip: lang.databasic.edit,
|
||||
click: context.createInvokeHandler('databasic.showDialog')
|
||||
}).render();
|
||||
});
|
||||
|
||||
// add popover size buttons
|
||||
context.memo('button.databasicSize100', function () {
|
||||
return ui.button({
|
||||
contents: '<span class="note-fontsize-10">100%</span>',
|
||||
tooltip: lang.image.resizeFull,
|
||||
click: context.createInvokeHandler('editor.resize', '1')
|
||||
}).render();
|
||||
});
|
||||
context.memo('button.databasicSize50', function () {
|
||||
return ui.button({
|
||||
contents: '<span class="note-fontsize-10">50%</span>',
|
||||
tooltip: lang.image.resizeHalf,
|
||||
click: context.createInvokeHandler('editor.resize', '0.5')
|
||||
}).render();
|
||||
});
|
||||
context.memo('button.databasicSize25', function () {
|
||||
return ui.button({
|
||||
contents: '<span class="note-fontsize-10">25%</span>',
|
||||
tooltip: lang.image.resizeQuarter,
|
||||
click: context.createInvokeHandler('editor.resize', '0.25')
|
||||
}).render();
|
||||
});
|
||||
|
||||
self.events = {
|
||||
'summernote.init': function (we, e) {
|
||||
// update existing containers
|
||||
$('data.ext-databasic', e.editable).each(function () { self.setContent($(this)); });
|
||||
// TODO: make this an undo snapshot...
|
||||
},
|
||||
'summernote.keyup summernote.mouseup summernote.change summernote.scroll': function () {
|
||||
self.update();
|
||||
},
|
||||
'summernote.dialog.shown': function () {
|
||||
self.hidePopover();
|
||||
}
|
||||
};
|
||||
|
||||
self.initialize = function () {
|
||||
// create dialog markup
|
||||
var $container = options.dialogsInBody ? $(document.body) : context.layoutInfo.editor;
|
||||
|
||||
var body = '<div class="form-group row-fluid">' +
|
||||
'<label>' + lang.databasic.testLabel + '</label>' +
|
||||
'<input class="ext-databasic-test form-control" type="text" />' +
|
||||
'</div>';
|
||||
var footer = '<button href="#" class="btn btn-primary ext-databasic-save">' + lang.databasic.insert + '</button>';
|
||||
|
||||
self.$dialog = ui.dialog({
|
||||
title: lang.databasic.name,
|
||||
fade: options.dialogsFade,
|
||||
body: body,
|
||||
footer: footer
|
||||
}).render().appendTo($container);
|
||||
|
||||
// create popover
|
||||
self.$popover = ui.popover({
|
||||
className: 'ext-databasic-popover'
|
||||
}).render().appendTo('body');
|
||||
var $content = self.$popover.find('.popover-content');
|
||||
|
||||
context.invoke('buttons.build', $content, options.popover.databasic);
|
||||
};
|
||||
|
||||
self.destroy = function () {
|
||||
self.$popover.remove();
|
||||
self.$popover = null;
|
||||
self.$dialog.remove();
|
||||
self.$dialog = null;
|
||||
};
|
||||
|
||||
self.update = function () {
|
||||
// Prevent focusing on editable when invoke('code') is executed
|
||||
if (!context.invoke('editor.hasFocus')) {
|
||||
self.hidePopover();
|
||||
return;
|
||||
}
|
||||
|
||||
var rng = context.invoke('editor.createRange');
|
||||
var visible = false;
|
||||
|
||||
if (rng.isOnData())
|
||||
{
|
||||
var $data = $(rng.sc).closest('data.ext-databasic');
|
||||
|
||||
if ($data.length)
|
||||
{
|
||||
var pos = dom.posFromPlaceholder($data[0]);
|
||||
|
||||
self.$popover.css({
|
||||
display: 'block',
|
||||
left: pos.left,
|
||||
top: pos.top
|
||||
});
|
||||
|
||||
// save editor target to let size buttons resize the container
|
||||
context.invoke('editor.saveTarget', $data[0]);
|
||||
|
||||
visible = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// hide if not visible
|
||||
if (!visible) {
|
||||
self.hidePopover();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
self.hidePopover = function () {
|
||||
self.$popover.hide();
|
||||
};
|
||||
|
||||
// define plugin dialog
|
||||
self.getInfo = function () {
|
||||
var rng = context.invoke('editor.createRange');
|
||||
|
||||
if (rng.isOnData())
|
||||
{
|
||||
var $data = $(rng.sc).closest('data.ext-databasic');
|
||||
|
||||
if ($data.length)
|
||||
{
|
||||
// Get the first node on range(for edit).
|
||||
return {
|
||||
node: $data,
|
||||
test: $data.attr('data-test')
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
self.setContent = function ($node) {
|
||||
$node.html('<p contenteditable="false">' + self.icon + ' ' + lang.databasic.name + ': ' +
|
||||
$node.attr('data-test') + '</p>');
|
||||
};
|
||||
|
||||
self.updateNode = function (info) {
|
||||
self.setContent(info.node
|
||||
.attr('data-test', info.test));
|
||||
};
|
||||
|
||||
self.createNode = function (info) {
|
||||
var $node = $('<data class="ext-databasic"></data>');
|
||||
|
||||
if ($node) {
|
||||
// save node to info structure
|
||||
info.node = $node;
|
||||
// insert node into editor dom
|
||||
context.invoke('editor.insertNode', $node[0]);
|
||||
}
|
||||
|
||||
return $node;
|
||||
};
|
||||
|
||||
self.showDialog = function () {
|
||||
var info = self.getInfo();
|
||||
var newNode = !info.node;
|
||||
context.invoke('editor.saveRange');
|
||||
|
||||
self
|
||||
.openDialog(info)
|
||||
.then(function (dialogInfo) {
|
||||
// [workaround] hide dialog before restore range for IE range focus
|
||||
ui.hideDialog(self.$dialog);
|
||||
context.invoke('editor.restoreRange');
|
||||
|
||||
// insert a new node
|
||||
if (newNode)
|
||||
{
|
||||
self.createNode(info);
|
||||
}
|
||||
|
||||
// update info with dialog info
|
||||
$.extend(info, dialogInfo);
|
||||
|
||||
self.updateNode(info);
|
||||
})
|
||||
.fail(function () {
|
||||
context.invoke('editor.restoreRange');
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
self.openDialog = function (info) {
|
||||
return $.Deferred(function (deferred) {
|
||||
var $inpTest = self.$dialog.find('.ext-databasic-test');
|
||||
var $saveBtn = self.$dialog.find('.ext-databasic-save');
|
||||
var onKeyup = function (event) {
|
||||
if (event.keyCode === 13)
|
||||
{
|
||||
$saveBtn.trigger('click');
|
||||
}
|
||||
};
|
||||
|
||||
ui.onDialogShown(self.$dialog, function () {
|
||||
context.triggerEvent('dialog.shown');
|
||||
|
||||
$inpTest.val(info.test).on('input', function () {
|
||||
ui.toggleBtn($saveBtn, $inpTest.val());
|
||||
}).trigger('focus').on('keyup', onKeyup);
|
||||
|
||||
$saveBtn
|
||||
.text(info.node ? lang.databasic.edit : lang.databasic.insert)
|
||||
.click(function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
deferred.resolve({ test: $inpTest.val() });
|
||||
});
|
||||
|
||||
// init save button
|
||||
ui.toggleBtn($saveBtn, $inpTest.val());
|
||||
});
|
||||
|
||||
ui.onDialogHidden(self.$dialog, function () {
|
||||
$inpTest.off('input keyup');
|
||||
$saveBtn.off('click');
|
||||
|
||||
if (deferred.state() === 'pending') {
|
||||
deferred.reject();
|
||||
}
|
||||
});
|
||||
|
||||
ui.showDialog(self.$dialog);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
// Extends summernote
|
||||
$.extend(true, $.summernote, {
|
||||
plugins: {
|
||||
databasic: DataBasicPlugin
|
||||
},
|
||||
|
||||
options: {
|
||||
popover: {
|
||||
databasic: [
|
||||
['databasic', ['databasicDialog', 'databasicSize100', 'databasicSize50', 'databasicSize25']]
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// add localization texts
|
||||
lang: {
|
||||
'en-US': {
|
||||
databasic: {
|
||||
name: 'Basic Data Container',
|
||||
insert: 'insert basic data container',
|
||||
edit: 'edit basic data container',
|
||||
testLabel: 'test input'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}));
|
||||
1
static/lib/summernote/plugin/databasic/summernote-ext-databasic.min.css
vendored
Normal file
1
static/lib/summernote/plugin/databasic/summernote-ext-databasic.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.ext-databasic{position:relative;display:block;min-height:50px;padding:20px;text-align:center;background-color:cyan;border:1px solid white;border-radius:10px}.ext-databasic p{margin:0;font-size:1.2em;color:white}
|
||||
3
static/lib/summernote/plugin/databasic/summernote-ext-databasic.min.js
vendored
Normal file
3
static/lib/summernote/plugin/databasic/summernote-ext-databasic.min.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/*! Summernote v0.8.4 | (c) 2013- Alan Hong and other contributors | MIT license */
|
||||
|
||||
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(window.jQuery)}(function(a){var b=a.summernote.ui,c=a.summernote.dom,d=function(d){var e=this,f=d.options,g=f.langInfo;e.icon='<i class="fa fa-object-group"/>',d.memo("button.databasic",function(){return b.button({contents:e.icon,tooltip:g.databasic.insert,click:d.createInvokeHandler("databasic.showDialog")}).render()}),d.memo("button.databasicDialog",function(){return b.button({contents:e.icon,tooltip:g.databasic.edit,click:d.createInvokeHandler("databasic.showDialog")}).render()}),d.memo("button.databasicSize100",function(){return b.button({contents:'<span class="note-fontsize-10">100%</span>',tooltip:g.image.resizeFull,click:d.createInvokeHandler("editor.resize","1")}).render()}),d.memo("button.databasicSize50",function(){return b.button({contents:'<span class="note-fontsize-10">50%</span>',tooltip:g.image.resizeHalf,click:d.createInvokeHandler("editor.resize","0.5")}).render()}),d.memo("button.databasicSize25",function(){return b.button({contents:'<span class="note-fontsize-10">25%</span>',tooltip:g.image.resizeQuarter,click:d.createInvokeHandler("editor.resize","0.25")}).render()}),e.events={"summernote.init":function(b,c){a("data.ext-databasic",c.editable).each(function(){e.setContent(a(this))})},"summernote.keyup summernote.mouseup summernote.change summernote.scroll":function(){e.update()},"summernote.dialog.shown":function(){e.hidePopover()}},e.initialize=function(){var c=f.dialogsInBody?a(document.body):d.layoutInfo.editor,h='<div class="form-group row-fluid"><label>'+g.databasic.testLabel+'</label><input class="ext-databasic-test form-control" type="text" /></div>',i='<button href="#" class="btn btn-primary ext-databasic-save">'+g.databasic.insert+"</button>";e.$dialog=b.dialog({title:g.databasic.name,fade:f.dialogsFade,body:h,footer:i}).render().appendTo(c),e.$popover=b.popover({className:"ext-databasic-popover"}).render().appendTo("body");var j=e.$popover.find(".popover-content");d.invoke("buttons.build",j,f.popover.databasic)},e.destroy=function(){e.$popover.remove(),e.$popover=null,e.$dialog.remove(),e.$dialog=null},e.update=function(){if(!d.invoke("editor.hasFocus"))return void e.hidePopover();var b=d.invoke("editor.createRange"),f=!1;if(b.isOnData()){var g=a(b.sc).closest("data.ext-databasic");if(g.length){var h=c.posFromPlaceholder(g[0]);e.$popover.css({display:"block",left:h.left,top:h.top}),d.invoke("editor.saveTarget",g[0]),f=!0}}f||e.hidePopover()},e.hidePopover=function(){e.$popover.hide()},e.getInfo=function(){var b=d.invoke("editor.createRange");if(b.isOnData()){var c=a(b.sc).closest("data.ext-databasic");if(c.length)return{node:c,test:c.attr("data-test")}}return{}},e.setContent=function(a){a.html('<p contenteditable="false">'+e.icon+" "+g.databasic.name+": "+a.attr("data-test")+"</p>")},e.updateNode=function(a){e.setContent(a.node.attr("data-test",a.test))},e.createNode=function(b){var c=a('<data class="ext-databasic"></data>');return c&&(b.node=c,d.invoke("editor.insertNode",c[0])),c},e.showDialog=function(){var c=e.getInfo(),f=!c.node;d.invoke("editor.saveRange"),e.openDialog(c).then(function(g){b.hideDialog(e.$dialog),d.invoke("editor.restoreRange"),f&&e.createNode(c),a.extend(c,g),e.updateNode(c)}).fail(function(){d.invoke("editor.restoreRange")})},e.openDialog=function(c){return a.Deferred(function(a){var f=e.$dialog.find(".ext-databasic-test"),h=e.$dialog.find(".ext-databasic-save"),i=function(a){13===a.keyCode&&h.trigger("click")};b.onDialogShown(e.$dialog,function(){d.triggerEvent("dialog.shown"),f.val(c.test).on("input",function(){b.toggleBtn(h,f.val())}).trigger("focus").on("keyup",i),h.text(c.node?g.databasic.edit:g.databasic.insert).click(function(b){b.preventDefault(),a.resolve({test:f.val()})}),b.toggleBtn(h,f.val())}),b.onDialogHidden(e.$dialog,function(){f.off("input keyup"),h.off("click"),"pending"===a.state()&&a.reject()}),b.showDialog(e.$dialog)})}};a.extend(!0,a.summernote,{plugins:{databasic:d},options:{popover:{databasic:[["databasic",["databasicDialog","databasicSize100","databasicSize50","databasicSize25"]]]}},lang:{"en-US":{databasic:{name:"Basic Data Container",insert:"insert basic data container",edit:"edit basic data container",testLabel:"test input"}}}})});
|
||||
Reference in New Issue
Block a user