-
Notifications
You must be signed in to change notification settings - Fork 131
Custom insert map #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
keshav234156
wants to merge
9
commits into
publiclab:main
Choose a base branch
from
keshav234156:CustomInsertMap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Custom insert map #546
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8516760
updated privacy link (#413)
anshukaira f537064
FIX: adds missing entries in .gitignore (#423)
shreyaa-s-zz ab8ba9f
Merge branch 'master' of https://github.com/publiclab/PublicLab.Edito…
keshav234156 6551b5f
Merge branch 'main' of https://github.com/publiclab/PublicLab.Editor …
keshav234156 c60113f
Merge branch 'main' of https://github.com/publiclab/PublicLab.Editor …
keshav234156 53b0ee3
Custom Insert Maps
keshav234156 ddbe58e
Merge branch 'main' of https://github.com/publiclab/PublicLab.Editor …
keshav234156 b64ef7a
Added test
keshav234156 186f86b
fux conflict
keshav234156 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
|
|
||
| module.exports = function CustomInsert(_module, wysiwyg) { | ||
| function Syntax(Latitude, Longitude, Layers) { | ||
| var syn = "[map:content:" + Latitude + ":" + Longitude; | ||
| if(Layers) | ||
| syn = syn + ":" + Layers; | ||
| syn = syn + "]" | ||
| return syn; | ||
| } | ||
|
|
||
| $('.wk-commands').append('<a class="woofmark-command-insert-map btn btn-default" data-toggle="Insert" title="Custom Insert Maps"><i class="fa fa-globe"></i></a>'); | ||
|
|
||
| var builder = '<div class="input-group">'; | ||
| builder += '<input type="number" class="form-control" placeholder="Latitude" id="Latitude" style="min-width: 150px;" required>'; | ||
| builder += '<input type="number" class="form-control" placeholder="Longitude" id="Longitude" style="min-width: 150px;">'; | ||
| builder += '<input type="text" class="form-control" placeholder="Preset Layers(separated with commas)" id="layer" style="min-width: 150px;">'; | ||
| builder += '<button class="btn btn-default" type="button" id ="submit">Go!</button>'; | ||
| builder += '</div>'; | ||
|
|
||
| $('.woofmark-command-insert-map').attr('data-content', builder); | ||
| $('.woofmark-command-insert-map').attr('data-container', 'body'); | ||
| $('.woofmark-command-insert-map').attr('data-placement','top'); | ||
| $('.woofmark-command-insert-map').popover({ html : true,sanitize: false}); | ||
| $('.wk-commands .woofmark-command-insert-map').click(function() { | ||
| $('#submit').click(function(){ | ||
| wysiwyg.runCommand(function(chunks, mode){ | ||
| var syntax = Syntax($('#Latitude')[0].value, $('#Longitude')[0].value, $('#layer')[0].value); | ||
| if (mode === 'markdown') chunks.before += syntax; | ||
| else { | ||
| chunks.before += _module.wysiwyg.parseMarkdown(syntax); | ||
| } | ||
| }) | ||
| }) | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| const timeout = process.env.SLOWMO ? 60000 : 10000; | ||
| const fs = require('fs'); | ||
| beforeAll(async () => { | ||
| path = fs.realpathSync('file://../examples/index.html'); | ||
| await page.goto('file://' + path, {waitUntil: 'domcontentloaded'}); | ||
| }); | ||
|
|
||
| describe('Custom Insert Map', () => { | ||
| test('Add Custom Insert Map in rich text mode', async () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd also love to incorporate any feedback people offer on this comment in this PR as well. Does that sound all right? Thanks!! |
||
| await page.waitForSelector('.ple-module-body'); | ||
| // Click on insert Map button | ||
| await page.click('.woofmark-command-insert-map'); | ||
| // Input Latitude value | ||
| await page.waitForSelector('#Latitude'); | ||
| await page.$eval('#Latitude', el => el.value = 50); | ||
| //Input Longitude value | ||
| await page.click('#Longitude'); | ||
| await page.$eval('#Longitude', el => el.value = 25); | ||
| // Input layers value | ||
| await page.click('#layer'); | ||
| await page.$eval('#layer', el => el.value = 'layer1,layer2'); | ||
| //Press the submit button | ||
| await page.click('#submit'); | ||
| await page.click('.woofmark-command-insert-map'); | ||
| //Evaluate the expression | ||
| await page.waitForSelector('.powertags'); | ||
| const stringIsIncluded = await page.evaluate(() => document.querySelector('.wk-wysiwyg').textContent.includes("Power tag: map:content:50:25:layer1,layer2")); | ||
| expect(stringIsIncluded).toBe(true); | ||
| }, timeout); | ||
| }) | ||
|
|
||
| describe('Custom Insert Map', () => { | ||
| test('Custpm Insert Map in Mardown mode', async () => { | ||
| await page.waitForSelector('.ple-module-body'); | ||
| // Click on Mardown mode button | ||
| await page.waitForSelector('.woofmark-mode-markdown'); | ||
| await page.click('.woofmark-mode-markdown'); | ||
| await page.evaluate(() => document.querySelector('.ple-textarea').value += ' '); | ||
| // Click on insert Map button | ||
| await page.click('.woofmark-command-insert-map'); | ||
| // Input Latitude value | ||
| await page.waitForSelector('#Latitude'); | ||
| await page.$eval('#Latitude', el => el.value = 50); | ||
| //Input Longitude value | ||
| await page.click('#Longitude'); | ||
| await page.$eval('#Longitude', el => el.value = 25); | ||
| // Input layers value | ||
| await page.click('#layer'); | ||
| await page.$eval('#layer', el => el.value = 'layer1,layer2'); | ||
| //Press the submit button | ||
| await page.click('#submit'); | ||
| await page.click('.woofmark-command-insert-map'); | ||
| //Evaluate the expression | ||
| let stringIsIncluded = await page.evaluate(() => document.querySelector('.ple-textarea').value.includes('[map:content:50:25:layer1,layer2]')); | ||
| expect(stringIsIncluded).toBe(true); | ||
| }, timeout); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I have some similar questions to this comment about the classnames and ids here. What do you think?