--[[ EditNoteHTML script by Daniel Hertrich, hermocom http://www.hermocom.com License The author, Daniel Hertrich, hereby waives all copyright and related or neighboring rights to this script package, pursuant to the Creative Commons CC0 Universal relinquishment of rights found at http://creativecommons.org/publicdomain/zero/1.0/ Purpose: Edit the raw HTML code of a note right within NoteCase Pro, without the need for an external editor or other external tools. Usage: 1. Select the note which you want to edit on HTML level, then start this script. A child note with the HTML will be generated and selected, which you can edit. 2. Once editing is finished, let the temporary HTML note selected and then execute this script again. The edited HTML will be pur back into the originating note and the temporary HTML note will be deleted. ]]-- -- get info on the currently active document/note nDocID = Nc_Doc_ID_GetCur() strCurNoteID = Nc_Note_ID_GetCur(nDocID) -- Find out if the current note is a normal note or a temporary -- HTML note generated by this script: bIsTempHtmp = 0 nExpCPIdx = Nc_Note_CustProp_FindByName( nDocID, strCurNoteID, "hmc_TempHtmlOf") if nExpCPIdx ~= -1 then bIsTempHtmp = 1 strOriginatingNoteID = Nc_Note_CustProp_GetValueByIdx(nDocID, strCurNoteID, nExpCPIdx) end -- Depending on if this note is a normal note or temporary HTML note, -- execute two different actions: if bIsTempHtmp == 0 then -- This is a normal note: Read out its contents as html -- and put it into a temporary note as non-html: -- get the note content strNoteHtml = Nc_Note_Content_Get(nDocID, strCurNoteID, 1) -- get note title strNoteTitle = Nc_Note_Title_Get(nDocID, strCurNoteID) -- create temporary HTML note strTempNoteID = Nc_Note_Insert(nDocID, strCurNoteID, -1, strNoteTitle .. " (HTML contents / Temporary note)") -- Put HTML into the new temporary note: Nc_Note_Content_Set(nDocID, strTempNoteID, strNoteHtml, 0) -- Enable HTML syntax highlighting for the temporary note Nc_Note_SourceLang_Set(nDocID,strTempNoteID, "html") -- Set custom property for recognizing this as a HTML-Temp-note -- The value of the custom property is the note the HTML stems from. Nc_Note_CustProp_Append(nDocID, strTempNoteID, "hmc_TempHtmlOf", strCurNoteID) Nc_GUI_InfoBox("Now edit this HTML code.\nAfter editing, let this temporary HTML note selected, then execute this script again.\nThe HTML in this temporary note will be put into the original note and this temporary HTML note will be deleted again.",1,"HTML note generated!") else -- This is a temporary HTML note and is considered to be edited and ready: -- Put its content as non-html back into its originating note as html. -- get the note content strNoteContent = Nc_Note_Content_Get(nDocID, strCurNoteID, 0) -- strOriginatingNoteID is the ID of the note which this HTML came from. Nc_Note_Content_Set(nDocID, strOriginatingNoteID, strNoteContent, 1) -- Make the originating note current: Nc_Note_ID_SetCur(strOriginatingNoteID) -- Delete the temporary HTML note: Nc_Note_Delete(nDocID, strCurNoteID, 0 ) end