Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing scrollbar, handling new record #55

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
manifest.json
_build/

*.swp
*.pyc
Expand Down
1 change: 1 addition & 0 deletions notepad/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ html,
body {
height: 100%;
font-size: 13px;
margin: 0;
}

.editor-container{
Expand Down
2 changes: 1 addition & 1 deletion notepad/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</head>

<body>
<form id="configuration">
<form id="configuration" style="display: none">
<h2>Notepad Widget Configuration</h1>
<div>
<label>Select Quill theme:
Expand Down
10 changes: 9 additions & 1 deletion notepad/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ grist.ready({requiredAccess: 'full', columns: [{name: 'Content', type: 'Text'}],
},
});
grist.onRecord(function (record, mappings) {
quill.enable();
// If this is a new record, or mapping is diffrent.
if (id !== record.id || mappings?.Content !== column) {
id = record.id;
Expand All @@ -113,6 +114,13 @@ grist.onRecord(function (record, mappings) {
}
});

grist.onNewRecord(function () {
id = null;
lastContent = null;
quill.setContents(null);
quill.disable();
})

// Register onOptions handler.
grist.onOptions((customOptions, _) => {
customOptions = customOptions || {};
Expand All @@ -129,7 +137,7 @@ saveEvent.subscribe(() => {
// If we are in a middle of saving, skip this.
if (lastSave) { return; }
// If we are mapped.
if (column) {
if (column && id) {
const content = quill.getContents();
// Store content as json.
const newContent = JSON.stringify(content);
Expand Down