Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not tested #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions sourcePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ module.exports = {
}

var contentType = mime.lookup(newInstance.uri)
if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) {
let msg = 'A new text file has to have an file extension like .txt .ttl etc.'
alert(msg)
throw new Error(msg)
if (!newInstance.uri.endsWith('acl')) { // special case allow .acl files
if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) {
let msg = 'A new text file has to have an file extension like .txt .ttl etc.'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be "like .txt, .ttl, etc."

alert(msg)
throw new Error(msg)
}
}

return new Promise(function (resolve, reject) {
Expand Down Expand Up @@ -129,16 +131,16 @@ module.exports = {
* @param {Integer} caretPos - the poisition starting at zero
* @credit https://stackoverflow.com/questions/512528/set-keyboard-caret-position-in-html-textbox
*/
function setCaretPosition(elem, caretPos) {
if(elem != null) {
if(elem.createTextRange) {
var range = elem.createTextRange();
range.move('character', caretPos);
range.select();
function setCaretPosition (elem, caretPos) {
if (elem != null) {
if (elem.createTextRange) {
var range = elem.createTextRange()
range.move('character', caretPos)
range.select()
} else {
elem.focus();
if(elem.selectionStart) {
elem.setSelectionRange(caretPos, caretPos);
elem.focus()
if (elem.selectionStart) {
elem.setSelectionRange(caretPos, caretPos)
}
}
}
Expand All @@ -151,9 +153,10 @@ module.exports = {
$rdf.parse(data, kb, base, contentType)
} catch (e) {
statusRow.appendChild(UI.widgets.errorMessageBlock(dom, e))
for (let cause = e; cause = cause.cause; cause) {
for (let cause = e; cause.cause; cause = cause.cause) {
if (cause.characterInFile) {
setCaretPosition(textArea, e2.characterInFile)
setCaretPosition(textArea, cause.characterInFile)
console.log('Syntax error at position: ' + cause.characterInFile)
}
}
return false
Expand Down