-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow intercept to widget and pass attributes
- Loading branch information
1 parent
4478f44
commit ba6d62e
Showing
1 changed file
with
48 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,48 @@ | ||
/*\ | ||
title: $:/core/modules/parsers/videoparser.js | ||
type: application/javascript | ||
module-type: parser | ||
The video parser parses a video tiddler into an embeddable HTML element | ||
\*/ | ||
(function(){ | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
var VideoParser = function(type,text,options) { | ||
var element = { | ||
type: "element", | ||
tag: "video", | ||
attributes: { | ||
controls: {type: "string", value: "controls"}, | ||
style: {type: "string", value: "width: 100%; object-fit: contain"} | ||
} | ||
}, | ||
src; | ||
if(options._canonical_uri) { | ||
element.attributes.src = {type: "string", value: options._canonical_uri}; | ||
} else if(text) { | ||
element.attributes.src = {type: "string", value: "data:" + type + ";base64," + text}; | ||
} | ||
this.tree = [element]; | ||
this.source = text; | ||
this.type = type; | ||
}; | ||
|
||
exports["video/ogg"] = VideoParser; | ||
exports["video/webm"] = VideoParser; | ||
exports["video/mp4"] = VideoParser; | ||
exports["video/quicktime"] = VideoParser; | ||
|
||
})(); | ||
/*\ | ||
title: $:/core/modules/parsers/videoparser.js | ||
type: application/javascript | ||
module-type: parser | ||
The video parser parses a video tiddler into an embeddable HTML element | ||
\*/ | ||
(function () { | ||
|
||
/*jslint node: true, browser: true */ | ||
/*global $tw: false */ | ||
"use strict"; | ||
|
||
var VideoParser = function (type, text, options) { | ||
var element = { | ||
type: "element", | ||
tag: "$video", // Changed to $video to enable widget interception | ||
attributes: { | ||
controls: { type: "string", value: "controls" }, | ||
style: { type: "string", value: "width: 100%; object-fit: contain" } | ||
} | ||
}; | ||
|
||
// Pass through source information | ||
if (options._canonical_uri) { | ||
element.attributes.src = { type: "string", value: options._canonical_uri }; | ||
element.attributes.type = { type: "string", value: type }; | ||
} else if (text) { | ||
element.attributes.src = { type: "string", value: "data:" + type + ";base64," + text }; | ||
element.attributes.type = { type: "string", value: type }; | ||
} | ||
|
||
// Pass through tiddler title if available | ||
if (options.title) { | ||
element.attributes.tiddler = { type: "string", value: options.title }; | ||
} | ||
|
||
this.tree = [element]; | ||
this.type = type; | ||
}; | ||
|
||
exports["video/ogg"] = VideoParser; | ||
exports["video/webm"] = VideoParser; | ||
exports["video/mp4"] = VideoParser; | ||
exports["video/quicktime"] = VideoParser; | ||
|
||
})(); |