mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
Mobile: Plugin API: Add support for the renderMarkup command (#11494)
This commit is contained in:
parent
81f3a02dba
commit
815b922988
@ -159,8 +159,6 @@ packages/app-desktop/commands/focusElement.js
|
|||||||
packages/app-desktop/commands/index.js
|
packages/app-desktop/commands/index.js
|
||||||
packages/app-desktop/commands/openNoteInNewWindow.js
|
packages/app-desktop/commands/openNoteInNewWindow.js
|
||||||
packages/app-desktop/commands/openProfileDirectory.js
|
packages/app-desktop/commands/openProfileDirectory.js
|
||||||
packages/app-desktop/commands/renderMarkup.test.js
|
|
||||||
packages/app-desktop/commands/renderMarkup.js
|
|
||||||
packages/app-desktop/commands/replaceMisspelling.js
|
packages/app-desktop/commands/replaceMisspelling.js
|
||||||
packages/app-desktop/commands/restoreNoteRevision.js
|
packages/app-desktop/commands/restoreNoteRevision.js
|
||||||
packages/app-desktop/commands/startExternalEditing.js
|
packages/app-desktop/commands/startExternalEditing.js
|
||||||
@ -995,6 +993,8 @@ packages/lib/commands/historyForward.js
|
|||||||
packages/lib/commands/index.js
|
packages/lib/commands/index.js
|
||||||
packages/lib/commands/openMasterPasswordDialog.js
|
packages/lib/commands/openMasterPasswordDialog.js
|
||||||
packages/lib/commands/permanentlyDeleteNote.js
|
packages/lib/commands/permanentlyDeleteNote.js
|
||||||
|
packages/lib/commands/renderMarkup.test.js
|
||||||
|
packages/lib/commands/renderMarkup.js
|
||||||
packages/lib/commands/synchronize.js
|
packages/lib/commands/synchronize.js
|
||||||
packages/lib/components/EncryptionConfigScreen/utils.test.js
|
packages/lib/components/EncryptionConfigScreen/utils.test.js
|
||||||
packages/lib/components/EncryptionConfigScreen/utils.js
|
packages/lib/components/EncryptionConfigScreen/utils.js
|
||||||
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -135,8 +135,6 @@ packages/app-desktop/commands/focusElement.js
|
|||||||
packages/app-desktop/commands/index.js
|
packages/app-desktop/commands/index.js
|
||||||
packages/app-desktop/commands/openNoteInNewWindow.js
|
packages/app-desktop/commands/openNoteInNewWindow.js
|
||||||
packages/app-desktop/commands/openProfileDirectory.js
|
packages/app-desktop/commands/openProfileDirectory.js
|
||||||
packages/app-desktop/commands/renderMarkup.test.js
|
|
||||||
packages/app-desktop/commands/renderMarkup.js
|
|
||||||
packages/app-desktop/commands/replaceMisspelling.js
|
packages/app-desktop/commands/replaceMisspelling.js
|
||||||
packages/app-desktop/commands/restoreNoteRevision.js
|
packages/app-desktop/commands/restoreNoteRevision.js
|
||||||
packages/app-desktop/commands/startExternalEditing.js
|
packages/app-desktop/commands/startExternalEditing.js
|
||||||
@ -971,6 +969,8 @@ packages/lib/commands/historyForward.js
|
|||||||
packages/lib/commands/index.js
|
packages/lib/commands/index.js
|
||||||
packages/lib/commands/openMasterPasswordDialog.js
|
packages/lib/commands/openMasterPasswordDialog.js
|
||||||
packages/lib/commands/permanentlyDeleteNote.js
|
packages/lib/commands/permanentlyDeleteNote.js
|
||||||
|
packages/lib/commands/renderMarkup.test.js
|
||||||
|
packages/lib/commands/renderMarkup.js
|
||||||
packages/lib/commands/synchronize.js
|
packages/lib/commands/synchronize.js
|
||||||
packages/lib/components/EncryptionConfigScreen/utils.test.js
|
packages/lib/components/EncryptionConfigScreen/utils.test.js
|
||||||
packages/lib/components/EncryptionConfigScreen/utils.js
|
packages/lib/components/EncryptionConfigScreen/utils.js
|
||||||
|
@ -8,7 +8,6 @@ import * as exportNotes from './exportNotes';
|
|||||||
import * as focusElement from './focusElement';
|
import * as focusElement from './focusElement';
|
||||||
import * as openNoteInNewWindow from './openNoteInNewWindow';
|
import * as openNoteInNewWindow from './openNoteInNewWindow';
|
||||||
import * as openProfileDirectory from './openProfileDirectory';
|
import * as openProfileDirectory from './openProfileDirectory';
|
||||||
import * as renderMarkup from './renderMarkup';
|
|
||||||
import * as replaceMisspelling from './replaceMisspelling';
|
import * as replaceMisspelling from './replaceMisspelling';
|
||||||
import * as restoreNoteRevision from './restoreNoteRevision';
|
import * as restoreNoteRevision from './restoreNoteRevision';
|
||||||
import * as startExternalEditing from './startExternalEditing';
|
import * as startExternalEditing from './startExternalEditing';
|
||||||
@ -30,7 +29,6 @@ const index: any[] = [
|
|||||||
focusElement,
|
focusElement,
|
||||||
openNoteInNewWindow,
|
openNoteInNewWindow,
|
||||||
openProfileDirectory,
|
openProfileDirectory,
|
||||||
renderMarkup,
|
|
||||||
replaceMisspelling,
|
replaceMisspelling,
|
||||||
restoreNoteRevision,
|
restoreNoteRevision,
|
||||||
startExternalEditing,
|
startExternalEditing,
|
||||||
|
@ -15,6 +15,8 @@ const babelLoaderConfiguration = {
|
|||||||
// Compiling these libraries with babel cause build errors.
|
// Compiling these libraries with babel cause build errors.
|
||||||
/.*node_modules[/\\]@babel.*/,
|
/.*node_modules[/\\]@babel.*/,
|
||||||
/.*node_modules[/\\]@sqlite\.org[/\\].*/,
|
/.*node_modules[/\\]@sqlite\.org[/\\].*/,
|
||||||
|
/.*node_modules[/\\]markdown-it-anchor[/\\].*/,
|
||||||
|
/.*node_modules[/\\]markdown-it-toc-done-right[/\\].*/,
|
||||||
],
|
],
|
||||||
|
|
||||||
use: {
|
use: {
|
||||||
|
@ -4,6 +4,7 @@ import * as historyBackward from './historyBackward';
|
|||||||
import * as historyForward from './historyForward';
|
import * as historyForward from './historyForward';
|
||||||
import * as openMasterPasswordDialog from './openMasterPasswordDialog';
|
import * as openMasterPasswordDialog from './openMasterPasswordDialog';
|
||||||
import * as permanentlyDeleteNote from './permanentlyDeleteNote';
|
import * as permanentlyDeleteNote from './permanentlyDeleteNote';
|
||||||
|
import * as renderMarkup from './renderMarkup';
|
||||||
import * as synchronize from './synchronize';
|
import * as synchronize from './synchronize';
|
||||||
|
|
||||||
const index: any[] = [
|
const index: any[] = [
|
||||||
@ -12,6 +13,7 @@ const index: any[] = [
|
|||||||
historyForward,
|
historyForward,
|
||||||
openMasterPasswordDialog,
|
openMasterPasswordDialog,
|
||||||
permanentlyDeleteNote,
|
permanentlyDeleteNote,
|
||||||
|
renderMarkup,
|
||||||
synchronize,
|
synchronize,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import shim from '@joplin/lib/shim';
|
import shim from '../shim';
|
||||||
import Resource from '@joplin/lib/models/Resource';
|
import Resource from '../models/Resource';
|
||||||
import Note from '@joplin/lib/models/Note';
|
import Note from '../models/Note';
|
||||||
import { setupDatabaseAndSynchronizer, supportDir, switchClient } from '@joplin/lib/testing/test-utils';
|
import { setupDatabaseAndSynchronizer, supportDir, switchClient } from '../testing/test-utils';
|
||||||
import { runtime } from './renderMarkup';
|
import { runtime } from './renderMarkup';
|
||||||
import { MarkupLanguage } from '@joplin/renderer';
|
import { MarkupLanguage } from '@joplin/renderer';
|
||||||
const testImagePath = `${supportDir}/photo.jpg`;
|
const testImagePath = `${supportDir}/photo.jpg`;
|
||||||
@ -38,7 +38,7 @@ describe('renderMarkup', () => {
|
|||||||
const resource = (await Resource.all())[0];
|
const resource = (await Resource.all())[0];
|
||||||
const noteBody = (await Note.load(note.id)).body;
|
const noteBody = (await Note.load(note.id)).body;
|
||||||
const renderedNote = await await command.execute(null, MarkupLanguage.Markdown, noteBody);
|
const renderedNote = await await command.execute(null, MarkupLanguage.Markdown, noteBody);
|
||||||
expect(renderedNote.html).toContain(`<div id="rendered-md"><p><img data-from-md data-resource-id="${resource.id}" src="joplin-content://note-viewer/`);
|
expect(renderedNote.html).toContain(`<div id="rendered-md"><p><img data-from-md data-resource-id="${resource.id}" src="`);
|
||||||
expect(renderedNote.html).toContain(`/resources-1/${resource.id}.jpg?t=`);
|
expect(renderedNote.html).toContain(`/resources-1/${resource.id}.jpg?t=`);
|
||||||
expect(renderedNote.html).toContain('" title alt="photo.jpg" /></p>');
|
expect(renderedNote.html).toContain('" title alt="photo.jpg" /></p>');
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
import markupLanguageUtils from '@joplin/lib/markupLanguageUtils';
|
import markupLanguageUtils from '../markupLanguageUtils';
|
||||||
import Setting from '@joplin/lib/models/Setting';
|
import Setting from '../models/Setting';
|
||||||
import { CommandRuntime, CommandDeclaration, CommandContext } from '@joplin/lib/services/CommandService';
|
import { CommandRuntime, CommandDeclaration, CommandContext } from '../services/CommandService';
|
||||||
import { themeStyle } from '@joplin/lib/theme';
|
import { themeStyle } from '../theme';
|
||||||
import attachedResources from '@joplin/lib/utils/attachedResources';
|
import attachedResources from '../utils/attachedResources';
|
||||||
import { MarkupLanguage } from '@joplin/renderer';
|
import { MarkupLanguage } from '@joplin/renderer';
|
||||||
import { Options } from '@joplin/renderer/MdToHtml';
|
import { Options } from '@joplin/renderer/MdToHtml';
|
||||||
import { RenderOptions } from '@joplin/renderer/types';
|
import { RenderOptions } from '@joplin/renderer/types';
|
||||||
@ -12,10 +12,8 @@ export const declaration: CommandDeclaration = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getMarkupToHtml = () => {
|
const getMarkupToHtml = () => {
|
||||||
const resourceBaseUrl = `joplin-content://note-viewer/${Setting.value('resourceDir')}/`;
|
|
||||||
|
|
||||||
return markupLanguageUtils.newMarkupToHtml({}, {
|
return markupLanguageUtils.newMarkupToHtml({}, {
|
||||||
resourceBaseUrl,
|
resourceBaseUrl: `file://${Setting.value('resourceDir')}/`,
|
||||||
customCss: '',
|
customCss: '',
|
||||||
});
|
});
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user