markjs | A plug-in polygon annotation library
kandi X-RAY | markjs Summary
kandi X-RAY | markjs Summary
A plug-in polygon annotation library
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of markjs
markjs Key Features
markjs Examples and Code Snippets
Community Discussions
Trending Discussions on markjs
QUESTION
I want to create a custom search box that can jump to its matches using mark.js
mark.js web page.
They do have an example here: https://jsfiddle.net/julmot/973gdh8g/
But it is written using jQuery.
I tried converting it to JS/Vue (using Quasar), but now I couldn't get it to work. No errors, but also no highlights.
I have updated jQuery lines like:
...ANSWER
Answered 2021-May-20 at 11:41I rewrote their jQuery example using pure JavaScript.
You should be able to compare the two examples to see how the various jQuery functions translate to JavaScript and then implement them into your Vue project.
https://jsfiddle.net/75qyu3j8/
I tried to keep the variable names the same so it is easier to understand.
QUESTION
I am currently writing a Firefox extension that uses fuzzy search to highligth words on a web page.
The highlighting is done by creating a range that contains the match, then wrapping the content of the range around a custom element. This method from my perspective is equivalent to splitting the text node's text and copying it manually to a newly created node.
The pre-release version of the add-on works beautifully, however there's one type of css styling that I cannot deal with: display: flex; justify-content: space-between
. The issue here is that when I partially wrap the content of a node styled as such, the rendered text loses its integrity.
Below you can find a simple demonstration. You can see that after 1 sec when the formatting starts, the 1st paragraph gets spaced out, while the 2nd one remains intact.
Could someone suggest a solution/workaround to this problem? I'd like to leave the web page's css intact so modifying the element's style is out of the question. I have checked mark.js API and it cannot handle this situation either. I wonder how the browser's built-in ctrl-f Highlight All searchbar deals with this..
...ANSWER
Answered 2020-Nov-22 at 16:58Can you modify html? Do you need to keep raw text inside the element with problematicClass
?
Easy solution is to wrap block of text in ex. .
QUESTION
I am using bootstrap carousel to make a website for a school project.
I want the search input box to highlight all text on the page its on so I Googled and found mark.js
: https://markjs.io/
And I looked at the Search bar with jump to matches
example which leads me here: https://jsfiddle.net/bap5uf8e/
So I copied and pasted the html into index.html
added all the basic elements like !DOCTYPE html
, head
and body
, copied the css into a test.css
and referenced to it in the of
index.html
. For the JS, I cloned the repo for mark.js
and put it in my project folder so the tree looks like this:
ANSWER
Answered 2020-Sep-05 at 20:23This worked:
QUESTION
I have just started using mark.js (https://markjs.io), and right now I am trying to find the right RegEx to capture as little data as possible (non-greedy type), and no more than a certain number of characters.
I tried multiple options, and so far I have these three regular expressions, but each has its own faults:
w(.{1,30})?3
- captures 'word1 word2 word3 wo rd3', instead of 'word3' and 'wo rd3';w(\w{1,30})?3
- captures 'word3' as it should, but fails for 'wo rd3';w((\w| ){1,30})?3
- this behaves exactly like the 1st option above.
For a better understanding, please run the code below.
What do you think, what am I missing here, please?
Alex
...ANSWER
Answered 2020-Aug-01 at 07:53
w(.{1,30})?3
- captures 'word1 word2 word3 wo rd3', instead of 'word3' and 'wo rd3';
Yes, because .{1, 30}
means capture up to 30 of any character (other than newlines). And since you have only 22 characters between the first w
and the last 3
, it will match everything.
w(\w{1,30})?3
- captures 'word3' as it should, but fails for 'wo rd3';
Yes, because \w
only matches word characters, not whitespace.
w((\w| ){1,30})?3
- this behaves exactly like the 1st option above.
Yes, because (\w | )
is nearly identical to .
. (.
will also match \t
and other kinds of whitespace.)
If you want to match anything starting with a w
and ending with 3
, with at most one space in between, you can use:
QUESTION
i am currently using mark.js for a google chrome extension to highlight some text on a web page.
Now whenever i refresh the page or do a right click all my marking is lost.
Is there a way to keep that marking? As far as i see mark.js does not change the DOM. I would like to mark the text but also be able e.g. when i print that page or save it as a pdf, to maintain the highlighting i did..
That is the way i mark. it is pretty much the same as instructed on https://markjs.io/:
...ANSWER
Answered 2020-Jan-20 at 10:17Found a way to overcome that problem. Just store the text items you want to mark and mark them again every time a page gets refreshed.
QUESTION
What I'm trying to accomplish is highlight a text that given by parameter inside a raw text which format is HTML.
I'm working with Angular 7 and tried to do that jQuery functions and some third party libs but did not do that yet.
Here the scenario;
raw HTML text comes as below
...ANSWER
Answered 2019-Dec-27 at 12:00You're almost there, but in Angular, code between double braces {{
}}
will be rendered as escaped html text (plain text). In order to your string be rendered as html, it must be in the attribute innerHTML
of your parent element, like this:
QUESTION
I'm working on a jquery search (mark.js) that highlights words on a page based on user input. I'm able to highlight the results, but the results do not display i.e. "1 of 1 matches". The matches should appear in matches
. I am not sure how to get it to work. Here is my JSFiddle:
ANSWER
Answered 2019-Aug-15 at 07:12Here is your updated code.Need to change only input event
QUESTION
I'm trying to highlight a query inside a text coming from an ajax response, before constructing HTML with it and pasting that into the DOM. Right now I'm using this code snippet:
...ANSWER
Answered 2018-Jun-01 at 09:25Snippet style: Warning: this uses DOM7 as per Question
Overview: Instead of appending the whole text as HTML string to your #container, Append the portions of normal text, as text, and the highlighted elements as elements, so you can style them at will.
QUESTION
I have a text block that is of a fixed width, and I'm trying to get each line of text's boundingClientRect. I'm wondering if the Selection api has a method for doing so that I'm just missing. Is there any simple way to get each line of a selected text?
Currently, the only solution I can think of is to create spans around each character in the selection and then join the characters if they have the same y coordinate in their bounding client rect. This is very inefficient, so I'm curious if there's a more simple method.
Below is an image representation of what I'm trying to find. The selection api only gives a rectangle around the box as a whole, including unselected text. I'm trying to find rectangles around each selection line.
The selection will always be text. So no need to worry about images. However, they may be in different elements, but they will be the same tag type (no links for example or em/strong tags).
Returns the selected block of text
...ANSWER
Answered 2019-Apr-10 at 16:48You can use getClientRects
instead:
QUESTION
I am trying to extent a mixin class in polymer. It works fine but as soon as I try to transpile my code with babel, I get Class constructor PolymerElement cannot be invoked without 'new. I get the error as soon as I call super. I am sure the problem has something to do with extend a native class with a transpiled class code but I could not yet find a resource/example that managed to solve my issue. My guess is that I need to configure my babel differently, but as I said, found examples did not help. You can access the repository where I am reproducing the error here: https://github.com/skukan159/DebuggingPolymerWebpack
This is my webpack config:
...ANSWER
Answered 2019-Jan-21 at 10:01I found out what was the problem. I needed to comment out options for my babel loader from the webpack config file. Only that way was my .babelrc configuration file being applied.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install markjs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page