making the image button of the editor actually add all the info needed, and made the images clickable for the full size

pull/8/head
Stephen Searles 7 years ago
parent 5897b6874d
commit ab6152cbfa
  1. 59
      assets/bindata.go
  2. 30
      assets/simplemde/debug/simplemde.css
  3. 18248
      assets/simplemde/debug/simplemde.debug.js
  4. 18241
      assets/simplemde/debug/simplemde.js
  5. 2
      assets/simplemde/dist/simplemde.min.css
  6. 10
      assets/simplemde/dist/simplemde.min.js
  7. 6
      assets/simplemde/gulpfile.js
  8. 11
      assets/simplemde/src/js/simplemde.js
  9. 7
      media.go
  10. 16
      templates.go

File diff suppressed because one or more lines are too long

@ -94,8 +94,14 @@
.cm-tab { display: inline-block; text-decoration: inherit; } .cm-tab { display: inline-block; text-decoration: inherit; }
.CodeMirror-rulers {
position: absolute;
left: 0; right: 0; top: -50px; bottom: -20px;
overflow: hidden;
}
.CodeMirror-ruler { .CodeMirror-ruler {
border-left: 1px solid #ccc; border-left: 1px solid #ccc;
top: 0; bottom: 0;
position: absolute; position: absolute;
} }
@ -206,9 +212,6 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
margin-bottom: -30px; margin-bottom: -30px;
/* Hack to make IE7 behave */
*zoom:1;
*display:inline;
} }
.CodeMirror-gutter-wrapper { .CodeMirror-gutter-wrapper {
position: absolute; position: absolute;
@ -226,11 +229,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
cursor: default; cursor: default;
z-index: 4; z-index: 4;
} }
.CodeMirror-gutter-wrapper { .CodeMirror-gutter-wrapper ::selection { background-color: transparent }
-webkit-user-select: none; .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
-moz-user-select: none;
user-select: none;
}
.CodeMirror-lines { .CodeMirror-lines {
cursor: text; cursor: text;
@ -252,8 +252,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
position: relative; position: relative;
overflow: visible; overflow: visible;
-webkit-tap-highlight-color: transparent; -webkit-tap-highlight-color: transparent;
-webkit-font-variant-ligatures: none; -webkit-font-variant-ligatures: contextual;
font-variant-ligatures: none; font-variant-ligatures: contextual;
} }
.CodeMirror-wrap pre { .CodeMirror-wrap pre {
word-wrap: break-word; word-wrap: break-word;
@ -275,6 +275,8 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
.CodeMirror-widget {} .CodeMirror-widget {}
.CodeMirror-rtl pre { direction: rtl; }
.CodeMirror-code { .CodeMirror-code {
outline: none; outline: none;
} }
@ -297,7 +299,10 @@ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
visibility: hidden; visibility: hidden;
} }
.CodeMirror-cursor { position: absolute; } .CodeMirror-cursor {
position: absolute;
pointer-events: none;
}
.CodeMirror-measure pre { position: static; } .CodeMirror-measure pre { position: static; }
div.CodeMirror-cursors { div.CodeMirror-cursors {
@ -324,9 +329,6 @@ div.CodeMirror-dragcursors {
background: rgba(255, 255, 0, .4); background: rgba(255, 255, 0, .4);
} }
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
.CodeMirror span { *vertical-align: text-bottom; }
/* Used to force a border model for a node */ /* Used to force a border model for a node */
.cm-force-border { padding-right: .1px; } .cm-force-border { padding-right: .1px; }

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -47,7 +47,7 @@ function taskBrowserify(opts) {
.bundle(); .bundle();
} }
gulp.task("browserify:debug", ["lint"], function() { gulp.task("browserify:debug", [], function() {
return taskBrowserify({debug:true, standalone:"SimpleMDE"}) return taskBrowserify({debug:true, standalone:"SimpleMDE"})
.pipe(source("simplemde.debug.js")) .pipe(source("simplemde.debug.js"))
.pipe(buffer()) .pipe(buffer())
@ -55,7 +55,7 @@ gulp.task("browserify:debug", ["lint"], function() {
.pipe(gulp.dest("./debug/")); .pipe(gulp.dest("./debug/"));
}); });
gulp.task("browserify", ["lint"], function() { gulp.task("browserify", [], function() {
return taskBrowserify({standalone:"SimpleMDE"}) return taskBrowserify({standalone:"SimpleMDE"})
.pipe(source("simplemde.js")) .pipe(source("simplemde.js"))
.pipe(buffer()) .pipe(buffer())
@ -63,7 +63,7 @@ gulp.task("browserify", ["lint"], function() {
.pipe(gulp.dest("./debug/")); .pipe(gulp.dest("./debug/"));
}); });
gulp.task("scripts", ["browserify:debug", "browserify", "lint"], function() { gulp.task("scripts", ["browserify:debug", "browserify"], function() {
var js_files = ["./debug/simplemde.js"]; var js_files = ["./debug/simplemde.js"];
return gulp.src(js_files) return gulp.src(js_files)

@ -635,11 +635,14 @@ function drawImage(editor) {
var stat = getState(cm); var stat = getState(cm);
var options = editor.options; var options = editor.options;
var url = "http://"; var url = "http://";
if(options.promptURLs) { if(options.imageURLFn) {
url = options.imageURLFn();
} else if(options.promptURLs) {
url = prompt(options.promptTexts.image); url = prompt(options.promptTexts.image);
if(!url) { }
return false;
} if(!url) {
return false;
} }
_replaceSelection(cm, stat.image, options.insertTexts.image, url); _replaceSelection(cm, stat.image, options.insertTexts.image, url);
} }

@ -245,7 +245,7 @@ func (ch *CaddyHugo) serveMediaPage(w http.ResponseWriter, r *http.Request) (int
<head><style> <head><style>
iframe { height: 100%; } iframe { height: 100%; }
.img { display: inline-block; text-align: center; max-width: 19.9vw; min-height: 120px;} .img { display: inline-block; text-align: center; max-width: 19.9vw; min-height: 120px;}
.img.selected { background-color: light-blue; } .img.selected { background-color: lightblue; }
.copy { cursor: pointer; } .copy { cursor: pointer; }
@media (max-width: 800px) { @media (max-width: 800px) {
.img { .img {
@ -279,7 +279,7 @@ func (ch *CaddyHugo) serveMediaPage(w http.ResponseWriter, r *http.Request) (int
fmt.Fprintf(w, `<div class="img">error rendering %q: %v</div>`, m.Name, err) fmt.Fprintf(w, `<div class="img">error rendering %q: %v</div>`, m.Name, err)
continue continue
} }
fmt.Fprintf(w, `<div class="img"><img width=%d height=%d src=%q /><br /><input type="text" readonly value=%q /><span class="copy">&#x1F4CB;</span></div>`, size.Dx(), size.Dy(), src, src) fmt.Fprintf(w, `<div class="img"><img width=%d height=%d src=%q data-filename=%q /><br /><input type="text" readonly value=%q /><span class="copy">&#x1F4CB;</span></div>`, size.Dx(), size.Dy(), src, m.Name, src)
} }
} }
io.WriteString(w, `<script> io.WriteString(w, `<script>
@ -297,6 +297,9 @@ func (ch *CaddyHugo) serveMediaPage(w http.ResponseWriter, r *http.Request) (int
current.classList = "img"; current.classList = "img";
} }
evt.target.parentElement.classList = "img selected"; evt.target.parentElement.classList = "img selected";
if (window.parent) {
window.parent.postMessage(evt.target.dataset.filename, location.origin);
}
} }
} }
document.querySelector('body').onmouseup = function (evt) { document.querySelector('body').onmouseup = function (evt) {

@ -216,8 +216,22 @@ a {
} }
} }
var selectedImage;
var editorElem = document.getElementById("editor"); var editorElem = document.getElementById("editor");
var editor = new SimpleMDE({element: editorElem, forceSync: true}); var editor = new SimpleMDE({
element: editorElem,
forceSync: true,
insertTexts: {
image: ["{\{% thumb filename=\"", "#url#\" width=\"200\" %}}"]
},
imageURLFn: function () {
return selectedImage;
}
});
window.onmessage = function (evt) {
selectedImage = evt.data;
}
// Create WebSocket connection. // Create WebSocket connection.

Loading…
Cancel
Save