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

usage of sintaxica as sparql editor; #12

Open
wants to merge 4 commits into
base: sparql_to_spin
Choose a base branch
from

Conversation

damianw27
Copy link
Collaborator

No description provided.

@william-vw
Copy link
Owner

@damianw27 This is great work. I created and pushed a separate branch (integrating some later changes I had made to the main code) to work on: https://github.com/william-vw/n3-editor-js/tree/pull_12

One problem is that if I copy paste a bunch of SPARQL queries (plain text, no formatting) I get the following (a bunch of whitespace on the left).

Screenshot 2023-07-19 at 5 22 48 PM

Also the layout is bunched to the left (this may also be related to my crappy HTML code):
Screenshot 2023-07-20 at 7 59 02 AM

Would it be possible to fix these issues?

@damianw27
Copy link
Collaborator Author

Yup, I will have a look at this after I do my job duties.

@damianw27
Copy link
Collaborator Author

I found few problems in styles. Now everything should fit fine.

@william-vw
Copy link
Owner

william-vw commented Jul 27, 2023

@damianw27 The updated editor.js still doesn't work for the editor (nor your online editor) when programmatically setting the editor value.

This is the code you used to update the editor value (with a hard-coded query):

$("#code-textarea--input").val("CONSTRUCT {?x ?y ?z} WHERE {?x ?y z} .") 

If you try it then the query appears, but after clicking in the editor window, it disappears. Feel free try it yourself here: http://n3-editor.herokuapp.com/n3/editor/sspin3.html

Also, when directly setting the query after loading the page nothing happens; if I delay this operation for two seconds, then the query does appear (but with the same "disappearing act" as before). Is there some specific onload event I should be listening for? (As I said, I already wait for the page onload event.)

@damianw27
Copy link
Collaborator Author

damianw27 commented Jul 28, 2023

In my case, the following code works just fine

  var observer = new MutationObserver(function() {
    const textarea = document.getElementById('code-textarea--input');

    if (textarea !== null) {
      textarea.value = "CONSTRUCT {?x ?y ?z} WHERE {?x ?y z} .";
      observer.disconnect();
    }
  });

  observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});

Is there any way to test the app with hot reload?

@william-vw
Copy link
Owner

@damianw27

Is there any way to test the app with hot reload?

You can clone the latest repo (sparql_to_n3 branch) and run nodemon app.js - the location defaults to localhost:3002/n3/editor/sspin3.html (version with syntaxica). Most features won't work but they're also not needed in this case.

See lines 296-300 for my efforts on updating the editor, as per the code you had previously shared (and trying the aforementioned delay).

@damianw27
Copy link
Collaborator Author

@william-vw with usage of MutationObserver everything works fine

@william-vw
Copy link
Owner

@damianw27 if you can show me an updated PR with functioning code then I will integrate into the editor next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants