Added footnote support

This commit is contained in:
2016-03-06 23:25:13 +08:00
parent eda4250533
commit 041617f0b4
9 changed files with 228 additions and 8 deletions

View File

@@ -0,0 +1,3 @@
.v_boundary[data-type="Footnote"] {
color: #f15a24;
}

View File

@@ -0,0 +1,97 @@
(function ()
{
var ns = __namespace( "Astro.Blog.AstroEdit.Visualizer.Snippet" );
/** @type {System.utils.IKey} */
var IKey = __import( "System.utils.IKey" );
/** @type {System.utils.DataKey} */
var DataKey = __import( "System.utils.DataKey" );
/** @type {Dandelion.IDOMElement} */
var IDOMElement = __import( "Dandelion.IDOMElement" );
/** @type {Dandelion} */
var Dand = __import( "Dandelion" );
/** @type {Components.MessageBox} */
var MessageBox = __import( "Components.MessageBox" );
var escapeStr = ns[ NS_INVOKE ]( "escapeStr" );
var footnote = function (insertSnippet, snippetWrap, createContext, override)
{
var temp, i, j
, handler = function ()
{
// Input fields
var v_snippetInput = Dand.wrap( "textarea", null, "v_snippet_input" );
if ( this._stage )
{
v_snippetInput.value = this._mText;
}
// Popup MessageBox
new MessageBox(
"Insert Footnote"
, v_snippetInput
, "OK", "Cancel"
, visualizer.bind({ mText: v_snippetInput, stage: this._stage })
).show();
}
, visualizer = function (submitted, override)
{
var mText, stage = this.stage;
mText = override ? override.value : this.mText.value;
if (submitted && mText)
{
if (!stage)
{
// Visualize component
temp = Dand.wrapne( "span", "^", [
new DataKey( "value", mText )
]);
insertSnippet(
j = snippetWrap( "Footnote", temp, false, "span" )
, Boolean( override )
);
}
else
{
IDOMElement( stage ).setAttribute(new DataKey( "value", mText ));
temp = stage;
}
i = { _mText: mText, _stage: temp };
// Set context menu
createContext( i, j, handler );
}
};
if ( override )
{
visualizer( true, override );
override = false;
}
else
{
return handler;
}
return true;
};
var compile = function (stage)
{
// [footnote][/footnote]
return "[footnote]" + escapeStr( IDOMElement(stage).getDAttribute("value") ) + "[/footnote]";
};
__static_method( footnote, "compile", compile );
ns[ NS_EXPORT ]( EX_CLASS, "Footnote", footnote );
})();