refactoring van de cmap structuren bijna compleet
This commit is contained in:
+25
-5
@@ -1,4 +1,4 @@
|
||||
import "/cmap/cmap-racket-wiki.js";
|
||||
import "/js/cmap/cmap-racket-wiki.js";
|
||||
|
||||
import {
|
||||
newPageReference,
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
expandNamespacedMarkdownLinks,
|
||||
expandTodoMarkup,
|
||||
expandWikiMentions,
|
||||
protectCamelCaseWikiWords,
|
||||
extractCmapEmbeds,
|
||||
restoreCmapEmbeds
|
||||
} from "./wiki/markdown.js";
|
||||
@@ -24,7 +25,7 @@ import { MailAdmin } from "./wiki/admin/mail-admin.js";
|
||||
import { loadAdminOverview } from "./wiki/admin/overview.js";
|
||||
import { OrphanedUploadsAdmin } from "./wiki/admin/orphaned-uploads-admin.js";
|
||||
import { UserAdmin } from "./wiki/admin/user-admin.js";
|
||||
import { CmapWorkspace } from "./wiki/cmap/workspace.js";
|
||||
import { CmapWorkspaceController } from "./wiki/cmap/cmap-workspace-controller.js";
|
||||
import { ComboBox } from "./widgets/combobox.js";
|
||||
|
||||
(() => {
|
||||
@@ -47,6 +48,7 @@ import { ComboBox } from "./widgets/combobox.js";
|
||||
currentPage: null,
|
||||
editingNew: false,
|
||||
newPageSlug: null,
|
||||
newPageSuggestedTitle: "",
|
||||
previousView: "page-view",
|
||||
translations: {},
|
||||
translationPage: "wiki-translations",
|
||||
@@ -77,7 +79,7 @@ import { ComboBox } from "./widgets/combobox.js";
|
||||
|
||||
const wikiCmapLinkCombobox = new ComboBox($("wiki-cmap-link-combobox"));
|
||||
const breadcrumbTrail = new BreadcrumbTrail(window.sessionStorage);
|
||||
const cmapWorkspace = new CmapWorkspace(
|
||||
const cmapWorkspace = new CmapWorkspaceController(
|
||||
state,
|
||||
api,
|
||||
tr,
|
||||
@@ -434,6 +436,16 @@ import { ComboBox } from "./widgets/combobox.js";
|
||||
easyMDE.codemirror.refresh();
|
||||
}
|
||||
|
||||
function protectCamelCaseInPage() {
|
||||
if (!easyMDE) return;
|
||||
const source = easyMDE.value();
|
||||
const protectedMarkdown = protectCamelCaseWikiWords(source);
|
||||
if (protectedMarkdown === source) return;
|
||||
easyMDE.value(protectedMarkdown);
|
||||
renderEditorToc();
|
||||
$("save-status").textContent = tr("camelcase-protected", "CamelCase links protected; save the page to keep the changes.");
|
||||
}
|
||||
|
||||
/**
|
||||
* goal : Configure the single EasyMDE instance used for page editing.
|
||||
* pre : Vendor scripts and the editor textarea are loaded.
|
||||
@@ -504,6 +516,7 @@ import { ComboBox } from "./widgets/combobox.js";
|
||||
console.error(error);
|
||||
});
|
||||
}, "share-2", tr("link-concept-map", "Link to CMap")),
|
||||
toolbarButton("protect-camelcase", protectCamelCaseInPage, "ban", tr("protect-camelcase", "Protect CamelCase")),
|
||||
toolbarButton("upload-image", EasyMDE.drawUploadedImage, "image-plus", tr("upload-image", "Upload image")),
|
||||
toolbarButton("file", () => $("file-input").click(), "paperclip", tr("upload-file", "Upload file")),
|
||||
toolbarButton("horizontal-rule", EasyMDE.drawHorizontalRule, "minus", tr("horizontal-rule", "Horizontal rule")),
|
||||
@@ -976,12 +989,13 @@ import { ComboBox } from "./widgets/combobox.js";
|
||||
* pre : requestedSlug is null or a compact root/namespaced page reference.
|
||||
* post : Namespace, title, template and Markdown controls are initialized for creation.
|
||||
*/
|
||||
function beginNewPage(requestedSlug = null) {
|
||||
function beginNewPage(requestedSlug = null, suggestedTitle = "") {
|
||||
state.editingNew = true;
|
||||
state.currentPage = null;
|
||||
state.newPageSlug = requestedSlug;
|
||||
const translationPage = requestedSlug && requestedSlug === state.translationPage;
|
||||
$("editor-title").value = translationPage ? tr("translations", "Translations") : "";
|
||||
$("editor-title").value = translationPage ? tr("translations", "Translations") :
|
||||
(suggestedTitle || "");
|
||||
$("editor-namespace").value = requestedSlug ? splitPageReference(requestedSlug).namespace : "";
|
||||
$("editor-namespace").disabled = Boolean(translationPage);
|
||||
$("editor-tags").value = "";
|
||||
@@ -1580,6 +1594,12 @@ import { ComboBox } from "./widgets/combobox.js";
|
||||
}
|
||||
|
||||
function showMissingEditablePage(slug) {
|
||||
const suggestedTitle = state.newPageSuggestedTitle;
|
||||
state.newPageSuggestedTitle = "";
|
||||
if (suggestedTitle) {
|
||||
beginNewPage(slug, suggestedTitle);
|
||||
return;
|
||||
}
|
||||
state.currentPage = null;
|
||||
state.editingNew = false;
|
||||
state.newPageSlug = slug;
|
||||
|
||||
Reference in New Issue
Block a user