Skip to content

Commit

Permalink
Improved notification when widget couldn't be highlighted due to text…
Browse files Browse the repository at this point in the history
… limit size
  • Loading branch information
GreenAsh committed Nov 9, 2021
1 parent ecb74a4 commit c702d91
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/feedback.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!doctype html><html lang="en"><head><title>miro-code-highlighter-plugin feedback</title><script src="https://miro.com/app/static/sdk.1.1.js"></script><link rel="stylesheet" href="https://unpkg.com/mirotone/dist/styles.css"/><script src="https://browser.sentry-cdn.com/6.14.0/bundle.min.js" integrity="sha384-1FVbcJ5cSGdCrMNyUndHGSl0WlS+Cq5zaYdfnVF7NqkkQpU+7plvm0NomKbzcD//" crossorigin="anonymous"></script><script>Sentry.init({
dsn: 'https://[email protected]/1831923',
release: '[email protected].14'
release: '[email protected].15'
});</script></head><body><div class="grid"><div class="cs11 ce12 grid" style="text-align: right"><button class="button-icon" style="width:40px; height: 40px;"></button> <button class="button-icon button-icon-small icon-close" type="button" onclick="miro.board.ui.closeModal();"></button></div><div class="cs2 ce11 form-group"><textarea id="feedback_area" class="textarea" placeholder="Please write your feedback here" rows="4" maxlength="1000"></textarea></div><div class="cs5 ce8"><button class="button button-primary" onclick="sendFeedback()">Send Feedback</button></div></div></body></html><script>function sendFeedback() {
try {
const feedbackText = document.getElementById('feedback_area').value;
Expand Down
4 changes: 2 additions & 2 deletions dist/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html><html lang="en"><head><title>miro-code-syntax-highlighter-plugin</title><script src="https://miro.com/app/static/sdk.1.1.js"></script><script src="https://browser.sentry-cdn.com/6.14.0/bundle.min.js" integrity="sha384-1FVbcJ5cSGdCrMNyUndHGSl0WlS+Cq5zaYdfnVF7NqkkQpU+7plvm0NomKbzcD//" crossorigin="anonymous"></script><script>Sentry.init({
dsn: 'https://[email protected]/1831923',
release: '[email protected].14'
});</script><script src="syntax-highlighter-miro-plugin.js?v0.5.14"></script></head><body><p><b>This is the main miro plugin page.</b> It's useful only within https://miro.com</p></body></html>
release: '[email protected].15'
});</script><script src="syntax-highlighter-miro-plugin.js?v0.5.15"></script></head><body><p><b>This is the main miro plugin page.</b> It's useful only within https://miro.com</p></body></html>
4 changes: 2 additions & 2 deletions dist/settings.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Color Highlighter Settings</title><link rel="stylesheet" href="https://unpkg.com/mirotone/dist/styles.css"/><script src="https://browser.sentry-cdn.com/6.14.0/bundle.min.js" integrity="sha384-1FVbcJ5cSGdCrMNyUndHGSl0WlS+Cq5zaYdfnVF7NqkkQpU+7plvm0NomKbzcD//" crossorigin="anonymous"></script><script>Sentry.init({
dsn: 'https://[email protected]/1831923',
release: '[email protected].14'
});</script><script src="https://miro.com/app/static/sdk.1.1.js"></script></head><body><div class="grid"><div class="cs2 ce10"><h3 class="h3">Code syntax highlighter Settings</h3></div><div class="cs11 ce12 grid"><button class="button-icon button-icon-small icon-help" type="button" onclick="location.href='feedback.html';"></button> <button class="button-icon button-icon-small icon-close" type="button" onclick="miro.board.ui.closeModal();"></button></div><div class="cs1 ce12" style="height: 10px;">&nbsp;</div><div class="cs2 ce4">Default language</div><div class="cs5 ce11"><select id="languages" class="select"></select></div><div class="cs2 ce4">Theme</div><div class="cs5 ce11"><select id="themes_select" class="select"></select></div></div></body></html><script src="syntax-highlighter-settings.js?v0.5.14"></script>
release: '[email protected].15'
});</script><script src="https://miro.com/app/static/sdk.1.1.js"></script></head><body><div class="grid"><div class="cs2 ce10"><h3 class="h3">Code syntax highlighter Settings</h3></div><div class="cs11 ce12 grid"><button class="button-icon button-icon-small icon-help" type="button" onclick="location.href='feedback.html';"></button> <button class="button-icon button-icon-small icon-close" type="button" onclick="miro.board.ui.closeModal();"></button></div><div class="cs1 ce12" style="height: 10px;">&nbsp;</div><div class="cs2 ce4">Default language</div><div class="cs5 ce11"><select id="languages" class="select"></select></div><div class="cs2 ce4">Theme</div><div class="cs5 ce11"><select id="themes_select" class="select"></select></div></div></body></html><script src="syntax-highlighter-settings.js?v0.5.15"></script>
2 changes: 1 addition & 1 deletion dist/syntax-highlighter-miro-plugin.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions src/miro-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ async function highlightWidgets(lang: string, widgets:Array<IWidget>) {
}

let count = 0;
let errorNotification = '';

for (let i = 0; i < widgets.length; i++) {
let widget = widgets[i];
Expand All @@ -172,7 +173,9 @@ async function highlightWidgets(lang: string, widgets:Array<IWidget>) {
}
let highlightedText = await highlighter.highlight(lang, plainText);
if (highlightedText.length >= MAX_TEXT_SIZE) {
miro.showErrorNotification('Highlight failed, due to possible loss of data');
if (errorNotification === '') {
errorNotification = `Highlight failed, due to possible loss of data. One of highlighted text length: ${highlightedText.length}, limit: ${MAX_TEXT_SIZE}`;
}
const message = `Highlighted length: ${highlightedText.length} Cleaned length: ${plainText.length} Widget text length: ${widgetText.length}`;
Sentry.captureMessage(message);
console.warn(message);
Expand Down Expand Up @@ -206,7 +209,11 @@ async function highlightWidgets(lang: string, widgets:Array<IWidget>) {
console.error(e);
}
}
await miro.showNotification(`Highlighted ${count} widgets`);
if (errorNotification !== ''){
await miro.showErrorNotification(`Highlighted ${count} widgets. ` + errorNotification);
} else {
await miro.showNotification(`Highlighted ${count} widgets`);
}
}

const BLOCK_ELEMENTS = new Map<string, number>([
Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin");

version = '0.5.14'
version = '0.5.15'

module.exports = {
mode: 'production',
Expand Down

0 comments on commit c702d91

Please sign in to comment.