mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-17 23:34:50 +00:00
Introduced widget base class
And renamed the wiki rule base class
This commit is contained in:
parent
2522529aac
commit
94d1c20846
@ -1,5 +1,5 @@
|
||||
/*\
|
||||
title: $:/core/modules/parsers/wikiparser/rules/wikirule.js
|
||||
title: $:/core/modules/parsers/wikiparser/rules/wikirulebase.js
|
||||
type: application/javascript
|
||||
module-type: global
|
||||
|
||||
@ -15,25 +15,25 @@ Base class for wiki parser rules
|
||||
/*
|
||||
This constructor is always overridden with a blank constructor, and so shouldn't be used
|
||||
*/
|
||||
var WikiRule = function() {
|
||||
var WikiRuleBase = function() {
|
||||
};
|
||||
|
||||
/*
|
||||
To be overridden by individual rules
|
||||
*/
|
||||
WikiRule.prototype.init = function(parser) {
|
||||
WikiRuleBase.prototype.init = function(parser) {
|
||||
this.parser = parser;
|
||||
};
|
||||
|
||||
/*
|
||||
Default implementation of findNextMatch uses RegExp matching
|
||||
*/
|
||||
WikiRule.prototype.findNextMatch = function(startPos) {
|
||||
WikiRuleBase.prototype.findNextMatch = function(startPos) {
|
||||
this.matchRegExp.lastIndex = startPos;
|
||||
this.match = this.matchRegExp.exec(this.parser.source);
|
||||
return this.match ? this.match.index : undefined;
|
||||
};
|
||||
|
||||
exports.WikiRule = WikiRule;
|
||||
exports.WikiRuleBase = WikiRuleBase;
|
||||
|
||||
})();
|
30
core/modules/widgetbase.js
Normal file
30
core/modules/widgetbase.js
Normal file
@ -0,0 +1,30 @@
|
||||
/*\
|
||||
title: $:/core/modules/widgetbase.js
|
||||
type: application/javascript
|
||||
module-type: global
|
||||
|
||||
Base class for widgets
|
||||
|
||||
\*/
|
||||
(function(){
|
||||
|
||||
/*jslint node: true, browser: true */
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
This constructor is always overridden with a blank constructor, and so shouldn't be used
|
||||
*/
|
||||
var WidgetBase = function() {
|
||||
};
|
||||
|
||||
/*
|
||||
To be overridden by individual widgets
|
||||
*/
|
||||
WidgetBase.prototype.init = function(renderer) {
|
||||
this.renderer = renderer;
|
||||
};
|
||||
|
||||
exports.WidgetBase = WidgetBase;
|
||||
|
||||
})();
|
@ -13,13 +13,13 @@ module-type: global
|
||||
var WikiVocabulary = function(options) {
|
||||
this.wiki = options.wiki;
|
||||
// Hashmaps of the various parse rule classes
|
||||
this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRule);
|
||||
this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRule);
|
||||
this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRule);
|
||||
this.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikipragmarule",$tw.WikiRuleBase);
|
||||
this.blockRuleClasses = $tw.modules.createClassesFromModules("wikiblockrule",$tw.WikiRuleBase);
|
||||
this.runRuleClasses = $tw.modules.createClassesFromModules("wikirunrule",$tw.WikiRuleBase);
|
||||
// Hashmap of the various renderer classes
|
||||
this.rendererClasses = $tw.modules.applyMethods("wikirenderer");
|
||||
// Hashmap of the available widgets
|
||||
this.widgetClasses = $tw.modules.createClassesFromModules("widget");
|
||||
this.widgetClasses = $tw.modules.createClassesFromModules("widget",$tw.WidgetBase);
|
||||
};
|
||||
|
||||
WikiVocabulary.prototype.parseText = function(type,text) {
|
||||
|
Loading…
Reference in New Issue
Block a user