From 6a468847939c8983b7e2ad2a0604d66beebdb94f Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 30 Oct 2024 17:00:45 +0800 Subject: refactor: remove custom elements REASON: apply custom elements in content script may change globalThis which is not equal to window. This makes type check in maplibregl always fails! --- src/editor.mjs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/editor.mjs') diff --git a/src/editor.mjs b/src/editor.mjs index f7b9c65..8d22918 100644 --- a/src/editor.mjs +++ b/src/editor.mjs @@ -434,7 +434,7 @@ function menuForEditor (event, menu) { } if (context.dataset.mode !== 'editing') { - const switchToEditingMode = new menuItem.Item({ + const switchToEditingMode = menuItem.Item({ innerHTML: 'EDIT', onclick: () => (context.dataset.mode = 'editing'), }) @@ -443,7 +443,7 @@ function menuForEditor (event, menu) { // const map = event.target.closest('.mapclay') // if (map) { - // const item = new menuItem.Item({ + // const item = menuItem.Item({ // text: 'Add Anchor', // onclick: () => { // let anchorName @@ -629,7 +629,7 @@ const getSuggestionsForOptions = (optionTyped, validOptions) => { return suggestOptions.map( o => - new menuItem.Suggestion({ + menuItem.Suggestion({ text: `${o.valueOf()}`, replace: `${o.valueOf()}: `, cm, @@ -649,7 +649,7 @@ const getSuggestionFromMapOption = option => { ? `${option.example_desc}${option.example}` : `${option.example}` - return new menuItem.Suggestion({ + return menuItem.Suggestion({ text, replace: `${option.valueOf()}: ${option.example ?? ''}`, cm, @@ -665,7 +665,7 @@ const getSuggestionsFromAliases = option => Object.entries(aliasesForMapOptions[option.valueOf()] ?? {})?.map(record => { const [alias, value] = record const valueString = JSON.stringify(value).replaceAll('"', '') - return new menuItem.Suggestion({ + return menuItem.Suggestion({ text: `${alias}${valueString}`, replace: `${option.valueOf()}: ${valueString}`, cm, @@ -789,7 +789,7 @@ const getSuggestions = anchor => { }) .map( ([renderer, info]) => - new menuItem.Suggestion({ + menuItem.Suggestion({ text: `use: ${renderer}`, replace: `use: ${renderer}`, cm, @@ -799,7 +799,7 @@ const getSuggestions = anchor => { ? [] : [ ...rendererSuggestions, - new menuItem.Item({ + menuItem.Item({ innerHTML: 'More...', className: ['suggestion'], onclick: () => window.open('https://github.com/outdoorsafetylab/mapclay#renderer', '_blank'), -- cgit v1.2.3-70-g09d2