Skip to content

Commit

Permalink
Move helper to new common place for view helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Jan 22, 2024
1 parent d22e023 commit 6047574
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
11 changes: 11 additions & 0 deletions src/fontra/client/core/view-tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function makeDisplayPath(pathItems) {
const displayPathItems = !pathItems[0].includes(":")
? ["", ...pathItems]
: [...pathItems];
let displayPath = displayPathItems.join("/");
while (displayPathItems.length > 2 && displayPath.length > 60) {
displayPathItems.splice(1, 1);
displayPath = [displayPathItems[0], "...", ...displayPathItems.slice(1)].join("/");
}
return displayPath;
}
13 changes: 1 addition & 12 deletions src/fontra/views/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { addItemwise, mulScalar, subItemwise } from "../core/var-funcs.js";
import { StaticGlyph, VariableGlyph, copyComponent } from "../core/var-glyph.js";
import { locationToString, makeSparseLocation } from "../core/var-model.js";
import { VarPackedPath, joinPaths } from "../core/var-path.js";
import { makeDisplayPath } from "../core/view-tools.js";
import { CJKDesignFrame } from "./cjk-design-frame.js";
import { HandTool } from "./edit-tools-hand.js";
import { PenTool } from "./edit-tools-pen.js";
Expand Down Expand Up @@ -1980,18 +1981,6 @@ function matchEvent(handlerDef, event) {
return true;
}

function makeDisplayPath(pathItems) {
const displayPathItems = !pathItems[0].includes(":")
? ["", ...pathItems]
: [...pathItems];
let displayPath = displayPathItems.join("/");
while (displayPathItems.length > 2 && displayPath.length > 60) {
displayPathItems.splice(1, 1);
displayPath = [displayPathItems[0], "...", ...displayPathItems.slice(1)].join("/");
}
return displayPath;
}

function newVisualizationLayersSettings(visualizationLayers) {
const settings = [];
for (const definition of visualizationLayers.definitions) {
Expand Down

0 comments on commit 6047574

Please sign in to comment.