^v43^pc_blog_bottom_relevance_base6&spm=1001.2101.3001.4242.1&utm_relevant_index=2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quill Form Submission</title>
</head>
<body>
<script src="https://cdn.bootcdn.net/ajax/libs/quill/2.0.2/quill.js"></script>
<link href="https://cdn.bootcdn.net/ajax/libs/quill/2.0.2/quill.snow.css" rel="stylesheet">
<style>
.edit_container {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
.ql-editor{
height:400px;
}
</style>
<form id="myForm" action="ContentUpdate" method="post">
<div id="editor"></div>
<input type="hidden" name="delta" id="deltaInput">
<input type="hidden" name="html" id="htmlInput">
<input type="submit" value="Submit">
</form>
<script>
const quill = new Quill('#editor', {
modules: {
toolbar: [
[{ header: [1, 2, false] }],
['bold', 'italic', 'underline'],
['image', 'code-block'],
],
},
theme: 'snow'
});
document.getElementById('myForm').addEventListener('submit', function() {
// 获取 Quill 编辑器的内容
const delta = JSON.stringify(quill.getContents());
const html = quill.root.innerHTML;
// 将内容放入隐藏输入框中
document.getElementById('deltaInput').value = delta;
document.getElementById('htmlInput').value = html;
});
</script>
</body>
</html>
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
FileContent: TStringList;
begin
Response.CustomHeaders.Values['Access-Control-Allow-Origin'] := '*';
FileContent := TStringList.Create;
// 假设你的HTML文件位于Web服务器的根目录下,文件名为a01.html
FileContent.LoadFromFile( ExtractFilePath (ParamStr (0))+ '\dddd.html');
Response.Content := FileContent.Text;
Response.ContentType := 'text/html; charset="UTF-8"';
Handled := True;
FileContent.Free;end;
///ContentUpdate submit提交后,保存文本到abcd.txt
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
S: string;
SL: TStringList;
begin
Response.ContentType := 'text/html; charset="UTF-8"';
S := UTF8String( Request.ContentFields.Values['html']); SL := TStringList.Create;
SL.LoadFromFile('abcd.txt');
SL.Text :=SL.Text+s;
SL.SaveToFile('abcd.txt');
SL.Free;
Response.SendRedirect('Show');//跳转到 Show页面
Handled := True;
end;
///Show 显示abcd.txt内容
procedure TWebModule1.WebModule1WebActionItem2Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var SL : TStringList;
begin
SL := TStringList.Create;
try
SL.LoadFromFile('abcd.txt');
Response.Content := SL.Text;
finally
SL.Free;
end;
end;
end.
















