mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 04:47:21 +02:00
Compare commits
No commits in common. "85e6f3c92b0d26b1c0ca740855a008ac32dd7978" and "72feb4c25694d1e4dcfe44a3243a5c91605be513" have entirely different histories.
85e6f3c92b
...
72feb4c256
@ -306,16 +306,6 @@ export default [
|
|||||||
selector: "NewExpression[callee.name='Ref']",
|
selector: "NewExpression[callee.name='Ref']",
|
||||||
message: "Use `Ref.get()` rather than `new Ref()`.",
|
message: "Use `Ref.get()` rather than `new Ref()`.",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
selector: "ExportNamedDeclaration[declaration]",
|
|
||||||
message:
|
|
||||||
"Separate the declaration and the export statement, using `export { ... }`.",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
selector: "ExportDefaultDeclaration:has(> :declaration)",
|
|
||||||
message:
|
|
||||||
"Separate the declaration and the export statement, using `export default <variable name>`.",
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
"no-unneeded-ternary": "error",
|
"no-unneeded-ternary": "error",
|
||||||
"operator-assignment": "error",
|
"operator-assignment": "error",
|
||||||
|
|||||||
@ -16,7 +16,6 @@
|
|||||||
// In mozilla-central, this file is loaded as non-module script,
|
// In mozilla-central, this file is loaded as non-module script,
|
||||||
// so it mustn't have any dependencies.
|
// so it mustn't have any dependencies.
|
||||||
|
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
|
||||||
export class SandboxSupportBase {
|
export class SandboxSupportBase {
|
||||||
/**
|
/**
|
||||||
* @param {DOMWindow} - win
|
* @param {DOMWindow} - win
|
||||||
|
|||||||
@ -217,104 +217,6 @@ describe("Text layer", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("doesn't jump when hovering on an empty area, with .markedContent", () => {
|
|
||||||
let pages;
|
|
||||||
|
|
||||||
beforeAll(async () => {
|
|
||||||
pages = await loadAndWait(
|
|
||||||
"chrome-text-selection-markedContent.pdf",
|
|
||||||
`.page[data-page-number = "1"] .endOfContent`
|
|
||||||
);
|
|
||||||
});
|
|
||||||
afterAll(async () => {
|
|
||||||
await closePages(pages);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("in per-character selection mode", async () => {
|
|
||||||
await Promise.all(
|
|
||||||
pages.map(async ([browserName, page]) => {
|
|
||||||
const [positionStart, positionEnd] = await Promise.all([
|
|
||||||
getSpanRectFromText(
|
|
||||||
page,
|
|
||||||
1,
|
|
||||||
"strengthen in the coming quarters as the railway projects under"
|
|
||||||
).then(middlePosition),
|
|
||||||
getSpanRectFromText(
|
|
||||||
page,
|
|
||||||
1,
|
|
||||||
"development enter the construction phase (estimated at around"
|
|
||||||
).then(belowEndPosition),
|
|
||||||
]);
|
|
||||||
|
|
||||||
await page.mouse.move(positionStart.x, positionStart.y);
|
|
||||||
await page.mouse.down();
|
|
||||||
await moveInSteps(page, positionStart, positionEnd, 20);
|
|
||||||
await page.mouse.up();
|
|
||||||
|
|
||||||
await expectAsync(page)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toHaveRoughlySelected(
|
|
||||||
"rs as the railway projects under\n" +
|
|
||||||
"development enter the construction phase (estimated at "
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("in per-word selection mode", async () => {
|
|
||||||
await Promise.all(
|
|
||||||
pages.map(async ([browserName, page]) => {
|
|
||||||
const [positionStart, positionEnd] = await Promise.all([
|
|
||||||
getSpanRectFromText(
|
|
||||||
page,
|
|
||||||
1,
|
|
||||||
"strengthen in the coming quarters as the railway projects under"
|
|
||||||
).then(middlePosition),
|
|
||||||
getSpanRectFromText(
|
|
||||||
page,
|
|
||||||
1,
|
|
||||||
"development enter the construction phase (estimated at around"
|
|
||||||
).then(belowEndPosition),
|
|
||||||
]);
|
|
||||||
|
|
||||||
if (browserName !== "firefox") {
|
|
||||||
await page.mouse.move(positionStart.x, positionStart.y);
|
|
||||||
await page.mouse.down({ clickCount: 1 });
|
|
||||||
await page.mouse.up({ clickCount: 1 });
|
|
||||||
await page.mouse.down({ clickCount: 2 });
|
|
||||||
} else {
|
|
||||||
// When running tests with Firefox we use WebDriver BiDi, for
|
|
||||||
// which puppeteer doesn't support emulating "double click and
|
|
||||||
// hold". We need to manually dispatch an action through the
|
|
||||||
// protocol.
|
|
||||||
// See https://github.com/puppeteer/puppeteer/issues/13745.
|
|
||||||
await page.mainFrame().browsingContext.performActions([
|
|
||||||
{
|
|
||||||
type: "pointer",
|
|
||||||
id: "__puppeteer_mouse",
|
|
||||||
actions: [
|
|
||||||
{ type: "pointerMove", ...positionStart },
|
|
||||||
{ type: "pointerDown", button: 0 },
|
|
||||||
{ type: "pointerUp", button: 0 },
|
|
||||||
{ type: "pointerDown", button: 0 },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
await moveInSteps(page, positionStart, positionEnd, 20);
|
|
||||||
await page.mouse.up();
|
|
||||||
|
|
||||||
await expectAsync(page)
|
|
||||||
.withContext(`In ${browserName}`)
|
|
||||||
.toHaveRoughlySelected(
|
|
||||||
"quarters as the railway projects under\n" +
|
|
||||||
"development enter the construction phase (estimated at around"
|
|
||||||
);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("when selecting over a link", () => {
|
describe("when selecting over a link", () => {
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -718,4 +718,3 @@
|
|||||||
!issue19424.pdf
|
!issue19424.pdf
|
||||||
!issue18529.pdf
|
!issue18529.pdf
|
||||||
!issue16742.pdf
|
!issue16742.pdf
|
||||||
!chrome-text-selection-markedContent.pdf
|
|
||||||
|
|||||||
Binary file not shown.
@ -307,14 +307,6 @@ class TextLayerBuilder {
|
|||||||
if (anchor.nodeType === Node.TEXT_NODE) {
|
if (anchor.nodeType === Node.TEXT_NODE) {
|
||||||
anchor = anchor.parentNode;
|
anchor = anchor.parentNode;
|
||||||
}
|
}
|
||||||
if (!modifyStart && range.endOffset === 0) {
|
|
||||||
do {
|
|
||||||
while (!anchor.previousSibling) {
|
|
||||||
anchor = anchor.parentNode;
|
|
||||||
}
|
|
||||||
anchor = anchor.previousSibling;
|
|
||||||
} while (!anchor.childNodes.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
const parentTextLayer = anchor.parentElement?.closest(".textLayer");
|
const parentTextLayer = anchor.parentElement?.closest(".textLayer");
|
||||||
const endDiv = this.#textLayers.get(parentTextLayer);
|
const endDiv = this.#textLayers.get(parentTextLayer);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user