mirror of
https://github.com/Jermolene/TiddlyWiki5.git
synced 2026-01-30 12:23:10 -08:00
Make Excision Available for Markdown (#8498)
* Updates to make Excision more friendly to Markdown users by adding Markdown as an option in the criteria to use excision and by making the excise operation reuse the type of the tiddler being excised. * Updated excise operation to use Markdown syntax for links.
This commit is contained in:
parent
40138beac4
commit
a960e4f658
2 changed files with 10 additions and 3 deletions
|
|
@ -12,9 +12,14 @@ Text editor operation to excise the selection to a new tiddler
|
|||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
function isMarkdown(mediaType) {
|
||||
return mediaType === 'text/markdown' || mediatype === 'text/x-markdown';
|
||||
}
|
||||
|
||||
exports["excise"] = function(event,operation) {
|
||||
var editTiddler = this.wiki.getTiddler(this.editTitle),
|
||||
editTiddlerTitle = this.editTitle,
|
||||
wikiLinks = !isMarkdown(editTiddler.fields.type),
|
||||
excisionBaseTitle = $tw.language.getString("Buttons/Excise/DefaultTitle");
|
||||
if(editTiddler && editTiddler.fields["draft.of"]) {
|
||||
editTiddlerTitle = editTiddler.fields["draft.of"];
|
||||
|
|
@ -26,7 +31,8 @@ exports["excise"] = function(event,operation) {
|
|||
{
|
||||
title: excisionTitle,
|
||||
text: operation.selection,
|
||||
tags: event.paramObject.tagnew === "yes" ? [editTiddlerTitle] : []
|
||||
tags: event.paramObject.tagnew === "yes" ? [editTiddlerTitle] : [],
|
||||
type: editTiddler.fields.type
|
||||
}
|
||||
));
|
||||
operation.replacement = excisionTitle;
|
||||
|
|
@ -35,7 +41,8 @@ exports["excise"] = function(event,operation) {
|
|||
operation.replacement = "{{" + operation.replacement+ "}}";
|
||||
break;
|
||||
case "link":
|
||||
operation.replacement = "[[" + operation.replacement+ "]]";
|
||||
operation.replacement = wikiLinks ? "[[" + operation.replacement+ "]]"
|
||||
: ("[" + operation.replacement + "](<#" + operation.replacement + ">)");
|
||||
break;
|
||||
case "macro":
|
||||
operation.replacement = "<<" + (event.paramObject.macro || "translink") + " \"\"\"" + operation.replacement + "\"\"\">>";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ tags: $:/tags/EditorToolbar
|
|||
icon: $:/core/images/excise
|
||||
caption: {{$:/language/Buttons/Excise/Caption}}
|
||||
description: {{$:/language/Buttons/Excise/Hint}}
|
||||
condition: [<targetTiddler>type[]] [<targetTiddler>get[type]prefix[text/vnd.tiddlywiki]] +[first[]]
|
||||
condition: [<targetTiddler>type[]] [<targetTiddler>type[text/vnd.tiddlywiki]] [<targetTiddler>type[text/markdown]] [<targetTiddler>type[text/x-markdown]] +[first[]]
|
||||
shortcuts: ((excise))
|
||||
dropdown: $:/core/ui/EditorToolbar/excise-dropdown
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue