mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-12-12 19:58:05 +00:00
Create setting for default type of draft tiddlers (#8783)
* Proof of concept to change type of tiddlers created by editing missing. * Adding a setting for default type so that it can be overridden for other wikis. * Incorporating PR feedback. * Adding documentation tiddler for new setting. * Added documentation to the markdown plugin documentation. * Added documentation to the markdown plugin documentation. * Added notice to markdown edition.
This commit is contained in:
committed by
GitHub
parent
dabbc1bacc
commit
81a972dc46
@@ -277,6 +277,8 @@ NavigatorWidget.prototype.makeDraftTiddler = function(targetTitle) {
|
|||||||
}
|
}
|
||||||
// Get the current value of the tiddler we're editing
|
// Get the current value of the tiddler we're editing
|
||||||
var tiddler = this.wiki.getTiddler(targetTitle);
|
var tiddler = this.wiki.getTiddler(targetTitle);
|
||||||
|
var defaultType = this.wiki.getTiddlerText("$:/config/DefaultMissingType", "").trim();
|
||||||
|
var defaultFields = { type: defaultType };
|
||||||
// Save the initial value of the draft tiddler
|
// Save the initial value of the draft tiddler
|
||||||
draftTitle = this.generateDraftTitle(targetTitle);
|
draftTitle = this.generateDraftTitle(targetTitle);
|
||||||
var draftTiddler = new $tw.Tiddler({
|
var draftTiddler = new $tw.Tiddler({
|
||||||
@@ -288,7 +290,8 @@ NavigatorWidget.prototype.makeDraftTiddler = function(targetTitle) {
|
|||||||
"draft.title": targetTitle,
|
"draft.title": targetTitle,
|
||||||
"draft.of": targetTitle
|
"draft.of": targetTitle
|
||||||
},
|
},
|
||||||
this.wiki.getModificationFields()
|
this.wiki.getModificationFields(),
|
||||||
|
tiddler === null || tiddler === undefined ? defaultFields : {}
|
||||||
);
|
);
|
||||||
this.wiki.addTiddler(draftTiddler);
|
this.wiki.addTiddler(draftTiddler);
|
||||||
return draftTiddler;
|
return draftTiddler;
|
||||||
|
|||||||
3
editions/markdowndemo/tiddlers/DefaultMissingType.tid
Normal file
3
editions/markdowndemo/tiddlers/DefaultMissingType.tid
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
title: $:/config/DefaultMissingType
|
||||||
|
|
||||||
|
text/markdown
|
||||||
@@ -7,3 +7,9 @@ This is a demo of TiddlyWiki5 incorporating a plugin for parsing tiddlers writte
|
|||||||
To add the plugin to your own TiddlyWiki5, just drag this link to the browser window:
|
To add the plugin to your own TiddlyWiki5, just drag this link to the browser window:
|
||||||
|
|
||||||
[[$:/plugins/tiddlywiki/markdown]]
|
[[$:/plugins/tiddlywiki/markdown]]
|
||||||
|
|
||||||
|
! Overridden Defaults
|
||||||
|
|
||||||
|
This demo overrides the default value for tiddlers created from missing tiddler
|
||||||
|
links so that Markdown is the default rather than WikiText. See
|
||||||
|
the [[$:/config/DefaultMissingType]] tiddler for the modification.
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
tags: [[Hidden Settings]]
|
||||||
|
title: Hidden Setting: Default-Missing Type
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
By default new tiddlers are created with a blank content type.
|
||||||
|
|
||||||
|
The hidden setting in $:/config/DefaultMissingType can be set to another content type which is used by default for new tiddlers created by clicking on a missing link (for example, `text/markdown` to default to Markdown for missing tiddlers). If no value is provided, the content type will be blank and WikiText will be used.
|
||||||
@@ -99,3 +99,21 @@ When [[typographer|$:/config/markdown/typographer]] is enabled, markdown-it will
|
|||||||
-- → –
|
-- → –
|
||||||
--- → —
|
--- → —
|
||||||
```
|
```
|
||||||
|
|
||||||
|
! Making Markdown the Default in TiddlyWiki
|
||||||
|
|
||||||
|
!! Modifying Existing Actions
|
||||||
|
|
||||||
|
Adding `type="text/markdown"` to the actions of the following buttons will
|
||||||
|
override the default behavior.
|
||||||
|
|
||||||
|
* New Journal - $:/core/ui/Actions/new-journal
|
||||||
|
* New Tiddler Here - $:/core/ui/Buttons/new-here
|
||||||
|
* New Tiddler - $:/core/ui/Actions/new-tiddler
|
||||||
|
|
||||||
|
!! Using Markdown for Missing Links
|
||||||
|
|
||||||
|
By default, missing tiddlers are created with a blank content type, which
|
||||||
|
implies WikiText. Setting [[$:/config/DefaultMissingType]] to `text/markdown`
|
||||||
|
will make it so that tiddlers created from a missing tiddler link will be in
|
||||||
|
Markdown rather than in WikiText.
|
||||||
|
|||||||
Reference in New Issue
Block a user