Commit ff16a325 authored by Michael Murtaugh's avatar Michael Murtaugh

rename to cceditorapp

parent 3cff643f
This diff is collapsed.
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title></title>
<script src="index.js"></script>
<script src="cceditorapp.js"></script>
<script>
var app = new cceditorapp.CCEditorApp({
notlayout: {
......
dist/index.js: src/*.js src/editor.css
dist/cceditorapp.js: src/*.js src/editor.css
node_modules/.bin/webpack
# dist/cceditor.js: src/cceditor.js src/editor.css src/*.js
......
......@@ -17,21 +17,21 @@ function parse_fragment (url) {
var CodeMirror = require("codemirror"),
timecode = require("./timecode.js"),
CCFrame = require("./ccframe.js"),
reflinks = require("./reflinks.js"),
tcpat = /(?:(\d\d):)?(\d\d):(\d\d)(?:[.,](\d{1,3}))?/;
CCFrame = require("./ccframe.js");
require("codemirror/lib/codemirror.css");
require("codemirror/addon/fold/foldgutter.css");
require("./editor.css");
require('codemirror/mode/markdown/markdown');
// require('codemirror/lib/codemirror.js');
require('codemirror/lib/codemirror.js');
require('codemirror/addon/mode/overlay.js');
// // require('codemirror/mode/markdown/markdown.js');
require('codemirror/mode/markdown/markdown.js');
require('codemirror/addon/fold/foldcode.js');
require('codemirror/addon/fold/foldgutter.js');
require('codemirror/addon/fold/markdown-fold.js')
require("codemirror/theme/monokai.css")
require("codemirror/lib/codemirror.css");
require("codemirror/addon/fold/foldgutter.css");
require("./editor.css");
function getText (url, callback) {
var request = new XMLHttpRequest();
......@@ -120,11 +120,11 @@ class CCEditor {
this.editor = CodeMirror(this.editorelt, {
// mode: "ccmarkdown",
mode: "text/x-markdown",
lineNumbers: false,
lineNumbers: true,
lineWrapping: true,
foldGutter: true,
value: ""
// gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
value: "",
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
});
this.current_href = undefined;
this.players_by_target = {};
......@@ -139,35 +139,9 @@ class CCEditor {
}
/* Map URL and timecode clicks */
clicker (e) {
var href, hsh, m, title;
// console.log("clicker", e);
if (e.target.classList.contains("cm-link")) {
// handles
// [ref]
// [][ref] ?
href = reflinks.trim_parentheses(reflinks.trim_brackets(e.target.textContent));
var thereflinks = reflinks.extract_reflink_definitions(this.editor.getValue());
var reflink = reflinks.xpandRefLink(href, thereflinks);
// console.log("cm-link", href, reflink.href, reflink.title);
if (reflink && reflink.href) { this.display_link(reflink.href, reflink.title); }
} else if (e.target.classList.contains("cm-url")) {
// handles regular links
// [](href)
// [](href "title")
href = e.target.textContent;
m = href.match(/^\((.+?)(?: *(?:\"(.+)\")?\))$/);
if (m) {
href = m[1],
title = m[2] || "";
// console.log("cm-url", href, title);
this.display_link(href, title);
}
} else if (e.target.classList.contains("cm-cctimecode")) {
player.currentTime = timecode.timecode_to_seconds(e.target.textContent);
}
if (this.opts.click) {
this.opts.click.call(this, e.target.textContent, e.target.classList);
}
}
hashchange () {
......@@ -250,12 +224,6 @@ class CCEditor {
this.editor.setOption("extraKeys", {
"Ctrl-Down": function(cm) {
if (that.opts.ctrlKey) { that.opts.ctrlKey.call(that, "down"); }
// if (that.current_player) {
// var thereflinks = reflinks.extract_reflink_definitions(that.editor.getValue());
// var ret = compactRefLink(strip_fragment(that.current_player.url)+player.fragment, reflinks);
// // cm.replaceSelection(player.fragment); // "" + timecode.seconds_to_timecode(player.currentTime));
// cm.replaceSelection("["+ret+"]\n");
// }
},
"Ctrl-Up": function(cm) {
if (that.opts.ctrlKey) { that.opts.ctrlKey.call(that, "up"); }
......@@ -298,19 +266,6 @@ class CCEditor {
}
/*
hashchange();
gebi("save").addEventListener("click", function () { do_save(editor); });
gebi("x").addEventListener("click", function () {
var dv = gebi("default_player");
if (dv) {
dv.remove();
}
})
*/
module.exports = {
CodeMirror: CodeMirror,
CCEditor: CCEditor,
......
......@@ -74,7 +74,26 @@ class CCEditorApp {
});
this.layout.registerComponent( 'cceditor', function( container, componentState ){
var editor = new cceditor.CCEditor(container.getElement()[0], {
click: function (href, target) {
click: function (src, classList) {
// console.log("index.click", src, classList);
var href, target;
if (classList.contains("cm-link")) {
href = reflinks.trim_parentheses(reflinks.trim_brackets(src));
var ev = this.editor.getValue();
var thereflinks = reflinks.extract_reflink_definitions(ev);
var reflink = reflinks.xpandRefLink(href, thereflinks);
href = reflink.href;
target = reflink.title;
} else {
var m = src.match(/^\((.+?)(?: *(?:\"(.+)\")?\))$/);
if (m) {
href = m[1],
target = m[2] || "";
}
}
if (!href) { return; }
// console.log("index.click", href, target);
if (href.match(/\.md$/) && !target) {
// EDITOR LINK
// console.log("editor link");
......
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
module.exports = {
entry: './src/index.js',
entry: './src/cceditorapp.js',
mode: 'development',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
filename: 'cceditorapp.js',
library: 'cceditorapp'
},
module: {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment