aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/dumbyUtils.mjs
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-10-12 15:46:50 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-10-12 16:44:28 +0800
commit72704e3f5d5f4cbe00640be875955d4649f30780 (patch)
tree7571e0ddbf006cdd1e1b9b37fa43ddd089ee03b8 /src/dumbyUtils.mjs
parent49b0b5eeab42fbd93bd2458c32c6170ab3edd0bf (diff)
feat: use selection as default name of anchor
Diffstat (limited to 'src/dumbyUtils.mjs')
-rw-r--r--src/dumbyUtils.mjs3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dumbyUtils.mjs b/src/dumbyUtils.mjs
index 2f92c18..24699b3 100644
--- a/src/dumbyUtils.mjs
+++ b/src/dumbyUtils.mjs
@@ -267,6 +267,7 @@ const isAnchorVisible = anchor => {
267 * @param {Function} options.validateAnchorName -- validate anchor name is OK to use 267 * @param {Function} options.validateAnchorName -- validate anchor name is OK to use
268 */ 268 */
269export const addAnchorByPoint = ({ 269export const addAnchorByPoint = ({
270 defaultName,
270 point, 271 point,
271 map, 272 map,
272 validateAnchorName = () => true, 273 validateAnchorName = () => true,
@@ -281,7 +282,7 @@ export const addAnchorByPoint = ({
281 282
282 do { 283 do {
283 prompt = prompt ? 'Anchor name exists' : 'Name this anchor' 284 prompt = prompt ? 'Anchor name exists' : 'Name this anchor'
284 anchorName = window.prompt(prompt, `${x},${y}`) 285 anchorName = window.prompt(prompt, defaultName ?? '')
285 } 286 }
286 while (anchorName !== null && !validateAnchorName(anchorName)) 287 while (anchorName !== null && !validateAnchorName(anchorName))
287 if (anchorName === null) return 288 if (anchorName === null) return