feat: Initial clean release of CHM
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
这个提交包含在:
@@ -0,0 +1,44 @@
|
||||
import { EditorApi } from '../../joplinEditorApiPlugin';
|
||||
import { EditorLanguageType } from '../../../../types';
|
||||
import showModal from '../../../utils/dom/showModal';
|
||||
import { focus } from '@joplin/lib/utils/focusHandler';
|
||||
|
||||
interface Options {
|
||||
source: string;
|
||||
cursor: number;
|
||||
editorApi: EditorApi;
|
||||
onSave: (newContent: string)=> void;
|
||||
onDismiss: ()=> void;
|
||||
}
|
||||
|
||||
const createEditorDialog = ({ editorApi, source, cursor, onSave, onDismiss }: Options) => {
|
||||
const content = document.createElement('div');
|
||||
content.classList.add('editor-dialog-content');
|
||||
document.body.appendChild(content);
|
||||
|
||||
const editor = editorApi.createCodeEditor(
|
||||
content,
|
||||
EditorLanguageType.Markdown,
|
||||
(newContent) => {
|
||||
onSave(newContent);
|
||||
},
|
||||
);
|
||||
editor.updateBody(source);
|
||||
editor.select(cursor, cursor);
|
||||
|
||||
const _ = editorApi.localize;
|
||||
const modal = showModal({
|
||||
content,
|
||||
doneLabel: _('Done'),
|
||||
onDismiss: () => {
|
||||
onDismiss();
|
||||
editor.remove();
|
||||
},
|
||||
});
|
||||
|
||||
focus('createEditorDialog', editor);
|
||||
|
||||
return modal;
|
||||
};
|
||||
|
||||
export default createEditorDialog;
|
||||
@@ -0,0 +1,42 @@
|
||||
// If renderedHtml is an HTMLElement, the content is modified in-place.
|
||||
const postProcessRenderedHtml = <InputType extends string|HTMLElement> (renderedHtml: InputType, isInline: boolean): InputType => {
|
||||
let rootElement;
|
||||
if (typeof renderedHtml === 'string') {
|
||||
const parser = new DOMParser();
|
||||
const parsed = parser.parseFromString(
|
||||
`<!DOCTYPE html><html><body>${renderedHtml}</body></html>`,
|
||||
'text/html',
|
||||
);
|
||||
rootElement = parsed.body;
|
||||
} else {
|
||||
rootElement = renderedHtml;
|
||||
}
|
||||
|
||||
const replaceChildMatching = (selector: string) => {
|
||||
const toReplace = [...rootElement.children].find(
|
||||
child => child.matches(selector),
|
||||
);
|
||||
toReplace?.replaceWith(...toReplace.childNodes);
|
||||
};
|
||||
// If the original HTML is from .renderToMarkup, it may have a <div> wrapper:
|
||||
replaceChildMatching('#rendered-md');
|
||||
|
||||
if (rootElement.children.length === 1 && isInline) {
|
||||
replaceChildMatching('p, div');
|
||||
}
|
||||
|
||||
// Remove the 'joplin-editable' container if it's the only thing in the content
|
||||
// (since this.dom is itself a joplin-editable)
|
||||
if (rootElement.children.length === 1) {
|
||||
replaceChildMatching('.joplin-editable');
|
||||
}
|
||||
|
||||
// Match the input type
|
||||
if (typeof renderedHtml === 'string') {
|
||||
return rootElement.innerHTML as InputType;
|
||||
} else {
|
||||
return rootElement as InputType;
|
||||
}
|
||||
};
|
||||
|
||||
export default postProcessRenderedHtml;
|
||||
在新工单中引用
屏蔽一个用户