1

I'm working on a Web-GUI for a semantic search with a single text-input as a search-box. Typical queries are: "buildings higher than 100 meters".

I want to format the input text as the server answers the question. The entities and operators should be colored to make it easier for the user to see what the computer understood.

Example:

search-box

I found thousands of hacks out there to accomplish this, but all of them were really awkward to some degree. I still want it to feel like a text-field. I want the user to be able to move the cursor by clicking and using the key-arrows. While querying the server, the text should of course be black only. The coloring comes from the servers interpretation and ususally is available "as-you-type" (few milliseconds answer-time).

I want this thread to be a discussion of the different possibilities of accomplishing this task and find the best general-purpose solution for everybody.

1 Answer 1

1

Perhaps a possible solution would be for you to use an editable div, like below:

<div contentEditable="true">
    Lorem <b>ipsum</b> dolor
</div>

This way you can able to style user input as user type in (may be on keyUp event). While you submit this value in a form, you'll have to use JavaScript to get the innerHTML of this div and assign it to a hidden input or something.

Sign up to request clarification or add additional context in comments.

2 Comments

Nice idea -- but how would I add the format without replacing the cursors position?
Something like this will do the trick, but you need put a lot effort to complete your full functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.