chore: add _self target to embedded plunkers (#2201)
This commit is contained in:
parent
8e15829189
commit
6962f03f30
|
@ -32,9 +32,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
|
|||
|
||||
function span(text) { return '<span>' + text + '</span>'; }
|
||||
|
||||
function embeddedTemplate(src, name) {
|
||||
function embeddedTemplate(src) {
|
||||
return '<div ng-if="embeddedShow">' +
|
||||
'<iframe frameborder="0" width="100%" height="100%" name="' + name + '" src="' + src + '"></iframe>' +
|
||||
'<iframe frameborder="0" width="100%" height="100%" src="' + src + '"></iframe>' +
|
||||
'</div>' +
|
||||
'<img ng-click="toggleEmbedded()" ng-if="!embeddedShow" src="/resources/images/plunker/placeholder.png" alt="plunker">';
|
||||
}
|
||||
|
@ -57,9 +57,9 @@ angularIO.directive('liveExample', ['$location', function ($location) {
|
|||
var isForJs = attrs.lang === 'js' || NgIoUtil.isDoc($location, 'js');
|
||||
var exLang = isForDart ? 'dart' : isForJs ? 'js' : 'ts';
|
||||
|
||||
if (attrs.hasOwnProperty('embedded') && !isForDart) {
|
||||
if (embedded && !isForDart) {
|
||||
href = '/resources/live-examples/' + ex + '/' + exLang + '/' + plnkr + '.html'
|
||||
template = embeddedTemplate(href, plnkr);
|
||||
template = embeddedTemplate(href);
|
||||
} else {
|
||||
var href = isForDart
|
||||
? 'http://angular-examples.github.io/' + ex
|
||||
|
|
|
@ -83,7 +83,7 @@ class PlunkerBuilder {
|
|||
var config = this._initConfigAndCollectFileNames(configFileName);
|
||||
var postData = this._createPostData(config);
|
||||
this._addPlunkerFiles(config, postData);
|
||||
var html = this._createPlunkerHtml(postData, altFileName);
|
||||
var html = this._createPlunkerHtml(postData);
|
||||
if (this.options.writeNoLink) {
|
||||
fs.writeFileSync(outputFileName, html, 'utf-8');
|
||||
}
|
||||
|
@ -106,15 +106,9 @@ class PlunkerBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
_createBasePlunkerHtml(embedded, altFileName) {
|
||||
// We extract the filename without extension
|
||||
var targetName = '';
|
||||
if (altFileName) {
|
||||
targetName = altFileName.split('/').pop().slice(0, -5);
|
||||
}
|
||||
var target = embedded ? targetName : '_self';
|
||||
_createBasePlunkerHtml(embedded) {
|
||||
var html = '<!DOCTYPE html><html lang="en"><body>'
|
||||
html += `<form id="mainForm" method="post" action="${this.options.url}" target="${target}">`
|
||||
html += `<form id="mainForm" method="post" action="${this.options.url}" target="_self">`
|
||||
|
||||
// html += '<div class="button"><button id="formButton" type="submit">Create Plunker</button></div>'
|
||||
// html += '</form><script>document.getElementById("formButton").click();</script>'
|
||||
|
@ -183,8 +177,8 @@ class PlunkerBuilder {
|
|||
return postData;
|
||||
}
|
||||
|
||||
_createPlunkerHtml(postData, altFileName) {
|
||||
var baseHtml = this._createBasePlunkerHtml(this.options.embedded, altFileName);
|
||||
_createPlunkerHtml(postData) {
|
||||
var baseHtml = this._createBasePlunkerHtml(this.options.embedded);
|
||||
var doc = jsdom.jsdom(baseHtml);
|
||||
var form = doc.querySelector('form');
|
||||
_.forEach(postData, (value, key) => {
|
||||
|
|
Loading…
Reference in New Issue