forked from basecamp/trix
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
317 additions
and
266 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ package-lock.json | |
/dist | ||
/node_modules | ||
/tmp | ||
.yarn |
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,82 +1,87 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Trix</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | ||
<meta name="csp-nonce" content="topsecret"> | ||
<link rel="icon" href="data:,"> | ||
<link rel="stylesheet" type="text/css" href="trix.css"> | ||
<style type="text/css"> | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
main { | ||
margin: 20px auto; | ||
max-width: 700px; | ||
} | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Trix</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | ||
<meta name="csp-nonce" content="topsecret"> | ||
<link rel="icon" href="data:,"> | ||
<link rel="stylesheet" type="text/css" href="trix.css"> | ||
<style type="text/css"> | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
#output { | ||
margin: 1rem 0 0; | ||
} | ||
main { | ||
margin: 20px auto; | ||
max-width: 700px; | ||
} | ||
|
||
#output textarea { | ||
width: 100%; | ||
height: 6rem; | ||
resize: vertical; | ||
font-family: monospace; | ||
border-radius: 5px; | ||
border: solid 1px #444; | ||
padding: 10px; | ||
} | ||
</style> | ||
<script type="module" src="trix.esm.js"></script> | ||
<script type="module" src="inspector.js"></script> | ||
<script type="module"> | ||
Trix.config.attachments.preview.caption.name = true | ||
Trix.config.attachments.preview.caption.size = false | ||
#output { | ||
margin: 1rem 0 0; | ||
} | ||
|
||
document.addEventListener("trix-initialize", function(event) { | ||
Trix.Inspector.install(event.target); | ||
}); | ||
#output textarea { | ||
width: 100%; | ||
height: 6rem; | ||
resize: vertical; | ||
font-family: monospace; | ||
border-radius: 5px; | ||
border: solid 1px #444; | ||
padding: 10px; | ||
} | ||
</style> | ||
<script type="module"> | ||
import TrixInitialize from './trix.esm/trix.js'; | ||
await TrixInitialize.init(); | ||
await import('./inspector.js'); | ||
Trix.config.attachments.preview.caption.name = true | ||
Trix.config.attachments.preview.caption.size = false | ||
|
||
document.addEventListener("trix-attachment-add", function(event) { | ||
var attachment = event.attachment; | ||
if (attachment.file) { | ||
var xhr = new XMLHttpRequest; | ||
xhr.open("POST", "/attachments", true); | ||
document.addEventListener("trix-initialize", function (event) { | ||
Trix.Inspector.install(event.target); | ||
}); | ||
|
||
xhr.upload.onprogress = function(event) { | ||
var progress = event.loaded / event.total * 100; | ||
attachment.setUploadProgress(progress); | ||
}; | ||
document.addEventListener("trix-attachment-add", function (event) { | ||
var attachment = event.attachment; | ||
if (attachment.file) { | ||
var xhr = new XMLHttpRequest; | ||
xhr.open("POST", "/attachments", true); | ||
|
||
xhr.onload = function() { | ||
if (xhr.status === 201) { | ||
setTimeout(function() { | ||
var url = xhr.responseText; | ||
attachment.setAttributes({ url: url, href: url }); | ||
}, 30) | ||
} | ||
}; | ||
xhr.upload.onprogress = function (event) { | ||
var progress = event.loaded / event.total * 100; | ||
attachment.setUploadProgress(progress); | ||
}; | ||
|
||
xhr.onload = function () { | ||
if (xhr.status === 201) { | ||
setTimeout(function () { | ||
var url = xhr.responseText; | ||
attachment.setAttributes({ url: url, href: url }); | ||
}, 30) | ||
} | ||
}; | ||
|
||
attachment.setUploadProgress(10); | ||
|
||
setTimeout(function () { | ||
xhr.send(attachment.file); | ||
}, 30) | ||
} | ||
}); | ||
</script> | ||
</head> | ||
|
||
attachment.setUploadProgress(10); | ||
<body> | ||
<main> | ||
<trix-toolbar id="my_toolbar"></trix-toolbar> | ||
<trix-editor toolbar="my_toolbar" autofocus class="trix-content" input="input"></trix-editor> | ||
<details id="output"> | ||
<summary>Output</summary> | ||
<textarea readonly id="input"></textarea> | ||
</details> | ||
</main> | ||
</body> | ||
|
||
setTimeout(function() { | ||
xhr.send(attachment.file); | ||
}, 30) | ||
} | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
<main> | ||
<trix-editor autofocus class="trix-content" input="input"></trix-editor> | ||
<details id="output"> | ||
<summary>Output</summary> | ||
<textarea readonly id="input"></textarea> | ||
</details> | ||
</main> | ||
</body> | ||
</html> | ||
</html> |
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,9 +1,9 @@ | ||
{ | ||
"name": "trix", | ||
"name": "@ernestasTheDev/trix-ssr", | ||
"version": "2.1.6", | ||
"description": "A rich text editor for everyday writing", | ||
"main": "dist/trix.umd.min.js", | ||
"module": "dist/trix.esm.min.js", | ||
"main": "dist/trix.esm.min/trix.js", | ||
"module": "dist/trix.esm.min/trix.js", | ||
"style": "dist/trix.css", | ||
"files": [ | ||
"dist/*.css", | ||
|
@@ -61,12 +61,13 @@ | |
"build": "yarn run build-js && yarn run build-css && yarn run build-assets", | ||
"watch": "rollup -c -w", | ||
"lint": "eslint .", | ||
"pretest": "yarn run lint && yarn run build", | ||
"pretest": "yarn run build", | ||
"test": "karma start", | ||
"prerelease": "yarn version && yarn test", | ||
"release": "npm adduser && npm publish", | ||
"postrelease": "git push && git push --tags", | ||
"dev": "web-dev-server --app-index index.html --root-dir dist --node-resolve --open", | ||
"start": "yarn build-assets && concurrently --kill-others --names js,css,dev-server 'yarn watch' 'yarn build-css --watch' 'yarn dev'" | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
} |
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
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,7 +1,5 @@ | ||
/* eslint-disable | ||
*/ | ||
import Trix from "trix/trix" | ||
|
||
import "trix/core/helpers/global" | ||
import "test/test_helper" | ||
|
||
|
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
Oops, something went wrong.