• Robert Knight's avatar
    Improve text selection behavior in VitalSource PDFs · 00763a2d
    Robert Knight authored
    Previously the text layer in VitalSource PDFs consisted of a set of
    absolutely positioned elements, one per word. When the user was making a
    text selection and the cursor was between words, the browser could not
    determine an appropriate caret position in the text. As a result text
    selection was tricky.
    
    Improve this by re-implementing ImageTextLayer to produce a more
    structured DOM tree. Group the characters into words, lines and columns.
    Words are laid out using inline layout into `<hypothesis-text-line>`
    elements, which are then arranged using block layouts into
    `<hypothesis-text-column>` elements. Columns are absolutely positioned.
    Within lines and columns the gaps between words and lines are fine-tuned
    using margins. This use of inline and block layouts allows the browser
    to set the selection correctly when the cursor is between words or
    lines. The visual gap between selected words has also been eliminated by
    adding inter-word spaces to the previous word.
    
     - Separate page layout analysis from DOM construction. This makes these
       elements easier to understand and improve.
    
     - Change DOM structure generated by `ImageTextLayer` to a hierarchical
       structure of words, lines and columns.
    
     - Change ImageTextLayer to use DOMRect and DOMPoint as the types for
       rect and point structs. This allows sharing of geometry utilities
       with other code.
    
     - Simplify rescaling of text layer when image size changes by
       expressing all margins, sizes and scales in the text layer in terms
       of CSS variables (`--x-scale` and `--y-scale`) defined on the root
       `<hypothesis-text-layer>` element. When the image is resized, these
       variables are simply updated to reflect the new image size.
    00763a2d
Name
Last commit
Last update
.github Loading commit data...
bin Loading commit data...
dev-server Loading commit data...
docs Loading commit data...
embedding-examples Loading commit data...
images Loading commit data...
requirements Loading commit data...
scripts Loading commit data...
src Loading commit data...
.babelrc Loading commit data...
.dockerignore Loading commit data...
.eslintignore Loading commit data...
.eslintrc Loading commit data...
.gitignore Loading commit data...
.npmignore Loading commit data...
.npmrc Loading commit data...
.prettierignore Loading commit data...
.python-version Loading commit data...
CODE_OF_CONDUCT Loading commit data...
Dockerfile Loading commit data...
Jenkinsfile Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
codecov.yml Loading commit data...
gulpfile.mjs Loading commit data...
package.json Loading commit data...
pyproject.toml Loading commit data...
requirements-dev.in Loading commit data...
rollup-boot.config.mjs Loading commit data...
rollup-tests.config.mjs Loading commit data...
rollup.config.mjs Loading commit data...
tailwind.config.mjs Loading commit data...
tox.ini Loading commit data...
tsconfig.json Loading commit data...
yarn.lock Loading commit data...