feat(editor): add lossless bounded CSV table editing
This commit is contained in:
1 parent
bd80ff6a0c
commit
2d6ceac0d7
19 files changed
+520
-40
No files matched your search
@@ -22,13 +22,14 @@
|
||||
|
||||
<link rel="stylesheet" href="/static/css/theme/base.css">
|
||||
<link rel="stylesheet" href="/static/css/content-viewer.css">
|
||||
{{ if .CSVEditor }}<link rel="stylesheet" href="/static/css/csv-editor.css?v=1">{{ end }}
|
||||
<link rel="stylesheet" href="{{ .ThemeCSS }}">
|
||||
<script defer src="/static/js/content-viewer.js?v=macro-projection-1"></script>
|
||||
|
||||
|
||||
<script
|
||||
type="module"
|
||||
src="/static/vendor/codemirror/editor.bundle.js?v=command-ux-1"
|
||||
src="/static/vendor/codemirror/editor.bundle.js?v=csv-edit-1"
|
||||
></script>
|
||||
|
||||
|
||||
@@ -39,7 +40,7 @@
|
||||
|
||||
</head>
|
||||
|
||||
<body class="mode-editor">
|
||||
<body class="mode-editor{{ if .CSVEditor }} csv-editor{{ end }}">
|
||||
|
||||
<header class="topbar">
|
||||
|
||||
@@ -165,8 +166,8 @@
|
||||
aria-pressed="true"
|
||||
aria-label="{{ T "editor.hide_preview" }}"
|
||||
title="{{ T "editor.hide_preview" }}"
|
||||
data-hide-label="{{ T "editor.hide_preview" }}"
|
||||
data-show-label="{{ T "editor.show_preview" }}"
|
||||
data-hide-label="{{ if .CSVEditor }}{{ T "editor.csv_source" }}{{ else }}{{ T "editor.hide_preview" }}{{ end }}"
|
||||
data-show-label="{{ if .CSVEditor }}{{ T "editor.csv_table" }}{{ else }}{{ T "editor.show_preview" }}{{ end }}"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||
<rect x="3" y="4" width="18" height="16" rx="2"/>
|
||||
@@ -204,6 +205,7 @@
|
||||
data-base-revision="{{ .BaseRevision }}"
|
||||
data-domain="{{ .Context.Domain.UUID }}"
|
||||
data-owner="{{ if .AuthUser }}{{ .AuthUser.UUID }}{{ end }}"
|
||||
data-csv="{{ .CSVEditor }}"
|
||||
></div>
|
||||
|
||||
<div
|
||||
@@ -215,7 +217,7 @@
|
||||
MODE
|
||||
</span>
|
||||
<span id="editor-format-status">
|
||||
{{ .EditType }}
|
||||
{{ if .CSVEditor }}CSV{{ else }}{{ .EditType }}{{ end }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -272,7 +274,8 @@ Ln 1, Col 1
|
||||
</main>
|
||||
|
||||
<script src="/static/js/editor-core.js?v=priority-ux-1"></script>
|
||||
<script src="/static/js/editor.js?v=priority-ux-1"></script>
|
||||
{{ if .CSVEditor }}<script>window.PagesCSVSource = {{ .Body }};</script><script src="/static/js/csv-core.js?v=1"></script><script src="/static/js/csv-editor.js?v=1"></script>{{ end }}
|
||||
<script src="/static/js/editor.js?v=csv-edit-1"></script>
|
||||
<script src="/static/js/path-actions.js"></script>
|
||||
|
||||
|
||||
@@ -295,12 +298,13 @@ window.addEventListener(
|
||||
const cm =
|
||||
window.PagesWikiEditor.create(
|
||||
mount,
|
||||
textarea.value,
|
||||
window.PagesEditor?.text() ?? textarea.value,
|
||||
"{{ .EditType }}",
|
||||
{
|
||||
keymap: mount.dataset.keymap,
|
||||
syntax: mount.dataset.syntax === "true",
|
||||
autocomplete: mount.dataset.autocomplete === "true",
|
||||
preserveLineEndings: mount.dataset.csv === "true",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -308,7 +312,11 @@ window.addEventListener(
|
||||
cm
|
||||
|
||||
cm.focus()
|
||||
setTimeout(() => cm.focus(), 0)
|
||||
setTimeout(() => {
|
||||
// Do not steal focus from a table cell or toolbar clicked while
|
||||
// the editor was initializing.
|
||||
if (document.activeElement === document.body || mount.contains(document.activeElement)) cm.focus()
|
||||
}, 0)
|
||||
|
||||
window.PagesWikiGetEditorText =
|
||||
() => window.PagesWikiCodeMirror.state.doc.toString()
|
||||
|
||||
Reference in new issue
Block a user