Created
October 28, 2015 21:55
-
-
Save javan/162b0c59f01aec953d9b to your computer and use it in GitHub Desktop.
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
diff --git a/assets/index.html b/assets/index.html | |
index fe3fa40..220421c 100644 | |
--- a/assets/index.html | |
+++ b/assets/index.html | |
@@ -6,6 +6,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | |
<link rel="stylesheet" type="text/css" href="trix.css"> | |
<script type="text/javascript" src="trix.js"></script> | |
+ <script type="text/javascript" src="people_attachments.js"></script> | |
</head> | |
<body> | |
<trix-editor autofocus class="trix-content"></trix-editor> | |
trix master [!?$] | |
$ git diff --staged | |
diff --git a/assets/index.html b/assets/index.html | |
index fe3fa40..220421c 100644 | |
--- a/assets/index.html | |
+++ b/assets/index.html | |
@@ -6,6 +6,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> | |
<link rel="stylesheet" type="text/css" href="trix.css"> | |
<script type="text/javascript" src="trix.js"></script> | |
+ <script type="text/javascript" src="people_attachments.js"></script> | |
</head> | |
<body> | |
<trix-editor autofocus class="trix-content"></trix-editor> | |
diff --git a/assets/people_attachments.coffee b/assets/people_attachments.coffee | |
new file mode 100644 | |
index 0000000..f8985e6 | |
--- /dev/null | |
+++ b/assets/people_attachments.coffee | |
@@ -0,0 +1,17 @@ | |
+contentType = "application/vnd.myApp.person" | |
+ | |
+document.addEventListener "trix-attachment-add", (event) -> | |
+ {attachment} = event | |
+ | |
+ if attachment.getContentType() is contentType | |
+ xhr = new XMLHttpRequest | |
+ xhr.open("GET", attachment.getURL()) | |
+ xhr.onload = -> | |
+ attachment.setAttributes(content: xhr.responseText) | |
+ xhr.send() | |
+ | |
+@insertPerson = -> | |
+ {editor} = document.querySelector("trix-editor") | |
+ | |
+ attachment = new Trix.Attachment({contentType, url: "person.html"}) | |
+ editor.insertAttachment(attachment) | |
diff --git a/assets/person.html b/assets/person.html | |
new file mode 100644 | |
index 0000000..ff46ca6 | |
--- /dev/null | |
+++ b/assets/person.html | |
@@ -0,0 +1,4 @@ | |
+<article class="person"> | |
+ <h1>John Smith</h1> | |
+ <a href="tel:1-555-555-5555">1-555-555-5555</a> | |
+</article> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment