在TinyMCE WYSIWYG编辑器中保存一些页面内容后,我发现以下HTML标记遍及整个内容:
<g class="gr_ gr_283 gr-alert gr_spell gr_run_anim gr_inline_cards ContextualSpelling ins-del multiReplace" id="283" data-gr-id="283"></g>
它通常会围绕单词或句子。它不会改变内容的外观,因为类没有在任何样式表中引用,但是它干扰了偶尔用内容自动替换的通配符。
我无法在网上找到任何答案,但谷歌搜索类名已经返回了一些结果,其中类似的标签被生成到页面内容的纯文本中。
有人知道为什么会发生这种情况,是否有办法阻止它?
答案 0 :(得分:4)
我向Tinymce的开发人员submitted this as a bug,他们回复说该错误是由Goolge Chrome扩展Grammarly引起的。安装此扩展后,我能够复制该错误,并可以确认问题与Grammarly。语法是在拼写错误/语法错误的内容周围注入元素。
我已经使用javascript替换函数实现了我自己的修复,以删除元素。
(function() {
'use strict';
angular
.module('FileLoggerManager', [])
.service('FileLogger', Body);
function Body(LocalData, $q, $timeout) {
var service = {
writeLog: writeLog,
SetLogLevel: SetLogLevel,
SetFilePath: SetFilePath,
SetMaxLogSize: SetMaxLogSize,
DeleteLogFiles: DeleteLogFiles,
SendLogsToEmail: SendLogsToEmail
};
// LOG WRITER
var logOb;
var logDirOb;
var logLocation;
var curlogsize = 0;
var logStrings = [];
var loggingStopped = true;
// DEFAULT CURRENT LOG FILE NAME
var logfilename = "MPC";
var appObj = null;
var maxlogsize = 1000000;
var customlogfolder = "sdcard/";
var maxloglevel = 2;
console.log("File Logger initialized.");
// SETTINGS
if (LocalData.loadData('application')) {
appObj = JSON.parse(LocalData.loadData('application'));
// MAX LOGFILE SIZE (BYTES)
maxlogsize = 1000000 * ( appObj.maxLogFileSize ? appObj.maxLogFileSize : 1 );
// LOG SAVE PATH CUSTOM FOLDER NAME
customlogfolder = appObj.logFilePath ? appObj.logFilePath + '/' : 'sdcard/';
// MAX LOG LEVEL (everything below will be logged)
maxloglevel = appObj.logLevel ? appObj.logLevel : 2;
}
// DEVICE READY
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady(){
// WRITE AND GET LOG FILE READY
SetFilePath(customlogfolder);
}
// SET LOG LEVEL
function SetLogLevel(logLevel) {
console.log("File Logger: Set log level to " + logLevel);
maxloglevel = logLevel;
}
// SET FILE PATH
function SetFilePath(filePath) {
while (filePath.indexOf('//') > -1) {
filePath = filePath.replace('//','/');
}
while(filePath[0] == '/') {
filePath = filePath.substring(1);
}
if (filePath[filePath.length-1] != '/') {
filePath = filePath + '/';
}
if (filePath.indexOf('sdcard') == 0) {
filePath = filePath.substring(7);
}
customlogfolder = filePath;
logLocation = cordova.file.externalRootDirectory + customlogfolder;
console.log("File Logger: Log Path = " + customlogfolder);
if (customlogfolder == "") {
initializeLogFile(logLocation);
}
else {
checkIfDirectoryExist(customlogfolder, cordova.file.externalRootDirectory);
}
}
/*
CHECK IF DIRECTORY EXISTS
*/
function checkIfDirectoryExist(filePath, rootDirLoc) {
window.resolveLocalFileSystemURL(filePath, function(dir) {
console.log("File Logger: Path found = " + filePath);
},
function (dir) {
var curFolder = filePath;
var withSubDir = false;
if ((filePath.indexOf('/') > 0) &&
(filePath.indexOf('/') != filePath.length-1)) {
withSubDir = true;
curFolder = filePath.substring(0, filePath.indexOf('/'));
}
window.resolveLocalFileSystemURL(rootDirLoc, function(dir) {
dir.getDirectory(curFolder, { create: true }, function (dirEntry) {
console.log("File Logger: New Directory = " + curFolder );
if(withSubDir == false) {
initializeLogFile(logLocation);
}
},
function(dirEntry) {
console.log("File Logger: Create Dir failed = " + curFolder);
});
},
function(dir){
console.log("File Logger: Root directory not found = " + rootDirLoc);
});
if (withSubDir) {
filePath = filePath.substring(filePath.indexOf('/')+1);
checkIfDirectoryExist(filePath, rootDirLoc + curFolder + '/');
}
});
}
// INITIALIZE AND CREATE LOG FILE
function initializeLogFile(logLocation) {
window.resolveLocalFileSystemURL(logLocation, function(dir) {
logDirOb = dir;
dir.getFile(logfilename + ".txt", { create:true }, function(file) {
logOb = file;
writeToLog();
});
});
}
// SET MAX SIZE
function SetMaxLogSize (maxSize) {
maxlogsize = 1000000 * ( maxSize? maxSize : 1 );
console.log("File Logger: Max File size = " + maxlogsize);
}
// WRITE LOG
function writeToLog() {
if(!logOb){
console.log("File Logger: No log added.");
return;
}
if(logStrings.length == 0) {
return;
}
loggingStopped = false;
logOb.createWriter(function(fileWriter) {
fileWriter.onwriteend = function(e) {
logStrings.splice(0,1);
if(logStrings.length == 0) {
loggingStopped = true;
}
else {
loggingStopped = false;
writeToLog();
}
};
var log = logStrings[0];
fileWriter.seek(fileWriter.length);
var blob = new Blob([log], {type:'text/plain'});
fileWriter.write(blob);
}, ReadLogfail);
CheckLogSize();
}
function writeLog(logLevel, str) {
if (maxloglevel == 0) return;
if (maxloglevel>=logLevel && logLevel>0){
var level;
if(logLevel == 4)
level = "DEBUG";
else if(logLevel == 3)
level = "INFO";
else if(logLevel == 2)
level = "WARNING";
else if(logLevel == 1)
level = "ERROR";
var log = "[" + GetLogDate() + "] " + level + " : " + str + "\n";
logStrings.push(log);
if(loggingStopped){
writeToLog();
}
}
}
// CHECK LOG SIZE
function CheckLogSize(){
logOb.file(function(file) {
curlogsize = file.size;
if (parseFloat(curlogsize)>parseFloat(maxlogsize)) {
DeleteLogFiles();
initializeLogFile(logLocation);
}
}, ReadLogfail);
}
function ReadLogfail(e) {
console.log("File Logger: FileSystem Error");
console.dir(e);
}
// GET DATE (SERIAL/NORMAL)
function GetLogDate(){
//var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var date = new Date();
var dateYear = date.getFullYear();
var dateMonth = LogPad(date.getMonth()+1);
var dateDay = LogPad(date.getDate());
var dateHour = LogPad(date.getHours());
var dateMinute = LogPad(date.getMinutes());
var dateSeconds = LogPad(date.getSeconds());
return dateYear + '.' + dateMonth + '.' + dateDay + ' ' + dateHour + ':' + dateMinute + ':' + dateSeconds;
}
// ADD 0 if number is below 9
function LogPad(n){
return n<10 ? '0'+n : n;
}
// DELETE LOG FILE
function DeleteLogFiles(){
if (!logOb) return 0;
window.resolveLocalFileSystemURL(logLocation, function(dir) {
logDirOb = dir;
dir.getFile(logfilename+".txt", {create:true}, function(file) {
file.remove(function() {
console.log('File logger: File removed = ' + logfilename + ".txt");
});
});
});
}
function SendLogsToEmail() {
cordova.plugins.email.isAvailable( function (isAvailable) {
if(isAvailable) {
cordova.plugins.email.open({
to: '',
subject: 'MSCM MPC Logs',
body: '',
attachments: [logLocation+'MPC.txt',logLocation+'MPC_COMM.txt']
});
} else {
console.log("No email account is setup in this device.");
var confirmPopup = $ionicPopup.alert({
cssClass: 'custom-popup',
template: '<div>{{ "confirm_no_email_setup" | translate }}</div>'
});
};
});
}
return service;
}})();
我还联系了Grammarly,告知他们这个错误,希望他们能够回复并解决问题。