Made escaping prompt URLs automatic instead of optional again

pull/393/head
Zignature 2 years ago
parent 47f1e4f892
commit 16545eb0e1

@ -165,7 +165,6 @@ easyMDE.value('New input for **EasyMDE**');
- **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`. - **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`.
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`. - **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
- **escapePromptURLs**: If set to `true`, urlencodes and escapes links entered via the JS prompt to prevent malformed Markdown rendered links. Only works when `promptURLs` is set to `true`. Defaults to `false`.
- **promptTexts**: Customize the text used to prompt for URLs. - **promptTexts**: Customize the text used to prompt for URLs.
- **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`. - **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`.
- **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`. - **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`.
@ -277,7 +276,6 @@ const editor = new EasyMDE({
return "Loading..."; return "Loading...";
}, },
promptURLs: true, promptURLs: true,
escapePromptURLs: true,
promptTexts: { promptTexts: {
image: "Custom prompt for URL:", image: "Custom prompt for URL:",
link: "Custom prompt for URL:", link: "Custom prompt for URL:",

@ -849,10 +849,8 @@ function drawLink(editor) {
return false; return false;
} }
if (options.escapePromptURLs) { url = encodeURI(url);
url = encodeURI(url); if (/[()]/.test(url)) url = escapePromptURL(url);
if (/[()]/.test(url)) url = escapePromptURL(url);
}
} }
_replaceSelection(cm, stat.link, options.insertTexts.link, url); _replaceSelection(cm, stat.link, options.insertTexts.link, url);
} }
@ -871,10 +869,8 @@ function drawImage(editor) {
return false; return false;
} }
if (options.escapePromptURLs) { url = encodeURI(url);
url = encodeURI(url); if (/[()]/.test(url)) url = escapePromptURL(url);
if (/[()]/.test(url)) url = escapePromptURL(url);
}
} }
_replaceSelection(cm, stat.image, options.insertTexts.image, url); _replaceSelection(cm, stat.image, options.insertTexts.image, url);
} }

@ -197,7 +197,6 @@ declare namespace EasyMDE {
previewImagesInEditor?: boolean; previewImagesInEditor?: boolean;
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string; previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string;
promptURLs?: boolean; promptURLs?: boolean;
escapePromptURLs?: boolean;
renderingConfig?: RenderingOptions; renderingConfig?: RenderingOptions;
shortcuts?: Shortcuts; shortcuts?: Shortcuts;
showIcons?: ReadonlyArray<ToolbarButton>; showIcons?: ReadonlyArray<ToolbarButton>;

Loading…
Cancel
Save