forked from vishwanath1306/quill-editor-starter-code
-
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.
Merge pull request #1 from jordanlleslie/formatting
formatting
- Loading branch information
Showing
1 changed file
with
122 additions
and
134 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 |
---|---|---|
@@ -1,134 +1,122 @@ | ||
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"> | ||
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script> | ||
|
||
<div id="toolbar"> | ||
<!-- Add a custom button --> | ||
<style> | ||
#myButton, #myButton1, #myButton2 { | ||
margin-right: 10px; | ||
} | ||
</style> | ||
|
||
<button id="myButton">GPT Call 1</button> | ||
<button id="myButton1">GPT Call 2</button> | ||
<button id="myButton2">GPT Call 3</button> | ||
<!-- Other toolbar items --> | ||
|
||
<button class="ql-bold">Bold</button> | ||
<button class="ql-italic">Italic</button> | ||
<!-- ... other toolbar items ... --> | ||
</div> | ||
|
||
<div id="editor"> | ||
<!-- This is where Quill will place the editor's content --> | ||
</div> | ||
|
||
<script> | ||
var quill = new Quill('#editor', { | ||
theme: 'snow', | ||
modules: { | ||
toolbar: '#toolbar' | ||
} | ||
}); | ||
|
||
// document.querySelector('#myButton').addEventListener('click', function() { | ||
// let range = quill.getSelection(true); | ||
// let aboutData; | ||
// fetch('https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc') | ||
// .then(response => response.text()) | ||
// .then(data => { | ||
// aboutData = data; | ||
// console.log(aboutData); | ||
// console.log(typeof(aboutData)); | ||
// }) | ||
// .catch(error => console.error(error)); | ||
// var parsed_data = JSON.parse(aboutData); | ||
// console.log(parsed_data); | ||
// quill.insertText(range.index, "CHATGBT ROCks"); | ||
// }); | ||
|
||
document.querySelector('#myButton').addEventListener('click', function() { | ||
let range = quill.getSelection(true); | ||
let aboutData; | ||
const xhr = new XMLHttpRequest(); | ||
// Set the request method and URL. | ||
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc'); | ||
|
||
// Set the request header. | ||
xhr.setRequestHeader('Accept', 'application/json'); | ||
|
||
// Send the request. | ||
xhr.send(); | ||
|
||
// Listen for the response. | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
// Success! | ||
const response = JSON.parse(xhr.responseText); | ||
console.log(response); | ||
quill.insertText(range.index, response.data); | ||
} else { | ||
// Error! | ||
console.log(xhr.statusText); | ||
} | ||
}; | ||
// quill.insertText(range.index, response.data); | ||
}); | ||
|
||
document.querySelector('#myButton1').addEventListener('click', function() { | ||
let range = quill.getSelection(true); | ||
let aboutData; | ||
const xhr = new XMLHttpRequest(); | ||
// Set the request method and URL. | ||
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc'); | ||
|
||
// Set the request header. | ||
xhr.setRequestHeader('Accept', 'application/json'); | ||
|
||
// Send the request. | ||
xhr.send(); | ||
|
||
// Listen for the response. | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
// Success! | ||
const response = JSON.parse(xhr.responseText); | ||
console.log(response); | ||
quill.insertText(range.index, response.data + "1"); | ||
} else { | ||
// Error! | ||
console.log(xhr.statusText); | ||
} | ||
}; | ||
// quill.insertText(range.index, response.data); | ||
}); | ||
|
||
document.querySelector('#myButton2').addEventListener('click', function() { | ||
let range = quill.getSelection(true); | ||
let aboutData; | ||
const xhr = new XMLHttpRequest(); | ||
// Set the request method and URL. | ||
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc'); | ||
|
||
// Set the request header. | ||
xhr.setRequestHeader('Accept', 'application/json'); | ||
|
||
// Send the request. | ||
xhr.send(); | ||
|
||
// Listen for the response. | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
// Success! | ||
const response = JSON.parse(xhr.responseText); | ||
console.log(response); | ||
quill.insertText(range.index, response.data + "2"); | ||
} else { | ||
// Error! | ||
console.log(xhr.statusText); | ||
} | ||
}; | ||
// quill.insertText(range.index, response.data); | ||
}); | ||
|
||
</script> | ||
<html> | ||
<head> | ||
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"> | ||
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div id="toolbar"> | ||
<!-- Add a custom button --> | ||
<style> | ||
#myButton, #myButton1, #myButton2 { | ||
margin-right: 10px; | ||
} | ||
</style> | ||
|
||
<button id="myButton">GPT Call 1</button> | ||
<button id="myButton1">GPT Call 2</button> | ||
<button id="myButton2">GPT Call 3</button> | ||
<!-- Other toolbar items --> | ||
|
||
<button class="ql-bold">Bold</button> | ||
<button class="ql-italic">Italic</button> | ||
<!-- ... other toolbar items ... --> | ||
</div> | ||
|
||
<div id="editor"> | ||
<!-- This is where Quill will place the editor's content --> | ||
</div> | ||
|
||
<script> | ||
var quill = new Quill('#editor', { | ||
theme: 'snow', | ||
modules: { | ||
toolbar: '#toolbar' | ||
} | ||
}); | ||
|
||
|
||
document.querySelector('#myButton').addEventListener('click', function() { | ||
let range = quill.getSelection(true); | ||
let aboutData; | ||
const xhr = new XMLHttpRequest(); | ||
// Set the request method and URL. | ||
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc'); | ||
|
||
// Set the request header. | ||
xhr.setRequestHeader('Accept', 'application/json'); | ||
|
||
// Send the request. | ||
xhr.send(); | ||
|
||
// Listen for the response. | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
// Success! | ||
const response = JSON.parse(xhr.responseText); | ||
console.log(response); | ||
quill.insertText(range.index, response.data); | ||
} else { | ||
// Error! | ||
console.log(xhr.statusText); | ||
} | ||
}; | ||
}); | ||
|
||
document.querySelector('#myButton1').addEventListener('click', function() { | ||
let range = quill.getSelection(true); | ||
let aboutData; | ||
const xhr = new XMLHttpRequest(); | ||
// Set the request method and URL. | ||
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc'); | ||
|
||
// Set the request header. | ||
xhr.setRequestHeader('Accept', 'application/json'); | ||
|
||
// Send the request. | ||
xhr.send(); | ||
|
||
// Listen for the response. | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
// Success! | ||
const response = JSON.parse(xhr.responseText); | ||
console.log(response); | ||
quill.insertText(range.index, response.data + "1"); | ||
} else { | ||
// Error! | ||
console.log(xhr.statusText); | ||
} | ||
}; | ||
}); | ||
|
||
document.querySelector('#myButton2').addEventListener('click', function() { | ||
let range = quill.getSelection(true); | ||
let aboutData; | ||
const xhr = new XMLHttpRequest(); | ||
// Set the request method and URL. | ||
xhr.open('GET', 'https://mocki.io/v1/baff67f5-4af8-4d62-86ad-f49d75ce98fc'); | ||
|
||
// Set the request header. | ||
xhr.setRequestHeader('Accept', 'application/json'); | ||
|
||
// Send the request. | ||
xhr.send(); | ||
|
||
// Listen for the response. | ||
xhr.onload = function() { | ||
if (xhr.status === 200) { | ||
// Success! | ||
const response = JSON.parse(xhr.responseText); | ||
console.log(response); | ||
quill.insertText(range.index, response.data + "2"); | ||
} else { | ||
// Error! | ||
console.log(xhr.statusText); | ||
} | ||
}; | ||
}); | ||
|
||
</script> | ||
</body> | ||
</html> |