Skip to content

Commit 3aa6ce6

Browse files
author
rongjun.qiu
committed
feat(): use vite to run dev server
1 parent a189719 commit 3aa6ce6

File tree

7 files changed

+822
-37
lines changed

7 files changed

+822
-37
lines changed

demo/index.html

Lines changed: 0 additions & 33 deletions
This file was deleted.

index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6+
<title>Canvas Text Editor</title>
7+
<meta name="description" content="">
8+
<meta name="keywords" content="">
9+
<script src="./lib/index.js" type="module"></script>
10+
</head>
11+
<body>
12+
</body>
13+
</html>

lib/CanvasTextEditor.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"use strict";
22

3-
var FontMetrics = require('FontMetrics'),
4-
Document = require('Document'),
5-
Selection = require('Selection');
3+
var FontMetrics = require('./FontMetrics'),
4+
Document = require('./Document'),
5+
Selection = require('./Selection');
66

77
/**
88
* Simple plain-text text editor using html5 canvas.

lib/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import CanvasTextEditor from "./CanvasTextEditor.js";
2+
import Document from "./Document.js";
3+
4+
document.addEventListener(
5+
"DOMContentLoaded",
6+
function () {
7+
var text = "",
8+
characterCount = 0,
9+
aCharCode = "a".charCodeAt(0);
10+
for (var i = 0; i < 100; i++) {
11+
characterCount = Math.floor(Math.random() * 120);
12+
for (var j = 0; j < characterCount; j++) {
13+
text += String.fromCharCode(aCharCode + Math.floor(Math.random() * 26));
14+
}
15+
text += "\n";
16+
}
17+
var doc = new Document(text),
18+
editor = new CanvasTextEditor(doc);
19+
document.body.appendChild(editor.getEl());
20+
editor.focus();
21+
},
22+
false
23+
);

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
"engines": {
77
"node": ">= 0.4.x < 0.7.0"
88
},
9+
"scripts": {
10+
"dev": "vite"
11+
},
912
"devDependencies": {
1013
"coffee-script": "latest",
14+
"express": "latest",
1115
"stitch": "latest",
1216
"uglify-js": "latest",
13-
"express": "latest"
17+
"vite": "^4.3.8",
18+
"vite-plugin-commonjs": "^0.7.1"
1419
}
1520
}

vite.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { defineConfig } from "vite";
2+
import commonjs from "vite-plugin-commonjs";
3+
4+
export default defineConfig({
5+
plugins: [commonjs(/* options */)],
6+
});

0 commit comments

Comments
 (0)