diff options
author | Hsieh Chin Fan <pham@topo.tw> | 2024-10-30 17:00:45 +0800 |
---|---|---|
committer | Hsieh Chin Fan <pham@topo.tw> | 2024-10-31 11:31:00 +0800 |
commit | 6a468847939c8983b7e2ad2a0604d66beebdb94f (patch) | |
tree | 9201ab9fca489af7843de28768cc97e606c5f41f /src/editor.mjs | |
parent | cba9e807dd39f3c03a66c554c092b0b2c094ba38 (diff) |
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!
Diffstat (limited to 'src/editor.mjs')
-rw-r--r-- | src/editor.mjs | 14 |
1 files changed, 7 insertions, 7 deletions
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) { | |||
434 | } | 434 | } |
435 | 435 | ||
436 | if (context.dataset.mode !== 'editing') { | 436 | if (context.dataset.mode !== 'editing') { |
437 | const switchToEditingMode = new menuItem.Item({ | 437 | const switchToEditingMode = menuItem.Item({ |
438 | innerHTML: '<strong>EDIT</strong>', | 438 | innerHTML: '<strong>EDIT</strong>', |
439 | onclick: () => (context.dataset.mode = 'editing'), | 439 | onclick: () => (context.dataset.mode = 'editing'), |
440 | }) | 440 | }) |
@@ -443,7 +443,7 @@ function menuForEditor (event, menu) { | |||
443 | 443 | ||
444 | // const map = event.target.closest('.mapclay') | 444 | // const map = event.target.closest('.mapclay') |
445 | // if (map) { | 445 | // if (map) { |
446 | // const item = new menuItem.Item({ | 446 | // const item = menuItem.Item({ |
447 | // text: 'Add Anchor', | 447 | // text: 'Add Anchor', |
448 | // onclick: () => { | 448 | // onclick: () => { |
449 | // let anchorName | 449 | // let anchorName |
@@ -629,7 +629,7 @@ const getSuggestionsForOptions = (optionTyped, validOptions) => { | |||
629 | 629 | ||
630 | return suggestOptions.map( | 630 | return suggestOptions.map( |
631 | o => | 631 | o => |
632 | new menuItem.Suggestion({ | 632 | menuItem.Suggestion({ |
633 | text: `<span>${o.valueOf()}</span><span class='info' title="${o.desc ?? ''}">ⓘ</span>`, | 633 | text: `<span>${o.valueOf()}</span><span class='info' title="${o.desc ?? ''}">ⓘ</span>`, |
634 | replace: `${o.valueOf()}: `, | 634 | replace: `${o.valueOf()}: `, |
635 | cm, | 635 | cm, |
@@ -649,7 +649,7 @@ const getSuggestionFromMapOption = option => { | |||
649 | ? `<span>${option.example_desc}</span><span class="truncate"style="color: gray">${option.example}</span>` | 649 | ? `<span>${option.example_desc}</span><span class="truncate"style="color: gray">${option.example}</span>` |
650 | : `<span>${option.example}</span>` | 650 | : `<span>${option.example}</span>` |
651 | 651 | ||
652 | return new menuItem.Suggestion({ | 652 | return menuItem.Suggestion({ |
653 | text, | 653 | text, |
654 | replace: `${option.valueOf()}: ${option.example ?? ''}`, | 654 | replace: `${option.valueOf()}: ${option.example ?? ''}`, |
655 | cm, | 655 | cm, |
@@ -665,7 +665,7 @@ const getSuggestionsFromAliases = option => | |||
665 | Object.entries(aliasesForMapOptions[option.valueOf()] ?? {})?.map(record => { | 665 | Object.entries(aliasesForMapOptions[option.valueOf()] ?? {})?.map(record => { |
666 | const [alias, value] = record | 666 | const [alias, value] = record |
667 | const valueString = JSON.stringify(value).replaceAll('"', '') | 667 | const valueString = JSON.stringify(value).replaceAll('"', '') |
668 | return new menuItem.Suggestion({ | 668 | return menuItem.Suggestion({ |
669 | text: `<span>${alias}</span><span class="truncate" style="color: gray">${valueString}</span>`, | 669 | text: `<span>${alias}</span><span class="truncate" style="color: gray">${valueString}</span>`, |
670 | replace: `${option.valueOf()}: ${valueString}`, | 670 | replace: `${option.valueOf()}: ${valueString}`, |
671 | cm, | 671 | cm, |
@@ -789,7 +789,7 @@ const getSuggestions = anchor => { | |||
789 | }) | 789 | }) |
790 | .map( | 790 | .map( |
791 | ([renderer, info]) => | 791 | ([renderer, info]) => |
792 | new menuItem.Suggestion({ | 792 | menuItem.Suggestion({ |
793 | text: `<span>use: ${renderer}</span><span class='info' title="${info.desc}">ⓘ</span>`, | 793 | text: `<span>use: ${renderer}</span><span class='info' title="${info.desc}">ⓘ</span>`, |
794 | replace: `use: ${renderer}`, | 794 | replace: `use: ${renderer}`, |
795 | cm, | 795 | cm, |
@@ -799,7 +799,7 @@ const getSuggestions = anchor => { | |||
799 | ? [] | 799 | ? [] |
800 | : [ | 800 | : [ |
801 | ...rendererSuggestions, | 801 | ...rendererSuggestions, |
802 | new menuItem.Item({ | 802 | menuItem.Item({ |
803 | innerHTML: '<a href="https://github.com/outdoorsafetylab/mapclay#renderer" class="external" style="display: block;">More...</a>', | 803 | innerHTML: '<a href="https://github.com/outdoorsafetylab/mapclay#renderer" class="external" style="display: block;">More...</a>', |
804 | className: ['suggestion'], | 804 | className: ['suggestion'], |
805 | onclick: () => window.open('https://github.com/outdoorsafetylab/mapclay#renderer', '_blank'), | 805 | onclick: () => window.open('https://github.com/outdoorsafetylab/mapclay#renderer', '_blank'), |