Skip to content

Commit

Permalink
Removing scrollbar, handling new record (gristlabs#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
berhalak authored Aug 4, 2023
1 parent a3eaa73 commit 6770fa9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
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

0 comments on commit 6770fa9

Please sign in to comment.