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

Citoid/Visual Editor integration. #32

Open
eggpi opened this issue Jan 23, 2016 · 3 comments
Open

Citoid/Visual Editor integration. #32

eggpi opened this issue Jan 23, 2016 · 3 comments

Comments

@eggpi
Copy link
Owner

eggpi commented Jan 23, 2016

See Twitter discussion.

@mvolz
Copy link

mvolz commented Jul 15, 2016

The main issue is that we need to open VE, and then select the proper citation. This could be done by open VE with a GET arg, and then by executing Javascript on the open page. However, figuring out where exactly in the linear model the selected citation is might be a bit tricky... see: https://www.mediawiki.org/wiki/VisualEditor/API/Data_Model/Surface Inside VE, we need to know where the selection is in the linear model, and that is generated from the HTML, and I'm not sure how to do this; perhaps it's possible to get from parsoid?

@eggpi
Copy link
Owner Author

eggpi commented Jul 15, 2016

Hi @mvolz! I know absolutely nothing about VE, so let's see if I understand your ideas...

This could be done by open VE with a GET arg, and then by executing Javascript on the open page.

I skimmed the documentation a bit, but saw no references to opening VE with a query parameter, or to passing it a script to run. Is this something that's already possible? Can you please point me to the relevant docs?

Inside VE, we need to know where the selection is in the linear model, and that is generated from the HTML

So if we manage to run JS in VE, we'll get access to the linear model through the VE API, and the corresponding HTML will just be the page itself, right?

I suppose the hackish way would be to craft some heuristic to match the snippet as displayed in Citation Hunt with one of the DOM elements in the page (it's always going to be a paragraph and we know what section it's in, we can try some matching based on the text), then look that up in the linear model. Does this make some sense? I'm hand-waving a lot here :)

Thanks for your input!

@mvolz
Copy link

mvolz commented Jul 15, 2016

To open VE you just need to do: https://en.wikipedia.org/wiki/SomePage?veaction=edit

And then yes, we'll get access to the linear model and also the whole library because it's all front-end javascript. You can kind of see what interacting with it looks like here: https://www.mediawiki.org/wiki/VisualEditor/Gadgets#Code_snippets

I think actually the easiest/hackish way to do it is just search for the text of the citation in the page. At the bottom of that gadgets link someone has actually written a search and replace gadget so you could probably adapt that code lot: https://en.wikipedia.org/wiki/User:%D7%A2%D7%A8%D7%9F/veReplace.js

Except instead of replacing, you just need to select it and that should open up the dialog.

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

No branches or pull requests

2 participants