Skip to content

Commit

Permalink
Merge pull request #18349 from Snuffleupagus/rm-renderTextLayer
Browse files Browse the repository at this point in the history
[api-minor] Remove the deprecated `renderTextLayer` and `updateTextLayer` functions (PR 18104 follow-up)
  • Loading branch information
timvandermeij authored Jul 2, 2024
2 parents 59620d3 + f3d177e commit ccad2f8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 56 deletions.
40 changes: 2 additions & 38 deletions src/display/text_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/** @typedef {import("./api").TextContent} TextContent */

import { AbortException, Util, warn } from "../shared/util.js";
import { deprecated, setLayerDimensions } from "./display_utils.js";
import { setLayerDimensions } from "./display_utils.js";

/**
* @typedef {Object} TextLayerParameters
Expand Down Expand Up @@ -557,40 +557,4 @@ class TextLayer {
}
}

function renderTextLayer() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
return;
}
deprecated("`renderTextLayer`, please use `TextLayer` instead.");

const { textContentSource, container, viewport, ...rest } = arguments[0];
const restKeys = Object.keys(rest);
if (restKeys.length > 0) {
warn("Ignoring `renderTextLayer` parameters: " + restKeys.join(", "));
}

const textLayer = new TextLayer({
textContentSource,
container,
viewport,
});

const { textDivs, textContentItemsStr } = textLayer;
const promise = textLayer.render();

// eslint-disable-next-line consistent-return
return {
promise,
textDivs,
textContentItemsStr,
};
}

function updateTextLayer() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
return;
}
deprecated("`updateTextLayer`, please use `TextLayer` instead.");
}

export { renderTextLayer, TextLayer, updateTextLayer };
export { TextLayer };
8 changes: 1 addition & 7 deletions src/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,14 @@ import {
RenderingCancelledException,
setLayerDimensions,
} from "./display/display_utils.js";
import {
renderTextLayer,
TextLayer,
updateTextLayer,
} from "./display/text_layer.js";
import { AnnotationEditorLayer } from "./display/editor/annotation_editor_layer.js";
import { AnnotationEditorUIManager } from "./display/editor/tools.js";
import { AnnotationLayer } from "./display/annotation_layer.js";
import { ColorPicker } from "./display/editor/color_picker.js";
import { DrawLayer } from "./display/draw_layer.js";
import { GlobalWorkerOptions } from "./display/worker_options.js";
import { Outliner } from "./display/editor/outliner.js";
import { TextLayer } from "./display/text_layer.js";
import { XfaLayer } from "./display/xfa_layer.js";

/* eslint-disable-next-line no-unused-vars */
Expand Down Expand Up @@ -121,12 +117,10 @@ export {
PermissionFlag,
PixelsPerInch,
RenderingCancelledException,
renderTextLayer,
setLayerDimensions,
shadow,
TextLayer,
UnexpectedResponseException,
updateTextLayer,
Util,
VerbosityLevel,
version,
Expand Down
8 changes: 1 addition & 7 deletions test/unit/pdf_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,14 @@ import {
RenderingCancelledException,
setLayerDimensions,
} from "../../src/display/display_utils.js";
import {
renderTextLayer,
TextLayer,
updateTextLayer,
} from "../../src/display/text_layer.js";
import { AnnotationEditorLayer } from "../../src/display/editor/annotation_editor_layer.js";
import { AnnotationEditorUIManager } from "../../src/display/editor/tools.js";
import { AnnotationLayer } from "../../src/display/annotation_layer.js";
import { ColorPicker } from "../../src/display/editor/color_picker.js";
import { DrawLayer } from "../../src/display/draw_layer.js";
import { GlobalWorkerOptions } from "../../src/display/worker_options.js";
import { Outliner } from "../../src/display/editor/outliner.js";
import { TextLayer } from "../../src/display/text_layer.js";
import { XfaLayer } from "../../src/display/xfa_layer.js";

const expectedAPI = Object.freeze({
Expand Down Expand Up @@ -106,12 +102,10 @@ const expectedAPI = Object.freeze({
PermissionFlag,
PixelsPerInch,
RenderingCancelledException,
renderTextLayer,
setLayerDimensions,
shadow,
TextLayer,
UnexpectedResponseException,
updateTextLayer,
Util,
VerbosityLevel,
version,
Expand Down
4 changes: 0 additions & 4 deletions web/pdfjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ const {
PermissionFlag,
PixelsPerInch,
RenderingCancelledException,
renderTextLayer,
setLayerDimensions,
shadow,
TextLayer,
UnexpectedResponseException,
updateTextLayer,
Util,
VerbosityLevel,
version,
Expand Down Expand Up @@ -99,12 +97,10 @@ export {
PermissionFlag,
PixelsPerInch,
RenderingCancelledException,
renderTextLayer,
setLayerDimensions,
shadow,
TextLayer,
UnexpectedResponseException,
updateTextLayer,
Util,
VerbosityLevel,
version,
Expand Down

0 comments on commit ccad2f8

Please sign in to comment.