From 60475746ca3590ec46d5279912b218fbd813b375 Mon Sep 17 00:00:00 2001 From: Just van Rossum Date: Mon, 22 Jan 2024 15:05:56 +0100 Subject: [PATCH] Move helper to new common place for view helpers --- src/fontra/client/core/view-tools.js | 11 +++++++++++ src/fontra/views/editor/editor.js | 13 +------------ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 100644 src/fontra/client/core/view-tools.js diff --git a/src/fontra/client/core/view-tools.js b/src/fontra/client/core/view-tools.js new file mode 100644 index 0000000000..7246ce771a --- /dev/null +++ b/src/fontra/client/core/view-tools.js @@ -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; +} diff --git a/src/fontra/views/editor/editor.js b/src/fontra/views/editor/editor.js index f5f1586a9d..8402ab8a46 100644 --- a/src/fontra/views/editor/editor.js +++ b/src/fontra/views/editor/editor.js @@ -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"; @@ -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) {